diff options
-rw-r--r-- | ChangeLog | 25 | ||||
-rw-r--r-- | tools/generate_wrap_init.pl.in | 51 | ||||
-rw-r--r-- | tools/m4/base.m4 | 35 | ||||
-rw-r--r-- | tools/m4/class_gtkobject.m4 | 13 | ||||
-rw-r--r-- | tools/m4/member.m4 | 26 | ||||
-rw-r--r-- | tools/m4/method.m4 | 16 | ||||
-rw-r--r-- | tools/pm/Output.pm | 28 | ||||
-rw-r--r-- | tools/pm/WrapParser.pm | 12 |
8 files changed, 189 insertions, 17 deletions
@@ -1,3 +1,28 @@ +2005-11-29 Murray Cumming <murrayc@murrayc.com> + + * tools/m4/base.m4: Add + _DEPRECATE_IFDEF_START and _DEPRECATE_IFDEF_END + macros, to #ifdef-out generated methods. + Added _DEPRECATE_IFDEF_CLASS_START and + _DEPRECATE_IFDEF_CLASS_END for whole classes. + Put _DEPRECATE_IFDEF_CLASS* around all generated + code. It does nothing if the class is not deprecated. + * tools/m4/class_gtkobject.m4: Add _DEPRECATED macro, + used to mark a class as deprecated. + * tools/m4/method.m4: Take an extra parameter, to + optionally mark the method as deprecated, to add + #ifdefs around the code, with + _DEPRECATE_IFDEF_START/END + * tools/pm/Output.pm: _DEPRECATE_IFDEF_START/END + around the declarations of deprecated methods. + * tools/pm/WrapParser.pm: Check for an optional + deprecated parameter to _WRAP_METHOD(). + * tools/m4/member.m4: Allow optional deprecated + method for _MEMBER_GET/SET*() to ifdef the code + out. + * tools/generate_wrap_init.pl.in: Put an #ifdef + around use of deprecated classes. + 2005-11-23 Murray Cumming <murrayc@murrayc.com> * configure.in: Depend on glib 2.9, which diff --git a/tools/generate_wrap_init.pl.in b/tools/generate_wrap_init.pl.in index f3e35cd5..202b5874 100644 --- a/tools/generate_wrap_init.pl.in +++ b/tools/generate_wrap_init.pl.in @@ -16,6 +16,7 @@ my %exceptions = (); my %namespaces = (); # hashmap of lists of strings. my %basenames = (); my %win32_nowrap = (); +my %deprecated = (); # Loop through command line arguments, setting variables: while ($ARGV[0] =~ /^-/) @@ -132,6 +133,10 @@ while ($ARGV[0]) { $win32_nowrap{$cppname} = 1; } + elsif (/_DEPRECATED/) + { + $deprecated{$cppname} = 1; + } } # Store header filename so that we can #include it later: @@ -183,6 +188,12 @@ print "\n//Declarations of the *_get_type() functions:\n\n"; my $i = 0; foreach $i (sort keys %objects) { + if( $deprecated{$i} eq 1 ) + { + # The uc(parent_dir) is a bit of a hack. One day it will get it wrong. + print "#ifndef " . uc($parent_dir) ."_DISABLE_DEPRECATED\n" + } + #On Win32, these classes are not compiled: if( $win32_nowrap{$i} eq 1 ) { @@ -190,11 +201,16 @@ foreach $i (sort keys %objects) } print "GType $basenames{$i}_get_type(void);\n"; - + if( $win32_nowrap{$i} eq 1 ) { print "#endif //G_OS_WIN32\n" } + + if( $deprecated{$i} eq 1 ) + { + print "#endif // *_DISABLE_DEPRECATED\n" + } } print "\n//Declarations of the *_error_quark() functions:\n\n"; @@ -213,6 +229,12 @@ print "\n//Declarations of the *_Class::wrap_new() methods, instead of including my $i = 0; foreach $i (sort keys %objects) { + if( $deprecated{$i} eq 1 ) + { + # The uc(parent_dir) is a bit of a hack. One day it will get it wrong. + print "#ifndef " . uc($parent_dir) ."_DISABLE_DEPRECATED\n" + } + #On Win32, these classes are not compiled: if( $win32_nowrap{$i} eq 1 ) { @@ -233,6 +255,11 @@ foreach $i (sort keys %objects) { print "#endif //G_OS_WIN32\n" } + + if( $deprecated{$i} eq 1 ) + { + print "#endif // *_DISABLE_DEPRECATED\n" + } } # print "\n//Declarations of the *Error::throw_func() methods:\n\n"; @@ -286,6 +313,12 @@ print "// Map gtypes to gtkmm wrapper-creation functions:\n"; foreach $i (sort keys %objects) { + if( $deprecated{$i} eq 1 ) + { + # The uc(parent_dir) is a bit of a hack. One day it will get it wrong. + print "#ifndef " . uc($parent_dir) ."_DISABLE_DEPRECATED\n" + } + #On Win32, these classes are not compiled: if( $win32_nowrap{$i} eq 1 ) { @@ -304,6 +337,11 @@ foreach $i (sort keys %objects) { print "#endif //G_OS_WIN32\n" } + + if( $deprecated{$i} eq 1 ) + { + print "#endif // *_DISABLE_DEPRECATED\n" + } } print "\n"; @@ -311,6 +349,12 @@ print " // Register the gtkmm gtypes:\n"; foreach $i (sort keys %objects) { + if( $deprecated{$i} eq 1 ) + { + # The uc(parent_dir) is a bit of a hack. One day it will get it wrong. + print "#ifndef " . uc($parent_dir) ."_DISABLE_DEPRECATED\n" + } + #On Win32, these classes are not compiled: if( $win32_nowrap{$i} eq 1 ) { @@ -329,6 +373,11 @@ foreach $i (sort keys %objects) { print "#endif //G_OS_WIN32\n" } + + if( $deprecated{$i} eq 1 ) + { + print "#endif // *_DISABLE_DEPRECATED\n" + } } print << "EOF"; diff --git a/tools/m4/base.m4 b/tools/m4/base.m4 index b0ef6be3..8ca26cfe 100644 --- a/tools/m4/base.m4 +++ b/tools/m4/base.m4 @@ -215,9 +215,33 @@ define(`__MODULE__',$2)dnl define(`__MODULE_CANONICAL__',$3)dnl define(`__HEADER_GUARD__',`_`'_UPPER(m4_translit(`$3`'_`'$1', `-', `_'))')dnl define(`__FILE__',$1)dnl +define(`__DEPRECATION_GUARD__',`_UPPER($3)'`_DISABLE_DEPRECATED')dnl _SECTION(SECTION_HEADER1) ') +dnl Start deprecation of individual methods: +define(`_DEPRECATE_IFDEF_START',`dnl +#ifndef __DEPRECATION_GUARD__' +) + +dnl end deprecation of individual methods: +define(`_DEPRECATE_IFDEF_END',`dnl +#endif // __DEPRECATION_GUARD__' +) + +dnl begin optional deprecation of whole class +define(`_DEPRECATE_IFDEF_CLASS_START',`dnl +ifdef(`__BOOL_DEPRECATED__',`dnl +_DEPRECATE_IFDEF_START',`dnl +') +') + +dnl end optional deprecation of whole class +define(`_DEPRECATE_IFDEF_CLASS_END',`dnl +ifdef(`__BOOL_DEPRECATED__',`dnl +_DEPRECATE_IFDEF_END',`dnl +') +') dnl This does all the work of assembling the final output dnl @@ -232,12 +256,17 @@ m4_divert(0)dnl #ifndef __HEADER_GUARD__`'_H #define __HEADER_GUARD__`'_H +_DEPRECATE_IFDEF_CLASS_START + m4_ifelse(__MODULE__,glibmm,,`dnl else #include <glibmm.h> ')dnl _IMPORT(SECTION_HEADER1) _IMPORT(SECTION_HEADER2) _IMPORT(SECTION_HEADER3) + +_DEPRECATE_IFDEF_CLASS_END + #endif /* __HEADER_GUARD__`'_H */ #S 1 dnl Marks the beginning of the private header file. @@ -246,26 +275,30 @@ _IMPORT(SECTION_HEADER3) // Generated by gtkmmproc -- DO NOT MODIFY! #ifndef __HEADER_GUARD__`'_P_H #define __HEADER_GUARD__`'_P_H +_DEPRECATE_IFDEF_CLASS_START _IMPORT(SECTION_PHEADER) +_DEPRECATE_IFDEF_CLASS_END #endif /* __HEADER_GUARD__`'_P_H */ #S 2 dnl Marks the beginning of the source file. // Generated by gtkmmproc -- DO NOT MODIFY! +_DEPRECATE_IFDEF_CLASS_START + #include <__MODULE__/__FILE__.h> #include <__MODULE__/private/__FILE__`'_p.h> _IMPORT(SECTION_CC_INCLUDES) _IMPORT(SECTION_SRC_CUSTOM) - namespace { _IMPORT(SECTION_ANONYMOUS_NAMESPACE) } // anonymous namespace _IMPORT(SECTION_SRC_GENERATED) +_DEPRECATE_IFDEF_CLASS_END m4_divert(-1) m4_undivert() diff --git a/tools/m4/class_gtkobject.m4 b/tools/m4/class_gtkobject.m4 index 1424841d..ab1ea079 100644 --- a/tools/m4/class_gtkobject.m4 +++ b/tools/m4/class_gtkobject.m4 @@ -54,6 +54,14 @@ define(`__BOOL_UNMANAGEABLE__',`$1') _POP() ') +dnl Optionally ifdef-out the whole .h and .cc files: +define(`_DEPRECATED',`dnl +_PUSH() +dnl Define this macro to be tested for later. +define(`__BOOL_DEPRECATED__',`$1') +_POP() +') + dnl Gnome::Canvas::CanvasAA::CanvasAA() needs access to the dnl normally-private canvas_class_ member variable. See comments there. define(`_GMMPROC_PROTECTED_GCLASS',`dnl @@ -69,11 +77,13 @@ dnl _END_CLASS_GTKOBJECT() dnl denotes the end of a class dnl define(`_END_CLASS_GTKOBJECT',` + _SECTION(SECTION_HEADER1) _STRUCT_PROTOTYPE() __NAMESPACE_BEGIN__ class __CPPNAME__`'_Class; __NAMESPACE_END__ _SECTION(SECTION_HEADER3) + namespace Glib { /** @relates __NAMESPACE__::__CPPNAME__ @@ -82,7 +92,8 @@ namespace Glib * @result A C++ instance that wraps this C instance. */ __NAMESPACE__::__CPPNAME__`'* wrap(__CNAME__`'* object, bool take_copy = false); -} +} //namespace Glib + dnl dnl _SECTION(SECTION_PHEADER) diff --git a/tools/m4/member.m4 b/tools/m4/member.m4 index c4665a49..ed144cdd 100644 --- a/tools/m4/member.m4 +++ b/tools/m4/member.m4 @@ -7,22 +7,29 @@ dnl Get: dnl Creates accessors for simple types: -dnl _MEMBER_GET(cpp_name, c_name, cpp_type, c_type) +dnl _MEMBER_GET(cpp_name, c_name, cpp_type, c_type, deprecated (optional)) define(`_MEMBER_GET',`dnl +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ') dnl $3 get_$1() const; +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ') dnl _PUSH(SECTION_CC) +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ') dnl $3 __CPPNAME__::get_$1() const { return _CONVERT($4,$3,`gobj()->$2'); } +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ') dnl _POP()') dnl Creates two accessors for pointer types, one const and one non-const: define(`_MEMBER_GET_PTR',`dnl +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ') dnl $3 get_$1(); const $3 get_$1() const; +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ') dnl _PUSH(SECTION_CC) +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ') dnl $3 __CPPNAME__::get_$1() { return _CONVERT($4,$3,`gobj()->$2'); @@ -32,14 +39,18 @@ const $3 __CPPNAME__::get_$1() const { return _CONVERT($4,const $3,`gobj()->$2'); } +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ') dnl _POP()') dnl Creates accessors for GObject-derived types that must be ref()ed. define(`_MEMBER_GET_GOBJECT',`dnl +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ') dnl Glib::RefPtr<$3> get_$1(); Glib::RefPtr<const $3> get_$1() const; +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ') dnl _PUSH(SECTION_CC) +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ') dnl Glib::RefPtr<$3> __CPPNAME__::get_$1() { Glib::RefPtr<$3> ref_ptr(_CONVERT($4,Glib::RefPtr<$3>,`gobj()->$2')); @@ -61,6 +72,7 @@ dnl We could use the bool with Glib::wrap(), but we want to share the m4 type-co return ref_ptr; } +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ') dnl _POP()') @@ -69,30 +81,41 @@ dnl Set: dnl Creates accessors for simple types: define(`_MEMBER_SET',`dnl +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ') dnl void set_$1(const $3`'& value); +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ') dnl _PUSH(SECTION_CC) +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ') dnl void __CPPNAME__::set_$1(const $3`'& value) { gobj()->$2 = _CONVERT($3,$4,`value'); } +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ') dnl _POP()') dnl Creates accessors for pointer types: define(`_MEMBER_SET_PTR',`dnl +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ') dnl void set_$1($3 value); +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ') dnl _PUSH(SECTION_CC) +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ') dnl void __CPPNAME__::set_$1($3 value) { gobj()->$2 = _CONVERT($3,$4,`value'); } +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ') dnl _POP()') dnl Creates accessors for GObject-derived types that must be ref()ed. define(`_MEMBER_SET_GOBJECT',`dnl +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ') dnl void set_$1(const Glib::RefPtr<$3>& value); +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ') dnl _PUSH(SECTION_CC) +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_START ') dnl void __CPPNAME__::set_$1(const Glib::RefPtr<$3>& value) { Glib::RefPtr<$3> valueOld(_CONVERT($4,Glib::RefPtr<$3>,`gobj()->$2')); //Take possession of the old one, unref-ing it in the destructor. @@ -102,6 +125,7 @@ void __CPPNAME__::set_$1(const Glib::RefPtr<$3>& value) gobj()->$2 = _CONVERT(const Glib::RefPtr<$3>&,$4,`value'); } +ifelse(`$5',`deprecated',`_DEPRECATE_IFDEF_END ') dnl _POP()') diff --git a/tools/m4/method.m4 b/tools/m4/method.m4 index bb2b6bef..ab4dcf4a 100644 --- a/tools/m4/method.m4 +++ b/tools/m4/method.m4 @@ -9,10 +9,11 @@ dnl dnl dnl method -dnl $1 $2 $3 $4 $5 $6 $7 $8 $9 -dnl _METHOD(cppname,cname,cpprettype,crettype,arglist,cargs,const,refreturn,errthrow) +dnl $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 +dnl _METHOD(cppname,cname,cpprettype,crettype,arglist,cargs,const,refreturn,errthrow,deprecated) define(`_METHOD',`dnl _PUSH(SECTION_CC) +ifelse(`$10',,,`_DEPRECATE_IFDEF_START') $3 __CPPNAME__::$1`'($5)ifelse(`$7',1,` const') { ifelse(`$8'`$9',,dnl @@ -28,15 +29,17 @@ ifelse(`$8',,,`dnl ifelse(`$3',void,,` return retvalue;') ')dnl } - +ifelse(`$10',,,`_DEPRECATE_IFDEF_END +') _POP()') dnl dnl static method -dnl $1 $2 $3 $4 $5 $6 $7 $8 -dnl _STATIC_METHOD(cppname,cname,cpprettype,crettype,arglist,cargs,refreturn,errthrow)) +dnl $1 $2 $3 $4 $5 $6 $7 $8 $9 +dnl _STATIC_METHOD(cppname,cname,cpprettype,crettype,arglist,cargs,refreturn,errthrow,deprecated)) define(`_STATIC_METHOD',`dnl _PUSH(SECTION_CC) +ifelse(`$9',,,`_DEPRECATE_IFDEF_START') dnl $3 __CPPNAME__::$1($5) { ifelse(`$7'`$8',,dnl @@ -52,7 +55,8 @@ ifelse(`$7',,,`dnl ifelse(`$3',void,,` return retvalue;') ')dnl } - +ifelse(`$9',,,`_DEPRECATE_IFDEF_END +') _POP()') diff --git a/tools/pm/Output.pm b/tools/pm/Output.pm index a9959364..2000ff5f 100644 --- a/tools/pm/Output.pm +++ b/tools/pm/Output.pm @@ -249,14 +249,32 @@ sub output_wrap_meth($$$$$$) # Doxygen documentation before the method declaration: $self->output_wrap_meth_docs_only($filename, $line_num, $documentation); + # Allow the generated .h/.cc code to have an #ifndef around it. + my $deprecated = ""; + if($$objCDefsFunc{deprecated}) + { + $deprecated = "errthrow" + } + #Declaration: + if($deprecated ne "") + { + $self->append("_DEPRECATE_IFDEF_START\n"); + } + $self->append(" ${cppMethodDecl};"); + if($deprecated ne "") + { + $self->append("\n_DEPRECATE_IFDEF_END\n"); + } + my $refneeded = ""; if($$objCDefsFunc{rettype_needs_ref}) { $refneeded = "refreturn" } + my $errthrow = ""; if($$objCDefsFunc{throw_any_errors}) { @@ -266,7 +284,7 @@ sub output_wrap_meth($$$$$$) #Implementation: my $str; if ($$objCppfunc{static}) { - $str = sprintf("_STATIC_METHOD(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s)dnl\n", + $str = sprintf("_STATIC_METHOD(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s,%s)dnl\n", $$objCppfunc{name}, $$objCDefsFunc{c_name}, $$objCppfunc{rettype}, @@ -274,9 +292,10 @@ sub output_wrap_meth($$$$$$) $objCppfunc->args_types_and_names(), convert_args_cpp_to_c($objCppfunc, $objCDefsFunc, 1, $line_num, $errthrow), #1 means it's static, so it has 'object'. $refneeded, - $errthrow); + $errthrow, + $deprecated); } else { - $str = sprintf("_METHOD(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s,%s)dnl\n", + $str = sprintf("_METHOD(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s,%s,%s)dnl\n", $$objCppfunc{name}, $$objCDefsFunc{c_name}, $$objCppfunc{rettype}, @@ -285,7 +304,8 @@ sub output_wrap_meth($$$$$$) convert_args_cpp_to_c($objCppfunc, $objCDefsFunc, 0, $line_num, $errthrow), $$objCppfunc{const}, $refneeded, - $errthrow); + $errthrow, + $deprecated); } diff --git a/tools/pm/WrapParser.pm b/tools/pm/WrapParser.pm index 9c83a71b..924d3a8e 100644 --- a/tools/pm/WrapParser.pm +++ b/tools/pm/WrapParser.pm @@ -756,18 +756,24 @@ sub on_wrap_method($) } } - # Extra ref needed? - while(scalar(@args) > 2) # If the optional ref/err arguments are there. + # Extra stuff needed? + while(scalar(@args) > 2) # If the optional ref/err/deprecated arguments are there. { my $argRef = string_trim(pop @args); if($argRef eq "refreturn") { $$objCfunc{rettype_needs_ref} = 1; } - if($argRef eq "errthrow") + + if($argRef eq "errthrow") { $$objCfunc{throw_any_errors} = 1; } + + if($argRef eq "deprecated") + { + $$objCfunc{deprecated} = 1; + } } my $commentblock = ""; |