[C++-sig] how do I instantiate templates in pyste with types defined in different files?

Alexis H. Rivera-Rios ahrivera at yahoo.com
Tue Aug 16 03:08:40 CEST 2005


That doesn't do it.  My template declaration is in one
file.  The actual types are in another.  There is no
way for me to tell pyste where the actual types are
when I try to instantiate the class.

For example,

Class("A","a.h")
Class("B","b.h")
Test = Template("Test","test.h")

Test("A","testA")
Test("B","testB") <-- these didn't work because when
the pyste code generator tries to instantiate the
class, it doesn't include the a.h or b.h because there
is no mechanism to tell it how to do so.

This didn't work either:
Include("a.h")
Test("A","testA")

I tried declaring the class as a typedef:

---- somefile.h ----
#include "test.h"
#include "a.h"
typedef Test<A> TestA

Then in pyste
Class("TestA","somefile.h")

Pyste doesn't complain, but doesn't generate any
functions or constructors or anything.  It would
generate something like this:
class_<Test<A>, boost::noncopyable >("TestA", no_init)
    ;

Any ideas? Or ways around this?

Thanks,
Alexis


> template <class A, class B>
> class Test
> {
>    A a;
>    B b;
> };
> 
> Now I want to export an instanciate this template
> class using the types Astruct1, Astruct2 defined in
> atruct1.h and astruct2.h respectively.
> 
> In pyste, I write this:
> 
> Test = Template("Test","test.h")
> Test(["Astruct1","Astruct2","Test1")



Programming Tutorial:
In Python: To do this, do this
In Perl: To do this, do this or this or this or this...
In C: To do this, do this, but be careful
In C++: To do this, do this, but don't do this, be careful of this, watch out for this, and whatever you do, don't do this

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Cplusplus-sig mailing list