pygccxml-development Mailing List for C++ Python language bindings (Page 14)
Brought to you by:
mbaas,
roman_yakovenko
You can subscribe to this list here.
2006 |
Jan
|
Feb
(6) |
Mar
(160) |
Apr
(96) |
May
(152) |
Jun
(72) |
Jul
(99) |
Aug
(189) |
Sep
(161) |
Oct
(110) |
Nov
(9) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(13) |
Feb
(48) |
Mar
(35) |
Apr
(7) |
May
(37) |
Jun
(8) |
Jul
(15) |
Aug
(8) |
Sep
(2) |
Oct
(1) |
Nov
(2) |
Dec
(38) |
2008 |
Jan
(11) |
Feb
(29) |
Mar
(17) |
Apr
(3) |
May
|
Jun
(64) |
Jul
(49) |
Aug
(51) |
Sep
(18) |
Oct
(22) |
Nov
(9) |
Dec
(9) |
2009 |
Jan
(28) |
Feb
(15) |
Mar
(2) |
Apr
(11) |
May
(6) |
Jun
(2) |
Jul
(3) |
Aug
(34) |
Sep
(5) |
Oct
(7) |
Nov
(13) |
Dec
(14) |
2010 |
Jan
(39) |
Feb
(3) |
Mar
(3) |
Apr
(14) |
May
(11) |
Jun
(8) |
Jul
(9) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
(7) |
Apr
|
May
|
Jun
(3) |
Jul
(3) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2016 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2021 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(1) |
Nov
|
Dec
|
From: Roman Y. <rom...@gm...> - 2008-08-26 11:26:28
|
On Tue, Aug 26, 2008 at 8:28 AM, Roman Yakovenko <rom...@gm...> wrote: > On Tue, Aug 26, 2008 at 1:58 AM, Gustavo Carneiro <gjc...@gm...> wrote: >> Sorry, I just discovered it's not a bug. It's not infinite recursion, just >> very slow :P > > This is also bug. I would like to see your use case, so I can improve it. > > The first obvious think we can do is to add cache for element_type > method. This should dramatically improve the speed of your application > - or discover another bottleneck. > >> It turns out that >> pygccxml.declarations.container_traits.xxx_traits.element_type() is rather >> slow and I was calling it more often than I should. >> >> Now, I am left with the old problem of distinguishing between sequence and >> mapping containers... </hint> > > :-). I will work on this today. done. http://pygccxml.svn.sourceforge.net/viewvc/pygccxml?view=rev&revision=1408 I also added cache for element_type and key_type functionality. Let me know whether this change improved performance or not. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Roman Y. <rom...@gm...> - 2008-08-26 05:28:16
|
On Tue, Aug 26, 2008 at 1:58 AM, Gustavo Carneiro <gjc...@gm...> wrote: > Sorry, I just discovered it's not a bug. It's not infinite recursion, just > very slow :P This is also bug. I would like to see your use case, so I can improve it. The first obvious think we can do is to add cache for element_type method. This should dramatically improve the speed of your application - or discover another bottleneck. > It turns out that > pygccxml.declarations.container_traits.xxx_traits.element_type() is rather > slow and I was calling it more often than I should. > > Now, I am left with the old problem of distinguishing between sequence and > mapping containers... </hint> :-). I will work on this today. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Roman Y. <rom...@gm...> - 2008-08-26 05:22:30
|
On Tue, Aug 26, 2008 at 1:27 AM, Gustavo Carneiro <gjc...@gm...> wrote: > Therefore I propose a patch to let pygccxml search in PATH for gccxml, by > default, and let your case be the exception, not the rule. > > I mean, I don't mind making my case a special case, but thinking of other > users I would advise to make unit tests Just Work™ out of the box. What do > you think? I agree with you. I just committed the fix to autoconfig.py http://pygccxml.svn.sourceforge.net/viewvc/pygccxml?view=rev gccxml_configuration_t class will look for gccxml binary in the environment. in case the path was not set -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Gustavo C. <gjc...@gm...> - 2008-08-25 22:58:06
|
2008/8/25 Roman Yakovenko <rom...@gm...> > On Mon, Aug 25, 2008 at 5:57 PM, Gustavo Carneiro <gjc...@gm...> > wrote: > > I just added this simple definition to PyBindGen's unit tests: > > > > std::map<std::string, int> get_map (); > > > > Afterwards, pygccxml (0.9.5) just enters what appears to be an inifinite > > loop when I call container_traits.element_type(). > > > > > > Traceback (most recent call last): > > File "../tests/foomodulegen-auto.py", line 51, in <module> > > main() > > ... > > KeyboardInterrupt > > Looks like a bug. I tested your example and everything works fine to > me, hovewer I tested it for current SVN. Sorry, I just discovered it's not a bug. It's not infinite recursion, just very slow :P It turns out that pygccxml.declarations.container_traits.xxx_traits.element_type() is rather slow and I was calling it more often than I should. Now, I am left with the old problem of distinguishing between sequence and mapping containers... </hint> -- Gustavo J. A. M. Carneiro INESC Porto, Telecommunications and Multimedia Unit "The universe is always one step beyond logic." -- Frank Herbert |
From: Roman Y. <rom...@gm...> - 2008-08-25 18:19:49
|
On Mon, Aug 25, 2008 at 5:57 PM, Gustavo Carneiro <gjc...@gm...> wrote: > I just added this simple definition to PyBindGen's unit tests: > > std::map<std::string, int> get_map (); > > Afterwards, pygccxml (0.9.5) just enters what appears to be an inifinite > loop when I call container_traits.element_type(). > > > Traceback (most recent call last): > File "../tests/foomodulegen-auto.py", line 51, in <module> > main() > ... > KeyboardInterrupt Looks like a bug. I tested your example and everything works fine to me, hovewer I tested it for current SVN. http://pygccxml.svn.sourceforge.net/viewvc/pygccxml?view=rev&revision=1405 > > Additionally, I have to ask, how to run unit tests in pygccxml? I found no > instructions, and the obvious does not seem to work: unittests directory contains "autoconfig.py" file. Take a look on it, I don't think you will have problems to setup your system settings there. I also can commit your setting to SVN. We can achieve this by querying for user name and applying them conditionally. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Gustavo C. <gjc...@gm...> - 2008-08-25 14:57:03
|
I just added this simple definition to PyBindGen's unit tests: std::map<std::string, int> get_map (); Afterwards, pygccxml (0.9.5) just enters what appears to be an inifinite loop when I call container_traits.element_type(). Traceback (most recent call last): File "../tests/foomodulegen-auto.py", line 51, in <module> main() File "../tests/foomodulegen-auto.py", line 48, in main profile.run('my_module_gen()', 'foomodulegen-auto.pstat') File "/usr/lib/python2.5/cProfile.py", line 29, in run prof = prof.run(statement) File "/usr/lib/python2.5/cProfile.py", line 135, in run return self.runctx(cmd, dict, dict) File "/usr/lib/python2.5/cProfile.py", line 140, in runctx exec cmd in globals, locals File "<string>", line 1, in <module> File "../tests/foomodulegen-auto.py", line 27, in my_module_gen gccxml_options=gccxml_options) File "/home/gjc/projects/pybindgen/trunk/pybindgen/gccxmlparser.py", line 599, in parse self.scan_types() File "/home/gjc/projects/pybindgen/trunk/pybindgen/gccxmlparser.py", line 778, in scan_types self._scan_namespace_types(self.module, self.module_namespace, pygen_register_function_name="register_types") File "/home/gjc/projects/pybindgen/trunk/pybindgen/gccxmlparser.py", line 1194, in _scan_namespace_types self._register_container(module, traits, type_info, _outer_class, name) File "/home/gjc/projects/pybindgen/trunk/pybindgen/gccxmlparser.py", line 1313, in _register_container element_type = traits.element_type(definition) File "/usr/local//lib/python2.5/site-packages/pygccxml/declarations/container_traits.py", line 345, in element_type return xxx_traits.impl.element_type( type ) File "/usr/local//lib/python2.5/site-packages/pygccxml/declarations/container_traits.py", line 309, in element_type ref = type_traits.impl_details.find_value_type( cls.top_parent, value_type_str ) File "/usr/local//lib/python2.5/site-packages/pygccxml/declarations/type_traits.py", line 1034, in find_value_type , allow_empty=True ) File "/usr/local//lib/python2.5/site-packages/pygccxml/declarations/scopedef.py", line 385, in decls , allow_empty=allow_empty) File "/usr/local//lib/python2.5/site-packages/pygccxml/declarations/scopedef.py", line 357, in _find_multiple found = matcher_module.matcher.find( matcher, decls, False ) File "/usr/local//lib/python2.5/site-packages/pygccxml/declarations/matcher.py", line 49, in find return filter( decl_matcher, where ) File "/usr/local//lib/python2.5/site-packages/pygccxml/declarations/scopedef.py", line 289, in <lambda> return lambda decl: matcher( decl ) and keywds['function'](decl) File "/usr/local//lib/python2.5/site-packages/pygccxml/declarations/matchers.py", line 210, in __call__ if not self.check_name( decl ): File "/usr/local//lib/python2.5/site-packages/pygccxml/declarations/matchers.py", line 240, in check_name and self.name != algorithm.full_name( decl, with_defaults=False ): File "/usr/local//lib/python2.5/site-packages/pygccxml/declarations/algorithm.py", line 100, in full_name return decl.cache.full_partial_name File "/usr/local//lib/python2.5/site-packages/pygccxml/declarations/algorithms_cache.py", line 42, in _get_full_partial_name def _get_full_partial_name( self ): KeyboardInterrupt Additionally, I have to ask, how to run unit tests in pygccxml? I found no instructions, and the obvious does not seem to work: gjc@dark-tower:unittests$ python test_all.py compiler: __GCCXML_09__ unittests will run on DEVELOPMENT version Traceback (most recent call last): File "test_all.py", line 119, in <module> print run_suite() File "test_all.py", line 110, in run_suite result = unittest.TextTestRunner(verbosity=2).run( create_suite() ) File "test_all.py", line 106, in create_suite main_suite.addTest( tester.create_suite() ) File "/home/gjc/projects/pygccxml_dev/unittests/start_with_declarations_tester.py", line 48, in create_suite suite.addTest( unittest.makeSuite(tester_t)) File "/usr/lib/python2.5/unittest.py", line 602, in makeSuite return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromTestCase(testCaseClass) File "/usr/lib/python2.5/unittest.py", line 507, in loadTestsFromTestCase return self.suiteClass(map(testCaseClass, testCaseNames)) File "/home/gjc/projects/pygccxml_dev/unittests/start_with_declarations_tester.py", line 19, in __init__ self.config = autoconfig.cxx_parsers_cfg.gccxml.clone() AttributeError: 'NoneType' object has no attribute 'clone' -- Gustavo J. A. M. Carneiro INESC Porto, Telecommunications and Multimedia Unit "The universe is always one step beyond logic." -- Frank Herbert |
From: Gordon W. <gor...@gm...> - 2008-08-22 02:12:49
|
in this statement bpl::class_< wrapper_t >( name, bpl::no_init ) .def( "__getitem__" , &wrapper_t::item_ref , ( bpl::arg("index") ) , CallPolicies() ) .def( "__setitem__" , &wrapper_t::set_item , ( bpl::arg("index"), bpl::arg("value") ) , CallPolicies() ) .def( "__len__", &wrapper_t::len ); what does this line , ( bpl::arg("index"), bpl::arg("value") ) do? doesn't the use of the comma operator cause the result of the index part to be discarded? |
From: Roman Y. <rom...@gm...> - 2008-08-21 08:18:15
|
On Thu, Aug 21, 2008 at 9:33 AM, Gordon Wrigley <gor...@gm...> wrote: > in the module builder is there a class that corresponds to the global > context? > > so for example if I had a global variable called bob in my cpp header, is > there a value for the className string in the following statement that would > make the statement valid? > mb.class_(className).decl("bob").exclude() I am not sure what you want. Some code will help. I also suggest you to read this article: http://language-binding.net/pygccxml/query_interface.html HTH -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Gordon W. <gor...@gm...> - 2008-08-21 06:33:32
|
in the module builder is there a class that corresponds to the global context? so for example if I had a global variable called bob in my cpp header, is there a value for the className string in the following statement that would make the statement valid? mb.class_(className).decl("bob").exclude() G |
From: Roman Y. <rom...@gm...> - 2008-08-19 20:11:52
|
On Tue, Aug 19, 2008 at 4:19 PM, Damien Fagnou <dam...@mo...> wrote: > Looking at the result that was what it looked it does > but in one use of it in pyopensg there is those comments that miss lead me > ... > > def unlocked_native(): > ''' > Returns a function transform creator for native functions and methods that > do not hold the GIL while they execute. > ''' > > this use a derived class from FT.transformer_t > with : > def required_headers(self): > return [ pyplusplus.code_repository.gil_guard.file_name ] > > def __configureSealed(self, controller): > # Create a guard for the GIL before the actual fucntion call is made. > # This is an exception-safe approach to managing the GIL. > controller.add_pre_call_code( > 'pyplusplus::threading::gil_guard_t guard(true);' > ) > ..... https://realityforge.vrsource.org/trac/pyopensg/changeset/505 I took a look on the code. May be I am missing something, but the effect achieved is the opposite one. Here is a link to Python documentation: http://docs.python.org/api/threads.html > so could I use the transformer to write a little wrapper that would do what > I need ? May be you not. RAII ( http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization ) is a popular design pattern, so Py++ makes developers life easier. Take a look on http://www.language-binding.net/pyplusplus/documentation/apidocs/pyplusplus.decl_wrappers.calldef_wrapper.member_function_t-class.html add_override_precall_code add_default_precall_code methods. > static boost::python::object applyTo_0fec81cf95d5ecaac2dd1187f0efac01( ... > .... ) > { > ::Muggins::MugginPtr result; > { > /// a object that wrapper the GIL unlocking > scoped_releaseGIL(); > /// my functiontion call > result = inst.applyTo(target); > } > return bp::object( result ); > } The last statement invokes Python, so it has to lock GIL. You can use gil_guard_t and its "ensure" and "release" functions. > or some things like that ? More or less. I don't have a clear example, so cant give you good advice. May be, after all you will have to create custom transformation - in this case, don't forget to contribute it :-) -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Damien F. <dam...@mo...> - 2008-08-19 13:19:08
|
Looking at the result that was what it looked it does but in one use of it in pyopensg there is those comments that miss lead me ... def unlocked_native(): ''' Returns a function transform creator for native functions and methods that do not hold the GIL while they execute. ''' this use a derived class from FT.transformer_t with : def required_headers(self): return [ pyplusplus.code_repository.gil_guard.file_name ] def __configureSealed(self, controller): # Create a guard for the GIL before the actual fucntion call is made. # This is an exception-safe approach to managing the GIL. controller.add_pre_call_code( 'pyplusplus::threading::gil_guard_t guard(true);' ) ..... so could I use the transformer to write a little wrapper that would do what I need ? static boost::python::object applyTo_0fec81cf95d5ecaac2dd1187f0efac01( ... .... ) { ::Muggins::MugginPtr result; { /// a object that wrapper the GIL unlocking scoped_releaseGIL(); /// my functiontion call result = inst.applyTo(target); } return bp::object( result ); } or some things like that ? Thanks Damien > On Tue, Aug 19, 2008 at 2:04 PM, Damien Fagnou > <dam...@mo...> wrote: > >> Hi , >> >> some of the member function that we bind can potentially take some time >> , and we are looking to a way to >> release the GIL during there execution . >> >> looking on the web I see that py++ as some things in place for that : >> gil_guard_t >> and I found couple of project using that , but I am still a little >> confuse on how to use it . >> > > gil_guard_t is used for completely other purposes. > > If you have algorithm, written in C++, which invokes code written in > Python, than you have to lock GIL. This is exactly what gil_guard_t > does. > > Not the opposite. > > >> is there an example somewhere on how to best use it ? >> > > No > > |
From: Roman Y. <rom...@gm...> - 2008-08-19 12:43:58
|
On Tue, Aug 19, 2008 at 2:04 PM, Damien Fagnou <dam...@mo...> wrote: > Hi , > > some of the member function that we bind can potentially take some time > , and we are looking to a way to > release the GIL during there execution . > > looking on the web I see that py++ as some things in place for that : > gil_guard_t > and I found couple of project using that , but I am still a little > confuse on how to use it . gil_guard_t is used for completely other purposes. If you have algorithm, written in C++, which invokes code written in Python, than you have to lock GIL. This is exactly what gil_guard_t does. Not the opposite. > is there an example somewhere on how to best use it ? No -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Damien F. <dam...@mo...> - 2008-08-19 11:04:20
|
Hi , some of the member function that we bind can potentially take some time , and we are looking to a way to release the GIL during there execution . looking on the web I see that py++ as some things in place for that : gil_guard_t and I found couple of project using that , but I am still a little confuse on how to use it . is there an example somewhere on how to best use it ? Thanks Damien |
From: Gordon W. <gor...@gm...> - 2008-08-18 01:15:34
|
> I would use boost::scoped_ptr I really don't see how that is supposed to work given that scoped pointers are subject to this restriction "If used as a member of a class, must be assigned in the constructor" > I suggest you to use string.Template class. I am sure, you will be pleased with the result. and I am pleased with the result, thank you On Sun, Jul 13, 2008 at 3:14 PM, Roman Yakovenko <rom...@gm...>wrote: > On Fri, Jul 11, 2008 at 6:51 AM, Gordon Wrigley > <gor...@gm...> wrote: > > I have my char *variables working now, here's the current py++ code I am > > using, any comments would be appreciated > > > > for (className, varName) in stringVars: > > wrapClass = mb.class_(className) > > wrapClass.var(varName).exclude() > > wrapAlias = wrapClass.wrapper_alias > > > > wrapperCode = """ > > char *wrap_%s; > > void set_%s(%s& inst, bp::object obj){ > > char **strPtr = &wrap_%s; > > if(*strPtr != NULL) delete *strPtr; > > bp::extract<std::string> x(obj); > > if (x.check()){ > > std::string str = x(); > > *strPtr = new char[str.length()+1]; > > strcpy_s(*strPtr, str.length()+1, str.c_str()); > > }else{ > > *strPtr = NULL; > > } > > inst.%s = *strPtr; > > } > > static boost::python::object get_%s(%s& inst){ > > std::string str; > > if(inst.%s != NULL){ > > std::string str(inst.%s); > > return bp::object(str); > > }else{ > > return bp::object(); > > } > > } > > """ % (varName, varName, className, varName, varName, varName, > > className, varName, varName) > > wrapClass.add_wrapper_code(wrapperCode) > > > > constructorCode = "wrap_%s = NULL;" % (varName) > > add_constructors_body(wrapClass, constructorCode) > > > > registrationCode = 'add_property("%s", &%s::get_%s, &%s::set_%s)' % > > (varName, wrapAlias, varName, wrapAlias, varName) > > wrapClass.add_registration_code(registrationCode) > > As for me you have few problems in this code: > * memory management > you "set..." function allocates the memory, but you don't release > it. If you have many instances created\destroyed during program > execution you will have serious memory leak > I would use boost::scoped_ptr ( > http://www.boost.org/doc/libs/1_35_0/libs/smart_ptr/scoped_ptr.htm ) > or just plain std::string classes > * readability > wrapperCode contains too many "%s" and it is really difficult to > follow what is going on and modify it letter. I suggest you to use > string.Template class( http://www.python.org/doc/2.5.2/lib/node40.html > ). I am sure, you will be pleased with the result. > > > > -- > Roman Yakovenko > C++ Python language binding > http://www.language-binding.net/ > |
From: Thomas R. <tho...@gm...> - 2008-08-17 12:55:55
|
On Sun, Aug 17, 2008 at 3:41 AM, Matthias Baas <mat...@gm...>wrote: > Thomas Rab wrote: > > earlier though. Can I do this for instance: > > inlineASM = mb.namespace("foo").class_("NxMath").member_function("bar") > > inlineASM.exclude() > > Well, assuming that gccxml could parse the files then yes, this should > work. But the problem is that your script never gets to this line > because of the errors you are seeing. > > > Right now because of this function I can't generate any code at all. > > Here is the error I get: > > > > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h: In > > static member function `static void NxMath::sinCos(float, NxF32&, > > NxF32&)': > > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: ` > > _asm' undeclared (first use this function) > > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: (Each > > undeclared identifier is reported only once for each function it > appears > > in.) > > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: syntax > > error before `local' > > You didn't post the full error message (I'm sure there was something > before or after that) but I'm assuming you got that error when > *generating* the Python binding source code (and not when compiling them). > Py++ runs gccxml to parse the header files when you create the module > builder object. If gccxml cannot parse the files you will get an error > and your script terminates. This is why the code where you try to > exclude the function will never get executed. Excluding a function > doesn't mean it will be excluded from the parsing step, it rather means > that the function will be excluded from the Python bindings. > So before you can actually start working with Py++ you have to make sure > that gccxml is able to parse the header files properly. > > - Matthias -<https://lists.sourceforge.net/lists/listinfo/pygccxml-development> > Ah, that's where I got confused. I misunderstood exclude's function. I thought it was supposed to exclude it from parsing. Thanks for clearing that up! -Tom |
From: Matthias B. <mat...@gm...> - 2008-08-17 08:40:56
|
Thomas Rab wrote: > earlier though. Can I do this for instance: > inlineASM = mb.namespace("foo").class_("NxMath").member_function("bar") > inlineASM.exclude() Well, assuming that gccxml could parse the files then yes, this should work. But the problem is that your script never gets to this line because of the errors you are seeing. > Right now because of this function I can't generate any code at all. > Here is the error I get: > > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h: In > static member function `static void NxMath::sinCos(float, NxF32&, > NxF32&)': > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: ` > _asm' undeclared (first use this function) > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: (Each > undeclared identifier is reported only once for each function it appears > in.) > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: syntax > error before `local' You didn't post the full error message (I'm sure there was something before or after that) but I'm assuming you got that error when *generating* the Python binding source code (and not when compiling them). Py++ runs gccxml to parse the header files when you create the module builder object. If gccxml cannot parse the files you will get an error and your script terminates. This is why the code where you try to exclude the function will never get executed. Excluding a function doesn't mean it will be excluded from the parsing step, it rather means that the function will be excluded from the Python bindings. So before you can actually start working with Py++ you have to make sure that gccxml is able to parse the header files properly. I think in your case you have to do the workaround I mentioned in my other mail (creating local copies of the header files that have the function bodies removed). You may still follow Roman's suggestion though and post a message about this in the gccxml mailing list (as it's really a gccxml problem, not a Py++ one). Personally, I don't consider this to be a bug in gccxml though as the offending code apparently is specific to the Microsoft compiler. As far as I know, the syntax for inline assembly code is not part of the C/C++ standard, so every compiler can just do whatever it wants, and I'm not sure if gccxml is meant to be able to emulate all compilers out there (after all, it's called _GCC_xml). But of course, it would be nice if gccxml could handle such a case. Personally, I would prefer an option that instructs gccxml to entirely ignore function bodies when parsing the code (they are not needed by Py++ anyway), then this would also fix my problem on OSX. :) - Matthias - |
From: Roman Y. <rom...@gm...> - 2008-08-17 04:14:12
|
On Sun, Aug 17, 2008 at 4:59 AM, Thomas Rab <tho...@gm...> wrote: > Sorry for not being more clear. Yes, I suppose I did mean if gccxml > supports inline assembly. I thought the answer would be no though, as I has > checked if GCC supported inline asm and it looks like it does, but you need > to do some things before it's able to work. I didn't really read into detail > though. Anyway, that is fine. I can exclude the function. > I'll try to explain the header problem more throughly. You answered the > first part for me Matthias, thanks. I hadn't actually checked if it was in > another namespace (doh!), I was trying to find the correct syntax earlier > though. Can I do this for instance: > inlineASM = mb.namespace("foo").class_("NxMath").member_function("bar") > inlineASM.exclude() > Right now because of this function I can't generate any code at all. Here is > the error I get: > > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h: In > static member function `static void NxMath::sinCos(float, NxF32&, > NxF32&)': > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: ` > _asm' undeclared (first use this function) > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: (Each > undeclared identifier is reported only once for each function it appears > in.) > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: syntax > error before `local' > > I get this error whether or not I exclude the function (the way I had shown > in the previous post). So I'm guess the problem is probably with namespaces > and gccxml can not find the function I'm giving it. Sorry if any of these > are silly questions. I'm still learning how to use py++ and I've never used > GCC before (I've always used Microsoft compilers). GCC surely has some > global define like WIN32 and LINUX to determine OS, does it not? I don't > think that's a problem though. At least I'm not getting any errors related > to it. The errors I posted are the only errors I'm getting at this point. > Hopefully I was a bit more clear this time :) - Tom If I understand right, you are not able to compile your code with gccxml and the reason is "_asm" function usage. I think, that this is a bug in gccxml and it could be fixed by Brad King, gccxml author. I suggest you to create small example and send it to him ( http://www.gccxml.org/mailman/listinfo/gccxml ) The current work-around is to move\comment the function body. HTH -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Thomas R. <tho...@gm...> - 2008-08-17 01:59:03
|
> Maybe he rather means whether *gccxml* supports inline asm. I actually > don't know the answer to that but I would imagine that it supports the > same syntax that gcc supports. Seeing that the posted code has a #ifdef > WIN32, it looks like those assembler statements might only be understood > by the Microsoft compiler. > > If this is the problem then it's similar to a problem I once had on OSX > where some system headers use code in some inline functions that is > specific to Apple's version of gcc. Of course, gccxml didn't understand > those things and issued an error. > My workaround to this problem was to create local copies of those system > headers and remove the function bodies. I could then use those copies > when running gccxml and use the original headers when compiling the > code. It's a bit awkward, but it works. > > > It doesn't matter in which header a function is declared (unless you > explicitly restrict a query to certain headers). > > Is the NxMath class inside a namespace? Then you would have to search > that namespace instead of the root namespace (or use the recursive flag). > > >> But that didn't work either. -Tom > > What do you mean by "it didn't work"? Did it produce an error message? > If so, what was that error? Or did everything run fine but your Python > module just contained more stuff than you wanted? > As Roman said, you should be more specific as to what the actual problem > is (it might also help knowing if you are actually on Windows or not (or > if you did define WIN32 yourself)). > > - Matthias - > > > > Sorry for not being more clear. Yes, I suppose I did mean if gccxml supports inline assembly. I thought the answer would be no though, as I has checked if GCC supported inline asm and it looks like it does, but you need to do some things before it's able to work. I didn't really read into detail though. Anyway, that is fine. I can exclude the function. I'll try to explain the header problem more throughly. You answered the first part for me Matthias, thanks. I hadn't actually checked if it was in another namespace (doh!), I was trying to find the correct syntax earlier though. Can I do this for instance: inlineASM = mb.namespace("foo").class_("NxMath").member_function("bar") inlineASM.exclude() Right now because of this function I can't generate any code at all. Here is the error I get: C:/Program Files/NVIDIA Corporation/NVIDIA PhysX SDK/v2.8.1/SDKs/Foundation/include/NxMath.h: In static member function `static void NxMath::sinCos(float, NxF32&, NxF32&)': C:/Program Files/NVIDIA Corporation/NVIDIA PhysX SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: ` _asm' undeclared (first use this function) C:/Program Files/NVIDIA Corporation/NVIDIA PhysX SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: (Each undeclared identifier is reported only once for each function it appears in.) C:/Program Files/NVIDIA Corporation/NVIDIA PhysX SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: syntax error before `local' I get this error whether or not I exclude the function (the way I had shown in the previous post). So I'm guess the problem is probably with namespaces and gccxml can not find the function I'm giving it. Sorry if any of these are silly questions. I'm still learning how to use py++ and I've never used GCC before (I've always used Microsoft compilers). GCC surely has some global define like WIN32 and LINUX to determine OS, does it not? I don't think that's a problem though. At least I'm not getting any errors related to it. The errors I posted are the only errors I'm getting at this point. Hopefully I was a bit more clear this time :) - Tom |
From: Matthias B. <mat...@gm...> - 2008-08-16 17:13:56
|
Roman Yakovenko wrote: > On Sat, Aug 16, 2008 at 11:23 AM, Thomas Rab <tho...@gm...> wrote: >> Now that I have my other problem solved.. does py++ support inline asm? > > What do you mean? Any way the answer is "no". Maybe he rather means whether *gccxml* supports inline asm. I actually don't know the answer to that but I would imagine that it supports the same syntax that gcc supports. Seeing that the posted code has a #ifdef WIN32, it looks like those assembler statements might only be understood by the Microsoft compiler. If this is the problem then it's similar to a problem I once had on OSX where some system headers use code in some inline functions that is specific to Apple's version of gcc. Of course, gccxml didn't understand those things and issued an error. My workaround to this problem was to create local copies of those system headers and remove the function bodies. I could then use those copies when running gccxml and use the original headers when compiling the code. It's a bit awkward, but it works. >> NX_INLINE void NxMath::sinCos(NxF32 f, NxF32& s, NxF32& c) >> { >> #ifdef WIN32 >> NxF32 localCos, localSin; >> NxF32 local = f; >> _asm fld local >> _asm fsincos >> _asm fstp localCos >> _asm fstp localSin >> c = localCos; >> s = localSin; >> #else >> c = cosf(f); >> s = sinf(f); >> #endif >> } >> It's from the PhysX sdk :P >> This function is in a different header than I'm trying to bind, so this may >> be my issue. How do I exclude a member function if it's in a different >> header than I'm binding? It doesn't matter in which header a function is declared (unless you explicitly restrict a query to certain headers). >> I tried doing it just the way I normally would: >> foo = mb.member_function("foo") >> foo.exclude() >> That didn't work. I also tried specifying the class: >> bar = mb.class_("bar") >> foo = bar.member_function("foo") >> foo.exclude() Is the NxMath class inside a namespace? Then you would have to search that namespace instead of the root namespace (or use the recursive flag). >> But that didn't work either. -Tom What do you mean by "it didn't work"? Did it produce an error message? If so, what was that error? Or did everything run fine but your Python module just contained more stuff than you wanted? As Roman said, you should be more specific as to what the actual problem is (it might also help knowing if you are actually on Windows or not (or if you did define WIN32 yourself)). - Matthias - |
From: Roman Y. <rom...@gm...> - 2008-08-16 10:08:25
|
On Sat, Aug 16, 2008 at 11:23 AM, Thomas Rab <tho...@gm...> wrote: > Now that I have my other problem solved.. does py++ support inline asm? What do you mean? Any way the answer is "no". > If > so, how exactly would I handle a function that uses inline asm? If not, I'm > having problems excluding the function and most likely I'm doing it wrong :P > This is the offending code: > > NX_INLINE void NxMath::sinCos(NxF32 f, NxF32& s, NxF32& c) > { > #ifdef WIN32 > NxF32 localCos, localSin; > NxF32 local = f; > _asm fld local > _asm fsincos > _asm fstp localCos > _asm fstp localSin > c = localCos; > s = localSin; > #else > c = cosf(f); > s = sinf(f); > #endif > } > It's from the PhysX sdk :P > This function is in a different header than I'm trying to bind, so this may > be my issue. How do I exclude a member function if it's in a different > header than I'm binding? I tried doing it just the way I normally would: > foo = mb.member_function("foo") > foo.exclude() > That didn't work. I also tried specifying the class: > bar = mb.class_("bar") > foo = bar.member_function("foo") > foo.exclude() > But that didn't work either. -Tom Sorry, I don't understand your question. Please create small and complete example, that demonstrates the problem. Also can you be clear what the problem is? -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Thomas R. <tho...@gm...> - 2008-08-16 08:23:05
|
Now that I have my other problem solved.. does py++ support inline asm? If so, how exactly would I handle a function that uses inline asm? If not, I'm having problems excluding the function and most likely I'm doing it wrong :P This is the offending code: NX_INLINE void NxMath::sinCos(NxF32 f, NxF32& s, NxF32& c) { #ifdef WIN32 NxF32 localCos, localSin; NxF32 local = f; _asm fld local _asm fsincos _asm fstp localCos _asm fstp localSin c = localCos; s = localSin; #else c = cosf(f); s = sinf(f); #endif } It's from the PhysX sdk :P This function is in a different header than I'm trying to bind, so this may be my issue. How do I exclude a member function if it's in a different header than I'm binding? I tried doing it just the way I normally would: foo = mb.member_function("foo") foo.exclude() That didn't work. I also tried specifying the class: bar = mb.class_("bar") foo = bar.member_function("foo") foo.exclude() But that didn't work either. -Tom |
From: Roman Y. <rom...@gm...> - 2008-08-16 06:51:13
|
On Sat, Aug 16, 2008 at 5:55 AM, Thomas Rab <tho...@gm...> wrote: > I'm currently trying to wrap a header and I had a problem whenever it uses > the size_t type. It's currently reading it as a variable as it doesn't > understand that it's a type. I know this is usually something that the > compiler (Microsoft's C++ compiler) knows. I located a header with what I > thought was the definition, but it still wouldn't compile. I believe cstddef > was the header the definition was in. Here is the line, if this helps any: > > typedef void (*NewtonSerialize) (void* serializeHandle, const void* buffer, > size_t size); > > and here is the error I get: > > Error occured while running GCC-XML: C:/Program > Files/NewtonSDK/sdk/Newton.h:89: error: type specifier omitted for parameter > `size_t' > > Which from my understanding means it doesn't understand it's a type (as it's > not specified), so it thinks it's a parameter, with no type specified. > Note this is my first time wrapping a header that is not mine, so I don't > really know all the gotchas or much about py++ yet (or even boost.python for > that matter). Any help would be appreciated :) -Tom This is exactly what happen to me. I added include to stddef.h file and now code compiles fine. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Thomas R. <tho...@gm...> - 2008-08-16 02:55:16
|
I'm currently trying to wrap a header and I had a problem whenever it uses the size_t type. It's currently reading it as a variable as it doesn't understand that it's a type. I know this is usually something that the compiler (Microsoft's C++ compiler) knows. I located a header with what I thought was the definition, but it still wouldn't compile. I believe cstddef was the header the definition was in. Here is the line, if this helps any: typedef void (*NewtonSerialize) (void* serializeHandle, const void* buffer, size_t size); and here is the error I get: Error occured while running GCC-XML: C:/Program Files/NewtonSDK/sdk/Newton.h:89: error: type specifier omitted for parameter `size_t' Which from my understanding means it doesn't understand it's a type (as it's not specified), so it thinks it's a parameter, with no type specified. Note this is my first time wrapping a header that is not mine, so I don't really know all the gotchas or much about py++ yet (or even boost.python for that matter). Any help would be appreciated :) -Tom |
From: Roman Y. <rom...@gm...> - 2008-08-15 17:58:26
|
On Fri, Aug 15, 2008 at 12:41 AM, Gustavo Carneiro <gjc...@gm...> wrote: > I am trying to use container_traits.find_container_traits(): > > http://www.language-binding.net/pygccxml/apidocs/pygccxml.declarations.container_traits-module.html > > The return value of the function appears to be None or > pygccxml.declarations.container_traits.xxx_traits. What's the deal with > this undocumented xxx_traits object? Sorry, I don't understand the question? xxx_traits is documented in the source code. I think epydoc skipped it. > In a related question, what is the easiest way to distinguish between > sequence (list, vector, set, ...) and associative (*map*) types? And > finally, if I ever get a map_traits, documentation tells me of a > element_type attribute, but how do I get the key type (maps have keys and > values...). I didn't have a need for such functionality, so it is not implemented. The easiest way to add is to extend xxx_traits class and to add few functions: * "is_sequence" * key_type As always, if you can wait a little, I can add this functionality, if not patches are welcome. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Gustavo C. <gjc...@gm...> - 2008-08-14 21:41:26
|
I am trying to use container_traits.find_container_traits(): http://www.language-binding.net/pygccxml/apidocs/pygccxml.declarations.container_traits-module.html The return value of the function appears to be None or pygccxml.declarations.container_traits.xxx_traits. What's the deal with this undocumented xxx_traits object? In a related question, what is the easiest way to distinguish between sequence (list, vector, set, ...) and associative (*map*) types? And finally, if I ever get a map_traits, documentation tells me of a element_type attribute, but how do I get the key type (maps have keys and values...). Thanks in advance. -- Gustavo J. A. M. Carneiro INESC Porto, Telecommunications and Multimedia Unit "The universe is always one step beyond logic." -- Frank Herbert |