From baa00a3b0c1db6b0b744655fcc474b94950b821e Mon Sep 17 00:00:00 2001 From: shenjackyuanjie <3695888@qq.com> Date: Tue, 3 May 2022 13:59:15 +0800 Subject: [PATCH] ruaaaaaa --- try/c/data_types.c | 52 ++++++++++++++++++------------------------- try/c/data_types.dll | Bin 48204 -> 47874 bytes try/c/data_types.so | Bin 49456 -> 0 bytes try/c/data_utils.h | 10 +++++++-- try/c/dll_build.ps1 | 1 - try/c/dll_builder.py | 21 +++++++++++++++++ try/c/dll_load.py | 12 +++++++++- 7 files changed, 62 insertions(+), 34 deletions(-) delete mode 100755 try/c/data_types.so delete mode 100644 try/c/dll_build.ps1 create mode 100644 try/c/dll_builder.py diff --git a/try/c/data_types.c b/try/c/data_types.c index a771152..13dd923 100644 --- a/try/c/data_types.c +++ b/try/c/data_types.c @@ -1,49 +1,41 @@ +/* +------------------------------- +Difficult Rocket +Copyright © 2021-2022 by shenjackyuanjie +All rights reserved +------------------------------- +*/ // DR数据类型 -#include -#include "data_utils.h" // 自己搓的一个常用数据类型的头文件 +#include"Python.h" +#include +#include"data_utils.h" // 自己搓的一个常用数据类型的头文件 -struct ship_part +struct ship_part // 一个部件的基本数据类型 { /* 一个 part 的数据格式 */ string part_type; int32 part_id; - bool enabled; float64 x; float64 v_x; float64 y; float64 v_y; - float32 angle; + float64 angle; float64 v_angle; + // TODO 会改成基于 float 64的数组 bool flip_x; bool flip_y; -} ship_part = { + bool part_enabled; + // TODO 也改成数组 +} a_ship_part = { "pod", 0, - false, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - false, - false + 0, 0, 0, 0, 0, 0, + false, false, false }; +struct ship_part a_part; +// a_part = {}; + int main(){ - // 创建一个 part - struct ship_part p; - p.part_type = "head"; - p.part_id = 1; - p.enabled = true; - - // 创建一个 part 的数组 - struct ship_part *parts = malloc(sizeof(struct ship_part) * 10); - - // 输出一个 part 的数据 - printf("%s %d %d %f %f %f %f %f %f %d %d\n", - p.part_type, p.part_id, p.enabled, - p.x, p.v_x, p.y, p.v_y, p.angle, p.v_angle, - p.flip_x, p.flip_y); - return 0; -} +} \ No newline at end of file diff --git a/try/c/data_types.dll b/try/c/data_types.dll index 01ffb5893280a5aef61ed6fd4993928838bd20c5..c30b22defa5f9403abb37c67392bdba5965e44de 100644 GIT binary patch delta 8733 zcmb_h4OmoF-oN+4!0;u*eDEQl12ZBf;b3BBYWO|%T8rfen zddR@v&KJ;PK1o&G&T$r+?M`a9gp+-%T4)|kyZCzqpFp4S4H2#=G_kj5B*wWon=iMb zywp+3aW%9>7|-{3pBGBP1V<7@N8}n#=W$%#i-$dl{Z&GIDfAH~C8#zDs zc?-v#j9`|np12kihJIn-xQjFWe*fw=tH)3U3N`n#npOk-Int2wC=WkpG*17&|*Z2k_ zgi;;p$)ldM@LuSfe6!sr94of{ov(j&=w)~Y(Ho+JurWIzh;OQg2O}L#kUEljjU_&6 zDxXi&qQ*zeM9ZOUs))+sGpHqM!aO)TbR5I&L*lI4P8e4nZ<8MkB-`pyHKnm3bJixG zBi%m$!oi5vLWHqEZFL(e(&+hUBTw|3=sN_HpJHOh-@I=HbKDVeJbvsv1XQ&HW#;q6 zb&5Dyte*7vG%ATP^4G}~lXTO|n^|8Dv(azZi7ZC$H?$(-{o;6{7}XxtEHq|({#&A4m4!8C?TZTMd{W?5Dn@uz2Szh% z^M{drTFPGY8-B@bw8s5m0`ta)0(`>XH(2vbtNU%gp%cZSm;`2GezMiA8eqM&&POm+ z757s{oR$ACS`#-Rs>;py{4zIn#%&SSucEP|5`~ggbnB>vLgFfNjhYTr7iK3v;JHx za<7a>xIIhE>P4P;mgJ%18j;-$*6Kbt)Jq@5X9&BB>4*3fVSOt)Yc?4|E<22< zJZoa^EGVLC{dmo7KgH(99z~bdR>Q<1dRlLfc^xgVL;Qv%>uHQ(hoD~W{kfru&zKF~ zZ}{5I29d5u!P@k(;}#qeCkWTn+V?i}Q+#nmnE`D~Bs z4SFicJmYR`Xlxd%`?zDKI~$&LvX<^fwcoHn>_hbs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Y A&j0`b diff --git a/try/c/data_types.so b/try/c/data_types.so deleted file mode 100755 index 3a3f2ae9b301bcb949bd0146141f364b048dd696..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 49456 zcmeI*PiS049KiA4=1+|_c2n#jQVUCK#6OT$E#jqhqgmKuQ>{rJ zb5K`G!B_%07QEKt!9xx`7P^g*nt;>q*4*_j_+%y1TI_1ux$r^JacC zlV4^&ZqVtIU-NJ@e%8-h+~@mY(dyD(OVQMzUtzHxW3vqS ze0F9lQ9f5Jl&ghW7o_I!SLv$1p9 zyK?U6kz=oB#*ak$BI|xh+P6MF;6J?9_-?r1VSPTSb+~KXcI$%0YN0+_x6jL7J>dau zEx)~s0d4Jj;*weyNokPQ*7BL7%~v(vrtOBdw%_eq<1@y4v9+dPQ{O zt!U!Q?74;2bJJ_dD-)N0OAck$^)Yc>AJa{JoVay2IaK)mZt|Vm8qIBtC$D6F(Z|HE z+2uoa5q5Rk#x8B1y|I+Juyj3p=G&7ezFBFFTu6(wMlR}8`%YNY|H*KNQ`Geav!bX>aY`tKFMFsIArb z4!rg4-t3^>haK`aYBh|m)@p}>00IagfB*srAbryfuc++qiuZNJ py&Csv?bjOjwJRynQ|KPuy* @@ -21,7 +27,7 @@ #define float32 float #define float64 double // bool 布尔值 -#define bool int8 +#define bool int #define true 1 #define false 0 // 字符串 diff --git a/try/c/dll_build.ps1 b/try/c/dll_build.ps1 deleted file mode 100644 index b062acb..0000000 --- a/try/c/dll_build.ps1 +++ /dev/null @@ -1 +0,0 @@ -gcc -shared -o \ No newline at end of file diff --git a/try/c/dll_builder.py b/try/c/dll_builder.py new file mode 100644 index 0000000..6c97f88 --- /dev/null +++ b/try/c/dll_builder.py @@ -0,0 +1,21 @@ +# ------------------------------- +# Difficult Rocket +# Copyright © 2021-2022 by shenjackyuanjie +# All rights reserved +# ------------------------------- + +import os +import sys +import getopt + + +# input_args = sys.argv + +# print(input_args) +filename = "./data_types.c" +dllname = "./data_types.dll" + +python_include_path = "C:/Users/shenjack.SHENJACK-5600X/AppData/Local/Programs/Python/Python38/include/" + +os.system("gcc -I {} -shared {} -o {}".format(python_include_path, filename, dllname)) +# gcc -I C:/Users/shenjack.SHENJACK-5600X/AppData/Local/Programs/Python/Python38/include/ -shared .\data_types.c -o .\data_types.dll \ No newline at end of file diff --git a/try/c/dll_load.py b/try/c/dll_load.py index bcd9b3b..dd6c89c 100644 --- a/try/c/dll_load.py +++ b/try/c/dll_load.py @@ -6,4 +6,14 @@ import ctypes -ctypes.CDLL('./data_types.dll') \ No newline at end of file +ctypes.cdll.LoadLibrary('./data_types.dll') + +data_type_dll = ctypes.CDLL("./data_types.dll") + +print(data_type_dll) + +a = data_type_dll.a_part + +print(a) + +print(a.part_type)