[DOC] Un-capitalize headings
This commit is contained in:
parent
cb820bff33
commit
bb60e4615f
Notes:
git
2022-12-26 11:30:15 +00:00
@ -1,6 +1,6 @@
|
||||
# extension.rdoc - -*- RDoc -*- created at: Mon Aug 7 16:45:54 JST 1995
|
||||
|
||||
= Creating Extension Libraries for Ruby
|
||||
= Creating extension libraries for Ruby
|
||||
|
||||
This document explains how to make extension libraries for Ruby.
|
||||
|
||||
@ -176,7 +176,7 @@ internal structure. To manipulate objects, use the functions supplied
|
||||
by the Ruby interpreter. Some (not all) of the useful functions are
|
||||
listed below:
|
||||
|
||||
==== String Functions
|
||||
==== String functions
|
||||
|
||||
rb_str_new(const char *ptr, long len) ::
|
||||
|
||||
@ -279,7 +279,7 @@ rb_str_modify(VALUE str) ::
|
||||
you MUST call this function before modifying the contents using
|
||||
RSTRING_PTR and/or rb_str_set_len.
|
||||
|
||||
==== Array Functions
|
||||
==== Array functions
|
||||
|
||||
rb_ary_new() ::
|
||||
|
||||
@ -338,13 +338,13 @@ rb_ary_cat(VALUE ary, const VALUE *ptr, long len) ::
|
||||
|
||||
== Extending Ruby with C
|
||||
|
||||
=== Adding New Features to Ruby
|
||||
=== Adding new features to Ruby
|
||||
|
||||
You can add new features (classes, methods, etc.) to the Ruby
|
||||
interpreter. Ruby provides APIs for defining the following things:
|
||||
|
||||
- Classes, Modules
|
||||
- Methods, Singleton Methods
|
||||
- Methods, singleton methods
|
||||
- Constants
|
||||
|
||||
==== Class and Module Definition
|
||||
@ -362,7 +362,7 @@ To define nested classes or modules, use the functions below:
|
||||
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
|
||||
VALUE rb_define_module_under(VALUE outer, const char *name)
|
||||
|
||||
==== Method and Singleton Method Definition
|
||||
==== Method and singleton method definition
|
||||
|
||||
To define methods or singleton methods, use these functions:
|
||||
|
||||
@ -467,7 +467,7 @@ available), you can use:
|
||||
|
||||
VALUE rb_current_receiver(void)
|
||||
|
||||
==== Constant Definition
|
||||
==== Constant definition
|
||||
|
||||
We have 2 functions to define constants:
|
||||
|
||||
@ -477,11 +477,11 @@ We have 2 functions to define constants:
|
||||
The former is to define a constant under specified class/module. The
|
||||
latter is to define a global constant.
|
||||
|
||||
=== Use Ruby Features from C
|
||||
=== Use Ruby features from C
|
||||
|
||||
There are several ways to invoke Ruby's features from C code.
|
||||
|
||||
==== Evaluate Ruby Programs in a String
|
||||
==== Evaluate Ruby programs in a string
|
||||
|
||||
The easiest way to use Ruby's functionality from a C program is to
|
||||
evaluate the string as Ruby program. This function will do the job:
|
||||
@ -550,7 +550,7 @@ and to convert Ruby Symbol object to ID, use
|
||||
|
||||
ID SYM2ID(VALUE symbol)
|
||||
|
||||
==== Invoke Ruby Method from C
|
||||
==== Invoke Ruby method from C
|
||||
|
||||
To invoke methods directly, you can use the function below
|
||||
|
||||
@ -559,7 +559,7 @@ To invoke methods directly, you can use the function below
|
||||
This function invokes a method on the recv, with the method name
|
||||
specified by the symbol mid.
|
||||
|
||||
==== Accessing the Variables and Constants
|
||||
==== Accessing the variables and constants
|
||||
|
||||
You can access class variables and instance variables using access
|
||||
functions. Also, global variables can be shared between both
|
||||
@ -578,9 +578,9 @@ To access the constants of the class/module:
|
||||
|
||||
See also Constant Definition above.
|
||||
|
||||
== Information Sharing Between Ruby and C
|
||||
== Information sharing between Ruby and C
|
||||
|
||||
=== Ruby Constants That Can Be Accessed From C
|
||||
=== Ruby constants that can be accessed from C
|
||||
|
||||
As stated in section 1.3,
|
||||
the following Ruby constants can be referred from C.
|
||||
@ -594,7 +594,7 @@ Qnil ::
|
||||
|
||||
Ruby nil in C scope.
|
||||
|
||||
=== Global Variables Shared Between C and Ruby
|
||||
=== Global variables shared between C and Ruby
|
||||
|
||||
Information can be shared between the two environments using shared global
|
||||
variables. To define them, you can use functions listed below:
|
||||
@ -788,7 +788,7 @@ OK, here's the example of making an extension library. This is the
|
||||
extension to access DBMs. The full source is included in the ext/
|
||||
directory in the Ruby's source tree.
|
||||
|
||||
=== Make the Directory
|
||||
=== Make the directory
|
||||
|
||||
% mkdir ext/dbm
|
||||
|
||||
@ -999,7 +999,7 @@ If a compilation condition is not fulfilled, you should not call
|
||||
``create_makefile''. The Makefile will not be generated, compilation will
|
||||
not be done.
|
||||
|
||||
=== Prepare Depend (Optional)
|
||||
=== Prepare depend (Optional)
|
||||
|
||||
If the file named depend exists, Makefile will include that file to
|
||||
check dependencies. You can make this file by invoking
|
||||
@ -1038,15 +1038,15 @@ You may need to rb_debug the extension. Extensions can be linked
|
||||
statically by adding the directory name in the ext/Setup file so that
|
||||
you can inspect the extension with the debugger.
|
||||
|
||||
=== Done! Now You Have the Extension Library
|
||||
=== Done! Now you have the extension library
|
||||
|
||||
You can do anything you want with your library. The author of Ruby
|
||||
will not claim any restrictions on your code depending on the Ruby API.
|
||||
Feel free to use, modify, distribute or sell your program.
|
||||
|
||||
== Appendix A. Ruby Header and Source Files Overview
|
||||
== Appendix A. Ruby header and source files overview
|
||||
|
||||
=== Ruby Header Files
|
||||
=== Ruby header files
|
||||
|
||||
Everything under <tt>$repo_root/include/ruby</tt> is installed with
|
||||
<tt>make install</tt>.
|
||||
@ -1063,7 +1063,7 @@ Header files under <tt>$repo_root/internal/</tt> or directly under the
|
||||
root <tt>$repo_root/*.h</tt> are not make-installed.
|
||||
They are internal headers with only internal APIs.
|
||||
|
||||
=== Ruby Language Core
|
||||
=== Ruby language core
|
||||
|
||||
class.c :: classes and modules
|
||||
error.c :: exception classes and exception mechanism
|
||||
@ -1072,14 +1072,14 @@ load.c :: library loading
|
||||
object.c :: objects
|
||||
variable.c :: variables and constants
|
||||
|
||||
=== Ruby Syntax Parser
|
||||
=== Ruby syntax parser
|
||||
|
||||
parse.y :: grammar definition
|
||||
parse.c :: automatically generated from parse.y
|
||||
defs/keywords :: reserved keywords
|
||||
lex.c :: automatically generated from keywords
|
||||
|
||||
=== Ruby Evaluator (a.k.a. YARV)
|
||||
=== Ruby evaluator (a.k.a. YARV)
|
||||
|
||||
compile.c
|
||||
eval.c
|
||||
@ -1105,7 +1105,7 @@ lex.c :: automatically generated from keywords
|
||||
-> opt*.inc : automatically generated
|
||||
-> vm.inc : automatically generated
|
||||
|
||||
=== Regular Expression Engine (Onigumo)
|
||||
=== Regular expression engine (Onigumo)
|
||||
|
||||
regcomp.c
|
||||
regenc.c
|
||||
@ -1114,7 +1114,7 @@ lex.c :: automatically generated from keywords
|
||||
regparse.c
|
||||
regsyntax.c
|
||||
|
||||
=== Utility Functions
|
||||
=== Utility functions
|
||||
|
||||
debug.c :: debug symbols for C debugger
|
||||
dln.c :: dynamic loading
|
||||
@ -1122,7 +1122,7 @@ st.c :: general purpose hash table
|
||||
strftime.c :: formatting times
|
||||
util.c :: misc utilities
|
||||
|
||||
=== Ruby Interpreter Implementation
|
||||
=== Ruby interpreter implementation
|
||||
|
||||
dmyext.c
|
||||
dmydln.c
|
||||
@ -1136,7 +1136,7 @@ util.c :: misc utilities
|
||||
gem_prelude.rb
|
||||
prelude.rb
|
||||
|
||||
=== Class Library
|
||||
=== Class library
|
||||
|
||||
array.c :: Array
|
||||
bignum.c :: Bignum
|
||||
@ -1175,13 +1175,13 @@ transcode.c :: Encoding::Converter
|
||||
enc/*.c :: encoding classes
|
||||
enc/trans/* :: codepoint mapping tables
|
||||
|
||||
=== goruby Interpreter Implementation
|
||||
=== goruby interpreter implementation
|
||||
|
||||
goruby.c
|
||||
golf_prelude.rb : goruby specific libraries.
|
||||
-> golf_prelude.c : automatically generated
|
||||
|
||||
== Appendix B. Ruby Extension API Reference
|
||||
== Appendix B. Ruby extension API reference
|
||||
|
||||
=== Types
|
||||
|
||||
@ -1191,7 +1191,7 @@ VALUE ::
|
||||
such as struct RString, etc. To refer the values in structures, use
|
||||
casting macros like RSTRING(obj).
|
||||
|
||||
=== Variables and Constants
|
||||
=== Variables and constants
|
||||
|
||||
Qnil ::
|
||||
|
||||
@ -1205,7 +1205,7 @@ Qfalse ::
|
||||
|
||||
false object
|
||||
|
||||
=== C Pointer Wrapping
|
||||
=== C pointer wrapping
|
||||
|
||||
Data_Wrap_Struct(VALUE klass, void (*mark)(), void (*free)(), void *sval) ::
|
||||
|
||||
@ -1339,7 +1339,7 @@ rb_str_new2(s) ::
|
||||
|
||||
char * -> String
|
||||
|
||||
=== Defining Classes and Modules
|
||||
=== Defining classes and modules
|
||||
|
||||
VALUE rb_define_class(const char *name, VALUE super) ::
|
||||
|
||||
@ -1366,7 +1366,7 @@ void rb_extend_object(VALUE object, VALUE module) ::
|
||||
|
||||
Extend the object with the module's attributes.
|
||||
|
||||
=== Defining Global Variables
|
||||
=== Defining global variables
|
||||
|
||||
void rb_define_variable(const char *name, VALUE *var) ::
|
||||
|
||||
@ -1410,7 +1410,7 @@ void rb_gc_register_mark_object(VALUE object) ::
|
||||
|
||||
Tells GC to protect the +object+, which may not be referenced anywhere.
|
||||
|
||||
=== Constant Definition
|
||||
=== Constant definition
|
||||
|
||||
void rb_define_const(VALUE klass, const char *name, VALUE val) ::
|
||||
|
||||
@ -1422,7 +1422,7 @@ void rb_define_global_const(const char *name, VALUE val) ::
|
||||
|
||||
rb_define_const(rb_cObject, name, val)
|
||||
|
||||
=== Method Definition
|
||||
=== Method definition
|
||||
|
||||
rb_define_method(VALUE klass, const char *name, VALUE (*func)(ANYARGS), int argc) ::
|
||||
|
||||
@ -1598,7 +1598,7 @@ int rb_respond_to(VALUE obj, ID id) ::
|
||||
|
||||
Returns true if the object responds to the message specified by id.
|
||||
|
||||
=== Instance Variables
|
||||
=== Instance variables
|
||||
|
||||
VALUE rb_iv_get(VALUE obj, const char *name) ::
|
||||
|
||||
@ -1609,7 +1609,7 @@ VALUE rb_iv_set(VALUE obj, const char *name, VALUE val) ::
|
||||
|
||||
Sets the value of the instance variable.
|
||||
|
||||
=== Control Structure
|
||||
=== Control structure
|
||||
|
||||
VALUE rb_block_call(VALUE recv, ID mid, int argc, VALUE * argv, VALUE (*func) (ANYARGS), VALUE data2) ::
|
||||
|
||||
@ -1705,7 +1705,7 @@ void rb_iter_break_value(VALUE value) ::
|
||||
return the given argument value. This function never return to the
|
||||
caller.
|
||||
|
||||
=== Exceptions and Errors
|
||||
=== Exceptions and errors
|
||||
|
||||
void rb_warn(const char *fmt, ...) ::
|
||||
|
||||
@ -1778,7 +1778,7 @@ int rb_wait_for_single_fd(int fd, int events, struct timeval *timeout) ::
|
||||
|
||||
Use a NULL +timeout+ to wait indefinitely.
|
||||
|
||||
=== I/O Multiplexing
|
||||
=== I/O multiplexing
|
||||
|
||||
Ruby supports I/O multiplexing based on the select(2) system call.
|
||||
The Linux select_tut(2) manpage
|
||||
@ -1830,7 +1830,7 @@ int rb_thread_fd_select(int nfds, rb_fdset_t *readfds, rb_fdset_t *writefds, rb_
|
||||
rb_io_wait_writable, or rb_wait_for_single_fd functions since
|
||||
they can be optimized for specific platforms (currently, only Linux).
|
||||
|
||||
=== Initialize and Start the Interpreter
|
||||
=== Initialize and start the interpreter
|
||||
|
||||
The embedding API functions are below (not needed for extension libraries):
|
||||
|
||||
@ -1855,7 +1855,7 @@ void ruby_script(char *name) ::
|
||||
|
||||
Specifies the name of the script ($0).
|
||||
|
||||
=== Hooks for the Interpreter Events
|
||||
=== Hooks for the interpreter events
|
||||
|
||||
void rb_add_event_hook(rb_event_hook_func_t func, rb_event_flag_t events, VALUE data) ::
|
||||
|
||||
@ -1897,7 +1897,7 @@ void rb_gc_adjust_memory_usage(ssize_t diff) ::
|
||||
is decreased; a memory block is freed or a block is reallocated as
|
||||
smaller size. This function may trigger the GC.
|
||||
|
||||
=== Macros for Compatibility
|
||||
=== Macros for compatibility
|
||||
|
||||
Some macros to check API compatibilities are available by default.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user