[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:01912] Re: object creation

From: matz@... (Yukihiro Matsumoto)
Date: 2000-03-16 17:17:05 UTC
List: ruby-talk #1912
In message "[ruby-talk:01894] Re: object creation"
    on 00/03/16, Andrew Hunt <andy@Toolshed.Com> writes:

|	>Yes.  But I think it's better for T_DATA object to use
|	>Data_Make_Struct/Data_Wrap_Struct, as Clemens stated.
|
|Agreed, but here's my real question: suppose you have a non-built-
|in class such as MD5, which does not expose a C-level constructor
|(something like rb_str_new, rb_time_new, etc).  What is the 
|preferred way to create a new MD5 object from C code?

I haven't settled my mind yet about this.

If you want to preserve `initialize' behavior, here's the way:

  a) in `new':

        obj = Data_Wrap_Struct(klass, mark, free, 0);
        rb_obj_call_init(obj, argc, argv);

  b) in `initialize'

        ... you may destroy previous non null DATA_PTR(obj) ...
	DATA_PTR(obj) = allocated struct.

							matz.

In This Thread