From: <je...@us...> - 2008-06-09 22:55:20
|
Revision: 10524 http://swig.svn.sourceforge.net/swig/?rev=10524&view=rev Author: jezabek Date: 2008-06-09 15:34:11 -0700 (Mon, 09 Jun 2008) Log Message: ----------- Merged revisions 10498-10499,10503-10504,10506,10508,10511,10515-10516,10518-10519 via svnmerge from https://swig.svn.sourceforge.net/svnroot/swig/trunk ........ r10498 | talby | 2008-05-26 22:09:56 +0200 (Mon, 26 May 2008) | 2 lines run test cases in the Perl set by the --with-perl5 configure option. ........ r10499 | talby | 2008-05-26 23:04:06 +0200 (Mon, 26 May 2008) | 3 lines The perl5 minherit runtime test will work better if the classes are actually built under SWIGPERL. ........ r10503 | wsfulton | 2008-05-28 11:44:37 +0200 (Wed, 28 May 2008) | 1 line Fix variable wrappers when using -proxy. Patch from Jan Jezabek ........ r10504 | bhy | 2008-05-28 19:27:48 +0200 (Wed, 28 May 2008) | 2 lines Fixed SF #1971977: typo in pycontainer.swg (related to -extranative option) ........ r10506 | wsfulton | 2008-05-29 02:45:28 +0200 (Thu, 29 May 2008) | 1 line Fix variable wrappers when using -noproxy ........ r10508 | bhy | 2008-05-30 15:53:33 +0200 (Fri, 30 May 2008) | 1 line Fixed SF #1976978, apply the macros for primitive types to std::wstring ........ r10511 | olly | 2008-05-30 18:11:27 +0200 (Fri, 30 May 2008) | 4 lines Fix typo in handling of /*@SWIG[...]*/ comments in the scanner. This just meant we were only actually looking for /*@SWI at the start of the comment, so was pretty harmless in practice. ........ r10515 | wsfulton | 2008-06-02 22:10:40 +0200 (Mon, 02 Jun 2008) | 1 line Fix samename testcase for c# and java ........ r10516 | wsfulton | 2008-06-02 22:15:39 +0200 (Mon, 02 Jun 2008) | 1 line Fix enums when using -noproxy ........ r10518 | bhy | 2008-06-07 13:20:07 +0200 (Sat, 07 Jun 2008) | 4 lines Added a test case for keyword renaming. Now it works for Python in SWIG's -c++ mode, but in C mode it doesn't work! (you can try with make keyword_rename.ctest) ........ r10519 | bhy | 2008-06-07 15:40:51 +0200 (Sat, 07 Jun 2008) | 1 line fixed keyword_rename.ctest tese case, caused by a mistake in Swig/naming.c ........ Modified Paths: -------------- branches/gsoc2008-jezabek/CHANGES.current branches/gsoc2008-jezabek/Examples/test-suite/common.mk branches/gsoc2008-jezabek/Examples/test-suite/minherit.i branches/gsoc2008-jezabek/Examples/test-suite/perl5/run-perl-test.pl branches/gsoc2008-jezabek/Examples/test-suite/samename.i branches/gsoc2008-jezabek/Lib/python/pycontainer.swg branches/gsoc2008-jezabek/Lib/typemaps/primtypes.swg branches/gsoc2008-jezabek/Source/CParse/cscanner.c branches/gsoc2008-jezabek/Source/Modules/csharp.cxx branches/gsoc2008-jezabek/Source/Modules/java.cxx branches/gsoc2008-jezabek/Source/Swig/naming.c Added Paths: ----------- branches/gsoc2008-jezabek/Examples/test-suite/keyword_rename.i branches/gsoc2008-jezabek/Examples/test-suite/python/keyword_rename_runme.py Property Changed: ---------------- branches/gsoc2008-jezabek/ Property changes on: branches/gsoc2008-jezabek ___________________________________________________________________ Name: svnmerge-integrated - /trunk:1-10491 + /trunk:1-10523 Modified: branches/gsoc2008-jezabek/CHANGES.current =================================================================== --- branches/gsoc2008-jezabek/CHANGES.current 2008-06-09 22:30:25 UTC (rev 10523) +++ branches/gsoc2008-jezabek/CHANGES.current 2008-06-09 22:34:11 UTC (rev 10524) @@ -1,6 +1,24 @@ Version 1.3.36 (in progress) ============================= +06/07/2008: bhy + Added test case keyword_rename, then made the keyword renaming works properly + by fixing Swig_name_make() for a incomplete condition checking. + +06/02/2008: wsfulton + [Java, C#] Fix enum wrappers when using -noproxy. + +05/30/2008: bhy + Added std::wstring into Lib/typemaps/primtypes.swg, since it is also a primitive + type in SWIG - fixed SF #1976978. + +05/29/2008: wsfulton + [Java, C#] Fix variable wrappers when using -noproxy. + +05/29/2008: bhy + [Python] Fixed a typo of %#ifdef in Lib/python/pycontainer.swg, which is related + to -extranative SWIG option - SF #1971977. + 05/20/2008: wsfulton New partialcheck makefile targets for partial testing of the test-suite. These just invoke SWIG, ie no compilation and no runtime testing. It can be faster Modified: branches/gsoc2008-jezabek/Examples/test-suite/common.mk =================================================================== --- branches/gsoc2008-jezabek/Examples/test-suite/common.mk 2008-06-09 22:30:25 UTC (rev 10523) +++ branches/gsoc2008-jezabek/Examples/test-suite/common.mk 2008-06-09 22:34:11 UTC (rev 10524) @@ -202,6 +202,7 @@ inherit_target_language \ inherit_void_arg \ inline_initializer \ + keyword_rename \ kind \ langobj \ li_attribute \ @@ -422,6 +423,7 @@ immutable \ inctest \ integers \ + keyword_rename \ lextype \ li_carrays \ li_cdata \ Copied: branches/gsoc2008-jezabek/Examples/test-suite/keyword_rename.i (from rev 10519, trunk/Examples/test-suite/keyword_rename.i) =================================================================== --- branches/gsoc2008-jezabek/Examples/test-suite/keyword_rename.i (rev 0) +++ branches/gsoc2008-jezabek/Examples/test-suite/keyword_rename.i 2008-06-09 22:34:11 UTC (rev 10524) @@ -0,0 +1,26 @@ +/* + * Test reserved keyword renaming + */ + +%module keyword_rename +%warnfilter(SWIGWARN_PARSE_KEYWORD); +%inline %{ + +#define KW(x, y) int x (int y) { return y;} + +/* Python keywords */ +KW(in, except) +KW(except, in) +KW(raise, in) + +/* Perl keywords */ +KW(tie, die) +KW(use, next) + +/* Java keywords */ +KW(implements, native) +KW(byte, final) + +%} + + Modified: branches/gsoc2008-jezabek/Examples/test-suite/minherit.i =================================================================== --- branches/gsoc2008-jezabek/Examples/test-suite/minherit.i 2008-06-09 22:30:25 UTC (rev 10523) +++ branches/gsoc2008-jezabek/Examples/test-suite/minherit.i 2008-06-09 22:34:11 UTC (rev 10524) @@ -6,7 +6,7 @@ %module(ruby_minherit="1") minherit -#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGOCAML) || defined(SWIGOCTAVE) +#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGOCAML) || defined(SWIGOCTAVE) || defined(SWIGPERL) %inline %{ Modified: branches/gsoc2008-jezabek/Examples/test-suite/perl5/run-perl-test.pl =================================================================== --- branches/gsoc2008-jezabek/Examples/test-suite/perl5/run-perl-test.pl 2008-06-09 22:30:25 UTC (rev 10523) +++ branches/gsoc2008-jezabek/Examples/test-suite/perl5/run-perl-test.pl 2008-06-09 22:34:11 UTC (rev 10524) @@ -7,7 +7,7 @@ my $command = shift @ARGV; -my $output = `perl $command 2>&1`; +my $output = `$^X $command 2>&1`; die "SWIG Perl test failed: \n\n$output\n" if $?; Copied: branches/gsoc2008-jezabek/Examples/test-suite/python/keyword_rename_runme.py (from rev 10519, trunk/Examples/test-suite/python/keyword_rename_runme.py) =================================================================== --- branches/gsoc2008-jezabek/Examples/test-suite/python/keyword_rename_runme.py (rev 0) +++ branches/gsoc2008-jezabek/Examples/test-suite/python/keyword_rename_runme.py 2008-06-09 22:34:11 UTC (rev 10524) @@ -0,0 +1,4 @@ +#!/usr/bin/env python +import keyword_rename +keyword_rename._in(1) +keyword_rename._except(1) Modified: branches/gsoc2008-jezabek/Examples/test-suite/samename.i =================================================================== --- branches/gsoc2008-jezabek/Examples/test-suite/samename.i 2008-06-09 22:30:25 UTC (rev 10523) +++ branches/gsoc2008-jezabek/Examples/test-suite/samename.i 2008-06-09 22:34:11 UTC (rev 10524) @@ -1,7 +1,16 @@ %module samename -%inline { +#if !(defined(SWIGCSHARP) || defined(SWIGJAVA)) +class samename { + public: + void do_something() { + // ... + } +}; +#endif +%{ + class samename { public: void do_something() { @@ -9,5 +18,5 @@ } }; -} +%} Modified: branches/gsoc2008-jezabek/Lib/python/pycontainer.swg =================================================================== --- branches/gsoc2008-jezabek/Lib/python/pycontainer.swg 2008-06-09 22:30:25 UTC (rev 10523) +++ branches/gsoc2008-jezabek/Lib/python/pycontainer.swg 2008-06-09 22:34:11 UTC (rev 10524) @@ -738,12 +738,12 @@ typedef typename sequence::const_iterator const_iterator; static PyObject *from(const sequence& seq) { -#ifdef SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS +%#ifdef SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS swig_type_info *desc = swig::type_info<sequence>(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN); } -#endif +%#endif size_type size = seq.size(); if (size <= (size_type)INT_MAX) { PyObject *obj = PyTuple_New((int)size); Modified: branches/gsoc2008-jezabek/Lib/typemaps/primtypes.swg =================================================================== --- branches/gsoc2008-jezabek/Lib/typemaps/primtypes.swg 2008-06-09 22:30:25 UTC (rev 10523) +++ branches/gsoc2008-jezabek/Lib/typemaps/primtypes.swg 2008-06-09 22:34:11 UTC (rev 10524) @@ -283,6 +283,7 @@ _apply_macro(Macro, std::size_t, Arg2); _apply_macro(Macro, std::ptrdiff_t, Arg2); _apply_macro(Macro, std::string, Arg2); +_apply_macro(Macro, std::wstring, Arg2); _apply_macro(Macro, std::complex<float>, Arg2); _apply_macro(Macro, std::complex<double>, Arg2); %enddef Modified: branches/gsoc2008-jezabek/Source/CParse/cscanner.c =================================================================== --- branches/gsoc2008-jezabek/Source/CParse/cscanner.c 2008-06-09 22:30:25 UTC (rev 10523) +++ branches/gsoc2008-jezabek/Source/CParse/cscanner.c 2008-06-09 22:34:11 UTC (rev 10524) @@ -423,7 +423,7 @@ { String *cmt = Scanner_text(scan); char *loc = Char(cmt); - if ((strncmp(loc,"/*@SWIG@",6) == 0) && (loc[Len(cmt)-3] == '@')) { + if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) { scanner_locator(cmt); } } Modified: branches/gsoc2008-jezabek/Source/Modules/csharp.cxx =================================================================== --- branches/gsoc2008-jezabek/Source/Modules/csharp.cxx 2008-06-09 22:30:25 UTC (rev 10523) +++ branches/gsoc2008-jezabek/Source/Modules/csharp.cxx 2008-06-09 22:34:11 UTC (rev 10524) @@ -1073,7 +1073,9 @@ global_variable_flag = false; generate_property_declaration_flag = false; - Printf(module_class_code, "\n }\n\n"); + if (proxy_flag) { + Printf(module_class_code, "\n }\n\n"); + } return ret; } @@ -1924,7 +1926,7 @@ Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number, "No cstype typemap defined for %s\n", SwigType_str(t, 0)); } - if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { + if (wrapping_member_flag && !enum_constant_flag) { // Properties setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) == 0); if (setter_flag) @@ -2107,7 +2109,7 @@ Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csout typemap defined for %s\n", SwigType_str(t, 0)); } - if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { + if (wrapping_member_flag && !enum_constant_flag) { // Properties if (generate_property_declaration_flag) { // Ensure the declaration is generated just once should the property contain both a set and get // Get the C# variable type - obtained differently depending on whether a setter is required. @@ -2541,6 +2543,7 @@ num_arguments = emit_num_arguments(l); num_required = emit_num_required(l); + bool global_or_member_variable = global_variable_flag || (wrapping_member_flag && !enum_constant_flag); int gencomma = 0; /* Output each parameter */ @@ -2567,7 +2570,7 @@ if (gencomma) Printf(imcall, ", "); - String *arg = makeParameterName(n, p, i, setter_flag); + String *arg = makeParameterName(n, p, i, global_or_member_variable); // Use typemaps to transform type used in C# wrapper function (in proxy class) to type used in PInvoke function (in intermediary class) if ((tm = Getattr(p, "tmap:csin"))) { @@ -2755,7 +2758,7 @@ value = Getattr(n, "enumvalue") ? Copy(Getattr(n, "enumvalue")) : Copy(Getattr(n, "enumvalueex")); } else { // Get the enumvalue from a PINVOKE call - if (!getCurrentClass() || !cparse_cplusplus) { + if (!getCurrentClass() || !cparse_cplusplus || !proxy_flag) { // Strange hack to change the name Setattr(n, "name", Getattr(n, "value")); /* for wrapping of enums in a namespace when emit_action is used */ constantWrapper(n); @@ -2877,7 +2880,7 @@ * n - Node * p - parameter node * arg_num - parameter argument number - * setter - set this flag when wrapping member variables + * setter - set this flag when wrapping variables * Return: * arg - a unique parameter name * ----------------------------------------------------------------------------- */ @@ -2886,20 +2889,22 @@ String *arg = 0; String *pn = Getattr(p, "name"); - if (setter) { + + // Use C parameter name unless it is a duplicate or an empty parameter name + int count = 0; + ParmList *plist = Getattr(n, "parms"); + while (plist) { + if ((Cmp(pn, Getattr(plist, "name")) == 0)) + count++; + plist = nextSibling(plist); + } + String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0; + arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn); + + if (setter && Cmp(arg, "self") != 0) { // Note that in C# properties, the input variable name is always called 'value' + Delete(arg); arg = NewString("value"); - } else { - // Use C parameter name unless it is a duplicate or an empty parameter name - int count = 0; - ParmList *plist = Getattr(n, "parms"); - while (plist) { - if ((Cmp(pn, Getattr(plist, "name")) == 0)) - count++; - plist = nextSibling(plist); - } - String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0; - arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn); } return arg; Modified: branches/gsoc2008-jezabek/Source/Modules/java.cxx =================================================================== --- branches/gsoc2008-jezabek/Source/Modules/java.cxx 2008-06-09 22:30:25 UTC (rev 10523) +++ branches/gsoc2008-jezabek/Source/Modules/java.cxx 2008-06-09 22:34:11 UTC (rev 10524) @@ -1932,7 +1932,7 @@ Swig_warning(WARN_JAVA_TYPEMAP_JSTYPE_UNDEF, input_file, line_number, "No jstype typemap defined for %s\n", SwigType_str(t, 0)); } - if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { + if (wrapping_member_flag && !enum_constant_flag) { // For wrapping member variables (Javabean setter) setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) == 0); } @@ -2463,6 +2463,7 @@ num_arguments = emit_num_arguments(l); num_required = emit_num_required(l); + bool global_or_member_variable = global_variable_flag || (wrapping_member_flag && !enum_constant_flag); int gencomma = 0; /* Output each parameter */ @@ -2487,7 +2488,7 @@ if (gencomma) Printf(imcall, ", "); - String *arg = makeParameterName(n, p, i, setter_flag); + String *arg = makeParameterName(n, p, i, global_or_member_variable); // Use typemaps to transform type used in Java wrapper function (in proxy class) to type used in JNI function (in intermediary class) if ((tm = Getattr(p, "tmap:javain"))) { @@ -2632,7 +2633,7 @@ value = Getattr(n, "enumvalue") ? Copy(Getattr(n, "enumvalue")) : Copy(Getattr(n, "enumvalueex")); } else { // Get the enumvalue from a JNI call - if (!getCurrentClass() || !cparse_cplusplus) { + if (!getCurrentClass() || !cparse_cplusplus || !proxy_flag) { // Strange hack to change the name Setattr(n, "name", Getattr(n, "value")); /* for wrapping of enums in a namespace when emit_action is used */ constantWrapper(n); @@ -2759,7 +2760,7 @@ * n - Node * p - parameter node * arg_num - parameter argument number - * setter - set this flag when wrapping member variables + * setter - set this flag when wrapping variables * Return: * arg - a unique parameter name * ----------------------------------------------------------------------------- */ @@ -2768,21 +2769,23 @@ String *arg = 0; String *pn = Getattr(p, "name"); - if (setter) { + + // Use C parameter name unless it is a duplicate or an empty parameter name + int count = 0; + ParmList *plist = Getattr(n, "parms"); + while (plist) { + if ((Cmp(pn, Getattr(plist, "name")) == 0)) + count++; + plist = nextSibling(plist); + } + String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0; + arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn); + + if (setter && Cmp(arg, "self") != 0) { // Note that for setters the parameter name is always set but sometimes includes C++ // scope resolution, so we need to strip off the scope resolution to make a valid name. + Delete(arg); arg = NewString("value"); //Swig_scopename_last(pn); - } else { - // Use C parameter name unless it is a duplicate or an empty parameter name - int count = 0; - ParmList *plist = Getattr(n, "parms"); - while (plist) { - if ((Cmp(pn, Getattr(plist, "name")) == 0)) - count++; - plist = nextSibling(plist); - } - String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0; - arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn); } return arg; Modified: branches/gsoc2008-jezabek/Source/Swig/naming.c =================================================================== --- branches/gsoc2008-jezabek/Source/Swig/naming.c 2008-06-09 22:30:25 UTC (rev 10523) +++ branches/gsoc2008-jezabek/Source/Swig/naming.c 2008-06-09 22:34:11 UTC (rev 10524) @@ -1477,7 +1477,7 @@ } - if (rename_hash || rename_list) { + if (rename_hash || rename_list || namewarn_hash || namewarn_list) { Hash *rn = Swig_name_object_get(Swig_name_rename_hash(), prefix, name, decl); if (!rn || !Swig_name_match_nameobj(rn, n)) { rn = Swig_name_nameobj_lget(Swig_name_rename_list(), n, prefix, name, decl); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |