aports/community/gir-to-d/add-main-context-pusher.patch
2025-05-14 15:33:21 +00:00

62 lines
1.9 KiB
Diff

diff --git a/source/gtd/GirFunction.d b/source/gtd/GirFunction.d
index 9cb0400..d925b22 100644
--- a/source/gtd/GirFunction.d
+++ b/source/gtd/GirFunction.d
@@ -255,6 +255,19 @@ final class GirFunction
return false;
}
+ /**
+ * Is this function a static inline function.
+ */
+
+ bool isStaticInline()
+ {
+ // Hardcoded list of known static inline functions
+ if (cType.among("g_main_context_pusher_new", "g_main_context_pusher_free"))
+ return true;
+
+ return false;
+}
+
string[] getCallbackDeclaration()
{
string[] buff;
diff --git a/source/gtd/GirPackage.d b/source/gtd/GirPackage.d
index b12c9d5..c54edcc 100644
--- a/source/gtd/GirPackage.d
+++ b/source/gtd/GirPackage.d
@@ -544,6 +544,24 @@ final class GirPackage
buff ~= getLibraries();
+ // Generate implementations for static inline functions
+ if (name == "glib")
+ {
+ // Implementation for g_main_context_pusher_new
+ buff ~= "\n// Static inline function implementations\n";
+ buff ~= "GMainContextPusher* g_main_context_pusher_new(GMainContext* mainContext)\n";
+ buff ~= "{\n";
+ buff ~= "\tg_main_context_push_thread_default(mainContext);\n";
+ buff ~= "\treturn cast(GMainContextPusher*)mainContext;\n";
+ buff ~= "}\n\n";
+
+ // Implementation for g_main_context_pusher_free
+ buff ~= "void g_main_context_pusher_free(GMainContextPusher* pusher)\n";
+ buff ~= "{\n";
+ buff ~= "\tg_main_context_pop_thread_default(cast(GMainContext*)pusher);\n";
+ buff ~= "}\n\n";
+ }
+
buff ~= "\n\n__gshared extern(C)\n"
~ "{\n";
@@ -556,7 +574,7 @@ final class GirPackage
foreach ( funct; strct.functions )
{
- if ( funct.type == GirFunctionType.Callback || funct.type == GirFunctionType.Signal || funct.name.empty )
+ if ( funct.type == GirFunctionType.Callback || funct.type == GirFunctionType.Signal || funct.name.empty || funct.isStaticInline() )
continue;
buff ~= "\t"~ funct.getExternal() ~"\n";