FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Wrapping D Object

 
Post new topic   Reply to topic     Forum Index -> PyD
View previous topic :: View next topic  
Author Message
Paolo Invernizzi



Joined: 20 Jul 2006
Posts: 17

PostPosted: Wed Nov 28, 2007 9:01 am    Post subject: Wrapping D Object Reply with quote

Hi Kirk,
Just to know if I've understood everything...

- I've wrapped some classes, let's say DButton.
- I instantiate the wrapped class from Python; A PydObject with inside a d_obj pointer to the D class is instantiated.
- I've wrapped a function that take a DButton object. The object is seen in the functions as an istance of class DButton allocated at memory Z;
- I've wrapped a function that take a Object object. I call the function with the same button python instance, and inside it the object is an instance of Object BUT at different address (but the d_obj is not the same?)

As a test, I've wrapped the standard Phobos Object and wrapped a function that accept a PydObject directly, then uses the WrapPyObject_AsObject!(Object)(pydobj.ptr) to extract the Phobos object, and this time the address is correct. Morale: it seems that automatic parameters conversion is not working if the D object to unwrap is a plain Phobos object. Some bug in the templates?

Cheers, and code as example below!
PS... can you contact me at paoloinvernizzi @ fastwebnet DOT it ? I'm on OSX...

Code:

class DButton {
    this(){
        writefln("Inside DButton ctor:%x",cast(void*)(this));
    }
}
void test_button(DButton o){ writefln("DButton->%x",cast(void*)(o)); }
void test_object(Object o){ writefln("Object->%x",cast(void*)(o)); }
void test_pydobject(PydObject o){ writefln("ManualUnwrap->%x",cast(void*)( WrapPyObject_AsObject!(Object)(o.ptr) )); }
...
def!(test_button);
def!(test_object);
def!(test_pydobject);
wrap_class!(DButton);
wrap_class!(Object);

Python...

b = DButton() # Inside DButton ctor:1006E80
test_button(b) # DButton->1006E80
test_object(b) # Object->10003B0  <<<<<==== ???
test_pydobject(b) # ManualUnwrap->1006E80
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> PyD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group