diff --git a/vrclient_x64/gen_wrapper.py b/vrclient_x64/gen_wrapper.py index 282e3764..97540bd7 100755 --- a/vrclient_x64/gen_wrapper.py +++ b/vrclient_x64/gen_wrapper.py @@ -881,46 +881,34 @@ def handle_struct(sdkver, struct): cppfile.write("} __attribute__ ((ms_struct));\n") cppfile.write("#pragma pack(pop)\n\n") - if LIN_TO_WIN in which: - hfile.write("extern void struct_%s_lin_to_win(void *l, void *w);\n" % handler_name) - - cppfile.write("void struct_%s_lin_to_win(void *l, void *w)\n{\n" % handler_name) - cppfile.write(" struct win%s *win = (struct win%s *)w;\n" % (handler_name, handler_name)) - cppfile.write(" %s *lin = (%s *)l;\n" % (struct.displayname, struct.displayname)) - + def dump_converter(src, dst): for m in struct.get_children(): if m.kind == clang.cindex.CursorKind.FIELD_DECL: if m.type.get_canonical().kind == clang.cindex.TypeKind.CONSTANTARRAY: #TODO: if this is a struct, or packed differently, we'll have to # copy each element in a for-loop - cppfile.write(" memcpy(win->%s, lin->%s, sizeof(win->%s));\n" % (m.displayname, m.displayname, m.displayname)) + cppfile.write(" memcpy(" + dst + "->" + m.displayname + ", " + src + "->" + m.displayname + ", sizeof(" + dst + "->" + m.displayname + "));\n") elif m.type.get_canonical().kind == clang.cindex.TypeKind.RECORD and \ struct_needs_conversion(m.type.get_canonical()): - cppfile.write(" lin_to_win_struct_%s_%s(&lin->%s, &win->%s);\n" % (strip_ns(m.type.spelling), display_sdkver(sdkver), m.displayname, m.displayname)) + cppfile.write(" struct_" + strip_ns(m.type.spelling) + "_" + display_sdkver(sdkver) + "_" + src + "_to_" + dst + \ + "(&" + src + "->" + m.displayname + ", &" + dst + "->" + m.displayname + ");\n") else: - cppfile.write(" win->%s = lin->%s;\n" % (m.displayname, m.displayname)) + cppfile.write(" " + dst + "->" + m.displayname + " = " + src + "->" + m.displayname + ";\n") + if LIN_TO_WIN in which: + hfile.write("extern void struct_%s_lin_to_win(void *l, void *w);\n" % handler_name) + cppfile.write("void struct_%s_lin_to_win(void *l, void *w)\n{\n" % handler_name) + cppfile.write(" struct win%s *win = (struct win%s *)w;\n" % (handler_name, handler_name)) + cppfile.write(" %s *lin = (%s *)l;\n" % (struct.displayname, struct.displayname)) + dump_converter("lin", "win") cppfile.write("}\n\n") if WIN_TO_LIN in which: hfile.write("extern void struct_%s_win_to_lin(void *w, void *l);\n" % handler_name) - cppfile.write("void struct_%s_win_to_lin(void *w, void *l)\n{\n" % handler_name) cppfile.write(" struct win%s *win = (struct win%s *)w;\n" % (handler_name, handler_name)) cppfile.write(" %s *lin = (%s *)l;\n" % (struct.displayname, struct.displayname)) - - for m in struct.get_children(): - if m.kind == clang.cindex.CursorKind.FIELD_DECL: - if m.type.get_canonical().kind == clang.cindex.TypeKind.CONSTANTARRAY: - #TODO: if this is a struct, or packed differently, we'll have to - # copy each element in a for-loop - cppfile.write(" memcpy(lin->%s, win->%s, sizeof(lin->%s));\n" % (m.displayname, m.displayname, m.displayname)) - elif m.type.get_canonical().kind == clang.cindex.TypeKind.RECORD and \ - struct_needs_conversion(m.type.get_canonical()): - cppfile.write(" win_to_lin_struct_%s_%s(&win->%s, &lin->%s);\n" % (m.type.spelling, display_sdkver(sdkver), m.displayname, m.displayname)) - else: - cppfile.write(" lin->%s = win->%s;\n" % (m.displayname, m.displayname)) - + dump_converter("win", "lin") cppfile.write("}\n\n") if WRAPPERS in which: @@ -930,14 +918,7 @@ def handle_struct(sdkver, struct): cppfile.write(" struct win%s *win = (struct win%s *)malloc(sizeof(*win));\n" % (handler_name, handler_name)) cppfile.write(" %s *lin = (%s *)l;\n" % (struct.displayname, struct.displayname)) - for m in struct.get_children(): - if m.kind == clang.cindex.CursorKind.FIELD_DECL: - if m.type.get_canonical().kind == clang.cindex.TypeKind.CONSTANTARRAY: - #TODO: if this is a struct, or packed differently, we'll have to - # copy each element in a for-loop - cppfile.write(" memcpy(win->%s, lin->%s, sizeof(win->%s));\n" % (m.displayname, m.displayname, m.displayname)) - else: - cppfile.write(" win->%s = lin->%s;\n" % (m.displayname, m.displayname)) + dump_converter("lin", "win") cppfile.write(" win->linux_side = lin;\n"); cppfile.write(" return win;\n") diff --git a/vrclient_x64/vrclient_x64/struct_converters_090.cpp b/vrclient_x64/vrclient_x64/struct_converters_090.cpp index 03f818c1..66f1bfd5 100644 --- a/vrclient_x64/vrclient_x64/struct_converters_090.cpp +++ b/vrclient_x64/vrclient_x64/struct_converters_090.cpp @@ -74,7 +74,7 @@ void struct_RenderModel_t_090_lin_to_win(void *l, void *w) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - lin_to_win_struct_RenderModel_TextureMap_t_090(&lin->diffuseTexture, &win->diffuseTexture); + struct_RenderModel_TextureMap_t_090_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); } void struct_RenderModel_t_090_win_to_lin(void *w, void *l) @@ -86,7 +86,7 @@ void struct_RenderModel_t_090_win_to_lin(void *w, void *l) lin->unVertexCount = win->unVertexCount; lin->rIndexData = win->rIndexData; lin->unTriangleCount = win->unTriangleCount; - win_to_lin_struct_vr::RenderModel_TextureMap_t_090(&win->diffuseTexture, &lin->diffuseTexture); + struct_RenderModel_TextureMap_t_090_win_to_lin(&win->diffuseTexture, &lin->diffuseTexture); } struct winRenderModel_t_090 *struct_RenderModel_t_090_wrap(void *l) @@ -98,7 +98,7 @@ struct winRenderModel_t_090 *struct_RenderModel_t_090_wrap(void *l) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - win->diffuseTexture = lin->diffuseTexture; + struct_RenderModel_TextureMap_t_090_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); win->linux_side = lin; return win; } diff --git a/vrclient_x64/vrclient_x64/struct_converters_091.cpp b/vrclient_x64/vrclient_x64/struct_converters_091.cpp index 7197ac22..fd29547a 100644 --- a/vrclient_x64/vrclient_x64/struct_converters_091.cpp +++ b/vrclient_x64/vrclient_x64/struct_converters_091.cpp @@ -74,7 +74,7 @@ void struct_RenderModel_t_091_lin_to_win(void *l, void *w) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - lin_to_win_struct_RenderModel_TextureMap_t_091(&lin->diffuseTexture, &win->diffuseTexture); + struct_RenderModel_TextureMap_t_091_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); } void struct_RenderModel_t_091_win_to_lin(void *w, void *l) @@ -86,7 +86,7 @@ void struct_RenderModel_t_091_win_to_lin(void *w, void *l) lin->unVertexCount = win->unVertexCount; lin->rIndexData = win->rIndexData; lin->unTriangleCount = win->unTriangleCount; - win_to_lin_struct_vr::RenderModel_TextureMap_t_091(&win->diffuseTexture, &lin->diffuseTexture); + struct_RenderModel_TextureMap_t_091_win_to_lin(&win->diffuseTexture, &lin->diffuseTexture); } struct winRenderModel_t_091 *struct_RenderModel_t_091_wrap(void *l) @@ -98,7 +98,7 @@ struct winRenderModel_t_091 *struct_RenderModel_t_091_wrap(void *l) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - win->diffuseTexture = lin->diffuseTexture; + struct_RenderModel_TextureMap_t_091_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); win->linux_side = lin; return win; } diff --git a/vrclient_x64/vrclient_x64/struct_converters_0910.cpp b/vrclient_x64/vrclient_x64/struct_converters_0910.cpp index 3ff1bcae..21369dbb 100644 --- a/vrclient_x64/vrclient_x64/struct_converters_0910.cpp +++ b/vrclient_x64/vrclient_x64/struct_converters_0910.cpp @@ -74,7 +74,7 @@ void struct_RenderModel_t_0910_lin_to_win(void *l, void *w) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - lin_to_win_struct_RenderModel_TextureMap_t_0910(&lin->diffuseTexture, &win->diffuseTexture); + struct_RenderModel_TextureMap_t_0910_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); } void struct_RenderModel_t_0910_win_to_lin(void *w, void *l) @@ -86,7 +86,7 @@ void struct_RenderModel_t_0910_win_to_lin(void *w, void *l) lin->unVertexCount = win->unVertexCount; lin->rIndexData = win->rIndexData; lin->unTriangleCount = win->unTriangleCount; - win_to_lin_struct_vr::RenderModel_TextureMap_t_0910(&win->diffuseTexture, &lin->diffuseTexture); + struct_RenderModel_TextureMap_t_0910_win_to_lin(&win->diffuseTexture, &lin->diffuseTexture); } struct winRenderModel_t_0910 *struct_RenderModel_t_0910_wrap(void *l) @@ -98,7 +98,7 @@ struct winRenderModel_t_0910 *struct_RenderModel_t_0910_wrap(void *l) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - win->diffuseTexture = lin->diffuseTexture; + struct_RenderModel_TextureMap_t_0910_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); win->linux_side = lin; return win; } diff --git a/vrclient_x64/vrclient_x64/struct_converters_092.cpp b/vrclient_x64/vrclient_x64/struct_converters_092.cpp index e5db5659..57a5047c 100644 --- a/vrclient_x64/vrclient_x64/struct_converters_092.cpp +++ b/vrclient_x64/vrclient_x64/struct_converters_092.cpp @@ -74,7 +74,7 @@ void struct_RenderModel_t_092_lin_to_win(void *l, void *w) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - lin_to_win_struct_RenderModel_TextureMap_t_092(&lin->diffuseTexture, &win->diffuseTexture); + struct_RenderModel_TextureMap_t_092_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); } void struct_RenderModel_t_092_win_to_lin(void *w, void *l) @@ -86,7 +86,7 @@ void struct_RenderModel_t_092_win_to_lin(void *w, void *l) lin->unVertexCount = win->unVertexCount; lin->rIndexData = win->rIndexData; lin->unTriangleCount = win->unTriangleCount; - win_to_lin_struct_vr::RenderModel_TextureMap_t_092(&win->diffuseTexture, &lin->diffuseTexture); + struct_RenderModel_TextureMap_t_092_win_to_lin(&win->diffuseTexture, &lin->diffuseTexture); } struct winRenderModel_t_092 *struct_RenderModel_t_092_wrap(void *l) @@ -98,7 +98,7 @@ struct winRenderModel_t_092 *struct_RenderModel_t_092_wrap(void *l) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - win->diffuseTexture = lin->diffuseTexture; + struct_RenderModel_TextureMap_t_092_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); win->linux_side = lin; return win; } diff --git a/vrclient_x64/vrclient_x64/struct_converters_093.cpp b/vrclient_x64/vrclient_x64/struct_converters_093.cpp index 00379e17..d84ef5af 100644 --- a/vrclient_x64/vrclient_x64/struct_converters_093.cpp +++ b/vrclient_x64/vrclient_x64/struct_converters_093.cpp @@ -74,7 +74,7 @@ void struct_RenderModel_t_093_lin_to_win(void *l, void *w) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - lin_to_win_struct_RenderModel_TextureMap_t_093(&lin->diffuseTexture, &win->diffuseTexture); + struct_RenderModel_TextureMap_t_093_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); } void struct_RenderModel_t_093_win_to_lin(void *w, void *l) @@ -86,7 +86,7 @@ void struct_RenderModel_t_093_win_to_lin(void *w, void *l) lin->unVertexCount = win->unVertexCount; lin->rIndexData = win->rIndexData; lin->unTriangleCount = win->unTriangleCount; - win_to_lin_struct_vr::RenderModel_TextureMap_t_093(&win->diffuseTexture, &lin->diffuseTexture); + struct_RenderModel_TextureMap_t_093_win_to_lin(&win->diffuseTexture, &lin->diffuseTexture); } struct winRenderModel_t_093 *struct_RenderModel_t_093_wrap(void *l) @@ -98,7 +98,7 @@ struct winRenderModel_t_093 *struct_RenderModel_t_093_wrap(void *l) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - win->diffuseTexture = lin->diffuseTexture; + struct_RenderModel_TextureMap_t_093_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); win->linux_side = lin; return win; } diff --git a/vrclient_x64/vrclient_x64/struct_converters_094.cpp b/vrclient_x64/vrclient_x64/struct_converters_094.cpp index f4ae33e9..ee5f300b 100644 --- a/vrclient_x64/vrclient_x64/struct_converters_094.cpp +++ b/vrclient_x64/vrclient_x64/struct_converters_094.cpp @@ -74,7 +74,7 @@ void struct_RenderModel_t_094_lin_to_win(void *l, void *w) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - lin_to_win_struct_RenderModel_TextureMap_t_094(&lin->diffuseTexture, &win->diffuseTexture); + struct_RenderModel_TextureMap_t_094_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); } void struct_RenderModel_t_094_win_to_lin(void *w, void *l) @@ -86,7 +86,7 @@ void struct_RenderModel_t_094_win_to_lin(void *w, void *l) lin->unVertexCount = win->unVertexCount; lin->rIndexData = win->rIndexData; lin->unTriangleCount = win->unTriangleCount; - win_to_lin_struct_vr::RenderModel_TextureMap_t_094(&win->diffuseTexture, &lin->diffuseTexture); + struct_RenderModel_TextureMap_t_094_win_to_lin(&win->diffuseTexture, &lin->diffuseTexture); } struct winRenderModel_t_094 *struct_RenderModel_t_094_wrap(void *l) @@ -98,7 +98,7 @@ struct winRenderModel_t_094 *struct_RenderModel_t_094_wrap(void *l) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - win->diffuseTexture = lin->diffuseTexture; + struct_RenderModel_TextureMap_t_094_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); win->linux_side = lin; return win; } diff --git a/vrclient_x64/vrclient_x64/struct_converters_096.cpp b/vrclient_x64/vrclient_x64/struct_converters_096.cpp index ba791fff..89702ab5 100644 --- a/vrclient_x64/vrclient_x64/struct_converters_096.cpp +++ b/vrclient_x64/vrclient_x64/struct_converters_096.cpp @@ -74,7 +74,7 @@ void struct_RenderModel_t_096_lin_to_win(void *l, void *w) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - lin_to_win_struct_RenderModel_TextureMap_t_096(&lin->diffuseTexture, &win->diffuseTexture); + struct_RenderModel_TextureMap_t_096_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); } void struct_RenderModel_t_096_win_to_lin(void *w, void *l) @@ -86,7 +86,7 @@ void struct_RenderModel_t_096_win_to_lin(void *w, void *l) lin->unVertexCount = win->unVertexCount; lin->rIndexData = win->rIndexData; lin->unTriangleCount = win->unTriangleCount; - win_to_lin_struct_vr::RenderModel_TextureMap_t_096(&win->diffuseTexture, &lin->diffuseTexture); + struct_RenderModel_TextureMap_t_096_win_to_lin(&win->diffuseTexture, &lin->diffuseTexture); } struct winRenderModel_t_096 *struct_RenderModel_t_096_wrap(void *l) @@ -98,7 +98,7 @@ struct winRenderModel_t_096 *struct_RenderModel_t_096_wrap(void *l) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - win->diffuseTexture = lin->diffuseTexture; + struct_RenderModel_TextureMap_t_096_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); win->linux_side = lin; return win; } diff --git a/vrclient_x64/vrclient_x64/struct_converters_097.cpp b/vrclient_x64/vrclient_x64/struct_converters_097.cpp index 4ad9e3bd..888aa687 100644 --- a/vrclient_x64/vrclient_x64/struct_converters_097.cpp +++ b/vrclient_x64/vrclient_x64/struct_converters_097.cpp @@ -74,7 +74,7 @@ void struct_RenderModel_t_097_lin_to_win(void *l, void *w) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - lin_to_win_struct_RenderModel_TextureMap_t_097(&lin->diffuseTexture, &win->diffuseTexture); + struct_RenderModel_TextureMap_t_097_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); } void struct_RenderModel_t_097_win_to_lin(void *w, void *l) @@ -86,7 +86,7 @@ void struct_RenderModel_t_097_win_to_lin(void *w, void *l) lin->unVertexCount = win->unVertexCount; lin->rIndexData = win->rIndexData; lin->unTriangleCount = win->unTriangleCount; - win_to_lin_struct_vr::RenderModel_TextureMap_t_097(&win->diffuseTexture, &lin->diffuseTexture); + struct_RenderModel_TextureMap_t_097_win_to_lin(&win->diffuseTexture, &lin->diffuseTexture); } struct winRenderModel_t_097 *struct_RenderModel_t_097_wrap(void *l) @@ -98,7 +98,7 @@ struct winRenderModel_t_097 *struct_RenderModel_t_097_wrap(void *l) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - win->diffuseTexture = lin->diffuseTexture; + struct_RenderModel_TextureMap_t_097_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); win->linux_side = lin; return win; } diff --git a/vrclient_x64/vrclient_x64/struct_converters_098.cpp b/vrclient_x64/vrclient_x64/struct_converters_098.cpp index f61a43cf..0c704a8b 100644 --- a/vrclient_x64/vrclient_x64/struct_converters_098.cpp +++ b/vrclient_x64/vrclient_x64/struct_converters_098.cpp @@ -74,7 +74,7 @@ void struct_RenderModel_t_098_lin_to_win(void *l, void *w) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - lin_to_win_struct_RenderModel_TextureMap_t_098(&lin->diffuseTexture, &win->diffuseTexture); + struct_RenderModel_TextureMap_t_098_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); } void struct_RenderModel_t_098_win_to_lin(void *w, void *l) @@ -86,7 +86,7 @@ void struct_RenderModel_t_098_win_to_lin(void *w, void *l) lin->unVertexCount = win->unVertexCount; lin->rIndexData = win->rIndexData; lin->unTriangleCount = win->unTriangleCount; - win_to_lin_struct_vr::RenderModel_TextureMap_t_098(&win->diffuseTexture, &lin->diffuseTexture); + struct_RenderModel_TextureMap_t_098_win_to_lin(&win->diffuseTexture, &lin->diffuseTexture); } struct winRenderModel_t_098 *struct_RenderModel_t_098_wrap(void *l) @@ -98,7 +98,7 @@ struct winRenderModel_t_098 *struct_RenderModel_t_098_wrap(void *l) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - win->diffuseTexture = lin->diffuseTexture; + struct_RenderModel_TextureMap_t_098_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); win->linux_side = lin; return win; } diff --git a/vrclient_x64/vrclient_x64/struct_converters_099.cpp b/vrclient_x64/vrclient_x64/struct_converters_099.cpp index 1349a7e8..795f2124 100644 --- a/vrclient_x64/vrclient_x64/struct_converters_099.cpp +++ b/vrclient_x64/vrclient_x64/struct_converters_099.cpp @@ -74,7 +74,7 @@ void struct_RenderModel_t_099_lin_to_win(void *l, void *w) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - lin_to_win_struct_RenderModel_TextureMap_t_099(&lin->diffuseTexture, &win->diffuseTexture); + struct_RenderModel_TextureMap_t_099_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); } void struct_RenderModel_t_099_win_to_lin(void *w, void *l) @@ -86,7 +86,7 @@ void struct_RenderModel_t_099_win_to_lin(void *w, void *l) lin->unVertexCount = win->unVertexCount; lin->rIndexData = win->rIndexData; lin->unTriangleCount = win->unTriangleCount; - win_to_lin_struct_vr::RenderModel_TextureMap_t_099(&win->diffuseTexture, &lin->diffuseTexture); + struct_RenderModel_TextureMap_t_099_win_to_lin(&win->diffuseTexture, &lin->diffuseTexture); } struct winRenderModel_t_099 *struct_RenderModel_t_099_wrap(void *l) @@ -98,7 +98,7 @@ struct winRenderModel_t_099 *struct_RenderModel_t_099_wrap(void *l) win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; - win->diffuseTexture = lin->diffuseTexture; + struct_RenderModel_TextureMap_t_099_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); win->linux_side = lin; return win; }