[glib] genmarshal Only wrap body prototypes in C++ guards



commit 100b83a7faf277e2ea5ed2ec6f667ef5ac916416
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Fri Aug 25 09:43:27 2017 +0100

    genmarshal Only wrap body prototypes in C++ guards
    
    Commit 31ae2c559810675aae483269f234a349cd933528 added the C++ guards
    around all prototypes, including inside the header file. The header
    file, though, already has C++ guards, so while it's harmless to have
    them there, it's also unnecessary.
    
    We should only emit C++ guards around the prototypes we include in the
    generated source.

 gobject/glib-genmarshal.in |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/gobject/glib-genmarshal.in b/gobject/glib-genmarshal.in
index ed6de0a..09e8408 100755
--- a/gobject/glib-genmarshal.in
+++ b/gobject/glib-genmarshal.in
@@ -556,7 +556,7 @@ def generate_prototype(retval, params,
                        va_marshal=False):
     '''Generate a marshaller declaration with the given @visibility. If @va_marshal
     is True, the marshaller will use variadic arguments in place of a GValue array.'''
-    signature = ['G_BEGIN_DECLS']
+    signature = []
 
     if visibility == Visibility.INTERNAL:
         signature += ['G_GNUC_INTERNAL']
@@ -585,8 +585,6 @@ def generate_prototype(retval, params,
         signature += [indent('int       n_params,', level=width, fill=' ')]
         signature += [indent('GType    *param_types);', level=width, fill=' ')]
 
-    signature += ['G_END_DECLS']
-
     return signature
 
 
@@ -822,7 +820,11 @@ def generate_marshallers_body(outfile, retval, params,
         else:
             decl_visibility = Visibility.EXTERN
         proto = ['/* Prototype for -Wmissing-prototypes */']
+        # Add C++ guards in case somebody compiles the generated code
+        # with a C++ compiler
+        proto += ['G_BEGIN_DECLS']
         proto += generate_prototype(retval, params, prefix, decl_visibility, False)
+        proto += ['G_END_DECLS']
         outfile.write('\n'.join(proto))
         outfile.write('\n')
 
@@ -838,7 +840,10 @@ def generate_marshallers_body(outfile, retval, params,
             else:
                 decl_visibility = Visibility.EXTERN
             proto = ['/* Prototype for -Wmissing-prototypes */']
+            # Add C++ guards here as well
+            proto += ['G_BEGIN_DECLS']
             proto += generate_prototype(retval, params, prefix, decl_visibility, True)
+            proto += ['G_END_DECLS']
             outfile.write('\n'.join(proto))
             outfile.write('\n')
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]