mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1e1b5cdd25
commit
9527d90951
6 changed files with 146 additions and 129 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Thu Oct 5 18:02:39 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* object.c (rb_obj_dup): should have propagated taint flag.
|
||||||
|
(ruby-bugs:#PR64,65)
|
||||||
|
|
||||||
|
Wed Oct 4 00:26:11 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (proc_arity): proc{|a|}'s arity should be -1.
|
||||||
|
|
||||||
Mon Oct 2 05:28:58 2000 akira yamada <akira@ruby-lang.org>
|
Mon Oct 2 05:28:58 2000 akira yamada <akira@ruby-lang.org>
|
||||||
|
|
||||||
* string.c (trnext): minus at the end of pattern.
|
* string.c (trnext): minus at the end of pattern.
|
||||||
|
|
106
README.EXT
106
README.EXT
|
@ -38,11 +38,13 @@ Ruby interpreter has data-types as below:
|
||||||
T_TRUE true
|
T_TRUE true
|
||||||
T_FALSE false
|
T_FALSE false
|
||||||
T_DATA data
|
T_DATA data
|
||||||
|
T_SYMBOL symbol
|
||||||
|
|
||||||
Otherwise, there are several other types used internally:
|
Otherwise, there are several other types used internally:
|
||||||
|
|
||||||
T_ICLASS
|
T_ICLASS
|
||||||
T_MATCH
|
T_MATCH
|
||||||
|
T_UNDEF
|
||||||
T_VARMAP
|
T_VARMAP
|
||||||
T_SCOPE
|
T_SCOPE
|
||||||
T_NODE
|
T_NODE
|
||||||
|
@ -141,25 +143,25 @@ interpreter. Useful functions are listed below (not all):
|
||||||
|
|
||||||
String functions
|
String functions
|
||||||
|
|
||||||
rb_str_new(char *ptr, int len)
|
rb_str_new(const char *ptr, long len)
|
||||||
|
|
||||||
Creates a new Ruby string.
|
Creates a new Ruby string.
|
||||||
|
|
||||||
rb_str_new2(char *ptr)
|
rb_str_new2(const char *ptr)
|
||||||
|
|
||||||
Creates a new Ruby string from C string. This is equivalent to
|
Creates a new Ruby string from C string. This is equivalent to
|
||||||
rb_str_new(ptr, strlen(ptr)).
|
rb_str_new(ptr, strlen(ptr)).
|
||||||
|
|
||||||
rb_tainted_str_new(char *ptr, int len)
|
rb_tainted_str_new(const char *ptr, long len)
|
||||||
|
|
||||||
Creates a new tainted Ruby string. Strings from external data
|
Creates a new tainted Ruby string. Strings from external data
|
||||||
should be tainted.
|
should be tainted.
|
||||||
|
|
||||||
rb_tainted_str_new2(char *ptr)
|
rb_tainted_str_new2(const char *ptr)
|
||||||
|
|
||||||
Creates a new tainted Ruby string from C string.
|
Creates a new tainted Ruby string from C string.
|
||||||
|
|
||||||
rb_str_cat(VALUE str, char *ptr, int len)
|
rb_str_cat(VALUE str, const char *ptr, long len)
|
||||||
|
|
||||||
Appends len bytes data from ptr to the Ruby string.
|
Appends len bytes data from ptr to the Ruby string.
|
||||||
|
|
||||||
|
@ -169,16 +171,16 @@ interpreter. Useful functions are listed below (not all):
|
||||||
|
|
||||||
Creates an array with no element.
|
Creates an array with no element.
|
||||||
|
|
||||||
rb_ary_new2(int len)
|
rb_ary_new2(long len)
|
||||||
|
|
||||||
Creates an array with no element, with allocating internal buffer
|
Creates an array with no element, with allocating internal buffer
|
||||||
for len elements.
|
for len elements.
|
||||||
|
|
||||||
rb_ary_new3(int n, ...)
|
rb_ary_new3(long n, ...)
|
||||||
|
|
||||||
Creates an n-elements array from arguments.
|
Creates an n-elements array from arguments.
|
||||||
|
|
||||||
rb_ary_new4(int n, VALUE *elts)
|
rb_ary_new4(long n, VALUE *elts)
|
||||||
|
|
||||||
Creates an n-elements array from C array.
|
Creates an n-elements array from C array.
|
||||||
|
|
||||||
|
@ -186,7 +188,6 @@ interpreter. Useful functions are listed below (not all):
|
||||||
rb_ary_pop(VALUE ary)
|
rb_ary_pop(VALUE ary)
|
||||||
rb_ary_shift(VALUE ary)
|
rb_ary_shift(VALUE ary)
|
||||||
rb_ary_unshift(VALUE ary, VALUE val)
|
rb_ary_unshift(VALUE ary, VALUE val)
|
||||||
rb_ary_entry(VALUE ary, int idx)
|
|
||||||
|
|
||||||
Array operations. The first argument to each functions must be an
|
Array operations. The first argument to each functions must be an
|
||||||
array. They may dump core if other types given.
|
array. They may dump core if other types given.
|
||||||
|
@ -206,25 +207,25 @@ interpreter. Ruby provides the API to define things below:
|
||||||
|
|
||||||
To define class or module, use functions below:
|
To define class or module, use functions below:
|
||||||
|
|
||||||
VALUE rb_define_class(char *name, VALUE super)
|
VALUE rb_define_class(const char *name, VALUE super)
|
||||||
VALUE rb_define_module(char *name)
|
VALUE rb_define_module(const char *name)
|
||||||
|
|
||||||
These functions return the newly created class or module. You may
|
These functions return the newly created class or module. You may
|
||||||
want to save this reference into the variable to use later.
|
want to save this reference into the variable to use later.
|
||||||
|
|
||||||
To define nested class or module, use functions below:
|
To define nested class or module, use functions below:
|
||||||
|
|
||||||
VALUE rb_define_class_under(VALUE outer, char *name, VALUE super)
|
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
|
||||||
VALUE rb_define_module_under(VALUE outer, char *name)
|
VALUE rb_define_module_under(VALUE outer, const char *name)
|
||||||
|
|
||||||
2.1.2 Method/singleton method definition
|
2.1.2 Method/singleton method definition
|
||||||
|
|
||||||
To define methods or singleton methods, use functions below:
|
To define methods or singleton methods, use functions below:
|
||||||
|
|
||||||
void rb_define_method(VALUE klass, char *name,
|
void rb_define_method(VALUE klass, const char *name,
|
||||||
VALUE (*func)(), int argc)
|
VALUE (*func)(), int argc)
|
||||||
|
|
||||||
void rb_define_singleton_method(VALUE object, char *name,
|
void rb_define_singleton_method(VALUE object, const char *name,
|
||||||
VALUE (*func)(), int argc)
|
VALUE (*func)(), int argc)
|
||||||
|
|
||||||
The `argc' represents the number of the arguments to the C function,
|
The `argc' represents the number of the arguments to the C function,
|
||||||
|
@ -251,7 +252,7 @@ actual arguments.
|
||||||
There're two more functions to define method. One is to define
|
There're two more functions to define method. One is to define
|
||||||
private method:
|
private method:
|
||||||
|
|
||||||
void rb_define_private_method(VALUE klass, char *name,
|
void rb_define_private_method(VALUE klass, const char *name,
|
||||||
VALUE (*func)(), int argc)
|
VALUE (*func)(), int argc)
|
||||||
|
|
||||||
The other is to define module function, which is private AND singleton
|
The other is to define module function, which is private AND singleton
|
||||||
|
@ -267,13 +268,13 @@ or
|
||||||
|
|
||||||
To define module function
|
To define module function
|
||||||
|
|
||||||
void rb_define_module_function(VALUE module, char *name,
|
void rb_define_module_function(VALUE module, const char *name,
|
||||||
VALUE (*func)(), int argc)
|
VALUE (*func)(), int argc)
|
||||||
|
|
||||||
Oh, in addition, function-like method, which is private method defined
|
Oh, in addition, function-like method, which is private method defined
|
||||||
in Kernel module, can be defined using:
|
in Kernel module, can be defined using:
|
||||||
|
|
||||||
void rb_define_global_function(char *name, VALUE (*func)(), int argc)
|
void rb_define_global_function(const char *name, VALUE (*func)(), int argc)
|
||||||
|
|
||||||
To define alias to the method,
|
To define alias to the method,
|
||||||
|
|
||||||
|
@ -283,8 +284,8 @@ To define alias to the method,
|
||||||
|
|
||||||
We have 2 functions to define constants:
|
We have 2 functions to define constants:
|
||||||
|
|
||||||
void rb_define_const(VALUE klass, char *name, VALUE val)
|
void rb_define_const(VALUE klass, const char *name, VALUE val)
|
||||||
void rb_define_global_const(char *name, VALUE val)
|
void rb_define_global_const(const char *name, VALUE val)
|
||||||
|
|
||||||
The former is to define constant under specified class/module. The
|
The former is to define constant under specified class/module. The
|
||||||
latter is to define global constant.
|
latter is to define global constant.
|
||||||
|
@ -298,7 +299,7 @@ There are several ways to invoke Ruby's features from C code.
|
||||||
Easiest way to call Ruby's function from C program is to evaluate the
|
Easiest way to call Ruby's function from C program is to evaluate the
|
||||||
string as Ruby program. This function will do the job.
|
string as Ruby program. This function will do the job.
|
||||||
|
|
||||||
VALUE rb_eval_string(char *str)
|
VALUE rb_eval_string(const char *str)
|
||||||
|
|
||||||
Evaluation is done under current context, thus current local variables
|
Evaluation is done under current context, thus current local variables
|
||||||
of the innermost method (which is defined by Ruby) can be accessed.
|
of the innermost method (which is defined by Ruby) can be accessed.
|
||||||
|
@ -314,10 +315,7 @@ It can be accessed from Ruby in the form like:
|
||||||
|
|
||||||
You can get the symbol value from string within C code, by using
|
You can get the symbol value from string within C code, by using
|
||||||
|
|
||||||
rb_intern(char *name)
|
rb_intern(const char *name)
|
||||||
|
|
||||||
In addition, the symbols for one character operators (e.g +) is the
|
|
||||||
code for that character.
|
|
||||||
|
|
||||||
2.2.3 Invoke Ruby method from C
|
2.2.3 Invoke Ruby method from C
|
||||||
|
|
||||||
|
@ -367,7 +365,7 @@ Ruby nil in C scope.
|
||||||
Information can be shared between two worlds, using shared global
|
Information can be shared between two worlds, using shared global
|
||||||
variables. To define them, you can use functions listed below:
|
variables. To define them, you can use functions listed below:
|
||||||
|
|
||||||
void rb_define_variable(char *name, VALUE *var)
|
void rb_define_variable(const char *name, VALUE *var)
|
||||||
|
|
||||||
This function defines the variable which is shared by the both world.
|
This function defines the variable which is shared by the both world.
|
||||||
The value of the global variable pointed by `var', can be accessed
|
The value of the global variable pointed by `var', can be accessed
|
||||||
|
@ -376,20 +374,20 @@ through Ruby's global variable named `name'.
|
||||||
You can define read-only (from Ruby, of course) variable by the
|
You can define read-only (from Ruby, of course) variable by the
|
||||||
function below.
|
function below.
|
||||||
|
|
||||||
void rb_define_readonly_variable(char *name, VALUE *var)
|
void rb_define_readonly_variable(const char *name, VALUE *var)
|
||||||
|
|
||||||
You can defined hooked variables. The accessor functions (getter and
|
You can defined hooked variables. The accessor functions (getter and
|
||||||
setter) are called on access to the hooked variables.
|
setter) are called on access to the hooked variables.
|
||||||
|
|
||||||
void rb_define_hooked_variable(char *name, VALUE *var,
|
void rb_define_hooked_variable(constchar *name, VALUE *var,
|
||||||
VALUE (*getter)(), VALUE (*setter)())
|
VALUE (*getter)(), void (*setter)())
|
||||||
|
|
||||||
If you need to supply either setter or getter, just supply 0 for the
|
If you need to supply either setter or getter, just supply 0 for the
|
||||||
hook you don't need. If both hooks are 0, rb_define_hooked_variable()
|
hook you don't need. If both hooks are 0, rb_define_hooked_variable()
|
||||||
works just like rb_define_variable().
|
works just like rb_define_variable().
|
||||||
|
|
||||||
void rb_define_virtual_variable(char *name,
|
void rb_define_virtual_variable(const char *name,
|
||||||
VALUE (*getter)(), VALUE (*setter)())
|
VALUE (*getter)(), void (*setter)())
|
||||||
|
|
||||||
This function defines the Ruby global variable without corresponding C
|
This function defines the Ruby global variable without corresponding C
|
||||||
variable. The value of the variable will be set/get only by hooks.
|
variable. The value of the variable will be set/get only by hooks.
|
||||||
|
@ -756,20 +754,20 @@ the variable sval.
|
||||||
|
|
||||||
** defining class/module
|
** defining class/module
|
||||||
|
|
||||||
VALUE rb_define_class(char *name, VALUE super)
|
VALUE rb_define_class(const char *name, VALUE super)
|
||||||
|
|
||||||
Defines new Ruby class as subclass of super.
|
Defines new Ruby class as subclass of super.
|
||||||
|
|
||||||
VALUE rb_define_class_under(VALUE module, char *name, VALUE super)
|
VALUE rb_define_class_under(VALUE module, const char *name, VALUE super)
|
||||||
|
|
||||||
Creates new Ruby class as subclass of super, under the module's
|
Creates new Ruby class as subclass of super, under the module's
|
||||||
namespace.
|
namespace.
|
||||||
|
|
||||||
VALUE rb_define_module(char *name)
|
VALUE rb_define_module(const char *name)
|
||||||
|
|
||||||
Defines new Ruby module.
|
Defines new Ruby module.
|
||||||
|
|
||||||
VALUE rb_define_module_under(VALUE module, char *name, VALUE super)
|
VALUE rb_define_module_under(VALUE module, const char *name, VALUE super)
|
||||||
|
|
||||||
Defines new Ruby module, under the module's namespace.
|
Defines new Ruby module, under the module's namespace.
|
||||||
|
|
||||||
|
@ -784,18 +782,18 @@ Extend the object with module's attribute.
|
||||||
|
|
||||||
** Defining Global Variables
|
** Defining Global Variables
|
||||||
|
|
||||||
void rb_define_variable(char *name, VALUE *var)
|
void rb_define_variable(const char *name, VALUE *var)
|
||||||
|
|
||||||
Defines a global variable which is shared between C and Ruby. If name
|
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,
|
contains the character which is not allowed to be part of the symbol,
|
||||||
it can't be seen from Ruby programs.
|
it can't be seen from Ruby programs.
|
||||||
|
|
||||||
void rb_define_readonly_variable(char *name, VALUE *var)
|
void rb_define_readonly_variable(const char *name, VALUE *var)
|
||||||
|
|
||||||
Defines a read-only global variable. Works just like
|
Defines a read-only global variable. Works just like
|
||||||
rb_define_variable(), except defined variable is read-only.
|
rb_define_variable(), except defined variable is read-only.
|
||||||
|
|
||||||
void rb_define_virtual_variable(char *name,
|
void rb_define_virtual_variable(const char *name,
|
||||||
VALUE (*getter)(), VALUE (*setter)())
|
VALUE (*getter)(), VALUE (*setter)())
|
||||||
|
|
||||||
Defines a virtual variable, whose behavior is defined by pair of C
|
Defines a virtual variable, whose behavior is defined by pair of C
|
||||||
|
@ -808,7 +806,7 @@ variable. The prototype for getter/setter functions are:
|
||||||
|
|
||||||
The getter function must return the value for the access.
|
The getter function must return the value for the access.
|
||||||
|
|
||||||
void rb_define_hooked_variable(char *name, VALUE *var,
|
void rb_define_hooked_variable(const char *name, VALUE *var,
|
||||||
VALUE (*getter)(), VALUE (*setter)())
|
VALUE (*getter)(), VALUE (*setter)())
|
||||||
|
|
||||||
Defines hooked variable. It's virtual variable with C variable. The
|
Defines hooked variable. It's virtual variable with C variable. The
|
||||||
|
@ -828,11 +826,11 @@ Tells GC to protect these variables.
|
||||||
|
|
||||||
** Constant Definition
|
** Constant Definition
|
||||||
|
|
||||||
void rb_define_const(VALUE klass, char *name, VALUE val)
|
void rb_define_const(VALUE klass, const char *name, VALUE val)
|
||||||
|
|
||||||
Defines a new constant under the class/module.
|
Defines a new constant under the class/module.
|
||||||
|
|
||||||
void rb_define_global_const(char *name, VALUE val)
|
void rb_define_global_const(const char *name, VALUE val)
|
||||||
|
|
||||||
Defines global constant. This is just work as
|
Defines global constant. This is just work as
|
||||||
|
|
||||||
|
@ -840,7 +838,7 @@ Defines global constant. This is just work as
|
||||||
|
|
||||||
** Method Definition
|
** Method Definition
|
||||||
|
|
||||||
rb_define_method(VALUE klass, char *name, VALUE (*func)(), int argc)
|
rb_define_method(VALUE klass, const char *name, VALUE (*func)(), int argc)
|
||||||
|
|
||||||
Defines a method for the class. func is the function pointer. argc
|
Defines a method for the class. func is the function pointer. argc
|
||||||
is the number of arguments. if argc is -1, the function will receive
|
is the number of arguments. if argc is -1, the function will receive
|
||||||
|
@ -848,16 +846,16 @@ is the number of arguments. if argc is -1, the function will receive
|
||||||
receive 2 arguments, self and args, where args is the Ruby array of
|
receive 2 arguments, self and args, where args is the Ruby array of
|
||||||
the method arguments.
|
the method arguments.
|
||||||
|
|
||||||
rb_define_private_method(VALUE klass, char *name, VALUE (*func)(), int argc)
|
rb_define_private_method(VALUE klass, const char *name, VALUE (*func)(), int argc)
|
||||||
|
|
||||||
Defines a private method for the class. Arguments are same as
|
Defines a private method for the class. Arguments are same as
|
||||||
rb_define_method().
|
rb_define_method().
|
||||||
|
|
||||||
rb_define_singleton_method(VALUE klass, char *name, VALUE (*func)(), int argc)
|
rb_define_singleton_method(VALUE klass, const char *name, VALUE (*func)(), int argc)
|
||||||
|
|
||||||
Defines a singleton method. Arguments are same as rb_define_method().
|
Defines a singleton method. Arguments are same as rb_define_method().
|
||||||
|
|
||||||
rb_scan_args(int argc, VALUE *argv, char *fmt, ...)
|
rb_scan_args(int argc, VALUE *argv, const char *fmt, ...)
|
||||||
|
|
||||||
Retrieve argument from argc, argv. The fmt is the format string for
|
Retrieve argument from argc, argv. The fmt is the format string for
|
||||||
the arguments, such as "12" for 1 non-optional argument, 2 optional
|
the arguments, such as "12" for 1 non-optional argument, 2 optional
|
||||||
|
@ -875,11 +873,11 @@ Invokes the method. To retrieve mid from method name, use rb_intern().
|
||||||
|
|
||||||
Invokes method, passing arguments by array of values.
|
Invokes method, passing arguments by array of values.
|
||||||
|
|
||||||
VALUE rb_eval_string(char *str)
|
VALUE rb_eval_string(const char *str)
|
||||||
|
|
||||||
Compiles and executes the string as Ruby program.
|
Compiles and executes the string as Ruby program.
|
||||||
|
|
||||||
ID rb_intern(char *name)
|
ID rb_intern(const char *name)
|
||||||
|
|
||||||
Returns ID corresponding the name.
|
Returns ID corresponding the name.
|
||||||
|
|
||||||
|
@ -897,12 +895,12 @@ Returns true if the object responds to the message specified by id.
|
||||||
|
|
||||||
** Instance Variables
|
** Instance Variables
|
||||||
|
|
||||||
VALUE rb_iv_get(VALUE obj, char *name)
|
VALUE rb_iv_get(VALUE obj, const char *name)
|
||||||
|
|
||||||
Retrieve the value of the instance variable. If the name is not
|
Retrieve the value of the instance variable. If the name is not
|
||||||
prefixed by `@', that variable shall be inaccessible from Ruby.
|
prefixed by `@', that variable shall be inaccessible from Ruby.
|
||||||
|
|
||||||
VALUE rb_iv_set(VALUE obj, char *name, VALUE val)
|
VALUE rb_iv_set(VALUE obj, const char *name, VALUE val)
|
||||||
|
|
||||||
Sets the value of the instance variable.
|
Sets the value of the instance variable.
|
||||||
|
|
||||||
|
@ -933,26 +931,26 @@ rb_ensure() is that of func1.
|
||||||
|
|
||||||
** Exceptions and Errors
|
** Exceptions and Errors
|
||||||
|
|
||||||
void rb_warn(char *fmt, ...)
|
void rb_warn(const char *fmt, ...)
|
||||||
|
|
||||||
Prints warning message according to the printf-like format.
|
Prints warning message according to the printf-like format.
|
||||||
|
|
||||||
void rb_warning(char *fmt, ...)
|
void rb_warning(const char *fmt, ...)
|
||||||
|
|
||||||
Prints warning message according to the printf-like format, if
|
Prints warning message according to the printf-like format, if
|
||||||
$VERBOSE is true.
|
$VERBOSE is true.
|
||||||
|
|
||||||
void rb_raise(VALUE exception, char *fmt, ...)
|
void rb_raise(VALUE exception, const char *fmt, ...)
|
||||||
|
|
||||||
Raises an exception of class exception. The fmt is the format string
|
Raises an exception of class exception. The fmt is the format string
|
||||||
just like printf().
|
just like printf().
|
||||||
|
|
||||||
void rb_fatal(char *fmt, ...)
|
void rb_fatal(const char *fmt, ...)
|
||||||
|
|
||||||
Raises fatal error, terminates the interpreter. No exception handling
|
Raises fatal error, terminates the interpreter. No exception handling
|
||||||
will be done for fatal error, but ensure blocks will be executed.
|
will be done for fatal error, but ensure blocks will be executed.
|
||||||
|
|
||||||
void rb_bug(char *fmt, ...)
|
void rb_bug(const char *fmt, ...)
|
||||||
|
|
||||||
Terminates the interpreter immediately. This function should be
|
Terminates the interpreter immediately. This function should be
|
||||||
called under the situation caused by the bug in the interpreter. No
|
called under the situation caused by the bug in the interpreter. No
|
||||||
|
|
122
README.EXT.jp
122
README.EXT.jp
|
@ -43,11 +43,13 @@ Ruby
|
||||||
T_TRUE 真
|
T_TRUE 真
|
||||||
T_FALSE 偽
|
T_FALSE 偽
|
||||||
T_DATA データ
|
T_DATA データ
|
||||||
|
T_SYMBOL シンボル
|
||||||
|
|
||||||
その他に内部で利用されている以下のタイプがあります.
|
その他に内部で利用されている以下のタイプがあります.
|
||||||
|
|
||||||
T_ICLASS
|
T_ICLASS
|
||||||
T_MATCH
|
T_MATCH
|
||||||
|
T_UNDEF
|
||||||
T_VARMAP
|
T_VARMAP
|
||||||
T_SCOPE
|
T_SCOPE
|
||||||
T_NODE
|
T_NODE
|
||||||
|
@ -171,26 +173,26 @@ Ruby
|
||||||
|
|
||||||
文字列に対する関数
|
文字列に対する関数
|
||||||
|
|
||||||
rb_str_new(char *ptr, int len)
|
rb_str_new(const char *ptr, long len)
|
||||||
|
|
||||||
新しいRubyの文字列を生成する.
|
新しいRubyの文字列を生成する.
|
||||||
|
|
||||||
rb_str_new2(char *ptr)
|
rb_str_new2(const char *ptr)
|
||||||
|
|
||||||
Cの文字列からRubyの文字列を生成する.この関数の機能は
|
Cの文字列からRubyの文字列を生成する.この関数の機能は
|
||||||
rb_str_new(ptr, strlen(ptr))と同等である.
|
rb_str_new(ptr, strlen(ptr))と同等である.
|
||||||
|
|
||||||
rb_tainted_str_new(char *ptr, int len)
|
rb_tainted_str_new(const char *ptr, long len)
|
||||||
|
|
||||||
汚染マークが付加された新しいRubyの文字列を生成する.外部
|
汚染マークが付加された新しいRubyの文字列を生成する.外部
|
||||||
からのデータに基づく文字列には汚染マークが付加されるべき
|
からのデータに基づく文字列には汚染マークが付加されるべき
|
||||||
である.
|
である.
|
||||||
|
|
||||||
rb_tainted_str_new2(char *ptr)
|
rb_tainted_str_new2(const char *ptr)
|
||||||
|
|
||||||
Cの文字列から汚染マークが付加されたRubyの文字列を生成する.
|
Cの文字列から汚染マークが付加されたRubyの文字列を生成する.
|
||||||
|
|
||||||
rb_str_cat(VALUE str, char *ptr, int len)
|
rb_str_cat(VALUE str, const char *ptr, long len)
|
||||||
|
|
||||||
Rubyの文字列strにlenバイトの文字列ptrを追加する.
|
Rubyの文字列strにlenバイトの文字列ptrを追加する.
|
||||||
|
|
||||||
|
@ -200,16 +202,16 @@ Ruby
|
||||||
|
|
||||||
要素が0の配列を生成する.
|
要素が0の配列を生成する.
|
||||||
|
|
||||||
rb_ary_new2(int len)
|
rb_ary_new2(long len)
|
||||||
|
|
||||||
要素が0の配列を生成する.len要素分の領域をあらかじめ割り
|
要素が0の配列を生成する.len要素分の領域をあらかじめ割り
|
||||||
当てておく.
|
当てておく.
|
||||||
|
|
||||||
rb_ary_new3(int n, ...)
|
rb_ary_new3(long n, ...)
|
||||||
|
|
||||||
引数で指定したn要素を含む配列を生成する.
|
引数で指定したn要素を含む配列を生成する.
|
||||||
|
|
||||||
rb_ary_new4(int n, VALUE *elts)
|
rb_ary_new4(long n, VALUE *elts)
|
||||||
|
|
||||||
配列で与えたn要素の配列を生成する.
|
配列で与えたn要素の配列を生成する.
|
||||||
|
|
||||||
|
@ -217,7 +219,6 @@ Ruby
|
||||||
rb_ary_pop(VALUE ary)
|
rb_ary_pop(VALUE ary)
|
||||||
rb_ary_shift(VALUE ary)
|
rb_ary_shift(VALUE ary)
|
||||||
rb_ary_unshift(VALUE ary, VALUE val)
|
rb_ary_unshift(VALUE ary, VALUE val)
|
||||||
rb_ary_entry(VALUE ary, int idx)
|
|
||||||
|
|
||||||
Arrayの同名のメソッドと同じ働きをする関数.第1引数は必ず
|
Arrayの同名のメソッドと同じ働きをする関数.第1引数は必ず
|
||||||
配列でなければならない.
|
配列でなければならない.
|
||||||
|
@ -245,8 +246,8 @@ Ruby
|
||||||
|
|
||||||
クラスやモジュールを定義するためには,以下の関数を使います.
|
クラスやモジュールを定義するためには,以下の関数を使います.
|
||||||
|
|
||||||
VALUE rb_define_class(char *name, VALUE super)
|
VALUE rb_define_class(const char *name, VALUE super)
|
||||||
VALUE rb_define_module(char *name)
|
VALUE rb_define_module(const char *name)
|
||||||
|
|
||||||
これらの関数は新しく定義されたクラスやモジュールを返します.
|
これらの関数は新しく定義されたクラスやモジュールを返します.
|
||||||
メソッドや定数の定義にこれらの値が必要なので,ほとんどの場合
|
メソッドや定数の定義にこれらの値が必要なので,ほとんどの場合
|
||||||
|
@ -255,17 +256,17 @@ Ruby
|
||||||
クラスやモジュールを他のクラスの内部にネストして定義する時に
|
クラスやモジュールを他のクラスの内部にネストして定義する時に
|
||||||
は以下の関数を使います.
|
は以下の関数を使います.
|
||||||
|
|
||||||
VALUE rb_define_class_under(VALUE outer, char *name, VALUE super)
|
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
|
||||||
VALUE rb_define_module_under(VALUE outer, char *name)
|
VALUE rb_define_module_under(VALUE outer, const char *name)
|
||||||
|
|
||||||
2.1.2 メソッド/特異メソッド定義
|
2.1.2 メソッド/特異メソッド定義
|
||||||
|
|
||||||
メソッドや特異メソッドを定義するには以下の関数を使います.
|
メソッドや特異メソッドを定義するには以下の関数を使います.
|
||||||
|
|
||||||
void rb_define_method(VALUE klass, char *name,
|
void rb_define_method(VALUE klass, const char *name,
|
||||||
VALUE (*func)(), int argc)
|
VALUE (*func)(), int argc)
|
||||||
|
|
||||||
void rb_define_singleton_method(VALUE object, char *name,
|
void rb_define_singleton_method(VALUE object, const char *name,
|
||||||
VALUE (*func)(), int argc)
|
VALUE (*func)(), int argc)
|
||||||
|
|
||||||
|
|
||||||
|
@ -287,7 +288,7 @@ argc
|
||||||
メソッドを定義する関数はもう二つあります.ひとつはprivateメ
|
メソッドを定義する関数はもう二つあります.ひとつはprivateメ
|
||||||
ソッドを定義する関数で,引数はrb_define_method()と同じです.
|
ソッドを定義する関数で,引数はrb_define_method()と同じです.
|
||||||
|
|
||||||
void rb_define_private_method(VALUE klass, char *name,
|
void rb_define_private_method(VALUE klass, const char *name,
|
||||||
VALUE (*func)(), int argc)
|
VALUE (*func)(), int argc)
|
||||||
|
|
||||||
privateメソッドとは関数形式でしか呼び出すことの出来ないメソッ
|
privateメソッドとは関数形式でしか呼び出すことの出来ないメソッ
|
||||||
|
@ -308,13 +309,13 @@ private
|
||||||
という形式でも使えます.モジュール関数を定義する関数は以下の
|
という形式でも使えます.モジュール関数を定義する関数は以下の
|
||||||
通りです.
|
通りです.
|
||||||
|
|
||||||
void rb_define_module_function(VALUE module, char *name,
|
void rb_define_module_function(VALUE module, const char *name,
|
||||||
VALUE (*func)(), int argc)
|
VALUE (*func)(), int argc)
|
||||||
|
|
||||||
関数的メソッド(Kernelモジュールのprivate method)を定義するた
|
関数的メソッド(Kernelモジュールのprivate method)を定義するた
|
||||||
めの関数は以下の通りです.
|
めの関数は以下の通りです.
|
||||||
|
|
||||||
void rb_define_global_function(char *name, VALUE (*func)(), int argc)
|
void rb_define_global_function(const char *name, VALUE (*func)(), int argc)
|
||||||
|
|
||||||
|
|
||||||
メソッドの別名を定義するための関数は以下の通りです。
|
メソッドの別名を定義するための関数は以下の通りです。
|
||||||
|
@ -326,8 +327,8 @@ private
|
||||||
拡張ライブラリが必要な定数はあらかじめ定義しておいた方が良い
|
拡張ライブラリが必要な定数はあらかじめ定義しておいた方が良い
|
||||||
でしょう.定数を定義する関数は二つあります.
|
でしょう.定数を定義する関数は二つあります.
|
||||||
|
|
||||||
void rb_define_const(VALUE klass, char *name, VALUE val)
|
void rb_define_const(VALUE klass, const char *name, VALUE val)
|
||||||
void rb_define_global_const(char *name, VALUE val)
|
void rb_define_global_const(const char *name, VALUE val)
|
||||||
|
|
||||||
前者は特定のクラス/モジュールに属する定数を定義するもの,後
|
前者は特定のクラス/モジュールに属する定数を定義するもの,後
|
||||||
者はグローバルな定数を定義するものです.
|
者はグローバルな定数を定義するものです.
|
||||||
|
@ -348,7 +349,7 @@ private
|
||||||
CからRubyの機能を呼び出すもっとも簡単な方法として,文字列で
|
CからRubyの機能を呼び出すもっとも簡単な方法として,文字列で
|
||||||
与えられたRubyのプログラムを評価する以下の関数があります.
|
与えられたRubyのプログラムを評価する以下の関数があります.
|
||||||
|
|
||||||
VALUE rb_eval_string(char *str)
|
VALUE rb_eval_string(const char *str)
|
||||||
|
|
||||||
この評価は現在の環境で行われます.つまり,現在のローカル変数
|
この評価は現在の環境で行われます.つまり,現在のローカル変数
|
||||||
などを受け継ぎます.
|
などを受け継ぎます.
|
||||||
|
@ -365,11 +366,10 @@ ID
|
||||||
|
|
||||||
でアクセスできます.Cからこの整数を得るためには関数
|
でアクセスできます.Cからこの整数を得るためには関数
|
||||||
|
|
||||||
rb_intern(char *name)
|
rb_intern(const char *name)
|
||||||
|
|
||||||
を使います.また一文字の演算子はその文字コードがそのままシン
|
を使います.Rubyから引数として与えられたシンボル(または文字
|
||||||
ボルになっています.Rubyから引数として与えられたシンボル(ま
|
列)をIDに変換するには以下の関数を使います.
|
||||||
たは文字列)をIDに変換するには以下の関数を使います.
|
|
||||||
|
|
||||||
rb_to_id(VALUE symbol)
|
rb_to_id(VALUE symbol)
|
||||||
|
|
||||||
|
@ -432,7 +432,7 @@ C
|
||||||
変数にはいくつかの種類があります.そのなかでもっとも良く使わ
|
変数にはいくつかの種類があります.そのなかでもっとも良く使わ
|
||||||
れると思われるのはrb_define_variable()です.
|
れると思われるのはrb_define_variable()です.
|
||||||
|
|
||||||
void rb_define_variable(char *name, VALUE *var)
|
void rb_define_variable(const char *name, VALUE *var)
|
||||||
|
|
||||||
この関数はRubyとCとで共有する大域変数を定義します.変数名が
|
この関数はRubyとCとで共有する大域変数を定義します.変数名が
|
||||||
`$'で始まらない時には自動的に追加されます.この変数の値を変
|
`$'で始まらない時には自動的に追加されます.この変数の値を変
|
||||||
|
@ -441,14 +441,14 @@ C
|
||||||
またRuby側からは更新できない変数もあります.このread onlyの
|
またRuby側からは更新できない変数もあります.このread onlyの
|
||||||
変数は以下の関数で定義します.
|
変数は以下の関数で定義します.
|
||||||
|
|
||||||
void rb_define_readonly_variable(char *name, VALUE *var)
|
void rb_define_readonly_variable(const char *name, VALUE *var)
|
||||||
|
|
||||||
これら変数の他にhookをつけた大域変数を定義できます.hook付き
|
これら変数の他にhookをつけた大域変数を定義できます.hook付き
|
||||||
の大域変数は以下の関数を用いて定義します.hook付き大域変数の
|
の大域変数は以下の関数を用いて定義します.hook付き大域変数の
|
||||||
値の参照や設定はhookで行う必要があります.
|
値の参照や設定はhookで行う必要があります.
|
||||||
|
|
||||||
void rb_define_hooked_variable(char *name, VALUE *var,
|
void rb_define_hooked_variable(const char *name, VALUE *var,
|
||||||
VALUE (*getter)(), VALUE (*setter)())
|
VALUE (*getter)(), void (*setter)())
|
||||||
|
|
||||||
この関数はCの関数によってhookのつけられた大域変数を定義しま
|
この関数はCの関数によってhookのつけられた大域変数を定義しま
|
||||||
す.変数が参照された時には関数getterが,変数に値がセットされ
|
す.変数が参照された時には関数getterが,変数に値がセットされ
|
||||||
|
@ -460,8 +460,8 @@ setter
|
||||||
それから,Cの関数によって実現されるRubyの大域変数を定義する
|
それから,Cの関数によって実現されるRubyの大域変数を定義する
|
||||||
関数があります.
|
関数があります.
|
||||||
|
|
||||||
void rb_define_virtual_variable(char *name,
|
void rb_define_virtual_variable(const char *name,
|
||||||
VALUE (*getter)(), VALUE (*setter)())
|
VALUE (*getter)(), void (*setter)())
|
||||||
|
|
||||||
この関数によって定義されたRubyの大域変数が参照された時には
|
この関数によって定義されたRubyの大域変数が参照された時には
|
||||||
getterが,変数に値がセットされた時にはsetterが呼ばれます.
|
getterが,変数に値がセットされた時にはsetterが呼ばれます.
|
||||||
|
@ -551,7 +551,7 @@ MANIFEST
|
||||||
まあ,当然なんですけど,どういう機能を実現するかどうかまず設
|
まあ,当然なんですけど,どういう機能を実現するかどうかまず設
|
||||||
計する必要があります.どんなクラスをつくるか,そのクラスには
|
計する必要があります.どんなクラスをつくるか,そのクラスには
|
||||||
どんなメソッドがあるか,クラスが提供する定数などについて設計
|
どんなメソッドがあるか,クラスが提供する定数などについて設計
|
||||||
します.dbmクラスについてはext/dbm.docを参照してください.
|
します.
|
||||||
|
|
||||||
(4) Cコードを書く
|
(4) Cコードを書く
|
||||||
|
|
||||||
|
@ -911,20 +911,20 @@ rb_str_new2(s)
|
||||||
|
|
||||||
** クラス/モジュール定義
|
** クラス/モジュール定義
|
||||||
|
|
||||||
VALUE rb_define_class(char *name, VALUE super)
|
VALUE rb_define_class(const char *name, VALUE super)
|
||||||
|
|
||||||
superのサブクラスとして新しいRubyクラスを定義する.
|
superのサブクラスとして新しいRubyクラスを定義する.
|
||||||
|
|
||||||
VALUE rb_define_class_under(VALUE module, char *name, VALUE super)
|
VALUE rb_define_class_under(VALUE module, const char *name, VALUE super)
|
||||||
|
|
||||||
superのサブクラスとして新しいRubyクラスを定義し,moduleの
|
superのサブクラスとして新しいRubyクラスを定義し,moduleの
|
||||||
定数として定義する.
|
定数として定義する.
|
||||||
|
|
||||||
VALUE rb_define_module(char *name)
|
VALUE rb_define_module(const char *name)
|
||||||
|
|
||||||
新しいRubyモジュールを定義する.
|
新しいRubyモジュールを定義する.
|
||||||
|
|
||||||
VALUE rb_define_module_under(VALUE module, char *name, VALUE super)
|
VALUE rb_define_module_under(VALUE module, const char *name, VALUE super)
|
||||||
|
|
||||||
新しいRubyモジュールを定義し,moduleの定数として定義する.
|
新しいRubyモジュールを定義し,moduleの定数として定義する.
|
||||||
|
|
||||||
|
@ -939,27 +939,27 @@ void rb_extend_object(VALUE object, VALUE module)
|
||||||
|
|
||||||
** 大域変数定義
|
** 大域変数定義
|
||||||
|
|
||||||
void rb_define_variable(char *name, VALUE *var)
|
void rb_define_variable(const char *name, VALUE *var)
|
||||||
|
|
||||||
RubyとCとで共有するグローバル変数を定義する.変数名が`$'で
|
RubyとCとで共有するグローバル変数を定義する.変数名が`$'で
|
||||||
始まらない時には自動的に追加される.nameとしてRubyの識別子
|
始まらない時には自動的に追加される.nameとしてRubyの識別子
|
||||||
として許されない文字(例えば` ')を含む場合にはRubyプログラ
|
として許されない文字(例えば` ')を含む場合にはRubyプログラ
|
||||||
ムからは見えなくなる.
|
ムからは見えなくなる.
|
||||||
|
|
||||||
void rb_define_readonly_variable(char *name, VALUE *var)
|
void rb_define_readonly_variable(const char *name, VALUE *var)
|
||||||
|
|
||||||
RubyとCとで共有するread onlyのグローバル変数を定義する.
|
RubyとCとで共有するread onlyのグローバル変数を定義する.
|
||||||
read onlyであること以外はrb_define_variable()と同じ.
|
read onlyであること以外はrb_define_variable()と同じ.
|
||||||
|
|
||||||
void rb_define_virtual_variable(char *name,
|
void rb_define_virtual_variable(const char *name,
|
||||||
VALUE (*getter)(), VALUE (*setter)())
|
VALUE (*getter)(), void (*setter)())
|
||||||
|
|
||||||
関数によって実現されるRuby変数を定義する.変数が参照された
|
関数によって実現されるRuby変数を定義する.変数が参照された
|
||||||
時にはgetterが,変数に値がセットされた時にはsetterが呼ばれ
|
時にはgetterが,変数に値がセットされた時にはsetterが呼ばれ
|
||||||
る.
|
る.
|
||||||
|
|
||||||
void rb_define_hooked_variable(char *name, VALUE *var,
|
void rb_define_hooked_variable(const char *name, VALUE *var,
|
||||||
VALUE (*getter)(), VALUE (*setter)())
|
VALUE (*getter)(), void (*setter)())
|
||||||
|
|
||||||
関数によってhookのつけられたグローバル変数を定義する.変数
|
関数によってhookのつけられたグローバル変数を定義する.変数
|
||||||
が参照された時にはgetterが,関数に値がセットされた時には
|
が参照された時にはgetterが,関数に値がセットされた時には
|
||||||
|
@ -973,21 +973,21 @@ void rb_global_variable(VALUE *var)
|
||||||
|
|
||||||
** 定数
|
** 定数
|
||||||
|
|
||||||
void rb_define_const(VALUE klass, char *name, VALUE val)
|
void rb_define_const(VALUE klass, const char *name, VALUE val)
|
||||||
|
|
||||||
定数を定義する.
|
定数を定義する.
|
||||||
|
|
||||||
void rb_define_global_const(char *name, VALUE val)
|
void rb_define_global_const(const char *name, VALUE val)
|
||||||
|
|
||||||
大域定数を定義する.
|
大域定数を定義する.
|
||||||
|
|
||||||
rb_define_const(cKernal, name, val)
|
rb_define_const(rb_cObject, name, val)
|
||||||
|
|
||||||
と同じ意味.
|
と同じ意味.
|
||||||
|
|
||||||
** メソッド定義
|
** メソッド定義
|
||||||
|
|
||||||
rb_define_method(VALUE klass, char *name, VALUE (*func)(), int argc)
|
rb_define_method(VALUE klass, const char *name, VALUE (*func)(), int argc)
|
||||||
|
|
||||||
メソッドを定義する.argcはselfを除く引数の数.argcが-1の時,
|
メソッドを定義する.argcはselfを除く引数の数.argcが-1の時,
|
||||||
関数には引数の数(selfを含まない)を第1引数, 引数の配列を第2
|
関数には引数の数(selfを含まない)を第1引数, 引数の配列を第2
|
||||||
|
@ -995,15 +995,15 @@ rb_define_method(VALUE klass, char *name, VALUE (*func)(), int argc)
|
||||||
第1引数がself, 第2引数がargs(argsは引数を含むRubyの配列)と
|
第1引数がself, 第2引数がargs(argsは引数を含むRubyの配列)と
|
||||||
いう形式で与えられる.
|
いう形式で与えられる.
|
||||||
|
|
||||||
rb_define_private_method(VALUE klass, char *name, VALUE (*func)(), int argc)
|
rb_define_private_method(VALUE klass, const char *name, VALUE (*func)(), int argc)
|
||||||
|
|
||||||
privateメソッドを定義する.引数はrb_define_method()と同じ.
|
privateメソッドを定義する.引数はrb_define_method()と同じ.
|
||||||
|
|
||||||
rb_define_singleton_method(VALUE klass, char *name, VALUE (*func)(), int argc)
|
rb_define_singleton_method(VALUE klass, const char *name, VALUE (*func)(), int argc)
|
||||||
|
|
||||||
特異メソッドを定義する.引数はrb_define_method()と同じ.
|
特異メソッドを定義する.引数はrb_define_method()と同じ.
|
||||||
|
|
||||||
rb_scan_args(int argc, VALUE *argv, char *fmt, ...)
|
rb_scan_args(int argc, VALUE *argv, const char *fmt, ...)
|
||||||
|
|
||||||
argc, argv形式で与えられた引数を分解する.fmtは必須引数の数,
|
argc, argv形式で与えられた引数を分解する.fmtは必須引数の数,
|
||||||
付加引数の数, 残りの引数があるかを指定する文字列で, "数字
|
付加引数の数, 残りの引数があるかを指定する文字列で, "数字
|
||||||
|
@ -1024,11 +1024,11 @@ VALUE rb_funcall2(VALUE recv, ID mid, int argc, VALUE *argv)
|
||||||
|
|
||||||
メソッド呼び出し.引数をargc, argv形式で渡す.
|
メソッド呼び出し.引数をargc, argv形式で渡す.
|
||||||
|
|
||||||
VALUE rb_eval_string(char *str)
|
VALUE rb_eval_string(const char *str)
|
||||||
|
|
||||||
文字列をRubyスクリプトとしてコンパイル・実行する.
|
文字列をRubyスクリプトとしてコンパイル・実行する.
|
||||||
|
|
||||||
ID rb_intern(char *name)
|
ID rb_intern(const char *name)
|
||||||
|
|
||||||
文字列に対応するIDを返す.
|
文字列に対応するIDを返す.
|
||||||
|
|
||||||
|
@ -1047,20 +1047,20 @@ int rb_respond_to(VALUE obj, ID id)
|
||||||
|
|
||||||
** インスタンス変数
|
** インスタンス変数
|
||||||
|
|
||||||
VALUE rb_iv_get(VALUE obj, char *name)
|
VALUE rb_iv_get(VALUE obj, const char *name)
|
||||||
|
|
||||||
objのインスタンス変数の値を得る.`@'で始まらないインスタン
|
objのインスタンス変数の値を得る.`@'で始まらないインスタン
|
||||||
ス変数は Rubyプログラムからアクセスできない「隠れた」イン
|
ス変数は Rubyプログラムからアクセスできない「隠れた」イン
|
||||||
スタンス変数になる.定数は大文字の名前を持つクラス(または
|
スタンス変数になる.定数は大文字の名前を持つクラス(または
|
||||||
モジュール)のインスタンス変数として実装されている.
|
モジュール)のインスタンス変数として実装されている.
|
||||||
|
|
||||||
VALUE rb_iv_set(VALUE obj, char *name, VALUE val)
|
VALUE rb_iv_set(VALUE obj, const char *name, VALUE val)
|
||||||
|
|
||||||
objのインスタンス変数をvalにセットする.
|
objのインスタンス変数をvalにセットする.
|
||||||
|
|
||||||
** 制御構造
|
** 制御構造
|
||||||
|
|
||||||
VALUE rb_iterate(VALUE (*func1)(), void *arg1, VALUE (*func2)(), void *arg2)
|
VALUE rb_iterate(VALUE (*func1)(), VALUE arg1, VALUE (*func2)(), VALUE arg2)
|
||||||
|
|
||||||
func2をブロックとして設定し, func1をイテレータとして呼ぶ.
|
func2をブロックとして設定し, func1をイテレータとして呼ぶ.
|
||||||
func1には arg1が引数として渡され, func2には第1引数にイテレー
|
func1には arg1が引数として渡され, func2には第1引数にイテレー
|
||||||
|
@ -1070,14 +1070,14 @@ VALUE rb_yield(VALUE val)
|
||||||
|
|
||||||
valを値としてイテレータブロックを呼び出す.
|
valを値としてイテレータブロックを呼び出す.
|
||||||
|
|
||||||
VALUE rb_rescue(VALUE (*func1)(), void *arg1, VALUE (*func2)(), void *arg2)
|
VALUE rb_rescue(VALUE (*func1)(), VALUE arg1, VALUE (*func2)(), VALUE arg2)
|
||||||
|
|
||||||
関数func1をarg1を引数に呼び出す.func1の実行中に例外が発生
|
関数func1をarg1を引数に呼び出す.func1の実行中に例外が発生
|
||||||
した時には func2をarg2を引数として呼ぶ.戻り値は例外が発生
|
した時には func2をarg2を引数として呼ぶ.戻り値は例外が発生
|
||||||
しなかった時はfunc1の戻り値, 例外が発生した時にはfunc2の戻
|
しなかった時はfunc1の戻り値, 例外が発生した時にはfunc2の戻
|
||||||
り値である.
|
り値である.
|
||||||
|
|
||||||
VALUE rb_ensure(VALUE (*func1)(), void *arg1, void (*func2)(), void *arg2)
|
VALUE rb_ensure(VALUE (*func1)(), VALUE arg1, void (*func2)(), VALUE arg2)
|
||||||
|
|
||||||
関数func1をarg1を引数として実行し, 実行終了後(たとえ例外が
|
関数func1をarg1を引数として実行し, 実行終了後(たとえ例外が
|
||||||
発生しても) func2をarg2を引数として実行する.戻り値はfunc1
|
発生しても) func2をarg2を引数として実行する.戻り値はfunc1
|
||||||
|
@ -1085,27 +1085,27 @@ VALUE rb_ensure(VALUE (*func1)(), void *arg1, void (*func2)(), void *arg2)
|
||||||
|
|
||||||
** 例外・エラー
|
** 例外・エラー
|
||||||
|
|
||||||
void rb_warning(char *fmt, ...)
|
void rb_warning(const char *fmt, ...)
|
||||||
|
|
||||||
rb_verbose時に標準エラー出力に警告情報を表示する.引数は
|
rb_verbose時に標準エラー出力に警告情報を表示する.引数は
|
||||||
printf()と同じ.
|
printf()と同じ.
|
||||||
|
|
||||||
void rb_raise(rb_eRuntimeError, char *fmt, ...)
|
void rb_raise(rb_eRuntimeError, const char *fmt, ...)
|
||||||
|
|
||||||
RuntimeError例外を発生させる.引数はprintf()と同じ.
|
RuntimeError例外を発生させる.引数はprintf()と同じ.
|
||||||
|
|
||||||
void rb_raise(VALUE exception, char *fmt, ...)
|
void rb_raise(VALUE exception, const char *fmt, ...)
|
||||||
|
|
||||||
exceptionで指定した例外を発生させる.fmt以下の引数は
|
exceptionで指定した例外を発生させる.fmt以下の引数は
|
||||||
printf()と同じ.
|
printf()と同じ.
|
||||||
|
|
||||||
void rb_fatal(char *fmt, ...)
|
void rb_fatal(const char *fmt, ...)
|
||||||
|
|
||||||
致命的例外を発生させる.通常の例外処理は行なわれず, インター
|
致命的例外を発生させる.通常の例外処理は行なわれず, インター
|
||||||
プリタが終了する(ただしensureで指定されたコードは終了前に
|
プリタが終了する(ただしensureで指定されたコードは終了前に
|
||||||
実行される).
|
実行される).
|
||||||
|
|
||||||
void rb_bug(char *fmt, ...)
|
void rb_bug(const char *fmt, ...)
|
||||||
|
|
||||||
インタープリタなどプログラムのバグでしか発生するはずのない
|
インタープリタなどプログラムのバグでしか発生するはずのない
|
||||||
状況の時呼ぶ.インタープリタはコアダンプし直ちに終了する.
|
状況の時呼ぶ.インタープリタはコアダンプし直ちに終了する.
|
||||||
|
|
33
eval.c
33
eval.c
|
@ -3986,15 +3986,24 @@ static int STACK_LEVEL_MAX = 655300;
|
||||||
|
|
||||||
extern VALUE *rb_gc_stack_start;
|
extern VALUE *rb_gc_stack_start;
|
||||||
static int
|
static int
|
||||||
stack_length()
|
stack_length(p)
|
||||||
|
VALUE **p;
|
||||||
{
|
{
|
||||||
VALUE pos;
|
#ifdef C_ALLOCA
|
||||||
|
VALUE stack_end;
|
||||||
|
alloca(0);
|
||||||
|
# define STACK_END (&stack_end)
|
||||||
|
#else
|
||||||
|
VALUE *stack_end = alloca(1);
|
||||||
|
# define STACK_END (stack_end)
|
||||||
|
#endif
|
||||||
|
if (p) *p = STACK_END;
|
||||||
|
|
||||||
#ifdef sparc
|
#ifdef sparc
|
||||||
return rb_gc_stack_start - &pos + 0x80;
|
return rb_gc_stack_start - STACK_END + 0x80;
|
||||||
#else
|
#else
|
||||||
return (&pos < rb_gc_stack_start) ? rb_gc_stack_start - &pos
|
return (STACK_END < rb_gc_stack_start) ? rb_gc_stack_start - STACK_END
|
||||||
: &pos - rb_gc_stack_start;
|
: STACK_END - rb_gc_stack_start;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4113,7 +4122,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
|
||||||
|
|
||||||
if ((++tick & 0xff) == 0) {
|
if ((++tick & 0xff) == 0) {
|
||||||
CHECK_INTS; /* better than nothing */
|
CHECK_INTS; /* better than nothing */
|
||||||
if (stack_length() > STACK_LEVEL_MAX) {
|
if (stack_length(0) > STACK_LEVEL_MAX) {
|
||||||
rb_raise(rb_eSysStackError, "stack level too deep");
|
rb_raise(rb_eSysStackError, "stack level too deep");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6111,7 +6120,7 @@ proc_arity(proc)
|
||||||
if (data->var == 0) return INT2FIX(-1);
|
if (data->var == 0) return INT2FIX(-1);
|
||||||
switch (nd_type(data->var)) {
|
switch (nd_type(data->var)) {
|
||||||
default:
|
default:
|
||||||
return INT2FIX(-2);
|
return INT2FIX(-1);
|
||||||
case NODE_MASGN:
|
case NODE_MASGN:
|
||||||
list = data->var->nd_head;
|
list = data->var->nd_head;
|
||||||
n = 0;
|
n = 0;
|
||||||
|
@ -6736,15 +6745,15 @@ static void
|
||||||
rb_thread_save_context(th)
|
rb_thread_save_context(th)
|
||||||
rb_thread_t th;
|
rb_thread_t th;
|
||||||
{
|
{
|
||||||
VALUE v;
|
VALUE *pos;
|
||||||
|
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
len = stack_length();
|
len = stack_length(&pos);
|
||||||
th->stk_len = 0;
|
th->stk_len = 0;
|
||||||
th->stk_pos = (rb_gc_stack_start<(VALUE*)&v)?rb_gc_stack_start
|
th->stk_pos = (rb_gc_stack_start<pos)?rb_gc_stack_start
|
||||||
:rb_gc_stack_start - len;
|
:rb_gc_stack_start - len;
|
||||||
if (len > th->stk_max) {
|
if (len > th->stk_max) {
|
||||||
REALLOC_N(th->stk_ptr, VALUE, len);
|
REALLOC_N(th->stk_ptr, VALUE, len);
|
||||||
th->stk_max = len;
|
th->stk_max = len;
|
||||||
}
|
}
|
||||||
|
|
1
object.c
1
object.c
|
@ -113,6 +113,7 @@ rb_obj_dup(obj)
|
||||||
}
|
}
|
||||||
if (!SPECIAL_CONST_P(dup)) {
|
if (!SPECIAL_CONST_P(dup)) {
|
||||||
OBJSETUP(dup, rb_obj_type(obj), BUILTIN_TYPE(obj));
|
OBJSETUP(dup, rb_obj_type(obj), BUILTIN_TYPE(obj));
|
||||||
|
OBJ_INFECT(dup, obj);
|
||||||
}
|
}
|
||||||
return dup;
|
return dup;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#define RUBY_VERSION "1.6.1"
|
#define RUBY_VERSION "1.6.1"
|
||||||
#define RUBY_RELEASE_DATE "2000-10-02"
|
#define RUBY_RELEASE_DATE "2000-10-05"
|
||||||
#define RUBY_VERSION_CODE 161
|
#define RUBY_VERSION_CODE 161
|
||||||
#define RUBY_RELEASE_CODE 20001002
|
#define RUBY_RELEASE_CODE 20001005
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue