[#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:02240] Re: A few questions

From: Clemens Hintze <c.hintze@...>
Date: 2000-03-29 08:49:01 UTC
List: ruby-talk #2240
Andrew Hunt writes:
>     >> 1. ... Does an extension module have to be in this file to be built
>     >> (it would appear not)?
>     >
>     >No it has not to be in this file. Simple add an directory to 'ext' and
>     >create a MANIFEST file for that extension within its directory. Then
>     >it will be build automagically during the next make run.
> 
> Then why does this file exist?  Solely for static linking?

Yep!

...

>     >Here an instance of class Data will be created. This instance is
>     >wrapping a pointer to an allocated dbmdata struct. Furthermore this
>     >Data instance will fake itself to be a DBM instance! So ruby thinks it
>     >is dealing with a DBM instance instead of a Data instance.
> 
> So the extra C stuff you have allocated adds itself to the other
> stuff (instance vars, etc.) in the DBM instance?

Hmmm ... do I say 'yes' now, or do I say 'no'?!? :-/

Perhaps I have not properly understood the meaning of oyu question. So
I will answer it as I have understood. If I answer the wrong question
now, please let me know!

If you use C to implement a new class (e.g. DBM) and you use
Data_Wrap_Struct to wrap a C pointer to your data, then this C
pointer, of course, will become part of your instance. But on Ruby
level you have no possibility to directly access the data referred by
the wrapped pointer -- means without help from methods of your
extension, coded in C.

If you now implement a new class on Ruby level inheriting from DBM
like this:

   class MyDBM < DBM
      :
   end

then your subclass is not able to access the data.

But if your extension would use instance variables (methods
'rb_iv_get' and 'rb_iv_set') both DBM *and* MyDBM could access them
properly.

So in that sense I should say 'yes'. The data are added to ivars. Only 
you have no direct access to them via Ruby programs...

...

> /\ndy

\cle

-- 
Clemens Hintze  mailto: c.hintze@gmx.net

In This Thread

Prev Next