From: Tim L. <tim...@am...> - 2006-03-27 21:31:32
|
ok that worked. for some reason my updating from cvs did not get the newest versions of those files. any idea why? Thanks, Tim Marcelo Matus wrote: > hmmm, probably the changes are not visible yet in the anonymous side. > > try copying the attached file to > > SWIG/Lib/perl > > where SWIG is the swig's installation directory. > > > Marcelo > > > Tim Lee wrote: > >> Didn't seem to work. I may have messed something up though since >> this was my first time building from cvs. How was the fix supposed >> to work (what should be changed)? >> >> Tim >> >> Marcelo Matus wrote: >> >>> Ok, it is fixed now, please try again using the CVS repository. >>> >>> Marcelo >>> >>> >>> >>> Tim Lee wrote: >>> >>>> sure. >>>> >>>> so I have a class defined as follows: >>>> class Foo { >>>> public: >>>> void test(unsigned long long l) >>>> { >>>> std::cout << "number=" << l << std::endl; >>>> } >>>> void test(std::string l) >>>> { >>>> std::cout << "string=" << l << std::endl; >>>> } >>>> }; >>>> >>>> it gets wrapped in a module bar >>>> >>>> in perl: >>>> $gen1 = bar::Foo>new(); >>>> $gen1->test(0); >>>> $gen1->test(5); >>>> $gen1->test(int(5)); >>>> $gen1->test(2523); >>>> >>>> output: >>>> stringr=0 >>>> stringr=5 >>>> stringr=5 >>>> stringr=2523 >>>> >>>> Tim >>>> >>>> Marcelo Matus wrote: >>>> >>>>> Could you also send some of perl code you use to reproduce the >>>>> problem? >>>>> >>>>> thanks, >>>>> >>>>> marcelo >>>>> >>>>> Tim Lee wrote: >>>>> >>>>>> Hi, I've got an overloaded function and the generated dispatch >>>>>> function does not work as expected. I expect the unsigned long >>>>>> long type to have precedence over the string type since long long >>>>>> (signed) does. I'm unsure of how this code is supposed to work, >>>>>> but I've annotated the source with some information gathered from >>>>>> gdb. I tried to figure out how this code is supposed to work but >>>>>> made little headroom. What do ranki, rankm and pi mean? It >>>>>> appears that it doesn't dispatch because the >>>>>> asval_unsigned_long_long function was forced to use stroull and >>>>>> returned the 'cast rank' value of 1. And whenever there is a >>>>>> non-0 cast rank, the dispatch fails. >>>>>> >>>>>> The annotated generated code follows: >>>>>> >>>>>> _wrap_Generator_test__SWIG_0 is the unsigned long long version >>>>>> _wrap_Generator_test__SWIG_1 is the string version >>>>>> >>>>>> dispatch: >>>>>> XS(_wrap_Generator_test) { >>>>>> dXSARGS; >>>>>> >>>>>> { >>>>>> unsigned long _index = 0; >>>>>> SWIG_TypeRank _rank = 0; >>>>>> if (items == 2) { >>>>>> SWIG_TypeRank _ranki = 0; >>>>>> SWIG_TypeRank _rankm = 0; >>>>>> SWIG_TypeRank _pi = 1; >>>>>> int _v = 0; >>>>>> { >>>>>> void *vptr = 0; >>>>>> int res = SWIG_ConvertPtr(ST(0), &vptr, >>>>>> SWIGTYPE_p_Generator, 0); >>>>>> _v = SWIG_CheckState(res); //_v = 1 >>>>>> } >>>>>> if (!_v) goto check_1; >>>>>> _ranki += _v*_pi; //_ranki = 1 >>>>>> _rankm += _pi; //_rankm = 1 >>>>>> _pi *= SWIG_MAXCASTRANK; //_pi = 2 >>>>>> { >>>>>> { >>>>>> int res = SWIG_AsVal_unsigned_SS_long_SS_long >>>>>> SWIG_PERL_CALL_ARGS_2(ST(1), NULL); >>>>>> _v = SWIG_CheckState(res); //_v = 2 >>>>>> } >>>>>> } >>>>>> if (!_v) goto check_1; >>>>>> _ranki += _v*_pi; //_ranki = 5 >>>>>> _rankm += _pi; //_rankm = 3 >>>>>> _pi *= SWIG_MAXCASTRANK; >>>>>> if (!_index || (_ranki < _rank)) { >>>>>> _rank = _ranki; _index = 1; >>>>>> if (_rank == _rankm) goto dispatch; //_rank=5, _rankm=3, >>>>>> do not go to dispatch >>>>>> } >>>>>> } >>>>>> check_1: >>>>>> if (items == 2) { >>>>>> SWIG_TypeRank _ranki = 0; >>>>>> SWIG_TypeRank _rankm = 0; >>>>>> SWIG_TypeRank _pi = 1; >>>>>> int _v = 0; >>>>>> { >>>>>> void *vptr = 0; >>>>>> int res = SWIG_ConvertPtr(ST(0), &vptr, >>>>>> SWIGTYPE_p_Generator, 0); >>>>>> _v = SWIG_CheckState(res); >>>>>> } >>>>>> if (!_v) goto check_2; >>>>>> _ranki += _v*_pi; >>>>>> _rankm += _pi; >>>>>> _pi *= SWIG_MAXCASTRANK; >>>>>> { >>>>>> int res = SWIG_AsPtr_std_string >>>>>> SWIG_PERL_CALL_ARGS_2(ST(1), (std::string**)(0)); >>>>>> _v = SWIG_CheckState(res); >>>>>> } >>>>>> if (!_v) goto check_2; >>>>>> _ranki += _v*_pi; >>>>>> _rankm += _pi; >>>>>> _pi *= SWIG_MAXCASTRANK; >>>>>> if (!_index || (_ranki < _rank)) { >>>>>> _rank = _ranki; _index = 2; >>>>>> if (_rank == _rankm) goto dispatch; >>>>>> } >>>>>> } >>>>>> check_2: >>>>>> dispatch: >>>>>> switch(_index) { >>>>>> case 1: >>>>>> >>>>>> (*PL_markstack_ptr++);SWIG_CALLXS(_wrap_Generator_test__SWIG_0); >>>>>> return; >>>>>> case 2: >>>>>> >>>>>> (*PL_markstack_ptr++);SWIG_CALLXS(_wrap_Generator_test__SWIG_1); >>>>>> return; >>>>>> } >>>>>> } >>>>>> >>>>>> croak("No matching function for overloaded 'Generator_test'"); >>>>>> XSRETURN(0); >>>>>> } >>>>>> >>>>>> >>>>>> >>>>>> SWIGINTERN int >>>>>> SWIG_AsVal_unsigned_SS_long_SS_long SWIG_PERL_DECL_ARGS_2(SV >>>>>> *obj, unsigned long long *val) >>>>>> { >>>>>> if (SvUOK(obj)) { // returns false for unsigned long long >>>>>> if (val) *val = SvUV(obj); >>>>>> return SWIG_OK; >>>>>> } else { >>>>>> int dispatch = 0; >>>>>> const char *nptr = SvPV(obj, PL_na); >>>>>> if (nptr) { >>>>>> char *endptr; >>>>>> unsigned long long v = strtoull(nptr, &endptr,0); >>>>>> if (errno == ERANGE) { >>>>>> errno = 0; >>>>>> return SWIG_OverflowError; >>>>>> } else { >>>>>> if (*endptr == '\0') { >>>>>> if (val) *val = v; >>>>>> return SWIG_AddCast(SWIG_OK); //returns 1+SWIG_OK which is 2 >>>>>> } >>>>>> } >>>>>> } >>>>>> if (!dispatch) { >>>>>> const double mant_max = 1LL << DBL_MANT_DIG; >>>>>> double d; >>>>>> int res = SWIG_AddCast(SWIG_AsVal_double >>>>>> SWIG_PERL_CALL_ARGS_2(obj,&d)); >>>>>> if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { >>>>>> if (val) *val = (unsigned long long)(d); >>>>>> return res; >>>>>> } >>>>>> } >>>>>> } >>>>>> return SWIG_TypeError; >>>>>> } >>>>>> >>>>>> >>>>>> >>>>>> Thanks, >>>>>> Tim >>>>>> >>>>>> >>>>>> >>>>>> ------------------------------------------------------- >>>>>> This SF.Net email is sponsored by xPML, a groundbreaking >>>>>> scripting language >>>>>> that extends applications into web and mobile media. Attend the >>>>>> live webcast >>>>>> and join the prime developer group breaking into this new coding >>>>>> territory! >>>>>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 >>>>>> >>>>>> _______________________________________________ >>>>>> Swig-user mailing list >>>>>> Swi...@li... >>>>>> https://lists.sourceforge.net/lists/listinfo/swig-user >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>> >> >> > |