|
List Info
Thread: Py++ and inner template classes
|
|
| Py++ and inner template classes |
  Finland |
2008-04-28 07:58:16 |
Can Py++ expose inner classes that come from templates?
I have code which is basically equivalent to the following:
class Outer {
public:
template <typename T>
class Inner {
public:
Inner(T);
};
typedef Inner<int> Inner_int;
Inner_int f();
};
If I use the Py++ module_builder to create bindings for
the code, the class Inner_int is not exposed, and I get
the warning
WARNING: Outer::Inner<int> [class declaration]
> execution error W1040: The declaration is unexposed,
but there are
other declarations, which refer to it. This
> could cause "no to_python converter found"
run time error.
Declarations: Outer::Inner<int> Outer::f() [member
> function]
--
Pertti
_______________________________________________
C++-sig mailing list
C++-sig python.org
http:
//mail.python.org/mailman/listinfo/c++-sig
|
|
| Re: Py++ and inner template classes |

|
2008-04-28 10:26:01 |
On Mon, Apr 28, 2008 at 3:58 PM, Pertti Kellomäki
<pertti.kellomaki tut.fi> wrote:
> Can Py++ expose inner classes that come from
templates?
> I have code which is basically equivalent to the
following:
>
> class Outer {
> public:
> template <typename T>
> class Inner {
> public:
> Inner(T);
> };
> typedef Inner<int> Inner_int;
> Inner_int f();
> };
>
> If I use the Py++ module_builder to create bindings
for
> the code, the class Inner_int is not exposed, and I
get
> the warning
>
> WARNING: Outer::Inner<int> [class declaration]
> > execution error W1040: The declaration is
unexposed, but there are other
> declarations, which refer to it. This
> > could cause "no to_python converter
found" run time error. Declarations:
> Outer::Inner<int> Outer::f() [member
> > function]
I just created new test case and everything works fine:
http://pygccxml.svn.sourceforge.ne
t/viewvc/pygccxml?view=rev&revision=1315
I attached the generated code.
I guess you somehow excluded the class.
--
Roman Yakovenko
C++ Python language binding
http://www.language-
binding.net/
_______________________________________________
C++-sig mailing list
C++-sig python.org
http:
//mail.python.org/mailman/listinfo/c++-sig
|
|
|
| Re: Py++ and inner template classes |
  Finland |
2008-04-29 02:56:52 |
Roman Yakovenko wrote:
> I just created new test case and everything works
fine:
> http://pygccxml.svn.sourceforge.ne
t/viewvc/pygccxml?view=rev&revision=1315
If you remove the body of function f in the test case, i.e.
instead of
Inner_int f() { return Inner_int(23); }
just have
Inner_int f();
then the exposing code is not generated. Should a file a
bug
in Bugzilla for this? Is there some short term workaround
to
force the exposing code to be generated?
Thanks,
--
Pertti
_______________________________________________
C++-sig mailing list
C++-sig python.org
http:
//mail.python.org/mailman/listinfo/c++-sig
|
|
| Re: Py++ and inner template classes |

|
2008-04-29 05:19:52 |
On Tue, Apr 29, 2008 at 10:56 AM, Pertti Kellomäki
<pertti.kellomaki tut.fi> wrote:
> Roman Yakovenko wrote:
>
> > I just created new test case and everything works
fine:
> > http://pygccxml.svn.sourceforge.ne
t/viewvc/pygccxml?view=rev&revision=1315
> >
>
> If you remove the body of function f in the test case,
i.e.
> instead of
>
> Inner_int f() { return Inner_int(23); }
>
> just have
>
> Inner_int f();
>
> then the exposing code is not generated. Should a file
a bug
> in Bugzilla for this?
No
> Is there some short term workaround to force the
exposing code to be generated?
This should help:
http://language-binding.net/pyplusplus
/documentation/how_to/templates.html
Basically you have to instantiate that class, sizeof
operator does this.
--
Roman Yakovenko
C++ Python language binding
http://www.language-
binding.net/
_______________________________________________
C++-sig mailing list
C++-sig python.org
http:
//mail.python.org/mailman/listinfo/c++-sig
|
|
| Re: Py++ and inner template classes |

|
2008-04-29 12:42:02 |
On Tue, Apr 29, 2008 at 3:35 PM, Pertti Kellomäki
<pertti.kellomaki tut.fi> wrote:
> Roman Yakovenko wrote:
>
> > This should help:
> > http://language-binding.net/pyplusplus
/documentation/how_to/templates.html
> >
> > Basically you have to instantiate that class,
sizeof operator does this.
> >
>
> One more thing. Is it possible to do this
non-invasively?
Yes
>I tried
> to play around, but the only way I was able to get the
inner template
> class exposed was to put the sizeof() somewhere in the
same header file
> as the original class. I can do it if necessary, but I
would prefer
> not to clutter the original header file if possible.
You can create another header file and instantiate the class
in it.
Then you can pass it to Py++. Take a look on this page:
http://www.language-binding.n
et/pyplusplus/documentation/how_to/best_practices.html
The short version: create header file, that belongs to
"bindings
project" and include all other files from it.
Instantiate the
templates within the file. Then pass this file to Py++.
HTH
--
Roman Yakovenko
C++ Python language binding
http://www.language-
binding.net/
_______________________________________________
C++-sig mailing list
C++-sig python.org
http:
//mail.python.org/mailman/listinfo/c++-sig
|
|
| Re: Py++ and inner template classes |

|
2008-04-30 13:06:03 |
2008/4/30 Pertti Kellomäki <pertti.kellomaki tut.fi>:
> Not directly related to the inner class issue, but
maybe I am
> not understanding something on the page correctly. It
says:
>
> "Create one header file, which will include all
project header files."
>
> However, when I do this, I do not get bindings for the
project
> headers. I've attached a sample of files to show how I
attempt
> to do it.
This is a known ( to me ) issue:
http://language-binding.
net/pyplusplus/documentation/how_to/absolute_relative_paths.
html
> Or do you mean that one should create one big header
> file by copying the contents of the headers into one
file? That
> certainly works. I'm just not sure which one is meant
by the page.
I've got it right: single header file, that include all
others.
--
Roman Yakovenko
C++ Python language binding
http://www.language-
binding.net/
_______________________________________________
C++-sig mailing list
C++-sig python.org
http:
//mail.python.org/mailman/listinfo/c++-sig
|
|
[1-6]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|