doc_extractor and py++ bug

26 views
Skip to first unread message

Krešimir Špes

unread,
Feb 10, 2009, 6:45:45 PM2/10/09
to Python Ogre Developers
for experimentation purposes, I tried compiling ogre wrapper without
documentation built-in to see how much megabytes can be removed from
the wrapper, but, a problem occours and I think it's related to py++.

here's a sample from genereated file AnimableObject.pypp.cpp:


WITHOUT DOC EXTRACTOR:
----------------------

AnimableObject_exposer.def(
"_getAnimableValueNames"
, _getAnimableValueNames_function_type
( &AnimableObject_wrapper::_getAnimableValueNames )
, bp::return_value_policy<
bp::reference_existing_object >()
, <<protected declaration>>\n );

}


WITH DOC EXTRACTOR:
-------------------
AnimableObject_exposer.def(
"_getAnimableValueNames"
, _getAnimableValueNames_function_type
( &AnimableObject_wrapper::_getAnimableValueNames )
, bp::return_value_policy<
bp::reference_existing_object >()
, "<<protected declaration>>\n\
Get an updateable reference to animable value list" );



-------------------

as you can see, the problem is in the line:

<<protected declaration>>\n

which isn't quoted, which causes compiler errors when I try to compile
the wrapper.

Roman Yakovenko

unread,
Feb 11, 2009, 1:18:23 AM2/11/09
to python-ogre...@googlegroups.com
On Wed, Feb 11, 2009 at 1:45 AM, Krešimir Špes <kresim...@gmail.com> wrote:
>
> for experimentation purposes, I tried compiling ogre wrapper without
> documentation built-in to see how much megabytes can be removed from
> the wrapper, but, a problem occours and I think it's related to py++.

I believe - it is not.

Try to search Python-Ogre code for "<<protected declaration>>" or ">>" only.


--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/

Krešimir Špes

unread,
Feb 11, 2009, 4:02:00 AM2/11/09
to Python Ogre Developers
you're right, it's not related to py++, my apologies :)

I've traced it down to this block of code in code_generators
\common_utils\__init__.py

for c in main_ns.calldefs( query, allow_empty=True ):
# print "PROTECTED:", c
s = c.documentation
if not s:
s = ""
c.documentation="<<protected declaration>>\\n"+s

where it should be:

c.documentation="\"<<protected declaration>>\\n\""+s

I'll test this when I get back home, and if turns out it caused the
problem, I'll commit the fix to svn.


so, the way I understand it, python ogre wraps protected functions as
well, so the user can override an ogre class and use protected
functions?
Just out of curiosity, is there a way to disable this feature during
code generation?



On Feb 11, 7:18 am, Roman Yakovenko <roman.yakove...@gmail.com> wrote:

Roman Yakovenko

unread,
Feb 11, 2009, 4:09:34 AM2/11/09
to python-ogre...@googlegroups.com
On Wed, Feb 11, 2009 at 11:02 AM, Krešimir Špes <kresim...@gmail.com> wrote:
>
> you're right, it's not related to py++, my apologies :)
>
> I've traced it down to this block of code in code_generators
> \common_utils\__init__.py
>
> for c in main_ns.calldefs( query, allow_empty=True ):
> # print "PROTECTED:", c
> s = c.documentation
> if not s:
> s = ""
> c.documentation="<<protected declaration>>\\n"+s
>
> where it should be:
>
> c.documentation="\"<<protected declaration>>\\n\""+s
>
> I'll test this when I get back home, and if turns out it caused the
> problem, I'll commit the fix to svn.
>
>
> so, the way I understand it, python ogre wraps protected functions as
> well, so the user can override an ogre class and use protected
> functions?
> Just out of curiosity, is there a way to disable this feature during
> code generation?

Yes: http://language-binding.net/pyplusplus/pyplusplus.html ( look for
"protected" )

On the previous isssue.

If you want to disable documentation string:

