[#3986] Re: Principle of least effort -- another Ruby virtue. — Andrew Hunt <andy@...>

> Principle of Least Effort.

14 messages 2000/07/14

[#4043] What are you using Ruby for? — Dave Thomas <Dave@...>

16 messages 2000/07/16

[#4139] Facilitating Ruby self-propagation with the rig-it autopolymorph application. — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/07/20

[ruby-talk:04124] Problems with Data_Wrap_Struct

From: Robert Feldt <feldt@...>
Date: 2000-07-19 08:56:20 UTC
List: ruby-talk #4124
I've been using Data_Wrap_Struct in the Ruby extension lib successfully
for wrapping up C/C++ structs and classes by using something like:

static VALUE
myext_new() {
	myclass* c = new myclass;
	return Data_Wrap_Struct(cMyExt, 0, RB_FINALIZER(myext_free), c);
}

where myext_free simply deletes the object. However, now I need to wrap up
a class and save it in a variable in the object. From the docs on
Data_Wrap_Struct I figured I might try:

static void
myext2_inititalize(VALUE self) {
	myclass* c = new myclass;
	VALUE temp = Data_Wrap_Struct(rb_cObject, 0,
RB_FINALIZER(myext_free), c);
	rb_ivar_set(self, rb_intern("@low_level_obj"), temp);
}

but when I run it it hangs on the Data_Wrap_Struct line. Can anyone shed
some light on this and explain in more detail than in the README.EXT file
how the Data_X_Struct defines work/should be used?

I have tried different classes to wrap it in but it doesn't matter. What
I'm I misunderstanding here?

Thanks in advance,

Robert


In This Thread

Prev Next