[C++-sig] Pyste add_method()
Dan Halbert
halbert at bbn.com
Mon Mar 15 16:35:00 CET 2004
>From: Nicodemus <nicodemus at esss.com.br>
>Daniel Holth wrote:
>>I think I've found the solution to my old problem:
>>
>>sync = Class("ogg::sync", "oggcc.h") # part 1
>>
>>syncwrite = Function("ogg::sync_write", "oggpy_wrappers.h") # part 2
>>add_method(sync, "ogg::sync_write")
>>rename(sync.sync_write, "write")
>>exclude(syncwrite)
>>
>>Doesn't work for me: it will say something like:
>>RuntimeError: no ogg::sync_write declaration found!
>>
>>Instead, if I say the class is in the file that declares the wrapper,
>>(oggpy_wrappers.h also includes oggcc.h):
>>
>>sync = Class("ogg::sync", "oggpy_wrappers.h")
>>
>>(insert part 2 here)
>>
>>it works nicely.
This reminds me of the issue I reported about set_wrapper yesterday,
and how it wasn't clear to me how to fix the problem.
Right now, both set_wrapper() and add_method() take a string as a
second argument to name the function, instead of a full-fledged
"declaration info" object, or whatever it's called. We say:
Include("wrappers.h")
set_wrapper(my_function, "my_function_wrapper")
Similarly we say:
add_method(MyClass, "my_new_method")
But suppose the second argument was not a string, but a definition object.
Maybe I'm wrong, but it seems to me clearer to say something like:
my_function_wrapper = Function("my_function_wrapper", "wrappers.h")
set_wrapper(my_function, my_function_wrapper)
and
my_new_method = Function("my_new_method", "new_methods.h")
add_method(MyClass, my_new_method)
Internally to Pyste, this would give set_wrapper() and add_method() more
information to work with.
Dan
More information about the Cplusplus-sig
mailing list