Struct needs to be a constant?

From: ts [mailto:decoux@moulon.inra.fr]
Sent: Thursday, August 08, 2002 8:08 AM
To: ruby-talk@ruby-lang.org
Cc: ruby-talk@ruby-lang.org
Subject: Re: struct needs to be a constant?

rb_struct_define(“Proto::ProtoStruct”,“name”,“aliases”,“number”,0);
^^^^^^^^^^^^^^^^^^^^
^^
^^

This is this that 1.7 don’t like, and I understand it.

I’m not sure what mean here (I’m having difficulty translating). Are you
saying that this is expected behavior and that you agree with it?

void Init_proto()
^^^^^
^^^^^

Now nobody can write an extension with the name `proto’, even if your
extension is called via ‘require “net/proto”’ :frowning:

Not true, at least not if I understand you correctly. With my own version
of Net::Proto already installed, I wrote this and installed it:

#include “ruby.h”
#include <stdio.h>

void Init_proto()
{
VALUE t_mTest, cTest;
t_mTest = rb_define_module(“Test”);
cTest = rb_define_class_under(t_mTest,“Proto”,rb_cObject);

printf(“Yes, this extension works, even though it’s called ‘Proto’\n”);
}

In the extconf.rb I did this:

require "mkmf"
create_makefile(‘test/proto’)

Then I did:

require "net/proto"
require “test/proto”

It seemed to work fine. Have I missed something?

Regards,

Dan

···

-----Original Message-----

This is this that 1.7 don't like, and I understand it.

I'm not sure what mean here (I'm having difficulty translating). Are you
saying that this is expected behavior and that you agree with it?

Yes expected behavior and yes I agree with it : you have strange
characters "::" in the name of the constant

Not true, at least not if I understand you correctly. With my own version
of Net::Proto already installed, I wrote this and installed it:

Well, personnaly I'll not trust this because you have defined *twice* the
function Init_proto()

Guy Decoux

Hi,

···

At Thu, 8 Aug 2002 23:15:37 +0900, ts wrote:

Not true, at least not if I understand you correctly. With my own version
of Net::Proto already installed, I wrote this and installed it:

Well, personnaly I’ll not trust this because you have defined twice the
function Init_proto()

They are in different modules, and names from extension
libraries are not exported to others by default, unless one was
linked with another.


Nobu Nakada

They are in different modules, and names from extension
libraries are not exported to others by default, unless one was
linked with another.

And if someone want to have a static version of ruby with these libraries,
how he do this ?

Guy Decoux

Hi,

···

At Fri, 9 Aug 2002 17:02:19 +0900, ts wrote:

They are in different modules, and names from extension
libraries are not exported to others by default, unless one was
linked with another.

And if someone want to have a static version of ruby with these libraries,
how he do this ?

I see. The issue would need discussion. How do you consider?


Nobu Nakada

I see. The issue would need discussion. How do you consider?

No good idea, actually. but try to compile a static version of ruby with
tk and you'll see that actually it exist a problem.

Guy Decoux

Hi,

I see. The issue would need discussion. How do you consider?

No good idea, actually.

What about searching Init_“feature”() function first? If it
failed, search Init_“basename”() function as now.

but try to compile a static version of ruby with
tk and you’ll see that actually it exist a problem.

Hmmm, I’m not sure but do you mean the difference between the
directory name “tk” and the module name “tkutil”?

···

At Fri, 9 Aug 2002 18:28:26 +0900, ts wrote:


Nobu Nakada

Hmmm, I'm not sure but do you mean the difference between the
directory name "tk" and the module name "tkutil"?

Yes, this is this case

  static version of ruby

pigeon% ldd ruby
        not a dynamic executable
pigeon%

ruby has registered "tk"

pigeon% ./ruby -e 'p $"'
["curses", "dbm", "digest", "dl", "etc", "fcntl", "gdbm", "iconv", "nkf",
"pty", "readline", "sdbm", "socket", "stringio", "strscan", "syslog",
"tcltklib", "tk", "digest/md5", "digest/rmd160", "digest/sha1",
"digest/sha2", "racc/cparse"]
pigeon%

but it try to load 'tkutil.so'

pigeon% ./ruby -rtk -e 1
/home/ts/local/r17/lib/ruby/1.7/tk.rb:8:in `require': No such file to load -- tkutil (LoadError)
        from /home/ts/local/r17/lib/ruby/1.7/tk.rb:8
pigeon%

it has generated

        Init_tkutil();
        rb_provide("tk");

I have not yet understood this case, where, apparently, the user request
for an extension but ruby try to load another extension

Guy Decoux

Hi,

···

At Sat, 10 Aug 2002 20:43:58 +0900, ts wrote:

it has generated

    Init_tkutil();
    rb_provide("tk");

I have not yet understood this case, where, apparently, the user request
for an extension but ruby try to load another extension

In this case, I guess extmk.rb.in should be fixed.

Index: extmk.rb.in

RCS file: /cvs/ruby/src/ruby/ext/extmk.rb.in,v
retrieving revision 1.79
diff -u -2 -p -r1.79 extmk.rb.in
extmk.rb.in 29 Jul 2002 07:06:34 -0000 1.79
+++ extmk.rb.in 10 Aug 2002 13:17:58 -0000
@@ -803,5 +803,5 @@ if $extlist.size > 0
\tInit_%s();\n
\trb_provide("%s");\n
-", t, s)
+", t, t)
$extobjs += “ext/”
$extobjs += f


Nobu Nakada

Hi,

···

In message “Re: struct needs to be a constant?” on 02/08/10, nobu.nokada@softhome.net nobu.nokada@softhome.net writes:

    Init_tkutil();
    rb_provide("tk");

I have not yet understood this case, where, apparently, the user request
for an extension but ruby try to load another extension

In this case, I guess extmk.rb.in should be fixed.

Yes, but in a different manner. $static should be updated if $target
is modified in extconf.rb.

						matz.