1. just before you call "build_code_creator" execute the following code:

mb.decls().documentation = ""

This will remove all documentation from all declarations

2. you have to pass to "build_code_creator" method - doc_extractor=None

This will disable documentation extraction from the source code.

HTH

Andy Miller

unread,
Feb 11, 2009, 6:55:18 AM2/11/09
to python-ogre...@googlegroups.com
This is not the cause of the issue -- the problem you are seeing is that the code generators intentionally don't put quotes on any of the doc strings (as the code became way too ugly etc)..

Instead it is the doc extractor function  (common_utils/extract_documentation) that does all the work and quotes the final doc string...

There is however a small bug in Py++ where functions (and their docstrings) get added to the source without calling the doc extractor function..

If a class has bases, and has one of the base functions inserted into the generated code, and that function happens to have documentation then the code (and doc string) is inserted without the doc extractor function being called.. So it ends up without quotes and in my case fails to compile...

Roman -- I just found this bug with some work I'm doing on the bullet wrapper do you need me to create a unittest to show the problem?

Thanks
Andy

2009/2/11 Krešimir Špes <kresim...@gmail.com>

Roman Yakovenko

unread,
Feb 11, 2009, 7:03:06 AM2/11/09
to python-ogre...@googlegroups.com
On Wed, Feb 11, 2009 at 1:55 PM, Andy Miller <nzmi...@gmail.com> wrote:
> This is not the cause of the issue -- the problem you are seeing is that the
> code generators intentionally don't put quotes on any of the doc strings (as
> the code became way too ugly etc)..
> Instead it is the doc extractor function
> (common_utils/extract_documentation) that does all the work and quotes the
> final doc string...
> There is however a small bug in Py++ where functions (and their docstrings)
> get added to the source without calling the doc extractor function..
> If a class has bases, and has one of the base functions inserted into the
> generated code, and that function happens to have documentation then the
> code (and doc string) is inserted without the doc extractor function being
> called.. So it ends up without quotes and in my case fails to compile...
> Roman -- I just found this bug with some work I'm doing on the bullet
> wrapper do you need me to create a unittest to show the problem?

I don't think so. The description is pretty good.

Krešimir Špes

unread,
Feb 15, 2009, 9:39:44 AM2/15/09
to Python Ogre Developers
has this been fixed? I've temporarily inserted quotation marks in
these strings in python ogre code in my working copy and it compiles
okay.


On Feb 11, 1:03 pm, Roman Yakovenko <roman.yakove...@gmail.com> wrote:

Roman Yakovenko

unread,
Feb 15, 2009, 2:58:33 PM2/15/09
to python-ogre...@googlegroups.com
On Sun, Feb 15, 2009 at 4:39 PM, Krešimir Špes <kresim...@gmail.com> wrote:
>
> has this been fixed? I've temporarily inserted quotation marks in
> these strings in python ogre code in my working copy and it compiles
> okay.

I am working on it right now. I was working on update to my site (
http://www.language-binding.net/ ).

I believe the fix will be available in a few hours from now.

Roman Yakovenko

unread,
Feb 15, 2009, 3:54:21 PM2/15/09
to python-ogre...@googlegroups.com
On Sun, Feb 15, 2009 at 9:58 PM, Roman Yakovenko
<roman.y...@gmail.com> wrote:
> On Sun, Feb 15, 2009 at 4:39 PM, Krešimir Špes <kresim...@gmail.com> wrote:
>>
>> has this been fixed? I've temporarily inserted quotation marks in
>> these strings in python ogre code in my working copy and it compiles
>> okay.
>
> I am working on it right now. I was working on update to my site (
> http://www.language-binding.net/ ).
>
> I believe the fix will be available in a few hours from now.

I committed the fix to SVN

P.S. It takes only 2873.159642 seconds to run 117 tests on my laptop :-(

Reply all
Reply to author
Forward
0 new messages