Hello!
Consider I have:
static VALUE foo_init (self)
{
return self;
}
cFoo = rb_define_class (“Foo”, cFoo);
rb_define_method (cFoo, “initialize”, foo_init, 0);
Now I want, from a method of another class, to create a new Foo
object, which contains nothing.
I don’t want to use Data_Make_Struct() since the object is
not connected with a C structure.
How can I do this simple thing? Perhaps using the NEWOBJ()
macro? But, again how can a specify that the new object’s type
is Foo?
Regards,
···
–
University of Athens I bet the human brain
Physics Department is a kludge --Marvin Minsky
Elias Athanasopoulos wrote:
Now I want, from a method of another class, to create a new Foo
object, which contains nothing.
What about:
VALUE fooInstance;
fooInstance = rb_funcall(cFoo, "new", 0, NULL);
Hope this helps,
Lyle
It does. Thank you.
I wonder if it is complex enough to do the above purely in
C via the Ruby API (it would be faster, I guess).
Regards,
···
On Tue, Dec 23, 2003 at 06:01:53AM +0900, Lyle Johnson wrote:
Now I want, from a method of another class, to create a new Foo
object, which contains nothing.
What about:
VALUE fooInstance;
fooInstance = rb_funcall(cFoo, "new", 0, NULL);
Hope this helps,
–
University of Athens I bet the human brain
Physics Department is a kludge --Marvin Minsky
Or:
#include <intern.h>
VALUE fooInstance = rb_class_new_instance( 0, NULL, cFoo );
···
On Dec 22, 2003, at 2:01 PM, Lyle Johnson wrote:
Elias Athanasopoulos wrote:
Now I want, from a method of another class, to create a new Foo
object, which contains nothing.
What about:
VALUE fooInstance;
fooInstance = rb_funcall(cFoo, "new", 0, NULL);
–
Michael Granger ged@FaerieMUD.org
Rubymage, Believer, Architect
The FaerieMUD Consortium http://www.FaerieMUD.org/