From e8cc8ac7e235f84770a8df171c10340597a8cd7a Mon Sep 17 00:00:00 2001 From: Aaron Bockover Date: Mon, 8 Nov 2010 16:48:01 -0500 Subject: [PATCH] More simplification through code generation Moved the maigre-codegen project to be a plain generic MD project --- Maigre.sln | 13 ++++---- Makefile | 2 -- libmaigre/maigre-style.c | 18 +----------- maigre-codegen/Makefile | 9 ------ maigre-codegen/maigre-codegen.mdproj | 44 ++++------------------------ maigre-codegen/maigre-codegen.py | 23 +++++---------- 6 files changed, 22 insertions(+), 87 deletions(-) delete mode 100644 maigre-codegen/Makefile diff --git a/Maigre.sln b/Maigre.sln index 3619ff1..7ca968e 100644 --- a/Maigre.sln +++ b/Maigre.sln @@ -5,22 +5,25 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Maigre", "Maigre\Maigre.csp EndProject Project("{2857B73E-F847-4B02-9238-064979017E93}") = "libmaigre", "libmaigre\libmaigre.cproj", "{3C4985A8-E1D7-4633-8D79-B2816289F777}" EndProject -Project("{9344bdbb-3e7f-41fc-a0dd-8665d75ee146}") = "maigre-codegen", "maigre-codegen\maigre-codegen.mdproj", "{94D14E44-7644-4331-AB34-BA909AE10EC7}" +Project("{9344bdbb-3e7f-41fc-a0dd-8665d75ee146}") = "maigre-codegen", "maigre-codegen\maigre-codegen.mdproj", "{B46730C2-5984-432D-9A11-B08ABAC62C2E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Default|Any CPU = Default|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {1D12C856-6559-4CE2-9DC5-CF2C5CA76D8C}.Debug|x86.ActiveCfg = Debug|x86 {1D12C856-6559-4CE2-9DC5-CF2C5CA76D8C}.Debug|x86.Build.0 = Debug|x86 {3C4985A8-E1D7-4633-8D79-B2816289F777}.Debug|x86.ActiveCfg = Debug|Any CPU {3C4985A8-E1D7-4633-8D79-B2816289F777}.Debug|x86.Build.0 = Debug|Any CPU - {94D14E44-7644-4331-AB34-BA909AE10EC7}.Debug|x86.ActiveCfg = Debug|Any CPU - {94D14E44-7644-4331-AB34-BA909AE10EC7}.Debug|x86.Build.0 = Debug|Any CPU - {94D14E44-7644-4331-AB34-BA909AE10EC7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {94D14E44-7644-4331-AB34-BA909AE10EC7}.Release|Any CPU.Build.0 = Release|Any CPU + {B46730C2-5984-432D-9A11-B08ABAC62C2E}.Debug|x86.ActiveCfg = Default|Any CPU + {B46730C2-5984-432D-9A11-B08ABAC62C2E}.Debug|x86.Build.0 = Default|Any CPU + {B46730C2-5984-432D-9A11-B08ABAC62C2E}.Default|Any CPU.ActiveCfg = Default|Any CPU + {B46730C2-5984-432D-9A11-B08ABAC62C2E}.Default|Any CPU.Build.0 = Default|Any CPU + {B46730C2-5984-432D-9A11-B08ABAC62C2E}.Release|Any CPU.ActiveCfg = Default|Any CPU + {B46730C2-5984-432D-9A11-B08ABAC62C2E}.Release|Any CPU.Build.0 = Default|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = Maigre\Maigre.csproj diff --git a/Makefile b/Makefile index 292bde6..d55dc9f 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,8 @@ all: - $(MAKE) -C maigre-codegen $(MAKE) -C libmaigre $(MAKE) -C Maigre clean: - $(MAKE) -C maigre-codegen clean $(MAKE) -C libmaigre clean $(MAKE) -C Maigre clean rm -rf lib diff --git a/libmaigre/maigre-style.c b/libmaigre/maigre-style.c index 7a0b02f..c508804 100644 --- a/libmaigre/maigre-style.c +++ b/libmaigre/maigre-style.c @@ -51,21 +51,5 @@ maigre_style_init (MaigreStyle *maigre) static void maigre_style_class_init (MaigreStyleClass *klass) { - MaigreMonoBridge *bridge; - gint i; - - bridge = maigre_mono_bridge (); - if (!bridge->init_success) { - return; - } - - maigre_style_init_method_map (); - - for (i = 0; native_draw_methods[i] != NULL; i++) { - DrawFnptr *slot = G_STRUCT_MEMBER_P ( - GTK_STYLE_CLASS (klass), - G_STRUCT_OFFSET (GtkStyleClass, draw_hline) + i * sizeof (gpointer) - ); - *slot = (DrawFnptr)native_draw_methods[i]; - } + maigre_style_override_methods (GTK_STYLE_CLASS (klass)); } \ No newline at end of file diff --git a/maigre-codegen/Makefile b/maigre-codegen/Makefile deleted file mode 100644 index 4a3c7a4..0000000 --- a/maigre-codegen/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -GENERATED = \ - ../libmaigre/maigre-style-overrides.c \ - ../Maigre/Maigre/Theme_Generated.cs - -all: maigre-codegen.py - ./$< - -clean: - rm -rf $(GENERATED) diff --git a/maigre-codegen/maigre-codegen.mdproj b/maigre-codegen/maigre-codegen.mdproj index 45906ff..c75fca8 100644 --- a/maigre-codegen/maigre-codegen.mdproj +++ b/maigre-codegen/maigre-codegen.mdproj @@ -1,50 +1,16 @@ - Debug + Default AnyCPU - PythonProject + GenericProject 9.0.21022 2.0 - {94D14E44-7644-4331-AB34-BA909AE10EC7} + {B46730C2-5984-432D-9A11-B08ABAC62C2E} - - .\Debug - - - - - - - - + + .\ - - .\Release - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/maigre-codegen/maigre-codegen.py b/maigre-codegen/maigre-codegen.py index 724826e..0a8d167 100755 --- a/maigre-codegen/maigre-codegen.py +++ b/maigre-codegen/maigre-codegen.py @@ -104,11 +104,7 @@ for item in draw_context: line = item[0] + ' ' + item[1] out.write (' %s;\n' % line) -out.write ('''} MaigreDrawContext; - -static gpointer *native_draw_methods[%d]; - -''' % (len (methods) + 1)) +out.write ('} MaigreDrawContext;\n') method_index = 0 for method in methods: @@ -143,7 +139,7 @@ for method in methods: static MonoMethod *managed_method = NULL; MaigreMonoBridge *bridge; - MaigreDrawContext draw_context, *dcp; + MaigreDrawContext draw_context, *draw_context_ptr; gpointer args[1]; ''') @@ -174,8 +170,8 @@ for method in methods: out.write (' draw_context.%s = %s;\n' % (var, var)) out.write (''' - dcp = &draw_context; - args[0] = &dcp; + draw_context_ptr = &draw_context; + args[0] = &draw_context_ptr; if (*(guchar *)mono_object_unbox (mono_runtime_invoke ( managed_method, bridge->theme_object, args, NULL)) == 0) { @@ -201,14 +197,12 @@ for method in methods: out.write (''' static void -maigre_style_init_method_map () +maigre_style_override_methods (GtkStyleClass *klass) { ''') -method_index = 0 for method in methods: - out.write (' native_draw_methods[%d] = (gpointer)maigre_style_%s;\n' \ - % (method_index, method[0])) - method_index += 1 + out.write (' klass->%s = maigre_style_%s;\n' \ + % (method[0], method[0])) out.write ('}') @@ -299,8 +293,7 @@ for type, name, gobject_type, native_name in managed_draw_context: : null; ''' % (native_name, name, gobject_type, name)) -out.write (''' - } +out.write (''' } ''')