Data_Wrap_Struct

T

Thomas Sondergaard

Is it okay to wrap something that is not a struct with Data_Wrap_Struct?
Like this where I just wrap an int?

VALUE DotNetObjectToRubyObject(VALUE klass, System::Object *anObject) {
GCHandle gchandle = GCHandle::Alloc(anObject);
int *handle = ALLOC(int);
*handle = GCHandle::eek:p_Explicit(gchandle).ToInt32();
return Data_Wrap_Struct(klass, 0, DotNetHandle_free, handle);
}

Thomas
 
S

Sean O'Dell

Thomas said:
Is it okay to wrap something that is not a struct with Data_Wrap_Struct?
Like this where I just wrap an int?

VALUE DotNetObjectToRubyObject(VALUE klass, System::Object *anObject) {
GCHandle gchandle = GCHandle::Alloc(anObject);
int *handle = ALLOC(int);
*handle = GCHandle::eek:p_Explicit(gchandle).ToInt32();
return Data_Wrap_Struct(klass, 0, DotNetHandle_free, handle);
}

Sure, anything will do. =)

Sean O'Dell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,135
Messages
2,570,783
Members
47,341
Latest member
hanifree

Latest Threads

Top