Re: [pygccxml-development] templates (again)
Brought to you by:
mbaas,
roman_yakovenko
|
From: Allen B. <al...@vr...> - 2006-08-31 12:42:53
|
Neal Becker wrote:
>On Thursday 31 August 2006 4:58 am, Matthias Baas wrote:
>
>
>>Neal Becker wrote:
>>
>>
>>>// file test.h
>>>#include <boost/numeric/ublas/vector.hpp>
>>>using namespace boost::numeric::ublas;
>>>
>>>typedef vector<int> vector_int;
>>>
>>># File: test_setup.py
>>>from pypp_api import *
>>>
>>>mod = ModuleBuilder(
>>> headerFiles = "test.h",
>>> moduleName = "test"
>>>)
>>>
>>>root = mod.parse()
>>>root.Class("vector_int").expose()
>>>
>>>mod.writeModule()
>>>
>>>result:
>>>[...]
>>> raise RuntimeError, "Query produced no results (filter: %s)"%filter
>>>RuntimeError: Query produced no results (filter: (name=='vector_int') &
>>>(type==CLASS) & (parent=='::'))
>>>
>>>
>>Well, I have never wrapped templates so far. This part of pypp_api was
>>written by Allen. You are not using the Template() method, so I don't
>>know if this could already work or not. Or maybe the result is empty
>>because you are actually querying for a typedef instead of a class...?
>>Try Decl() instead of Class():
>>
>>root.Decl("vector_int").expose()
>>
>>
>>
I think the problem you are running into is that the decl for the
typedef is really just a reference to the real type.
You have to do a little more processing to get to the full type.
The code that I am using right now is in the TemplateBuilder and
TemplateWrapper classes in the goodies contrib:
http://svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/contrib/goodies/goodie_utils.py?revision=500&view=markup
To use this code you would do something like this:
tb = TemplateBuilder()
vec3f_t = tb.Template("osg::vector<float,3>")
# Add autogen code to a header that is included in myheaders list
# using tb.buildAutogenContents() which returns the text that needs
# processed
mb = moduble_builder_t([myheaders], ...)
tb.process(mb)
vec3f = vec3f_t.decl
vec3f.method("getSize").exclude()
mb.builde_code_creator(...)
I am not sure if you will want to use this helper class directly, but it
should at least show you all the steps involved in getting templates
wrapped.
-Allen
>>
>>
>
>OK. This time no error, but no code generated either!
>// This file has been generated by Py++.
>
>#include "boost/python.hpp"
>
>#include "test.h"
>
>namespace bp = boost::python;
>
>BOOST_PYTHON_MODULE(test){
>
>}
>---test.h
>#include <boost/numeric/ublas/vector.hpp>
>typedef boost::numeric::ublas::vector<int> vector_int;
>
>inline void instantiate() {
> sizeof (vector_int);
>}
>
># File: pypp_setup.py
>
>from pypp_api import *
>
>mod = ModuleBuilder(
> headerFiles = "test.h",
> moduleName = "test"
>)
>
>root = mod.parse()
>root.Decl("vector_int").expose()
>
>mod.writeModule()
>
>
>-------------------------------------------------------------------------
>Using Tomcat but need to do more? Need to support web services, security?
>Get stuff done quickly with pre-integrated technology to make your job easier
>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>_______________________________________________
>pygccxml-development mailing list
>pyg...@li...
>https://lists.sourceforge.net/lists/listinfo/pygccxml-development
>
>
>
|