1998-01-16 07:13:05 -05:00
|
|
|
|
.\" README.EXT - -*- Text -*- created at: Mon Aug 7 16:45:54 JST 1995
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
This document explains how to make extention modules for Ruby.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
1<EFBFBD><EFBFBD>Basic knowledge
|
|
|
|
|
|
|
|
|
|
In C, variables have types and data do not have types. In contrast,
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Ruby variables do not have static type and data themselves have
|
1998-01-16 07:13:05 -05:00
|
|
|
|
types. So, data need to be converted across the languages.
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Data in Ruby represented C type `VALUE'. Each VALUE data have its
|
1998-01-16 07:13:05 -05:00
|
|
|
|
data-type.
|
|
|
|
|
|
|
|
|
|
To retrieve an C data from the VALUE, you need to:
|
|
|
|
|
|
|
|
|
|
(1) Identify VALUE's data type
|
|
|
|
|
(2) Convert VALUE into C data
|
|
|
|
|
|
|
|
|
|
Converting to wrong data type may cause serious promblems.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.1 Data-types
|
|
|
|
|
|
|
|
|
|
Ruby interpreter has data-types as below:
|
|
|
|
|
|
|
|
|
|
T_NIL nil
|
|
|
|
|
T_OBJECT ordinaly object
|
|
|
|
|
T_CLASS class
|
|
|
|
|
T_MODULE module
|
|
|
|
|
T_FLOAT floating point number
|
|
|
|
|
T_STRING string
|
|
|
|
|
T_REGEXP regular expression
|
|
|
|
|
T_ARRAY array
|
|
|
|
|
T_FIXNUM Fixnum(31bit integer)
|
|
|
|
|
T_HASH assosiative array
|
1999-01-19 23:59:39 -05:00
|
|
|
|
T_STRUCT (Ruby) structure
|
1998-01-16 07:13:05 -05:00
|
|
|
|
T_BIGNUM multi precision integer
|
|
|
|
|
T_TRUE true
|
|
|
|
|
T_FALSE false
|
|
|
|
|
T_DATA data
|
|
|
|
|
|
|
|
|
|
Otherwise, there are several other types used internally:
|
|
|
|
|
|
|
|
|
|
T_ICLASS
|
|
|
|
|
T_MATCH
|
|
|
|
|
T_VARMAP
|
|
|
|
|
T_SCOPE
|
|
|
|
|
T_NODE
|
|
|
|
|
|
|
|
|
|
Most of the types are represented by C structures.
|
|
|
|
|
|
|
|
|
|
1.2 Check Data Type of the VALUE
|
|
|
|
|
|
|
|
|
|
The macro TYPE() defined in ruby.h shows data-type of the VALUE.
|
|
|
|
|
TYPE() returns the constant number T_XXXX described above. To handle
|
|
|
|
|
data-types, the code will be like:
|
|
|
|
|
|
|
|
|
|
switch (TYPE(obj)) {
|
|
|
|
|
case T_FIXNUM:
|
|
|
|
|
/* process Fixnum */
|
|
|
|
|
break;
|
|
|
|
|
case T_STRING:
|
|
|
|
|
/* process String */
|
|
|
|
|
break;
|
|
|
|
|
case T_ARRAY:
|
|
|
|
|
/* process Array */
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
/* raise exception */
|
|
|
|
|
Fail("not valid value");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
There is the data-type check function.
|
|
|
|
|
|
|
|
|
|
void Check_Type(VALUE value, int type)
|
|
|
|
|
|
|
|
|
|
It raises an exception, if the VALUE does not have the type specified.
|
|
|
|
|
|
|
|
|
|
There are faster check-macros for fixnums and nil.
|
|
|
|
|
|
|
|
|
|
FIXNUM_P(obj)
|
|
|
|
|
NIL_P(obj)
|
|
|
|
|
|
|
|
|
|
1.3 Convert VALUE into C data
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
The data for type T_NIL, T_FALSE, T_TRUE are nil, true, false
|
|
|
|
|
respectively. They are singletons for the data type.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
The T_FIXNUM data is the 31bit length fixed integer (63bit length on
|
|
|
|
|
some machines), which can be conver to the C integer by using
|
|
|
|
|
FIX2INT() macro. There also be NUM2INT() which converts any Ruby
|
|
|
|
|
numbers into C integer. The NUM2INT() macro includes type check, so
|
|
|
|
|
the exception will be raised if conversion failed.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Other data types have corresponding C structures, e.g. struct RArray
|
|
|
|
|
for T_ARRAY etc. VALUE of the type which has corresponding structure
|
|
|
|
|
can be cast to retrieve the pointer to the struct. The casting macro
|
|
|
|
|
RXXXX for each data type like RARRAY(obj). see "ruby.h".
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
For example, `RSTRING(size)->len' is the way to get the size of the
|
|
|
|
|
Ruby String object. The allocated region can be accessed by
|
|
|
|
|
`RSTRING(str)->ptr'. For arrays, `RARRAY(ary)->len' and
|
|
|
|
|
`RARRAY(ary)->ptr' respectively.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Notice: Do not change the value of the structure directly, unless you
|
|
|
|
|
are responsible about the result. It will be the cause of interesting
|
|
|
|
|
bugs.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
1.4 Convert C data into VALUE
|
|
|
|
|
|
|
|
|
|
VALUE<EFBFBD>μºݤι<EFBFBD>¤<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
* FIXNUM<55>ξ<EFBFBD><CEBE><EFBFBD>
|
|
|
|
|
|
|
|
|
|
1bit<69><74><EFBFBD><EFBFBD><EFBFBD>եȤ<D5A5><C8A4>ơ<EFBFBD>LSB<53><42>Ω<EFBFBD>Ƥ롥
|
|
|
|
|
|
|
|
|
|
* <20><><EFBFBD><EFBFBD>¾<EFBFBD>Υݥ<CEA5><DDA5>ξ<F3A5BFA4><CEBE><EFBFBD>
|
|
|
|
|
|
|
|
|
|
<20><><EFBFBD>Τޤ<CEA4>VALUE<55>˥<EFBFBD><CBA5>㥹<EFBFBD>Ȥ<EFBFBD><C8A4>롥
|
|
|
|
|
|
|
|
|
|
<EFB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BFBD><EFBFBD>٤<EFBFBD>)<29><>
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
1.5 Manipulate Ruby data
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
As I already told, it is not recommended to modify object's internal
|
|
|
|
|
structure. To manipulate objects, use functions supplied by Ruby
|
|
|
|
|
interpreter. Useful functions are listed below (not all):
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
String funtions
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
rb_str_new(char *ptr, int len)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Creates a new Ruby string.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
rb_str_new2(char *ptr)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Creates a new Ruby string from C string. This is equivalent to
|
|
|
|
|
rb_str_new(ptr, strlen(ptr)).
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
rb_str_cat(VALUE str, char *ptr, int len)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Appends len bytes data from ptr to the Ruby string.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
Array functions
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
rb_ary_new()
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
Creates an array with no element.
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
rb_ary_new2(int len)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
Creates an array with no element, with allocating internal buffer
|
|
|
|
|
for len elements.
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
rb_ary_new3(int n, ...)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
Creates an n-elements array from arguments.
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
rb_ary_new4(int n, VALUE *elts)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
Creates an n-elements array from C array.
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
rb_ary_push(VALUE ary, VALUE val)
|
|
|
|
|
rb_ary_pop(VALUE ary)
|
|
|
|
|
rb_ary_shift(VALUE ary)
|
|
|
|
|
rb_ary_unshift(VALUE ary, VALUE val)
|
|
|
|
|
rb_ary_entry(VALUE ary, int idx)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
Array operations. The first argument to each functions must be an
|
|
|
|
|
array. They may dump core if other types given.
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2. Extend Ruby with C
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ū<EFBFBD><EFBFBD>Ruby<EFBFBD>ǽ뤳<EFBFBD>Ȥ<EFBFBD>C<EFBFBD>Ǥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>Ruby<EFBFBD><EFBFBD><EFBFBD>Τ<EFBFBD><EFBFBD>Τ<EFBFBD>C<EFBFBD>ǵ<EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
<EFBFBD>Ҥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>顤<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD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BFBD><EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD><EFBFBD><EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
* Classes, Modules
|
|
|
|
|
* Methods, Singleton Methods
|
|
|
|
|
* Constants
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
<EFBFBD>ǤϽ<EFBFBD><EFBFBD>˾Ҳ𤷤ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
2.1.1 Class/module definition
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
To define class or module, use functions below:
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
VALUE rb_define_class(char *name, VALUE super)
|
|
|
|
|
VALUE rb_define_module(char *name)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
These functions return the newly created class ot module. You may
|
|
|
|
|
want to save this reference into the variable to use later.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
2.1.2 Method/singleton method definition
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
To define methods or singleton methods, use functions below:
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
void rb_define_method(VALUE class, char *name,
|
|
|
|
|
VALUE (*func)(), int argc)
|
|
|
|
|
|
|
|
|
|
void rb_define_singleton_method(VALUE object, char *name,
|
1999-01-19 23:59:39 -05:00
|
|
|
|
VALUE (*func)(), int argc)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
The `argc' represents the number of the arguments to the C function,
|
|
|
|
|
which must be less than 17. But I believe you don't need that much. :-)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
If `argc' is negative, it specifies calling sequence, not number of
|
|
|
|
|
the arguments.
|
|
|
|
|
|
|
|
|
|
If argc is -1, the function will be called like:
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
VALUE func(int argc, VALUE *argv, VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
where argc is the actual number of arguments, argv is the C array of
|
|
|
|
|
the arguments, and obj is the receiver.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
if argc is -2, the arguments are passed in Ruby array. The function
|
|
|
|
|
will be called like:
|
|
|
|
|
|
|
|
|
|
VALUE func(VALUE obj, VALUE args)
|
|
|
|
|
|
|
|
|
|
where obj is the receiver, and args is the Ruby array containing
|
|
|
|
|
actual arguments.
|
|
|
|
|
|
|
|
|
|
There're two more functions to define method. One is to define
|
|
|
|
|
private method:
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
void rb_define_private_method(VALUE class, char *name,
|
|
|
|
|
VALUE (*func)(), int argc)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
The other is to define module function, which is private AND singleton
|
|
|
|
|
method of the module. For example, sqrt is the module function
|
|
|
|
|
defined in Math module. It can be call in the form like:
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
Math.sqrt(4)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
or
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
include Math
|
|
|
|
|
sqrt(4)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
To define module function
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
void rb_define_module_function(VALUE module, char *name,
|
|
|
|
|
VALUE (*func)(), int argc)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Oh, in addition, function-like method, which is private method defined
|
|
|
|
|
in Kernel module, can be defined using:
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
void rb_define_global_function(char *name, VALUE (*func)(), int argc)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2.1.3 Constant definition
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
We have 2 functions to define constants:
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
void rb_define_const(VALUE class, char *name, VALUE val)
|
|
|
|
|
void rb_define_global_const(char *name, VALUE val)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
The former is to define constant under specified class/module. The
|
|
|
|
|
latter is to define global constant.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2.2 Use Ruby features from C
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
There are several ways to invoke Ruby's features from C code.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2.2.1 Evaluate Ruby Program in String
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Easiest way to call Ruby's function from C program is to evaluate the
|
|
|
|
|
string as Ruby program. This function will do the job.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
VALUE rb_eval_string(char *str)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Evaluation is done under current context, thus current local variables
|
|
|
|
|
of the innermost method (which is defined by Ruby) can be accessed.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
2.2.2 ID or Symbol
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
You can invoke methods directly, without parsing the string. First I
|
|
|
|
|
need to explain about symbols (which data type is ID). ID is the
|
|
|
|
|
integer number to represent Ruby's identifiers such as variable names.
|
|
|
|
|
It can be accessed from Ruby in the form like:
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
:Identifier
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
You can get the symbol value from string within C code, by using
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
rb_intern(char *name)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
In addition, the symbols for one character operators (e.g +) is the
|
|
|
|
|
code for that character.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2.2.3 Invoke Ruby method from C
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
To invoke methods directly, you can use the function below
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
VALUE rb_funcall(VALUE recv, ID mid, int argc, ...)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
This function invokes the method of the recv, which name is specified
|
|
|
|
|
by the symbol mid.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2.2.4 Accessing the variables and constants
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥäƻ<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Τϡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>饹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD>ϰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Τ<EFBFBD><EFBFBD>Τ<EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˡ<EFBFBD>ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
The functions to access/modify instance variables are below:
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
VALUE rb_ivar_get(VALUE obj, ID id)
|
|
|
|
|
VALUE rb_ivar_set(VALUE obj, ID id, VALUE val)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
id must be the symbol, which can be retrieved by rb_intern().
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
To access the constants of the class/module:
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
VALUE rb_const_get(VALUE obj, ID id)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
See 2.1.3 for defining new constant.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
3. Informatin sharing between Ruby and C
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ruby<EFBFBD>δ֤Ǿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˡ<EFBFBD>ˤĤ<EFBFBD><EFBFBD>Ʋ<EFBFBD><EFBFBD>⤷<EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
3.1 Ruby constant that C<><43><EFBFBD>黲<EFBFBD>ȤǤ<C8A4><C7A4><EFBFBD>Ruby<62><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Following Ruby constants can be referred from C.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Qtrue
|
|
|
|
|
Qfalse
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Boolean values. Qfalse is false in the C also (i.e. 0).
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
Qnil
|
|
|
|
|
|
|
|
|
|
Ruby nil in C scope.
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
3.2 Global variables shared between C and Ruby
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
C<EFBFBD><EFBFBD>Ruby<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD><E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D><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
void rb_define_readonly_variable(char *name, VALUE *var)
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD><EFBFBD>¾<EFBFBD><EFBFBD>hook<EFBFBD><EFBFBD><EFBFBD>Ĥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>hook<EFBFBD>դ<EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD>ϰʲ<EFBFBD><EFBFBD>δؿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>hook<EFBFBD>դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD>ͤλ<EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>hook<EFBFBD>ǹԤ<EFBFBD>ɬ<EFBFBD>פ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
void rb_define_hooked_variable(char *name, VALUE *var,
|
|
|
|
|
VALUE (*getter)(), VALUE (*setter)())
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFB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FBFBD><EFBFBD><EFBFBD>줫<EFBFBD>顤C<EFBFBD>δؿ<EFBFBD><EFBFBD>ˤ<EFBFBD><EFBFBD>äƼ¸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ruby<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
<EFBFBD>ؿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
void rb_define_virtual_variable(char *name,
|
|
|
|
|
VALUE (*getter)(), VALUE (*setter)())
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>δؿ<EFBFBD><EFBFBD>ˤ<EFBFBD><EFBFBD>ä<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>줿Ruby<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD>줿<EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
getter<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<EFBFBD><EFBFBD>줿<EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD>setter<EFBFBD><EFBFBD><EFBFBD>ƤФ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
The prototypes of the getter and setter functions are as following:
|
|
|
|
|
|
|
|
|
|
(*getter)(ID id, void *data, struct global_entry* entry);
|
|
|
|
|
(*setter)(VALUE val, ID id, void *data, struct global_entry* entry);
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
3.3 Encapsulate C data into Ruby object
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>줿<EFBFBD>ǡ<EFBFBD><EFBFBD><EFBFBD>(<28><>¤<EFBFBD><C2A4>)<29><>Ruby<62>Υ<EFBFBD><CEA5>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȤȤ<C8A4><C8A4><EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>갷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>礬<EFBFBD><EFBFBD><EFBFBD>ꤨ<EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Τ褦<EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˤϡ<EFBFBD>Data<EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD>
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Ruby<EFBFBD><EFBFBD><EFBFBD>֥<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD>C<EFBFBD>ι<EFBFBD>¤<EFBFBD><EFBFBD>(<28>ؤΥݥ<CEA5><DDA5><EFBFBD><EFBFBD><EFBFBD>)<29><EFBFBD><F2A4AFA4>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BD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
Data_Make_Struct(class, type, mark, free, sval)
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>Υޥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>줿Data<EFBFBD><EFBFBD><EFBFBD>֥<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȤǤ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
class, mark, free<65><65>Data_Wrap_Struct<63><74>Ʊ<EFBFBD><C6B1>Ư<EFBFBD><C6AF><EFBFBD>ޤ<F2A4B7A4><DEA4><EFBFBD>type
|
|
|
|
|
<EFBFBD>ϳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD>C<EFBFBD><EFBFBD>¤<EFBFBD>Τη<EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD>줿<EFBFBD><EFBFBD>¤<EFBFBD>Τ<EFBFBD><EFBFBD>ѿ<EFBFBD>sval
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD>η<EFBFBD><EFBFBD><EFBFBD> (type*) <20>Ǥ<EFBFBD><C7A4><EFBFBD>ɬ<EFBFBD>פ<EFBFBD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FBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
4<EFBFBD><EFBFBD>Example - Create dbm module
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤǤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǤȤꤢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĥ<EFBFBD>饤<EFBFBD>֥<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϥ<EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Ruby<EFBFBD><EFBFBD>ext<EFBFBD>ǥ<EFBFBD><EFBFBD>쥯<EFBFBD>ȥ<EFBFBD><EFBFBD>ˤ<EFBFBD><EFBFBD>Ǥ˴ޤޤ<EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD><EFBFBD>dbm<EFBFBD>⥸<EFBFBD>塼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʳ<EFBFBD>Ū<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
(1) make the directory
|
|
|
|
|
|
|
|
|
|
% mkdir ext/dbm
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Make a directory for the extension library under ext directory.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
(2) create MANIFEST file
|
|
|
|
|
|
|
|
|
|
% cd ext/dbm
|
|
|
|
|
% touch MANIFEST
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
There should be MANIFEST file in the directory for the extension
|
|
|
|
|
library. Make empty file now.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
(3) design the library
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
You need to design the library features, before making it.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
(4) write C code.
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
<EFBFBD><EFBFBD>ĥ<EFBFBD>饤<EFBFBD>֥<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΤȤʤ<EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Υ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Υ<EFBFBD><EFBFBD><EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҤȤĤλ<EFBFBD><EFBFBD>ˤϡ֥⥸<EFBFBD>塼<EFBFBD><EFBFBD>̾.c<>פ<EFBFBD><D7A4><EFBFBD><EFBFBD>֤<EFBFBD><D6A4>ɤ<EFBFBD><C9A4>Ǥ<EFBFBD><C7A4>礦<EFBFBD><E7A4A6>C
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Υ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><EFBFBD><EFBFBD>ξ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˤϵդˡ֥⥸<EFBFBD>塼<EFBFBD><EFBFBD>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פ<EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ưŪ<EFBFBD>˼¹Ԥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>dbm<EFBFBD>⥸<EFBFBD>塼<EFBFBD><EFBFBD><EFBFBD>ξ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Init_dbm<EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δؿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǥ<EFBFBD><EFBFBD>饹<EFBFBD><EFBFBD><EFBFBD>⥸<EFBFBD>塼<EFBFBD>롤<EFBFBD><EFBFBD>åɡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʤɤ<EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>dbm.c<><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѥ<EFBFBD><D1A4>ޤ<EFBFBD><DEA4><EFBFBD>
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
|
Init_dbm()
|
|
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
|
/* define DBM class */
|
|
|
|
|
cDBM = rb_define_class("DBM", rb_cObject);
|
|
|
|
|
/* DBM includes Enumerate module */
|
|
|
|
|
rb_include_module(cDBM, rb_mEnumerable);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
/* DBM has class method open(): arguments are received as C array */
|
1998-01-16 07:13:05 -05:00
|
|
|
|
rb_define_singleton_method(cDBM, "open", fdbm_s_open, -1);
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
/* DBM instance method close(): no args */
|
1998-01-16 07:13:05 -05:00
|
|
|
|
rb_define_method(cDBM, "close", fdbm_close, 0);
|
1999-01-19 23:59:39 -05:00
|
|
|
|
/* DBM instance method []: 1 argument */
|
1998-01-16 07:13:05 -05:00
|
|
|
|
rb_define_method(cDBM, "[]", fdbm_fetch, 1);
|
|
|
|
|
:
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
DBM<EFBFBD>⥸<EFBFBD>塼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>dbm<EFBFBD>Υǡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD>륪<EFBFBD>֥<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥˤʤ<EFBFBD><EFBFBD>Ϥ<EFBFBD><EFBFBD><EFBFBD>
|
1999-01-19 23:59:39 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>顤C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>dbm<EFBFBD><EFBFBD>Ruby<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɬ<EFBFBD>פ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dbm.c<>Ǥ<EFBFBD>Data_Make_Struct<63><74><EFBFBD>ʲ<EFBFBD><CAB2>Τ褦<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><EFBFBD>Ǽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD>DBM<EFBFBD>Υ<EFBFBD><EFBFBD>饹<EFBFBD><EFBFBD>åɤǤ<EFBFBD><EFBFBD><EFBFBD>open()<29>Ǥ<EFBFBD><C7A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD>fdbm_s_open()<29>Ϥ<EFBFBD><CFA4><EFBFBD><EFBFBD>ʤäƤ<C3A4><C6A4>ޤ<EFBFBD><DEA4><EFBFBD>
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
|
static VALUE
|
|
|
|
|
fdbm_s_open(argc, argv, class)
|
|
|
|
|
int argc;
|
|
|
|
|
VALUE *argv;
|
|
|
|
|
VALUE class;
|
|
|
|
|
{
|
|
|
|
|
:
|
|
|
|
|
if (rb_scan_args(argc, argv, "11", &file, &vmode) == 1) {
|
|
|
|
|
mode = 0666; /* default value */
|
|
|
|
|
}
|
|
|
|
|
:
|
|
|
|
|
}
|
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>Υ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>פδؿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>줿<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD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FBD>indexes<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϥ<EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
|
static VALUE
|
|
|
|
|
fdbm_indexes(obj, args)
|
|
|
|
|
VALUE obj;
|
|
|
|
|
struct RArray *args;
|
|
|
|
|
{
|
|
|
|
|
:
|
|
|
|
|
}
|
|
|
|
|
--
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>self<EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ruby<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥϥ<EFBFBD><EFBFBD>㥹<EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
<EFBFBD>餹<EFBFBD><EFBFBD><EFBFBD><EFBFBD> struct RArray* <20>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD>VALUE<55>Ǥ<EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
** Notice
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
GC should know about global variables which refers Ruby's objects, but
|
|
|
|
|
not exported to the Ruby world. You need to protect them by
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
void rb_global_variable(VALUE *var)
|
|
|
|
|
|
|
|
|
|
(5) prepare extconf.rb
|
|
|
|
|
|
|
|
|
|
<EFBFBD>⤷<EFBFBD>ǥ<EFBFBD><EFBFBD>쥯<EFBFBD>ȥ<EFBFBD><EFBFBD>ˡ<EFBFBD>extconf.rb<72>פȤ<D7A4><C8A4><EFBFBD><EFBFBD>ե<EFBFBD><D5A5><EFBFBD><EFBFBD>뤬¸<EBA4AC>ߤ<EFBFBD><DFA4><EFBFBD><EFBFBD>С<EFBFBD>
|
|
|
|
|
make<EFBFBD><EFBFBD><EFBFBD>˼¹Ԥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Makefile<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
extconf.rb<72>ϥ⥸<CFA5>塼<EFBFBD><E5A1BC><EFBFBD>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ѥ<EFBFBD><D1A5><EFBFBD><EFBFBD><EFBFBD>ɬ<EFBFBD>פʾ<D7A4><CABE><EFBFBD><EFBFBD>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>å<EFBFBD><C3A5>ʤ<EFBFBD>
|
1999-01-19 23:59:39 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD>Ū<EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD>extconf.rb<72><62><EFBFBD><EFBFBD><EFBFBD>Ǥϰʲ<CFB0><CAB2><EFBFBD>Ruby<62>ؿ<EFBFBD><D8BF><EFBFBD><EFBFBD>Ȥ<EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
have_library(lib, func): <20>饤<EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD>¸<EFBFBD>ߥ<EFBFBD><DFA5><EFBFBD><EFBFBD>å<EFBFBD>
|
|
|
|
|
have_func(func): <20>ؿ<EFBFBD><D8BF><EFBFBD>¸<EFBFBD>ߥ<EFBFBD><DFA5><EFBFBD><EFBFBD>å<EFBFBD>
|
|
|
|
|
have_header(header): <20>إå<D8A5><C3A5>ե<EFBFBD><D5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¸<EFBFBD>ߥ<EFBFBD><DFA5><EFBFBD><EFBFBD>å<EFBFBD>
|
|
|
|
|
create_makefile(target): Makefile<6C><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
<EFBFBD>ʲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
$CFLAGS: <20><><EFBFBD><EFBFBD><EFBFBD>ѥ<EFBFBD><D1A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɲ<EFB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FBFBD><EFBFBD>make<EFBFBD><EFBFBD><EFBFBD>¹Ԥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Makefile<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>make<EFBFBD><EFBFBD>
|
|
|
|
|
ɬ<EFBFBD>פˤ<EFBFBD><EFBFBD>äƤϤ<EFBFBD><EFBFBD>Υ⥸<EFBFBD>塼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ruby<EFBFBD>ؤΥ<EFBFBD><EFBFBD>ޤǼ<EFBFBD>ưŪ<EFBFBD>˼¹<EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>extconf.rb<72><62><EFBFBD><EFBFBD><F1A4ADB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʤɤ<CAA4><C9A4><EFBFBD>Makefile<6C>κ<EFBFBD><CEBA><EFBFBD><EFBFBD><EFBFBD>
|
1999-01-19 23:59:39 -05:00
|
|
|
|
<EFBFBD><EFBFBD>ɬ<EFBFBD>פʻ<EFBFBD><EFBFBD>Ϥޤ<EFBFBD>Ruby<EFBFBD>ǥ<EFBFBD><EFBFBD>쥯<EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD>make<EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
(9) debug
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
You may need to rb_debug the module. The modules can be linked
|
|
|
|
|
statically by adding directory name in the ext/Setup file,
|
|
|
|
|
so that you can inspect the module by the debugger.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
(10) done, now you have the extension library
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>Ϥ<EFBFBD><EFBFBD>ä<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD>ʤꡤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʤꡤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʤꡤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD>ˤ<EFBFBD>
|
1999-01-19 23:59:39 -05:00
|
|
|
|
<EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ruby<EFBFBD>κ<EFBFBD><EFBFBD>Ԥϳ<EFBFBD>ĥ<EFBFBD>饤<EFBFBD>֥<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˴ؤ<EFBFBD><EFBFBD>ư<EFBFBD><EFBFBD>ڤθ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
<EFBFBD><EFBFBD>ĥ<EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Appendix A. Ruby<62>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɤ<EFBFBD>ʬ<EFBFBD><CAAC>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Ruby<EFBFBD>Υ<EFBFBD><EFBFBD><E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core
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
class.c
|
|
|
|
|
error.c
|
|
|
|
|
eval.c
|
|
|
|
|
gc.c
|
|
|
|
|
object.c
|
|
|
|
|
parse.y
|
|
|
|
|
variable.c
|
|
|
|
|
|
|
|
|
|
utility functions
|
|
|
|
|
|
|
|
|
|
dln.c
|
|
|
|
|
fnmatch.c
|
|
|
|
|
glob.c
|
|
|
|
|
regex.c
|
|
|
|
|
st.c
|
|
|
|
|
util.c
|
|
|
|
|
|
|
|
|
|
ruby interpreter implementation
|
|
|
|
|
|
|
|
|
|
dmyext.c
|
|
|
|
|
inits.c
|
|
|
|
|
main.c
|
|
|
|
|
ruby.c
|
|
|
|
|
version.c
|
|
|
|
|
|
|
|
|
|
class library
|
|
|
|
|
|
|
|
|
|
array.c
|
|
|
|
|
bignum.c
|
|
|
|
|
compar.c
|
|
|
|
|
dir.c
|
|
|
|
|
enum.c
|
|
|
|
|
file.c
|
|
|
|
|
hash.c
|
|
|
|
|
io.c
|
|
|
|
|
math.c
|
|
|
|
|
numeric.c
|
|
|
|
|
pack.c
|
|
|
|
|
process.c
|
|
|
|
|
random.c
|
|
|
|
|
range.c
|
|
|
|
|
re.c
|
|
|
|
|
signal.c
|
|
|
|
|
sprintf.c
|
|
|
|
|
string.c
|
|
|
|
|
struct.c
|
|
|
|
|
time.c
|
|
|
|
|
|
|
|
|
|
Appendix B. <20><>ĥ<EFBFBD>Ѵؿ<D1B4><D8BF><EFBFBD><EFBFBD>ե<EFBFBD><D5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
C<EFBFBD><EFBFBD><EFBFBD>줫<EFBFBD><EFBFBD>Ruby<EFBFBD>ε<EFBFBD>ǽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѥ<EFBFBD><EFBFBD><EFBFBD>API<EFBFBD>ϰʲ<EFBFBD><EFBFBD><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D><EFBFBD><EFBFBD>Υޥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѱդ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD>롥
|
|
|
|
|
|
|
|
|
|
** Variables and constants
|
|
|
|
|
|
|
|
|
|
Qnil
|
|
|
|
|
|
|
|
|
|
const: nil object
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Qtrue
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
const: Qtrue object(default true value)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Qfalse
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
const: Qfalse object
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
** C<>ǡ<EFBFBD><C7A1><EFBFBD><EFBFBD>Υ<EFBFBD><CEA5>ץ<EFBFBD><D7A5>벽
|
|
|
|
|
|
|
|
|
|
Data_Wrap_Struct(VALUE class, void (*mark)(), void (*free)(), void *sval)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
C<EFBFBD><EFBFBD>Ǥ<EFBFBD>դΥݥ<EFBFBD><EFBFBD>ץ<EFBFBD><EFBFBD>벽<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ruby<EFBFBD><EFBFBD><EFBFBD>֥<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD>Υݥ<EFBFBD><EFBFBD><EFBFBD>Ruby<EFBFBD><EFBFBD><EFBFBD>饢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBF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FBD><EFBFBD><EFBFBD>ץ<EFBFBD>
|
|
|
|
|
<EFBFBD>벽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD>ޥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
Data_Get_Struct(data, type, sval)
|
|
|
|
|
|
|
|
|
|
data<EFBFBD><EFBFBD><EFBFBD><EFBFBD>type<EFBFBD><EFBFBD><EFBFBD>Υݥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ф<EFBFBD><EFBFBD>ѿ<EFBFBD>sval<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
** <20><><EFBFBD>饹/<2F>⥸<EFBFBD>塼<EFBFBD><E5A1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
VALUE rb_define_class(char *name, VALUE super)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
super<EFBFBD>Υ<EFBFBD><EFBFBD>֥<EFBFBD><EFBFBD>饹<EFBFBD>Ȥ<EFBFBD><EFBFBD>ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ruby<EFBFBD><EFBFBD><EFBFBD>饹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>롥
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
VALUE rb_define_class_under(VALUE module, char *name, VALUE super)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
super<EFBFBD>Υ<EFBFBD><EFBFBD>֥<EFBFBD><EFBFBD>饹<EFBFBD>Ȥ<EFBFBD><EFBFBD>ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ruby<EFBFBD><EFBFBD><EFBFBD>饹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>module<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>롥
|
|
|
|
|
|
|
|
|
|
VALUE rb_define_module(char *name)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ruby<EFBFBD>⥸<EFBFBD>塼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>롥
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
VALUE rb_define_module_under(VALUE module, char *name, VALUE super)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ruby<EFBFBD>⥸<EFBFBD>塼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>module<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>롥
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
void rb_include_module(VALUE class, VALUE module)
|
|
|
|
|
|
|
|
|
|
<EFBFBD>⥸<EFBFBD>塼<EFBFBD><EFBFBD><EFBFBD>롼<EFBFBD>ɤ<EFBFBD><EFBFBD>롥class<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD>module<EFBFBD>롼
|
|
|
|
|
<EFBFBD>ɤ<EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˤϲ<EFBFBD><EFBFBD>⤷<EFBFBD>ʤ<EFBFBD>(¿<>ť<EFBFBD><C5A5>롼<F3A5AFA5>ɤζػ<CEB6>)<29><>
|
|
|
|
|
|
|
|
|
|
void rb_extend_object(VALUE object, VALUE module)
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>֥<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD>⥸<EFBFBD>塼<EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD><EFBFBD>å<EFBFBD>)<29>dz<EFBFBD>ĥ<EFBFBD><C4A5><EFBFBD>롥
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
** Defining Global Variables
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
void rb_define_variable(char *name, VALUE *var)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Defines a global variable which is shared between C and Ruby. If name
|
|
|
|
|
contains the character which is not allowed to be part of the symbol,
|
|
|
|
|
it can't be seen from Ruby programs.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
void rb_define_readonly_variable(char *name, VALUE *var)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Defines a read-only global variable. Works just like
|
|
|
|
|
rb_define_variable(), except defined variable is read-only.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
void rb_define_virtual_variable(char *name,
|
|
|
|
|
VALUE (*getter)(), VALUE (*setter)())
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Defines a virtual variable, whose behavior is defined by pair of C
|
|
|
|
|
functions. The getter function is called when the variable is
|
|
|
|
|
referred. The setter function is called when the value is set to the
|
|
|
|
|
variable. The prototype for getter/setter functions are:
|
|
|
|
|
|
|
|
|
|
VALUE getter(ID id)
|
|
|
|
|
void setter(VALUE val, ID id)
|
|
|
|
|
|
|
|
|
|
The getter function must return the value for the access.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
void rb_define_hooked_variable(char *name, VALUE *var,
|
|
|
|
|
VALUE (*getter)(), VALUE (*setter)())
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Defines hooked variable. It's virtual variable with C variable. The
|
|
|
|
|
getter is called as
|
|
|
|
|
|
|
|
|
|
VALUE getter(ID id, VALUE *var)
|
|
|
|
|
|
|
|
|
|
returning new value. The setter is called as
|
|
|
|
|
|
|
|
|
|
void setter(VALUE val, ID id, VALUE *var)
|
|
|
|
|
|
|
|
|
|
GC requires to mark the C global variables which hold Ruby values.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
void rb_global_variable(VALUE *var)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Tells GC to protect these variables.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
** Constant Definition
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
void rb_define_const(VALUE klass, char *name, VALUE val)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Defines a new constant under the class/module.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
void rb_define_global_const(char *name, VALUE val)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Defines global contant. This is just work as
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
rb_define_const(cKernal, name, val)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
** Method Definition
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
rb_define_method(VALUE class, char *name, VALUE (*func)(), int argc)
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD>åɤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>롥argc<EFBFBD><EFBFBD>self<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD><EFBFBD><EFBFBD>argc<EFBFBD><EFBFBD>-1<>λ<EFBFBD>,
|
|
|
|
|
<EFBFBD>ؿ<EFBFBD><EFBFBD>ˤϰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD>(self<6C><66><EFBFBD>ޤޤʤ<DEA4>)<29><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><32>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><>3<EFBFBD><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD>self)<29><>argc<67><63>-2<>λ<EFBFBD>, <20><>1<EFBFBD><31>
|
1999-01-19 23:59:39 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>self, <20><>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>args(args<67>ϰ<EFBFBD><CFB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD>Ruby<62><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<29>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD><EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>롥
|
|
|
|
|
|
|
|
|
|
rb_define_private_method(VALUE class, char *name, VALUE (*func)(), int argc)
|
|
|
|
|
|
|
|
|
|
private<EFBFBD><EFBFBD>åɤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>롥<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rb_define_method()<29><>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
rb_define_singleton_method(VALUE class, char *name, VALUE (*func)(), int argc)
|
|
|
|
|
|
|
|
|
|
<EFBFBD>ðۥ<EFBFBD>åɤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>롥<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rb_define_method()<29><>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
rb_scan_args(int atgc, VALUE *argv, char *fmt, ...)
|
|
|
|
|
|
|
|
|
|
argc,argv<67><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><CDBF><EFBFBD><EFBFBD><EFBFBD>줿<EFBFBD><ECA4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʬ<EFB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FBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><C7A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><D1BF>˳<EFBFBD>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD><EFBFBD>롥<EFBFBD>ղð<D5B2>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD>ʤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD><EFBFBD>Qnil<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD>롥
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
** Ruby<62><EFBFBD>åɸƤӽФ<D3BD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
VALUE rb_funcall(VALUE recv, ID mid, int narg, ...)
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD>åɸƤӽФ<EFBFBD><EFBFBD><EFBFBD>ʸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>mid<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뤿<EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD>rb_intern()<29><><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD>
|
|
|
|
|
|
|
|
|
|
VALUE rb_funcall2(VALUE recv, ID mid, int argc, VALUE *argv)
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD>åɸƤӽФ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>argc,argv<67><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϥ<EFBFBD><CFA4><EFBFBD>
|
|
|
|
|
|
|
|
|
|
VALUE rb_eval_string(char *str)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
ʸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ruby<EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ץȤ<EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѥ<EFBFBD><EFBFBD>롦<EFBFBD>¹Ԥ<EFBFBD><EFBFBD>롥
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
ID rb_intern(char *name)
|
|
|
|
|
|
|
|
|
|
ʸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID<EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
char *rb_id2name(ID id)
|
|
|
|
|
|
|
|
|
|
ID<EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD>(<28>ǥХå<D0A5><C3A5><EFBFBD>)<29><>
|
|
|
|
|
|
|
|
|
|
char *rb_class2name(VALUE class)
|
|
|
|
|
|
|
|
|
|
class<EFBFBD><EFBFBD>̾<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD>(<28>ǥХå<D0A5><C3A5><EFBFBD>)<29><>class<73><73>̾<EFBFBD><CCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBF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|
|
|
|
|
|
VALUE rb_iv_set(VALUE obj, char *name, VALUE val)
|
|
|
|
|
|
|
|
|
|
obj<EFBFBD>Υ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD><EFBFBD>val<EFBFBD>˥<EFBFBD><EFBFBD>åȤ<EFBFBD><EFBFBD>롥
|
|
|
|
|
|
|
|
|
|
** <20><><EFBFBD>湽¤
|
|
|
|
|
|
|
|
|
|
VALUE rb_iterate(VALUE (*func1)(), void *arg1, VALUE (*func2)(), void *arg2)
|
|
|
|
|
|
|
|
|
|
func2<EFBFBD><EFBFBD><EFBFBD>֥<EFBFBD><EFBFBD>å<EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꤷ, func1<63>ƥ졼<C6A5><ECA1BC><EFBFBD>Ȥ<EFBFBD><C8A4>ƸƤ֡<C6A4>
|
|
|
|
|
func1<EFBFBD>ˤ<EFBFBD> arg1<67><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD>Ϥ<EFBFBD><CFA4><EFBFBD>, func2<63>ˤ<EFBFBD><CBA4><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD>˥<EFBFBD><CBA5>ƥ졼
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>줿<EFBFBD><EFBFBD>, <20><>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>arg2<67><32><EFBFBD>Ϥ<EFBFBD><CFA4><EFBFBD><EFBFBD>롥
|
|
|
|
|
|
|
|
|
|
VALUE rb_yield(VALUE val)
|
|
|
|
|
|
|
|
|
|
val<EFBFBD><EFBFBD><EFBFBD>ͤȤ<EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD>ƥ졼<EFBFBD><EFBFBD><EFBFBD>֥<EFBFBD><EFBFBD>å<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƤӽФ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
VALUE rb_rescue(VALUE (*func1)(), void *arg1, VALUE (*func2)(), void *arg2)
|
|
|
|
|
|
|
|
|
|
<EFBFBD>ؿ<EFBFBD>func1<EFBFBD><EFBFBD>arg1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˸ƤӽФ<EFBFBD><EFBFBD><EFBFBD>func1<EFBFBD>μ¹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㳰<EFBFBD><EFBFBD>ȯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD> func2<63><32>arg2<67><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4>ƸƤ֡<C6A4><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͤ<EFBFBD><CDA4>㳰<EFBFBD><E3B3B0>ȯ<EFBFBD><C8AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>ä<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>func1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20>㳰<EFBFBD><E3B3B0>ȯ<EFBFBD><C8AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD>func2<63><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͤ<EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>롥
|
|
|
|
|
|
|
|
|
|
VALUE rb_ensure(VALUE (*func1)(), void *arg1, void (*func2)(), void *arg2)
|
|
|
|
|
|
|
|
|
|
<EFBFBD>ؿ<EFBFBD>func1<EFBFBD><EFBFBD>arg1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD>Ƽ¹Ԥ<EFBFBD>, <20>¹Խ<C2B9>λ<EFBFBD><CEBB>(<28><><EFBFBD>Ȥ<EFBFBD><C8A4>㳰<EFBFBD><E3B3B0>ȯ
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD>) func2<63><32>arg2<67><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4>Ƽ¹Ԥ<C2B9><D4A4>롥<EFBFBD><EBA1A5><EFBFBD><EFBFBD><EFBFBD>ͤ<EFBFBD>func1<63><31><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>ͤǤ<EFBFBD><EFBFBD><EFBFBD>(<28>㳰<EFBFBD><E3B3B0>ȯ<EFBFBD><C8AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʤ<EFBFBD>)<29><>
|
|
|
|
|
|
|
|
|
|
** <20>㳰<EFBFBD><E3B3B0><EFBFBD><EFBFBD><EFBFBD>顼
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
void rb_warning(char *fmt, ...)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
rb_verbose<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɸ<EFBFBD>२<EFBFBD>顼<EFBFBD><EFBFBD><EFBFBD>Ϥ˷ٹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>롥<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>printf()<29><>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
void rb_raise(rb_eRuntimeError, char *fmt, ...)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
<EFBFBD>㳰<EFBFBD><EFBFBD>ȯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>롥<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>printf()<29><>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
void rb_fatal(char *fmt, ...)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD>̿Ū<EFBFBD>㳰<EFBFBD><EFBFBD>ȯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>롥<EFBFBD>̾<EFBFBD><EFBFBD><EFBFBD><EFBFBD>㳰<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϹԤʤ<EFBFBD><EFBFBD>줺, <20><><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD>ץ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ensure<72>ǻ<EFBFBD><C7BB>ꤵ<EFBFBD>줿<EFBFBD><ECA4BF><EFBFBD><EFBFBD><EFBFBD>ɤϽ<C9A4>λ<EFBFBD><CEBB><EFBFBD>˼<EFBFBD>
|
|
|
|
|
<EFBFBD>Ԥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<29><>
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
void rb_bug(char *fmt, ...)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ץ<EFBFBD>ʤɥץ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΥХ<EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD>ȯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϥ<EFBFBD><EFBFBD>Τʤ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>Ƥ֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ץ<EFBFBD>ϥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>פ<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>˽<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>롥<EFBFBD>㳰
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD><EFBFBD>ڹԤʤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʤ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
** Initialize and Starts the Interpreter
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
The embedding API are below (not needed for extension libraries):
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
void ruby_init(int argc, char **argv, char **envp)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Initializes the interpreter.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
void ruby_run()
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Starts execution of the interpreter.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
void ruby_script(char *name)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Specifies the name of the script ($0).
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Appendix B. Functions Available in extconf.rb
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
extconf.rb<72><62><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><C7A4><EFBFBD><EFBFBD>Ѳ<EFBFBD>ǽ<EFBFBD>ʥ<EFBFBD><CAA5><EFBFBD><EFBFBD>ѥ<EFBFBD><D1A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>å<EFBFBD><C3A5>δؿ<CEB4><D8BF>ϰ<EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̤<EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD>롥
|
|
|
|
|
|
|
|
|
|
have_library(lib, func)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Checks whether library which contains specified function exists.
|
|
|
|
|
Returns true if the library exists.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
have_func(func)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Checks whether func exists. Returns true if the function exists. To
|
|
|
|
|
check functions in the additional library, you need to check that
|
|
|
|
|
library first using have_library().
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
have_header(header)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Checks for the header files. Returns true if the header file exists.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
create_makefile(target)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
Generates the Makefile for the extension library. If you don't invoke
|
|
|
|
|
this method, the compilation will not be done.
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Local variables:
|
|
|
|
|
* fill-column: 60
|
|
|
|
|
* end:
|
|
|
|
|
*/
|