Mogre Autowrapper and beyond..

Marioko

15-05-2008 16:40:19

Getting the juice from Bekas i want ask him: :twisted:

1) How autowrapper works internally?? i know the surface but there is a lot of thing that i cant understand (its need deep research i dont have time)

2) There is a Attribute.xml file in the autowrapper that contain custom code and wrapping code, how can i add a custom code for a specific class, this is for auto add support for Unicode strings in OgreOverlayElement and OgreOverlayTextElement..

3) What i need to do to improve this autowrapper for autowrap OGRE addons using the same tecnique as mogre?.

4) We need add the option to add Ogre doc in XML doc.. :D

Ok take your time to awnser and thanks in advance.. :lol:

Bekas

22-05-2008 12:45:44

How autowrapper works internally?
First, let me be the first to say that the Autowrapper source is an *awful* mess, no comments, hardly any design thought was poured in it; I consider it a quick hack.
Frankly, I'd never publish the source code if I wasn't going away.

The general idea is reading "meta.xml", making classes to represent the C++ classes found in there, and outputting .h/.cpp with the wrapping process getting directed by the manually created "Attributes.xml".
Ok, this isn't very helpful, I'm way better at more specific questions :)

There is a Attribute.xml file in the autowrapper that contain custom code and wrapping code, how can i add a custom code for a specific class, this is for auto add support for Unicode strings in OgreOverlayElement and OgreOverlayTextElement.
Inside "Attributes.xml" you'll find this:

<class name="Camera">
<function name="forwardIntersect">
<_CustomIncDeclaration>
void ForwardIntersect(Mogre::Plane worldPlane, [Out] array&lt;Mogre::Vector4>^% intersect3d);
</_CustomIncDeclaration>
<_CustomCppDeclaration>
void Camera::ForwardIntersect(Mogre::Plane worldPlane, array&lt;Mogre::Vector4>^% intersect3d)
{
std::vector&lt;Ogre::Vector4> vec;
static_cast&lt;Ogre::Camera*>(_native)->forwardIntersect( worldPlane, &amp;vec);
intersect3d = GetArrayFromVector&lt;Mogre::Vector4, std::vector&lt;Ogre::Vector4> >(vec);
}
</_CustomCppDeclaration>
</function>
</class>


Basically, you specify class and function and use "_CustomIncDeclaration" and/or "_CustomCppDeclaration" to override the wrapping process and specify the exact code that should be put in the automatically produced .h/.cpp files.

Something like this should work for OgreOverlayElement:

<class name="OgreOverlayElement">
<function name="getCaption">
<_CustomCppDeclaration>
String^ OverlayElement::Caption::get()
{
#ifdef OGRE_UNICODE_SUPPORT
return UTF_TO_CLR_STRING( static_cast&lt;const Ogre::OverlayElement*>(_native)->getCaption( ) );
#else
return TO_CLR_STRING( static_cast&lt;const Ogre::OverlayElement*>(_native)->getCaption( ) );
#endif
}
</_CustomCppDeclaration>
</function>
<function name="setCaption">
<_CustomCppDeclaration>
void OverlayElement::Caption::set( String^ text )
{
#ifdef OGRE_UNICODE_SUPPORT
DECLARE_NATIVE_UTFSTRING( o_text, text )
#else
DECLARE_NATIVE_STRING( o_text, text )
#endif
static_cast&lt;Ogre::OverlayElement*>(_native)->setCaption( o_text );
} </_CustomCppDeclaration>
</function>
</class>


You can put it anywhere you like in "Attributes.xml". As a sidenote, you don't have to put everything about a class/function in one place, you can split it too:

<class name="OgreOverlayElement">
<function name="getCaption">
<_CustomCppDeclaration>
.............
</_CustomCppDeclaration>
</function>
</class>

<class name="OgreOverlayElement">
<function name="setCaption">
<_CustomCppDeclaration>
.........
</_CustomCppDeclaration>
</function>
</class>


3) What i need to do to improve this autowrapper for autowrap OGRE addons using the same tecnique as mogre?.
Either dig in the autowrapper code and try to make some sense out of it, or start a new wrapper with the specific design of a "general purpose" wrapper.
Some suggestions about this topic:
-cpp2java has evolved into its own sourceforge project, you should check out what kind of "meta.xml" it produces now.
-Or maybe check out Py++ which python-ogre use to split out the wrapping code. It provides a python API to read the C++ classes using gccxml.

4) We need add the option to add Ogre doc in XML doc..
Maybe xbig (the new cpp2java) puts comments in meta.xml too now. If it does not, it should be possible to add them, since it is based on doxygen which is designed specifically to pick up comments.

Marioko

22-05-2008 14:28:02

Oohh thanks..

Mmm the idea of make a General Purpose autowrapper is great, its solve the addons problem and will work with other non-ogre non-addons libraries.. :D


I going to study about xbig (cpp2java)..

thanks agains.