Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
206f89e2
Commit
206f89e2
authored
Aug 04, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add MRB_API modifiers to mruby API functions
parent
0878900f
Changes
40
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
40 changed files
with
543 additions
and
533 deletions
+543
-533
include/mrbconf.h
include/mrbconf.h
+11
-0
include/mruby.h
include/mruby.h
+125
-125
include/mruby/array.h
include/mruby/array.h
+19
-19
include/mruby/boxing_word.h
include/mruby/boxing_word.h
+3
-3
include/mruby/class.h
include/mruby/class.h
+12
-12
include/mruby/compile.h
include/mruby/compile.h
+15
-15
include/mruby/data.h
include/mruby/data.h
+4
-4
include/mruby/debug.h
include/mruby/debug.h
+5
-5
include/mruby/dump.h
include/mruby/dump.h
+3
-3
include/mruby/error.h
include/mruby/error.h
+9
-9
include/mruby/gc.h
include/mruby/gc.h
+1
-1
include/mruby/hash.h
include/mruby/hash.h
+13
-13
include/mruby/irep.h
include/mruby/irep.h
+6
-6
include/mruby/numeric.h
include/mruby/numeric.h
+3
-4
include/mruby/proc.h
include/mruby/proc.h
+5
-5
include/mruby/range.h
include/mruby/range.h
+2
-2
include/mruby/string.h
include/mruby/string.h
+29
-29
include/mruby/value.h
include/mruby/value.h
+1
-1
include/mruby/variable.h
include/mruby/variable.h
+28
-28
mrbgems/mruby-proc-ext/src/proc.c
mrbgems/mruby-proc-ext/src/proc.c
+2
-2
src/array.c
src/array.c
+20
-20
src/backtrace.c
src/backtrace.c
+6
-6
src/class.c
src/class.c
+42
-42
src/debug.c
src/debug.c
+5
-5
src/error.c
src/error.c
+13
-13
src/etc.c
src/etc.c
+11
-11
src/gc.c
src/gc.c
+15
-15
src/hash.c
src/hash.c
+11
-11
src/kernel.c
src/kernel.c
+6
-6
src/load.c
src/load.c
+6
-6
src/numeric.c
src/numeric.c
+4
-4
src/object.c
src/object.c
+14
-14
src/print.c
src/print.c
+4
-4
src/proc.c
src/proc.c
+1
-1
src/range.c
src/range.c
+2
-2
src/state.c
src/state.c
+8
-8
src/string.c
src/string.c
+29
-29
src/symbol.c
src/symbol.c
+11
-11
src/variable.c
src/variable.c
+28
-28
src/vm.c
src/vm.c
+11
-11
No files found.
include/mrbconf.h
View file @
206f89e2
...
...
@@ -93,4 +93,15 @@
# define TRUE 1
#endif
#if defined(MRB_BUILD_AS_DLL)
#if defined(MRB_CORE) || defined(MRB_LIB)
#define MRB_API __declspec(dllexport)
#else
#define MRB_API __declspec(dllimport)
#endif
#else
#define MRB_API extern
#endif
#endif
/* MRUBYCONF_H */
include/mruby.h
View file @
206f89e2
This diff is collapsed.
Click to expand it.
include/mruby/array.h
View file @
206f89e2
...
...
@@ -35,26 +35,26 @@ struct RArray {
#define RARRAY_PTR(a) (RARRAY(a)->ptr)
#define MRB_ARY_SHARED 256
void
mrb_ary_modify
(
mrb_state
*
,
struct
RArray
*
);
void
mrb_ary_decref
(
mrb_state
*
,
mrb_shared_array
*
);
mrb_value
mrb_ary_new_capa
(
mrb_state
*
,
mrb_int
);
mrb_value
mrb_ary_new
(
mrb_state
*
mrb
);
mrb_value
mrb_ary_new_from_values
(
mrb_state
*
mrb
,
mrb_int
size
,
const
mrb_value
*
vals
);
mrb_value
mrb_assoc_new
(
mrb_state
*
mrb
,
mrb_value
car
,
mrb_value
cdr
);
void
mrb_ary_concat
(
mrb_state
*
,
mrb_value
,
mrb_value
);
mrb_value
mrb_ary_splat
(
mrb_state
*
,
mrb_value
);
void
mrb_ary_push
(
mrb_state
*
,
mrb_value
,
mrb_value
);
mrb_value
mrb_ary_pop
(
mrb_state
*
mrb
,
mrb_value
ary
);
mrb_value
mrb_ary_ref
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_int
n
);
void
mrb_ary_set
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_int
n
,
mrb_value
val
);
void
mrb_ary_replace
(
mrb_state
*
mrb
,
mrb_value
a
,
mrb_value
b
);
mrb_value
mrb_check_array_type
(
mrb_state
*
mrb
,
mrb_value
self
);
mrb_value
mrb_ary_unshift
(
mrb_state
*
mrb
,
mrb_value
self
,
mrb_value
item
);
mrb_value
mrb_ary_entry
(
mrb_value
ary
,
mrb_int
offset
);
mrb_value
mrb_ary_shift
(
mrb_state
*
mrb
,
mrb_value
self
);
mrb_value
mrb_ary_clear
(
mrb_state
*
mrb
,
mrb_value
self
);
mrb_value
mrb_ary_join
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_value
sep
);
mrb_value
mrb_ary_resize
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_int
len
);
MRB_API
void
mrb_ary_modify
(
mrb_state
*
,
struct
RArray
*
);
MRB_API
mrb_value
mrb_ary_new_capa
(
mrb_state
*
,
mrb_int
);
MRB_API
mrb_value
mrb_ary_new
(
mrb_state
*
mrb
);
MRB_API
mrb_value
mrb_ary_new_from_values
(
mrb_state
*
mrb
,
mrb_int
size
,
const
mrb_value
*
vals
);
MRB_API
mrb_value
mrb_assoc_new
(
mrb_state
*
mrb
,
mrb_value
car
,
mrb_value
cdr
);
MRB_API
void
mrb_ary_concat
(
mrb_state
*
,
mrb_value
,
mrb_value
);
MRB_API
mrb_value
mrb_ary_splat
(
mrb_state
*
,
mrb_value
);
MRB_API
void
mrb_ary_push
(
mrb_state
*
,
mrb_value
,
mrb_value
);
MRB_API
mrb_value
mrb_ary_pop
(
mrb_state
*
mrb
,
mrb_value
ary
);
MRB_API
mrb_value
mrb_ary_ref
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_int
n
);
MRB_API
void
mrb_ary_set
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_int
n
,
mrb_value
val
);
MRB_API
void
mrb_ary_replace
(
mrb_state
*
mrb
,
mrb_value
a
,
mrb_value
b
);
MRB_API
mrb_value
mrb_check_array_type
(
mrb_state
*
mrb
,
mrb_value
self
);
MRB_API
mrb_value
mrb_ary_unshift
(
mrb_state
*
mrb
,
mrb_value
self
,
mrb_value
item
);
MRB_API
mrb_value
mrb_ary_entry
(
mrb_value
ary
,
mrb_int
offset
);
MRB_API
mrb_value
mrb_ary_shift
(
mrb_state
*
mrb
,
mrb_value
self
);
MRB_API
mrb_value
mrb_ary_clear
(
mrb_state
*
mrb
,
mrb_value
self
);
MRB_API
mrb_value
mrb_ary_join
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_value
sep
);
MRB_API
mrb_value
mrb_ary_resize
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_int
len
);
static
inline
mrb_int
mrb_ary_len
(
mrb_state
*
mrb
,
mrb_value
ary
)
...
...
include/mruby/boxing_word.h
View file @
206f89e2
...
...
@@ -53,9 +53,9 @@ typedef union mrb_value {
unsigned
long
w
;
}
mrb_value
;
mrb_value
mrb_word_boxing_cptr_value
(
struct
mrb_state
*
,
void
*
);
mrb_value
mrb_word_boxing_float_value
(
struct
mrb_state
*
,
mrb_float
);
mrb_value
mrb_word_boxing_float_pool
(
struct
mrb_state
*
,
mrb_float
);
MRB_API
mrb_value
mrb_word_boxing_cptr_value
(
struct
mrb_state
*
,
void
*
);
MRB_API
mrb_value
mrb_word_boxing_float_value
(
struct
mrb_state
*
,
mrb_float
);
MRB_API
mrb_value
mrb_word_boxing_float_pool
(
struct
mrb_state
*
,
mrb_float
);
#define mrb_float_pool(mrb,f) mrb_word_boxing_float_pool(mrb,f)
...
...
include/mruby/class.h
View file @
206f89e2
...
...
@@ -51,20 +51,20 @@ mrb_class(mrb_state *mrb, mrb_value v)
#define MRB_SET_INSTANCE_TT(c, tt) c->flags = ((c->flags & ~0xff) | (char)tt)
#define MRB_INSTANCE_TT(c) (enum mrb_vtype)(c->flags & 0xff)
struct
RClass
*
mrb_define_class_id
(
mrb_state
*
,
mrb_sym
,
struct
RClass
*
);
struct
RClass
*
mrb_define_module_id
(
mrb_state
*
,
mrb_sym
);
struct
RClass
*
mrb_vm_define_class
(
mrb_state
*
,
mrb_value
,
mrb_value
,
mrb_sym
);
struct
RClass
*
mrb_vm_define_module
(
mrb_state
*
,
mrb_value
,
mrb_sym
);
void
mrb_define_method_vm
(
mrb_state
*
,
struct
RClass
*
,
mrb_sym
,
mrb_value
);
void
mrb_define_method_raw
(
mrb_state
*
,
struct
RClass
*
,
mrb_sym
,
struct
RProc
*
);
void
mrb_define_method_id
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
mid
,
mrb_func_t
func
,
mrb_aspec
aspec
);
void
mrb_alias_method
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
a
,
mrb_sym
b
);
MRB_API
struct
RClass
*
mrb_define_class_id
(
mrb_state
*
,
mrb_sym
,
struct
RClass
*
);
MRB_API
struct
RClass
*
mrb_define_module_id
(
mrb_state
*
,
mrb_sym
);
MRB_API
struct
RClass
*
mrb_vm_define_class
(
mrb_state
*
,
mrb_value
,
mrb_value
,
mrb_sym
);
MRB_API
struct
RClass
*
mrb_vm_define_module
(
mrb_state
*
,
mrb_value
,
mrb_sym
);
MRB_API
void
mrb_define_method_vm
(
mrb_state
*
,
struct
RClass
*
,
mrb_sym
,
mrb_value
);
MRB_API
void
mrb_define_method_raw
(
mrb_state
*
,
struct
RClass
*
,
mrb_sym
,
struct
RProc
*
);
MRB_API
void
mrb_define_method_id
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
mid
,
mrb_func_t
func
,
mrb_aspec
aspec
);
MRB_API
void
mrb_alias_method
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
a
,
mrb_sym
b
);
struct
RClass
*
mrb_class_outer_module
(
mrb_state
*
,
struct
RClass
*
);
struct
RProc
*
mrb_method_search_vm
(
mrb_state
*
,
struct
RClass
**
,
mrb_sym
);
struct
RProc
*
mrb_method_search
(
mrb_state
*
,
struct
RClass
*
,
mrb_sym
);
MRB_API
struct
RClass
*
mrb_class_outer_module
(
mrb_state
*
,
struct
RClass
*
);
MRB_API
struct
RProc
*
mrb_method_search_vm
(
mrb_state
*
,
struct
RClass
**
,
mrb_sym
);
MRB_API
struct
RProc
*
mrb_method_search
(
mrb_state
*
,
struct
RClass
*
,
mrb_sym
);
struct
RClass
*
mrb_class_real
(
struct
RClass
*
cl
);
MRB_API
struct
RClass
*
mrb_class_real
(
struct
RClass
*
cl
);
void
mrb_gc_mark_mt
(
mrb_state
*
,
struct
RClass
*
);
size_t
mrb_gc_mark_mt_size
(
mrb_state
*
,
struct
RClass
*
);
...
...
include/mruby/compile.h
View file @
206f89e2
...
...
@@ -154,32 +154,32 @@ struct mrb_parser_state {
struct
mrb_jmpbuf
*
jmp
;
};
struct
mrb_parser_state
*
mrb_parser_new
(
mrb_state
*
);
void
mrb_parser_free
(
struct
mrb_parser_state
*
);
void
mrb_parser_parse
(
struct
mrb_parser_state
*
,
mrbc_context
*
);
MRB_API
struct
mrb_parser_state
*
mrb_parser_new
(
mrb_state
*
);
MRB_API
void
mrb_parser_free
(
struct
mrb_parser_state
*
);
MRB_API
void
mrb_parser_parse
(
struct
mrb_parser_state
*
,
mrbc_context
*
);
void
mrb_parser_set_filename
(
struct
mrb_parser_state
*
,
char
const
*
);
char
const
*
mrb_parser_get_filename
(
struct
mrb_parser_state
*
,
uint16_t
idx
);
MRB_API
void
mrb_parser_set_filename
(
struct
mrb_parser_state
*
,
char
const
*
);
MRB_API
char
const
*
mrb_parser_get_filename
(
struct
mrb_parser_state
*
,
uint16_t
idx
);
/* utility functions */
#ifdef ENABLE_STDIO
struct
mrb_parser_state
*
mrb_parse_file
(
mrb_state
*
,
FILE
*
,
mrbc_context
*
);
MRB_API
struct
mrb_parser_state
*
mrb_parse_file
(
mrb_state
*
,
FILE
*
,
mrbc_context
*
);
#endif
struct
mrb_parser_state
*
mrb_parse_string
(
mrb_state
*
,
const
char
*
,
mrbc_context
*
);
struct
mrb_parser_state
*
mrb_parse_nstring
(
mrb_state
*
,
const
char
*
,
int
,
mrbc_context
*
);
struct
RProc
*
mrb_generate_code
(
mrb_state
*
,
struct
mrb_parser_state
*
);
MRB_API
struct
mrb_parser_state
*
mrb_parse_string
(
mrb_state
*
,
const
char
*
,
mrbc_context
*
);
MRB_API
struct
mrb_parser_state
*
mrb_parse_nstring
(
mrb_state
*
,
const
char
*
,
int
,
mrbc_context
*
);
MRB_API
struct
RProc
*
mrb_generate_code
(
mrb_state
*
,
struct
mrb_parser_state
*
);
/* program load functions */
#ifdef ENABLE_STDIO
mrb_value
mrb_load_file
(
mrb_state
*
,
FILE
*
);
MRB_API
mrb_value
mrb_load_file
(
mrb_state
*
,
FILE
*
);
#endif
mrb_value
mrb_load_string
(
mrb_state
*
mrb
,
const
char
*
s
);
mrb_value
mrb_load_nstring
(
mrb_state
*
mrb
,
const
char
*
s
,
int
len
);
MRB_API
mrb_value
mrb_load_string
(
mrb_state
*
mrb
,
const
char
*
s
);
MRB_API
mrb_value
mrb_load_nstring
(
mrb_state
*
mrb
,
const
char
*
s
,
int
len
);
#ifdef ENABLE_STDIO
mrb_value
mrb_load_file_cxt
(
mrb_state
*
,
FILE
*
,
mrbc_context
*
cxt
);
MRB_API
mrb_value
mrb_load_file_cxt
(
mrb_state
*
,
FILE
*
,
mrbc_context
*
cxt
);
#endif
mrb_value
mrb_load_string_cxt
(
mrb_state
*
mrb
,
const
char
*
s
,
mrbc_context
*
cxt
);
mrb_value
mrb_load_nstring_cxt
(
mrb_state
*
mrb
,
const
char
*
s
,
int
len
,
mrbc_context
*
cxt
);
MRB_API
mrb_value
mrb_load_string_cxt
(
mrb_state
*
mrb
,
const
char
*
s
,
mrbc_context
*
cxt
);
MRB_API
mrb_value
mrb_load_nstring_cxt
(
mrb_state
*
mrb
,
const
char
*
s
,
int
len
,
mrbc_context
*
cxt
);
#if defined(__cplusplus)
}
/* extern "C" { */
...
...
include/mruby/data.h
View file @
206f89e2
...
...
@@ -23,7 +23,7 @@ struct RData {
void
*
data
;
};
struct
RData
*
mrb_data_object_alloc
(
mrb_state
*
mrb
,
struct
RClass
*
klass
,
void
*
datap
,
const
mrb_data_type
*
type
);
MRB_API
struct
RData
*
mrb_data_object_alloc
(
mrb_state
*
mrb
,
struct
RClass
*
klass
,
void
*
datap
,
const
mrb_data_type
*
type
);
#define Data_Wrap_Struct(mrb,klass,type,ptr)\
mrb_data_object_alloc(mrb,klass,ptr,type)
...
...
@@ -37,10 +37,10 @@ struct RData *mrb_data_object_alloc(mrb_state *mrb, struct RClass* klass, void *
#define RDATA(obj) ((struct RData *)(mrb_ptr(obj)))
#define DATA_PTR(d) (RDATA(d)->data)
#define DATA_TYPE(d) (RDATA(d)->type)
void
mrb_data_check_type
(
mrb_state
*
mrb
,
mrb_value
,
const
mrb_data_type
*
);
void
*
mrb_data_get_ptr
(
mrb_state
*
mrb
,
mrb_value
,
const
mrb_data_type
*
);
MRB_API
void
mrb_data_check_type
(
mrb_state
*
mrb
,
mrb_value
,
const
mrb_data_type
*
);
MRB_API
void
*
mrb_data_get_ptr
(
mrb_state
*
mrb
,
mrb_value
,
const
mrb_data_type
*
);
#define DATA_GET_PTR(mrb,obj,dtype,type) (type*)mrb_data_get_ptr(mrb,obj,dtype)
void
*
mrb_data_check_get_ptr
(
mrb_state
*
mrb
,
mrb_value
,
const
mrb_data_type
*
);
MRB_API
void
*
mrb_data_check_get_ptr
(
mrb_state
*
mrb
,
mrb_value
,
const
mrb_data_type
*
);
#define DATA_CHECK_GET_PTR(mrb,obj,dtype,type) (type*)mrb_data_check_get_ptr(mrb,obj,dtype)
/* obsolete functions and macros */
...
...
include/mruby/debug.h
View file @
206f89e2
...
...
@@ -44,19 +44,19 @@ typedef struct mrb_irep_debug_info {
* get line from irep's debug info and program counter
* @return returns NULL if not found
*/
const
char
*
mrb_debug_get_filename
(
mrb_irep
*
irep
,
uint32_t
pc
);
MRB_API
const
char
*
mrb_debug_get_filename
(
mrb_irep
*
irep
,
uint32_t
pc
);
/*
* get line from irep's debug info and program counter
* @return returns -1 if not found
*/
int32_t
mrb_debug_get_line
(
mrb_irep
*
irep
,
uint32_t
pc
);
MRB_API
int32_t
mrb_debug_get_line
(
mrb_irep
*
irep
,
uint32_t
pc
);
mrb_irep_debug_info_file
*
mrb_debug_info_append_file
(
MRB_API
mrb_irep_debug_info_file
*
mrb_debug_info_append_file
(
mrb_state
*
mrb
,
mrb_irep
*
irep
,
uint32_t
start_pos
,
uint32_t
end_pos
);
mrb_irep_debug_info
*
mrb_debug_info_alloc
(
mrb_state
*
mrb
,
mrb_irep
*
irep
);
void
mrb_debug_info_free
(
mrb_state
*
mrb
,
mrb_irep_debug_info
*
d
);
MRB_API
mrb_irep_debug_info
*
mrb_debug_info_alloc
(
mrb_state
*
mrb
,
mrb_irep
*
irep
);
MRB_API
void
mrb_debug_info_free
(
mrb_state
*
mrb
,
mrb_irep_debug_info
*
d
);
#if defined(__cplusplus)
}
/* extern "C" { */
...
...
include/mruby/dump.h
View file @
206f89e2
...
...
@@ -19,10 +19,10 @@ int mrb_dump_irep(mrb_state *mrb, mrb_irep *irep, int debug_info, uint8_t **bin,
int
mrb_dump_irep_binary
(
mrb_state
*
,
mrb_irep
*
,
int
,
FILE
*
);
int
mrb_dump_irep_cfunc
(
mrb_state
*
mrb
,
mrb_irep
*
,
int
,
FILE
*
f
,
const
char
*
initname
);
mrb_irep
*
mrb_read_irep_file
(
mrb_state
*
,
FILE
*
);
mrb_value
mrb_load_irep_file
(
mrb_state
*
,
FILE
*
);
mrb_value
mrb_load_irep_file_cxt
(
mrb_state
*
,
FILE
*
,
mrbc_context
*
);
MRB_API
mrb_value
mrb_load_irep_file
(
mrb_state
*
,
FILE
*
);
MRB_API
mrb_value
mrb_load_irep_file_cxt
(
mrb_state
*
,
FILE
*
,
mrbc_context
*
);
#endif
mrb_irep
*
mrb_read_irep
(
mrb_state
*
,
const
uint8_t
*
);
MRB_API
mrb_irep
*
mrb_read_irep
(
mrb_state
*
,
const
uint8_t
*
);
/* dump/load error code
*
...
...
include/mruby/error.h
View file @
206f89e2
...
...
@@ -18,18 +18,18 @@ struct RException {
#define mrb_exc_ptr(v) ((struct RException*)mrb_ptr(v))
void
mrb_sys_fail
(
mrb_state
*
mrb
,
const
char
*
mesg
);
mrb_value
mrb_exc_new_str
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_value
str
);
MRB_API
void
mrb_sys_fail
(
mrb_state
*
mrb
,
const
char
*
mesg
);
MRB_API
mrb_value
mrb_exc_new_str
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_value
str
);
#define mrb_exc_new_str_lit(mrb, c, lit) mrb_exc_new_str(mrb, c, mrb_str_new_lit(mrb, lit))
mrb_value
mrb_make_exception
(
mrb_state
*
mrb
,
int
argc
,
const
mrb_value
*
argv
);
void
mrb_exc_print
(
mrb_state
*
mrb
,
struct
RObject
*
exc
);
void
mrb_print_backtrace
(
mrb_state
*
mrb
);
mrb_value
mrb_exc_backtrace
(
mrb_state
*
mrb
,
mrb_value
exc
);
mrb_value
mrb_get_backtrace
(
mrb_state
*
mrb
);
mrb_noreturn
void
mrb_no_method_error
(
mrb_state
*
mrb
,
mrb_sym
id
,
mrb_int
argc
,
const
mrb_value
*
argv
,
const
char
*
fmt
,
...);
MRB_API
mrb_value
mrb_make_exception
(
mrb_state
*
mrb
,
int
argc
,
const
mrb_value
*
argv
);
MRB_API
void
mrb_exc_print
(
mrb_state
*
mrb
,
struct
RObject
*
exc
);
MRB_API
void
mrb_print_backtrace
(
mrb_state
*
mrb
);
MRB_API
mrb_value
mrb_exc_backtrace
(
mrb_state
*
mrb
,
mrb_value
exc
);
MRB_API
mrb_value
mrb_get_backtrace
(
mrb_state
*
mrb
);
MRB_API
mrb_noreturn
void
mrb_no_method_error
(
mrb_state
*
mrb
,
mrb_sym
id
,
mrb_int
argc
,
const
mrb_value
*
argv
,
const
char
*
fmt
,
...);
/* declaration for fail method */
mrb_value
mrb_f_raise
(
mrb_state
*
,
mrb_value
);
MRB_API
mrb_value
mrb_f_raise
(
mrb_state
*
,
mrb_value
);
#if defined(__cplusplus)
}
/* extern "C" { */
...
...
include/mruby/gc.h
View file @
206f89e2
...
...
@@ -13,7 +13,7 @@ extern "C" {
typedef
void
(
mrb_each_object_callback
)(
mrb_state
*
mrb
,
struct
RBasic
*
obj
,
void
*
data
);
void
mrb_objspace_each_objects
(
mrb_state
*
mrb
,
mrb_each_object_callback
*
callback
,
void
*
data
);
void
mrb_free_context
(
mrb_state
*
mrb
,
struct
mrb_context
*
c
);
MRB_API
void
mrb_free_context
(
mrb_state
*
mrb
,
struct
mrb_context
*
c
);
#if defined(__cplusplus)
}
/* extern "C" { */
...
...
include/mruby/hash.h
View file @
206f89e2
...
...
@@ -20,32 +20,32 @@ struct RHash {
#define mrb_hash_ptr(v) ((struct RHash*)(mrb_ptr(v)))
#define mrb_hash_value(p) mrb_obj_value((void*)(p))
mrb_value
mrb_hash_new_capa
(
mrb_state
*
,
int
);
MRB_API
mrb_value
mrb_hash_new_capa
(
mrb_state
*
,
int
);
mrb_value
mrb_hash_new
(
mrb_state
*
mrb
);
void
mrb_hash_set
(
mrb_state
*
mrb
,
mrb_value
hash
,
mrb_value
key
,
mrb_value
val
);
mrb_value
mrb_hash_get
(
mrb_state
*
mrb
,
mrb_value
hash
,
mrb_value
key
);
mrb_value
mrb_hash_fetch
(
mrb_state
*
mrb
,
mrb_value
hash
,
mrb_value
key
,
mrb_value
def
);
mrb_value
mrb_hash_delete_key
(
mrb_state
*
mrb
,
mrb_value
hash
,
mrb_value
key
);
mrb_value
mrb_hash_keys
(
mrb_state
*
mrb
,
mrb_value
hash
);
mrb_value
mrb_check_hash_type
(
mrb_state
*
mrb
,
mrb_value
hash
);
mrb_value
mrb_hash_empty_p
(
mrb_state
*
mrb
,
mrb_value
self
);
mrb_value
mrb_hash_clear
(
mrb_state
*
mrb
,
mrb_value
hash
);
MRB_API
void
mrb_hash_set
(
mrb_state
*
mrb
,
mrb_value
hash
,
mrb_value
key
,
mrb_value
val
);
MRB_API
mrb_value
mrb_hash_get
(
mrb_state
*
mrb
,
mrb_value
hash
,
mrb_value
key
);
MRB_API
mrb_value
mrb_hash_fetch
(
mrb_state
*
mrb
,
mrb_value
hash
,
mrb_value
key
,
mrb_value
def
);
MRB_API
mrb_value
mrb_hash_delete_key
(
mrb_state
*
mrb
,
mrb_value
hash
,
mrb_value
key
);
MRB_API
mrb_value
mrb_hash_keys
(
mrb_state
*
mrb
,
mrb_value
hash
);
MRB_API
mrb_value
mrb_check_hash_type
(
mrb_state
*
mrb
,
mrb_value
hash
);
MRB_API
mrb_value
mrb_hash_empty_p
(
mrb_state
*
mrb
,
mrb_value
self
);
MRB_API
mrb_value
mrb_hash_clear
(
mrb_state
*
mrb
,
mrb_value
hash
);
/* RHASH_TBL allocates st_table if not available. */
#define RHASH(obj) ((struct RHash*)(mrb_ptr(obj)))
#define RHASH_TBL(h) (RHASH(h)->ht)
#define RHASH_IFNONE(h) mrb_iv_get(mrb, (h), mrb_intern_lit(mrb, "ifnone"))
#define RHASH_PROCDEFAULT(h) RHASH_IFNONE(h)
struct
kh_ht
*
mrb_hash_tbl
(
mrb_state
*
mrb
,
mrb_value
hash
);
MRB_API
struct
kh_ht
*
mrb_hash_tbl
(
mrb_state
*
mrb
,
mrb_value
hash
);
#define MRB_HASH_PROC_DEFAULT 256
#define MRB_RHASH_PROCDEFAULT_P(h) (RHASH(h)->flags & MRB_HASH_PROC_DEFAULT)
/* GC functions */
void
mrb_gc_mark_hash
(
mrb_state
*
,
struct
RHash
*
);
size_t
mrb_gc_mark_hash_size
(
mrb_state
*
,
struct
RHash
*
);
void
mrb_gc_free_hash
(
mrb_state
*
,
struct
RHash
*
);
MRB_API
void
mrb_gc_mark_hash
(
mrb_state
*
,
struct
RHash
*
);
MRB_API
size_t
mrb_gc_mark_hash_size
(
mrb_state
*
,
struct
RHash
*
);
MRB_API
void
mrb_gc_free_hash
(
mrb_state
*
,
struct
RHash
*
);
#if defined(__cplusplus)
}
/* extern "C" { */
...
...
include/mruby/irep.h
View file @
206f89e2
...
...
@@ -46,12 +46,12 @@ typedef struct mrb_irep {
#define MRB_ISEQ_NO_FREE 1
mrb_irep
*
mrb_add_irep
(
mrb_state
*
mrb
);
mrb_value
mrb_load_irep
(
mrb_state
*
,
const
uint8_t
*
);
mrb_value
mrb_load_irep_cxt
(
mrb_state
*
,
const
uint8_t
*
,
mrbc_context
*
);
void
mrb_irep_free
(
mrb_state
*
,
struct
mrb_irep
*
);
void
mrb_irep_incref
(
mrb_state
*
,
struct
mrb_irep
*
);
void
mrb_irep_decref
(
mrb_state
*
,
struct
mrb_irep
*
);
MRB_API
mrb_irep
*
mrb_add_irep
(
mrb_state
*
mrb
);
MRB_API
mrb_value
mrb_load_irep
(
mrb_state
*
,
const
uint8_t
*
);
MRB_API
mrb_value
mrb_load_irep_cxt
(
mrb_state
*
,
const
uint8_t
*
,
mrbc_context
*
);
MRB_API
void
mrb_irep_free
(
mrb_state
*
,
struct
mrb_irep
*
);
MRB_API
void
mrb_irep_incref
(
mrb_state
*
,
struct
mrb_irep
*
);
MRB_API
void
mrb_irep_decref
(
mrb_state
*
,
struct
mrb_irep
*
);
#if defined(__cplusplus)
}
/* extern "C" { */
...
...
include/mruby/numeric.h
View file @
206f89e2
...
...
@@ -15,15 +15,14 @@ extern "C" {
#define NEGFIXABLE(f) ((f) >= MRB_INT_MIN)
#define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f))
mrb_value
mrb_flo_to_fixnum
(
mrb_state
*
mrb
,
mrb_value
val
);
mrb_value
mrb_fixnum_to_str
(
mrb_state
*
mrb
,
mrb_value
x
,
int
base
);
MRB_API
mrb_value
mrb_flo_to_fixnum
(
mrb_state
*
mrb
,
mrb_value
val
);
MRB_API
mrb_value
mrb_fixnum_to_str
(
mrb_state
*
mrb
,
mrb_value
x
,
int
base
);
MRB_API
mrb_float
mrb_to_flo
(
mrb_state
*
mrb
,
mrb_value
x
);
mrb_value
mrb_fixnum_plus
(
mrb_state
*
mrb
,
mrb_value
x
,
mrb_value
y
);
mrb_value
mrb_fixnum_minus
(
mrb_state
*
mrb
,
mrb_value
x
,
mrb_value
y
);
mrb_value
mrb_fixnum_mul
(
mrb_state
*
mrb
,
mrb_value
x
,
mrb_value
y
);
mrb_value
mrb_num_div
(
mrb_state
*
mrb
,
mrb_value
x
,
mrb_value
y
);
mrb_float
mrb_to_flo
(
mrb_state
*
mrb
,
mrb_value
x
);
#define MRB_UINT_MAKE2(n) uint ## n ## _t
#define MRB_UINT_MAKE(n) MRB_UINT_MAKE2(n)
...
...
include/mruby/proc.h
View file @
206f89e2
...
...
@@ -51,17 +51,17 @@ struct RProc {
#define mrb_proc_ptr(v) ((struct RProc*)(mrb_ptr(v)))
struct
RProc
*
mrb_proc_new
(
mrb_state
*
,
mrb_irep
*
);
struct
RProc
*
mrb_proc_new_cfunc
(
mrb_state
*
,
mrb_func_t
);
struct
RProc
*
mrb_closure_new
(
mrb_state
*
,
mrb_irep
*
);
struct
RProc
*
mrb_closure_new_cfunc
(
mrb_state
*
mrb
,
mrb_func_t
func
,
int
nlocals
);
void
mrb_proc_copy
(
struct
RProc
*
a
,
struct
RProc
*
b
);
MRB_API
struct
RProc
*
mrb_proc_new_cfunc
(
mrb_state
*
,
mrb_func_t
);
MRB_API
struct
RProc
*
mrb_closure_new_cfunc
(
mrb_state
*
mrb
,
mrb_func_t
func
,
int
nlocals
);
MRB_API
void
mrb_proc_copy
(
struct
RProc
*
a
,
struct
RProc
*
b
);
/* implementation of #send method */
mrb_value
mrb_f_send
(
mrb_state
*
mrb
,
mrb_value
self
);
/* following functions are defined in mruby-proc-ext so please include it when using */
struct
RProc
*
mrb_proc_new_cfunc_with_env
(
mrb_state
*
,
mrb_func_t
,
mrb_int
,
const
mrb_value
*
);
mrb_value
mrb_cfunc_env_get
(
mrb_state
*
,
mrb_int
);
MRB_API
struct
RProc
*
mrb_proc_new_cfunc_with_env
(
mrb_state
*
,
mrb_func_t
,
mrb_int
,
const
mrb_value
*
);
MRB_API
mrb_value
mrb_cfunc_env_get
(
mrb_state
*
,
mrb_int
);
#include "mruby/khash.h"
KHASH_DECLARE
(
mt
,
mrb_sym
,
struct
RProc
*
,
TRUE
)
...
...
include/mruby/range.h
View file @
206f89e2
...
...
@@ -25,8 +25,8 @@ struct RRange {
#define mrb_range_ptr(v) ((struct RRange*)(mrb_ptr(v)))
#define mrb_range_value(p) mrb_obj_value((void*)(p))
mrb_value
mrb_range_new
(
mrb_state
*
,
mrb_value
,
mrb_value
,
mrb_bool
);
mrb_bool
mrb_range_beg_len
(
mrb_state
*
mrb
,
mrb_value
range
,
mrb_int
*
begp
,
mrb_int
*
lenp
,
mrb_int
len
);
MRB_API
mrb_value
mrb_range_new
(
mrb_state
*
,
mrb_value
,
mrb_value
,
mrb_bool
);
MRB_API
mrb_bool
mrb_range_beg_len
(
mrb_state
*
mrb
,
mrb_value
range
,
mrb_int
*
begp
,
mrb_int
*
lenp
,
mrb_int
len
);
mrb_value
mrb_get_values_at
(
mrb_state
*
mrb
,
mrb_value
obj
,
mrb_int
olen
,
mrb_int
argc
,
const
mrb_value
*
argv
,
mrb_value
(
*
func
)(
mrb_state
*
,
mrb_value
,
mrb_int
));
#if defined(__cplusplus)
...
...
include/mruby/string.h
View file @
206f89e2
...
...
@@ -74,38 +74,38 @@ mrb_int mrb_str_strlen(mrb_state*, struct RString*);
#define MRB_STR_EMBED_LEN_MASK 0xf8
#define MRB_STR_EMBED_LEN_SHIFT 3
void
mrb_gc_free_str
(
mrb_state
*
,
struct
RString
*
);
void
mrb_str_modify
(
mrb_state
*
,
struct
RString
*
);
void
mrb_str_concat
(
mrb_state
*
,
mrb_value
,
mrb_value
);
mrb_value
mrb_str_plus
(
mrb_state
*
,
mrb_value
,
mrb_value
);
mrb_value
mrb_ptr_to_str
(
mrb_state
*
,
void
*
);
mrb_value
mrb_obj_as_string
(
mrb_state
*
mrb
,
mrb_value
obj
);
mrb_value
mrb_str_resize
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_int
len
);
mrb_value
mrb_str_substr
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_int
beg
,
mrb_int
len
);
mrb_value
mrb_string_type
(
mrb_state
*
mrb
,
mrb_value
str
);
mrb_value
mrb_check_string_type
(
mrb_state
*
mrb
,
mrb_value
str
);
mrb_value
mrb_str_buf_new
(
mrb_state
*
mrb
,
size_t
capa
);
char
*
mrb_string_value_cstr
(
mrb_state
*
mrb
,
mrb_value
*
ptr
);
char
*
mrb_string_value_ptr
(
mrb_state
*
mrb
,
mrb_value
ptr
);
mrb_value
mrb_str_dup
(
mrb_state
*
mrb
,
mrb_value
str
);
mrb_value
mrb_str_intern
(
mrb_state
*
mrb
,
mrb_value
self
);
mrb_value
mrb_str_to_inum
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_int
base
,
mrb_bool
badcheck
);
double
mrb_str_to_dbl
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_bool
badcheck
);
mrb_value
mrb_str_to_str
(
mrb_state
*
mrb
,
mrb_value
str
);
mrb_int
mrb_str_hash
(
mrb_state
*
mrb
,
mrb_value
str
);
mrb_value
mrb_str_inspect
(
mrb_state
*
mrb
,
mrb_value
str
);
mrb_bool
mrb_str_equal
(
mrb_state
*
mrb
,
mrb_value
str1
,
mrb_value
str2
);
mrb_value
mrb_str_dump
(
mrb_state
*
mrb
,
mrb_value
str
);
mrb_value
mrb_str_cat
(
mrb_state
*
mrb
,
mrb_value
str
,
const
char
*
ptr
,
size_t
len
);
mrb_value
mrb_str_cat_cstr
(
mrb_state
*
mrb
,
mrb_value
str
,
const
char
*
ptr
);
mrb_value
mrb_str_cat_str
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_value
str2
);
MRB_API
void
mrb_gc_free_str
(
mrb_state
*
,
struct
RString
*
);
MRB_API
void
mrb_str_modify
(
mrb_state
*
,
struct
RString
*
);
MRB_API
void
mrb_str_concat
(
mrb_state
*
,
mrb_value
,
mrb_value
);
MRB_API
mrb_value
mrb_str_plus
(
mrb_state
*
,
mrb_value
,
mrb_value
);
MRB_API
mrb_value
mrb_ptr_to_str
(
mrb_state
*
,
void
*
);
MRB_API
mrb_value
mrb_obj_as_string
(
mrb_state
*
mrb
,
mrb_value
obj
);
MRB_API
mrb_value
mrb_str_resize
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_int
len
);
MRB_API
mrb_value
mrb_str_substr
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_int
beg
,
mrb_int
len
);
MRB_API
mrb_value
mrb_string_type
(
mrb_state
*
mrb
,
mrb_value
str
);
MRB_API
mrb_value
mrb_check_string_type
(
mrb_state
*
mrb
,
mrb_value
str
);
MRB_API
mrb_value
mrb_str_buf_new
(
mrb_state
*
mrb
,
size_t
capa
);
MRB_API
const
char
*
mrb_string_value_cstr
(
mrb_state
*
mrb
,
mrb_value
*
ptr
);
MRB_API
const
char
*
mrb_string_value_ptr
(
mrb_state
*
mrb
,
mrb_value
ptr
);
MRB_API
mrb_value
mrb_str_dup
(
mrb_state
*
mrb
,
mrb_value
str
);
MRB_API
mrb_value
mrb_str_intern
(
mrb_state
*
mrb
,
mrb_value
self
);
MRB_API
mrb_value
mrb_str_to_inum
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_int
base
,
mrb_bool
badcheck
);
MRB_API
double
mrb_str_to_dbl
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_bool
badcheck
);
MRB_API
mrb_value
mrb_str_to_str
(
mrb_state
*
mrb
,
mrb_value
str
);
MRB_API
mrb_bool
mrb_str_equal
(
mrb_state
*
mrb
,
mrb_value
str1
,
mrb_value
str2
);
MRB_API
mrb_value
mrb_str_cat
(
mrb_state
*
mrb
,
mrb_value
str
,
const
char
*
ptr
,
size_t
len
);
MRB_API
mrb_value
mrb_str_cat_cstr
(
mrb_state
*
mrb
,
mrb_value
str
,
const
char
*
ptr
);
MRB_API
mrb_value
mrb_str_cat_str
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_value
str2
);
#define mrb_str_cat_lit(mrb, str, lit) mrb_str_cat(mrb, str, lit, mrb_strlen_lit(lit))
mrb_value
mrb_str_append
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_value
str2
);
MRB_API
mrb_value
mrb_str_append
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_value
str2
);
int
mrb_str_cmp
(
mrb_state
*
mrb
,
mrb_value
str1
,
mrb_value
str2
);
char
*
mrb_str_to_cstr
(
mrb_state
*
mrb
,
mrb_value
str
);
MRB_API
int
mrb_str_cmp
(
mrb_state
*
mrb
,
mrb_value
str1
,
mrb_value
str2
);
MRB_API
const
char
*
mrb_str_to_cstr
(
mrb_state
*
mrb
,
mrb_value
str
);
mrb_value
mrb_str_pool
(
mrb_state
*
mrb
,
mrb_value
str
);
mrb_int
mrb_str_hash
(
mrb_state
*
mrb
,
mrb_value
str
);
mrb_value
mrb_str_dump
(
mrb_state
*
mrb
,
mrb_value
str
);
mrb_value
mrb_str_inspect
(
mrb_state
*
mrb
,
mrb_value
str
);
/* For backward compatibility */
static
inline
mrb_value
...
...
include/mruby/value.h
View file @
206f89e2
...
...
@@ -124,7 +124,7 @@ enum mrb_vtype {
#define mrb_cptr_p(o) (mrb_type(o) == MRB_TT_CPTR)
#define mrb_exception_p(o) (mrb_type(o) == MRB_TT_EXCEPTION)
#define mrb_test(o) mrb_bool(o)
mrb_bool
mrb_regexp_p
(
struct
mrb_state
*
,
mrb_value
);
MRB_API
mrb_bool
mrb_regexp_p
(
struct
mrb_state
*
,
mrb_value
);
static
inline
mrb_value
mrb_float_value
(
struct
mrb_state
*
mrb
,
mrb_float
f
)
...
...
include/mruby/variable.h
View file @
206f89e2
...
...
@@ -34,43 +34,43 @@ mrb_value mrb_vm_cv_get(mrb_state*, mrb_sym);
void
mrb_vm_cv_set
(
mrb_state
*
,
mrb_sym
,
mrb_value
);
mrb_value
mrb_vm_const_get
(
mrb_state
*
,
mrb_sym
);
void
mrb_vm_const_set
(
mrb_state
*
,
mrb_sym
,
mrb_value
);
mrb_value
mrb_const_get
(
mrb_state
*
,
mrb_value
,
mrb_sym
);
void
mrb_const_set
(
mrb_state
*
,
mrb_value
,
mrb_sym
,
mrb_value
);
mrb_bool
mrb_const_defined
(
mrb_state
*
,
mrb_value
,
mrb_sym
);
void
mrb_const_remove
(
mrb_state
*
,
mrb_value
,
mrb_sym
);
MRB_API
mrb_value
mrb_const_get
(
mrb_state
*
,
mrb_value
,
mrb_sym
);
MRB_API
void
mrb_const_set
(
mrb_state
*
,
mrb_value
,
mrb_sym
,
mrb_value
);
MRB_API
mrb_bool
mrb_const_defined
(
mrb_state
*
,
mrb_value
,
mrb_sym
);
MRB_API
void
mrb_const_remove
(
mrb_state
*
,
mrb_value
,
mrb_sym
);
mrb_value
mrb_obj_iv_get
(
mrb_state
*
mrb
,
struct
RObject
*
obj
,
mrb_sym
sym
);
void
mrb_obj_iv_set
(
mrb_state
*
mrb
,
struct
RObject
*
obj
,
mrb_sym
sym
,
mrb_value
v
);
mrb_bool
mrb_obj_iv_defined
(
mrb_state
*
mrb
,
struct
RObject
*
obj
,
mrb_sym
sym
);
void
mrb_obj_iv_ifnone
(
mrb_state
*
mrb
,
struct
RObject
*
obj
,
mrb_sym
sym
,
mrb_value
v
);
mrb_value
mrb_iv_get
(
mrb_state
*
mrb
,
mrb_value
obj
,
mrb_sym
sym
);
void
mrb_iv_set
(
mrb_state
*
mrb
,
mrb_value
obj
,
mrb_sym
sym
,
mrb_value
v
);
mrb_bool
mrb_iv_defined
(
mrb_state
*
,
mrb_value
,
mrb_sym
);
mrb_value
mrb_iv_remove
(
mrb_state
*
mrb
,
mrb_value
obj
,
mrb_sym
sym
);
void
mrb_iv_copy
(
mrb_state
*
mrb
,
mrb_value
dst
,
mrb_value
src
);
mrb_bool
mrb_const_defined_at
(
mrb_state
*
mrb
,
struct
RClass
*
klass
,
mrb_sym
id
);
MRB_API
mrb_value
mrb_obj_iv_get
(
mrb_state
*
mrb
,
struct
RObject
*
obj
,
mrb_sym
sym
);
MRB_API
void
mrb_obj_iv_set
(
mrb_state
*
mrb
,
struct
RObject
*
obj
,
mrb_sym
sym
,
mrb_value
v
);
MRB_API
mrb_bool
mrb_obj_iv_defined
(
mrb_state
*
mrb
,
struct
RObject
*
obj
,
mrb_sym
sym
);
MRB_API
void
mrb_obj_iv_ifnone
(
mrb_state
*
mrb
,
struct
RObject
*
obj
,
mrb_sym
sym
,
mrb_value
v
);
MRB_API
mrb_value
mrb_iv_get
(
mrb_state
*
mrb
,
mrb_value
obj
,
mrb_sym
sym
);
MRB_API
void
mrb_iv_set
(
mrb_state
*
mrb
,
mrb_value
obj
,
mrb_sym
sym
,
mrb_value
v
);
MRB_API
mrb_bool
mrb_iv_defined
(
mrb_state
*
,
mrb_value
,
mrb_sym
);
MRB_API
mrb_value
mrb_iv_remove
(
mrb_state
*
mrb
,
mrb_value
obj
,
mrb_sym
sym
);
MRB_API
void
mrb_iv_copy
(
mrb_state
*
mrb
,
mrb_value
dst
,
mrb_value
src
);
MRB_API
mrb_bool
mrb_const_defined_at
(
mrb_state
*
mrb
,
struct
RClass
*
klass
,
mrb_sym
id
);
MRB_API
mrb_value
mrb_gv_get
(
mrb_state
*
mrb
,
mrb_sym
sym
);
MRB_API
void
mrb_gv_set
(
mrb_state
*
mrb
,
mrb_sym
sym
,
mrb_value
val
);
MRB_API
void
mrb_gv_remove
(
mrb_state
*
mrb
,
mrb_sym
sym
);
MRB_API
mrb_value
mrb_cv_get
(
mrb_state
*
mrb
,
mrb_value
mod
,
mrb_sym
sym
);
MRB_API
void
mrb_mod_cv_set
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
sym
,
mrb_value
v
);
MRB_API
void
mrb_cv_set
(
mrb_state
*
mrb
,
mrb_value
mod
,
mrb_sym
sym
,
mrb_value
v
);
MRB_API
mrb_bool
mrb_cv_defined
(
mrb_state
*
mrb
,
mrb_value
mod
,
mrb_sym
sym
);
mrb_value
mrb_obj_iv_inspect
(
mrb_state
*
,
struct
RObject
*
);
mrb_value
mrb_mod_constants
(
mrb_state
*
mrb
,
mrb_value
mod
);
mrb_value
mrb_f_global_variables
(
mrb_state
*
mrb
,
mrb_value
self
);
mrb_value
mrb_gv_get
(
mrb_state
*
mrb
,
mrb_sym
sym
);
void
mrb_gv_set
(
mrb_state
*
mrb
,
mrb_sym
sym
,
mrb_value
val
);
void
mrb_gv_remove
(
mrb_state
*
mrb
,
mrb_sym
sym
);
mrb_value
mrb_obj_instance_variables
(
mrb_state
*
,
mrb_value
);
mrb_value
mrb_obj_iv_inspect
(
mrb_state
*
,
struct
RObject
*
);
mrb_sym
mrb_class_sym
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
struct
RClass
*
outer
);
mrb_value
mrb_mod_class_variables
(
mrb_state
*
,
mrb_value
);
mrb_value
mrb_mod_cv_get
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
sym
);
mrb_value
mrb_cv_get
(
mrb_state
*
mrb
,
mrb_value
mod
,
mrb_sym
sym
);
void
mrb_mod_cv_set
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
sym
,
mrb_value
v
);
void
mrb_cv_set
(
mrb_state
*
mrb
,
mrb_value
mod
,
mrb_sym
sym
,
mrb_value
v
);
mrb_bool
mrb_mod_cv_defined
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
sym
);
mrb_
bool
mrb_cv_defined
(
mrb_state
*
mrb
,
mrb_value
mod
,
mrb_sym
sym
);
mrb_
sym
mrb_class_sym
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
struct
RClass
*
outer
);
/* GC functions */
void
mrb_gc_mark_gv
(
mrb_state
*
);
void
mrb_gc_free_gv
(
mrb_state
*
);
void
mrb_gc_mark_iv
(
mrb_state
*
,
struct
RObject
*
);
size_t
mrb_gc_mark_iv_size
(
mrb_state
*
,
struct
RObject
*
);
void
mrb_gc_free_iv
(
mrb_state
*
,
struct
RObject
*
);
MRB_API
void
mrb_gc_mark_gv
(
mrb_state
*
);
MRB_API
void
mrb_gc_free_gv
(
mrb_state
*
);
MRB_API
void
mrb_gc_mark_iv
(
mrb_state
*
,
struct
RObject
*
);
MRB_API
size_t
mrb_gc_mark_iv_size
(
mrb_state
*
,
struct
RObject
*
);
MRB_API
void
mrb_gc_free_iv
(
mrb_state
*
,
struct
RObject
*
);
#if defined(__cplusplus)
}
/* extern "C" { */
...
...
mrbgems/mruby-proc-ext/src/proc.c
View file @
206f89e2
...
...
@@ -5,7 +5,7 @@
#include "mruby/string.h"
#include "mruby/debug.h"
struct
RProc
*
MRB_API
struct
RProc
*
mrb_proc_new_cfunc_with_env
(
mrb_state
*
mrb
,
mrb_func_t
f
,
mrb_int
argc
,
const
mrb_value
*
argv
)
{
struct
RProc
*
p
;
...
...
@@ -28,7 +28,7 @@ mrb_proc_new_cfunc_with_env(mrb_state *mrb, mrb_func_t f, mrb_int argc, const mr
return
p
;
}
mrb_value
MRB_API
mrb_value
mrb_cfunc_env_get
(
mrb_state
*
mrb
,
mrb_int
idx
)
{
struct
RProc
*
p
=
mrb
->
c
->
ci
->
proc
;
...
...
src/array.c
View file @
206f89e2
...
...
@@ -51,14 +51,14 @@ ary_new_capa(mrb_state *mrb, mrb_int capa)
return
a
;
}
mrb_value
MRB_API
mrb_value
mrb_ary_new_capa
(
mrb_state
*
mrb
,
mrb_int
capa
)
{
struct
RArray
*
a
=
ary_new_capa
(
mrb
,
capa
);
return
mrb_obj_value
(
a
);
}
mrb_value
MRB_API
mrb_value
mrb_ary_new
(
mrb_state
*
mrb
)
{
return
mrb_ary_new_capa
(
mrb
,
0
);
...
...
@@ -88,7 +88,7 @@ array_copy(mrb_value *dst, const mrb_value *src, mrb_int size)
}
}
mrb_value
MRB_API
mrb_value
mrb_ary_new_from_values
(
mrb_state
*
mrb
,
mrb_int
size
,
const
mrb_value
*
vals
)
{
mrb_value
ary
;
...
...
@@ -102,7 +102,7 @@ mrb_ary_new_from_values(mrb_state *mrb, mrb_int size, const mrb_value *vals)
return
ary
;
}
mrb_value
MRB_API
mrb_value
mrb_assoc_new
(
mrb_state
*
mrb
,
mrb_value
car
,
mrb_value
cdr
)
{
struct
RArray
*
a
;
...
...
@@ -153,7 +153,7 @@ ary_modify(mrb_state *mrb, struct RArray *a)
}
}
void
MRB_API
void
mrb_ary_modify
(
mrb_state
*
mrb
,
struct
RArray
*
a
)
{
mrb_write_barrier
(
mrb
,
(
struct
RBasic
*
)
a
);
...
...
@@ -227,7 +227,7 @@ ary_shrink_capa(mrb_state *mrb, struct RArray *a)
}
}
mrb_value
MRB_API
mrb_value
mrb_ary_resize
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_int
new_len
)
{
mrb_int
old_len
;
...
...
@@ -272,7 +272,7 @@ ary_concat(mrb_state *mrb, struct RArray *a, mrb_value *ptr, mrb_int blen)
a
->
len
=
len
;
}
void
MRB_API
void
mrb_ary_concat
(
mrb_state
*
mrb
,
mrb_value
self
,
mrb_value
other
)
{
struct
RArray
*
a2
=
mrb_ary_ptr
(
other
);
...
...
@@ -321,7 +321,7 @@ ary_replace(mrb_state *mrb, struct RArray *a, mrb_value *argv, mrb_int len)
a
->
len
=
len
;
}
void
MRB_API
void
mrb_ary_replace
(
mrb_state
*
mrb
,
mrb_value
self
,
mrb_value
other
)
{
struct
RArray
*
a2
=
mrb_ary_ptr
(
other
);
...
...
@@ -410,7 +410,7 @@ mrb_ary_reverse(mrb_state *mrb, mrb_value self)
return
ary
;
}
void
MRB_API
void
mrb_ary_push
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_value
elem
)
{
struct
RArray
*
a
=
mrb_ary_ptr
(
ary
);
...
...
@@ -436,7 +436,7 @@ mrb_ary_push_m(mrb_state *mrb, mrb_value self)
return
self
;
}
mrb_value
MRB_API
mrb_value
mrb_ary_pop
(
mrb_state
*
mrb
,
mrb_value
ary
)
{
struct
RArray
*
a
=
mrb_ary_ptr
(
ary
);
...
...
@@ -447,7 +447,7 @@ mrb_ary_pop(mrb_state *mrb, mrb_value ary)
#define ARY_SHIFT_SHARED_MIN 10
mrb_value
MRB_API
mrb_value
mrb_ary_shift
(
mrb_state
*
mrb
,
mrb_value
self
)
{
struct
RArray
*
a
=
mrb_ary_ptr
(
self
);
...
...
@@ -483,7 +483,7 @@ mrb_ary_shift(mrb_state *mrb, mrb_value self)
item = 0
self.unshift item
p self #=> [0, 1, 2, 3] */
mrb_value
MRB_API
mrb_value
mrb_ary_unshift
(
mrb_state
*
mrb
,
mrb_value
self
,
mrb_value
item
)
{
struct
RArray
*
a
=
mrb_ary_ptr
(
self
);
...
...
@@ -536,7 +536,7 @@ mrb_ary_unshift_m(mrb_state *mrb, mrb_value self)
return
self
;
}
mrb_value
MRB_API
mrb_value
mrb_ary_ref
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_int
n
)
{
struct
RArray
*
a
=
mrb_ary_ptr
(
ary
);
...
...
@@ -548,7 +548,7 @@ mrb_ary_ref(mrb_state *mrb, mrb_value ary, mrb_int n)
return
a
->
ptr
[
n
];
}
void
MRB_API
void
mrb_ary_set
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_int
n
,
mrb_value
val
)
{
struct
RArray
*
a
=
mrb_ary_ptr
(
ary
);
...
...
@@ -572,7 +572,7 @@ mrb_ary_set(mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val)
mrb_field_write_barrier_value
(
mrb
,
(
struct
RBasic
*
)
a
,
val
);
}
mrb_value
MRB_API
mrb_value
mrb_ary_splice
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_int
head
,
mrb_int
len
,
mrb_value
rpl
)
{
struct
RArray
*
a
=
mrb_ary_ptr
(
ary
);
...
...
@@ -893,7 +893,7 @@ mrb_ary_rindex_m(mrb_state *mrb, mrb_value self)
return
mrb_nil_value
();
}
mrb_value
MRB_API
mrb_value
mrb_ary_splat
(
mrb_state
*
mrb
,
mrb_value
v
)
{
if
(
mrb_array_p
(
v
))
{
...
...
@@ -915,7 +915,7 @@ mrb_ary_size(mrb_state *mrb, mrb_value self)
return
mrb_fixnum_value
(
a
->
len
);
}
mrb_value
MRB_API
mrb_value
mrb_ary_clear
(
mrb_state
*
mrb
,
mrb_value
self
)
{
struct
RArray
*
a
=
mrb_ary_ptr
(
self
);
...
...
@@ -942,13 +942,13 @@ mrb_ary_empty_p(mrb_state *mrb, mrb_value self)
return
mrb_bool_value
(
a
->
len
==
0
);
}
mrb_value
MRB_API
mrb_value
mrb_check_array_type
(
mrb_state
*
mrb
,
mrb_value
ary
)
{
return
mrb_check_convert_type
(
mrb
,
ary
,
MRB_TT_ARRAY
,
"Array"
,
"to_ary"
);
}
mrb_value
MRB_API
mrb_value
mrb_ary_entry
(
mrb_value
ary
,
mrb_int
offset
)
{
if
(
offset
<
0
)
{
...
...
@@ -1012,7 +1012,7 @@ join_ary(mrb_state *mrb, mrb_value ary, mrb_value sep, mrb_value list)
return
result
;
}
mrb_value
MRB_API
mrb_value
mrb_ary_join
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_value
sep
)
{
sep
=
mrb_obj_as_string
(
mrb
,
sep
);
...
...
src/backtrace.c
View file @
206f89e2
...
...
@@ -144,7 +144,7 @@ exc_output_backtrace(mrb_state *mrb, struct RObject *exc, output_stream_func fun
overwritten. So invoke these functions just after detecting exceptions.
*/
void
MRB_API
void
mrb_print_backtrace
(
mrb_state
*
mrb
)
{
if
(
!
mrb
->
exc
||
mrb_obj_is_kind_of
(
mrb
,
mrb_obj_value
(
mrb
->
exc
),
E_SYSSTACK_ERROR
))
{
...
...
@@ -153,7 +153,7 @@ mrb_print_backtrace(mrb_state *mrb)
exc_output_backtrace
(
mrb
,
mrb
->
exc
,
print_backtrace_i
,
(
void
*
)
stderr
);
}
mrb_value
MRB_API
mrb_value
mrb_exc_backtrace
(
mrb_state
*
mrb
,
mrb_value
self
)
{
mrb_value
ary
;
...
...
@@ -164,7 +164,7 @@ mrb_exc_backtrace(mrb_state *mrb, mrb_value self)
return
ary
;
}
mrb_value
MRB_API
mrb_value
mrb_get_backtrace
(
mrb_state
*
mrb
)
{
mrb_value
ary
;
...
...
@@ -181,18 +181,18 @@ mrb_get_backtrace(mrb_state *mrb)
#else
void
MRB_API
void
mrb_print_backtrace
(
mrb_state
*
mrb
)
{
}
mrb_value
MRB_API
mrb_value
mrb_exc_backtrace
(
mrb_state
*
mrb
,
mrb_value
self
)
{
return
mrb_ary_new
(
mrb
);
}
mrb_value
MRB_API
mrb_value
mrb_get_backtrace
(
mrb_state
*
mrb
)
{
return
mrb_ary_new
(
mrb
);
...
...
src/class.c
View file @
206f89e2
...
...
@@ -122,7 +122,7 @@ module_from_sym(mrb_state *mrb, struct RClass *klass, mrb_sym id)
return
mrb_class_ptr
(
c
);
}
struct
RClass
*
MRB_API
struct
RClass
*
mrb_class_outer_module
(
mrb_state
*
mrb
,
struct
RClass
*
c
)
{
mrb_value
outer
;
...
...
@@ -146,25 +146,25 @@ define_module(mrb_state *mrb, mrb_sym name, struct RClass *outer)
return
m
;
}
struct
RClass
*
MRB_API
struct
RClass
*
mrb_define_module_id
(
mrb_state
*
mrb
,
mrb_sym
name
)
{
return
define_module
(
mrb
,
name
,
mrb
->
object_class
);
}
struct
RClass
*
MRB_API
struct
RClass
*
mrb_define_module
(
mrb_state
*
mrb
,
const
char
*
name
)
{
return
define_module
(
mrb
,
mrb_intern_cstr
(
mrb
,
name
),
mrb
->
object_class
);
}
struct
RClass
*
MRB_API
struct
RClass
*
mrb_vm_define_module
(
mrb_state
*
mrb
,
mrb_value
outer
,
mrb_sym
id
)
{
return
define_module
(
mrb
,
id
,
mrb_class_ptr
(
outer
));
}
struct
RClass
*
MRB_API
struct
RClass
*
mrb_define_module_under
(
mrb_state
*
mrb
,
struct
RClass
*
outer
,
const
char
*
name
)
{
mrb_sym
id
=
mrb_intern_cstr
(
mrb
,
name
);
...
...
@@ -195,7 +195,7 @@ define_class(mrb_state *mrb, mrb_sym name, struct RClass *super, struct RClass *
return
c
;
}
struct
RClass
*
MRB_API
struct
RClass
*
mrb_define_class_id
(
mrb_state
*
mrb
,
mrb_sym
name
,
struct
RClass
*
super
)
{
if
(
!
super
)
{
...
...
@@ -204,7 +204,7 @@ mrb_define_class_id(mrb_state *mrb, mrb_sym name, struct RClass *super)
return
define_class
(
mrb
,
name
,
super
,
mrb
->
object_class
);
}
struct
RClass
*
MRB_API
struct
RClass
*
mrb_define_class
(
mrb_state
*
mrb
,
const
char
*
name
,
struct
RClass
*
super
)
{
return
mrb_define_class_id
(
mrb
,
mrb_intern_cstr
(
mrb
,
name
),
super
);
...
...
@@ -218,7 +218,7 @@ mrb_class_inherited(mrb_state *mrb, struct RClass *super, struct RClass *klass)
mrb_funcall
(
mrb
,
mrb_obj_value
(
super
),
"inherited"
,
1
,
mrb_obj_value
(
klass
));
}
struct
RClass
*
MRB_API
struct
RClass
*
mrb_vm_define_class
(
mrb_state
*
mrb
,
mrb_value
outer
,
mrb_value
super
,
mrb_sym
id
)
{
struct
RClass
*
s
;
...
...
@@ -248,7 +248,7 @@ mrb_vm_define_class(mrb_state *mrb, mrb_value outer, mrb_value super, mrb_sym id
return
c
;
}
mrb_bool
MRB_API
mrb_bool
mrb_class_defined
(
mrb_state
*
mrb
,
const
char
*
name
)
{
mrb_value
sym
=
mrb_check_intern_cstr
(
mrb
,
name
);
...
...
@@ -258,25 +258,25 @@ mrb_class_defined(mrb_state *mrb, const char *name)
return
mrb_const_defined
(
mrb
,
mrb_obj_value
(
mrb
->
object_class
),
mrb_symbol
(
sym
));
}
struct
RClass
*
MRB_API
struct
RClass
*
mrb_class_get_under
(
mrb_state
*
mrb
,
struct
RClass
*
outer
,
const
char
*
name
)
{
return
class_from_sym
(
mrb
,
outer
,
mrb_intern_cstr
(
mrb
,
name
));
}
struct
RClass
*
MRB_API
struct
RClass
*
mrb_class_get
(
mrb_state
*
mrb
,
const
char
*
name
)
{
return
mrb_class_get_under
(
mrb
,
mrb
->
object_class
,
name
);
}
struct
RClass
*
MRB_API
struct
RClass
*
mrb_module_get_under
(
mrb_state
*
mrb
,
struct
RClass
*
outer
,
const
char
*
name
)
{
return
module_from_sym
(
mrb
,
outer
,
mrb_intern_cstr
(
mrb
,
name
));
}
struct
RClass
*
MRB_API
struct
RClass
*
mrb_module_get
(
mrb_state
*
mrb
,
const
char
*
name
)
{
return
mrb_module_get_under
(
mrb
,
mrb
->
object_class
,
name
);
...
...
@@ -298,7 +298,7 @@ mrb_module_get(mrb_state *mrb, const char *name)
* \note if a class named \a name is already defined and its superclass is
* \a super, the function just returns the defined class.
*/
struct
RClass
*
MRB_API
struct
RClass
*
mrb_define_class_under
(
mrb_state
*
mrb
,
struct
RClass
*
outer
,
const
char
*
name
,
struct
RClass
*
super
)
{
mrb_sym
id
=
mrb_intern_cstr
(
mrb
,
name
);
...
...
@@ -315,7 +315,7 @@ mrb_define_class_under(mrb_state *mrb, struct RClass *outer, const char *name, s
return
c
;
}
void
MRB_API
void
mrb_define_method_raw
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
mid
,
struct
RProc
*
p
)
{
khash_t
(
mt
)
*
h
=
c
->
mt
;
...
...
@@ -329,7 +329,7 @@ mrb_define_method_raw(mrb_state *mrb, struct RClass *c, mrb_sym mid, struct RPro
}
}
void
MRB_API
void
mrb_define_method_id
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
mid
,
mrb_func_t
func
,
mrb_aspec
aspec
)
{
struct
RProc
*
p
;
...
...
@@ -341,13 +341,13 @@ mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t f
mrb_gc_arena_restore
(
mrb
,
ai
);
}
void
MRB_API
void
mrb_define_method
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
const
char
*
name
,
mrb_func_t
func
,
mrb_aspec
aspec
)
{
mrb_define_method_id
(
mrb
,
c
,
mrb_intern_cstr
(
mrb
,
name
),
func
,
aspec
);
}
void
MRB_API
void
mrb_define_method_vm
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
name
,
mrb_value
body
)
{
khash_t
(
mt
)
*
h
=
c
->
mt
;
...
...
@@ -422,7 +422,7 @@ to_hash(mrb_state *mrb, mrb_value val)
|: optional Next argument of '|' and later are optional.
?: optional given [mrb_bool] true if preceding argument (optional) is given.
*/
mrb_int
MRB_API
mrb_int
mrb_get_args
(
mrb_state
*
mrb
,
const
char
*
format
,
...)
{
char
c
;
...
...
@@ -543,9 +543,9 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
case
'z'
:
{
mrb_value
ss
;
char
**
ps
;
c
onst
c
har
**
ps
;
ps
=
va_arg
(
ap
,
char
**
);
ps
=
va_arg
(
ap
,
c
onst
c
har
**
);
if
(
i
<
argc
)
{
ss
=
to_str
(
mrb
,
*
sp
++
);
*
ps
=
mrb_string_value_cstr
(
mrb
,
&
ss
);
...
...
@@ -739,7 +739,7 @@ boot_defclass(mrb_state *mrb, struct RClass *super)
return
c
;
}
void
MRB_API
void
mrb_include_module
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
struct
RClass
*
m
)
{
struct
RClass
*
ins_pos
;
...
...
@@ -989,27 +989,27 @@ mrb_singleton_class(mrb_state *mrb, mrb_value v)
return
mrb_obj_value
(
obj
->
c
);
}
void
MRB_API
void
mrb_define_singleton_method
(
mrb_state
*
mrb
,
struct
RObject
*
o
,
const
char
*
name
,
mrb_func_t
func
,
mrb_aspec
aspec
)
{
prepare_singleton_class
(
mrb
,
(
struct
RBasic
*
)
o
);
mrb_define_method_id
(
mrb
,
o
->
c
,
mrb_intern_cstr
(
mrb
,
name
),
func
,
aspec
);
}
void
MRB_API
void
mrb_define_class_method
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
const
char
*
name
,
mrb_func_t
func
,
mrb_aspec
aspec
)
{
mrb_define_singleton_method
(
mrb
,
(
struct
RObject
*
)
c
,
name
,
func
,
aspec
);
}
void
MRB_API
void
mrb_define_module_function
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
const
char
*
name
,
mrb_func_t
func
,
mrb_aspec
aspec
)
{
mrb_define_class_method
(
mrb
,
c
,
name
,
func
,
aspec
);
mrb_define_method
(
mrb
,
c
,
name
,
func
,
aspec
);
}
struct
RProc
*
MRB_API
struct
RProc
*
mrb_method_search_vm
(
mrb_state
*
mrb
,
struct
RClass
**
cp
,
mrb_sym
mid
)
{
khiter_t
k
;
...
...
@@ -1033,7 +1033,7 @@ mrb_method_search_vm(mrb_state *mrb, struct RClass **cp, mrb_sym mid)
return
0
;
/* no method */
}
struct
RProc
*
MRB_API
struct
RProc
*
mrb_method_search
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
mid
)
{
struct
RProc
*
m
;
...
...
@@ -1077,7 +1077,7 @@ mrb_instance_alloc(mrb_state *mrb, mrb_value cv)
*
*/
mrb_value
MRB_API
mrb_value
mrb_instance_new
(
mrb_state
*
mrb
,
mrb_value
cv
)
{
mrb_value
obj
,
blk
;
...
...
@@ -1091,7 +1091,7 @@ mrb_instance_new(mrb_state *mrb, mrb_value cv)
return
obj
;
}
mrb_value
MRB_API
mrb_value
mrb_obj_new
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_int
argc
,
const
mrb_value
*
argv
)
{
mrb_value
obj
;
...
...
@@ -1221,7 +1221,7 @@ mrb_bob_missing(mrb_state *mrb, mrb_value mod)
return
mrb_nil_value
();
}
mrb_bool
MRB_API
mrb_bool
mrb_obj_respond_to
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
mid
)
{
khiter_t
k
;
...
...
@@ -1245,13 +1245,13 @@ mrb_obj_respond_to(mrb_state *mrb, struct RClass* c, mrb_sym mid)
return
FALSE
;
/* no method */
}
mrb_bool
MRB_API
mrb_bool
mrb_respond_to
(
mrb_state
*
mrb
,
mrb_value
obj
,
mrb_sym
mid
)
{
return
mrb_obj_respond_to
(
mrb
,
mrb_class
(
mrb
,
obj
),
mid
);
}
mrb_value
MRB_API
mrb_value
mrb_class_path
(
mrb_state
*
mrb
,
struct
RClass
*
c
)
{
mrb_value
path
;
...
...
@@ -1291,7 +1291,7 @@ mrb_class_path(mrb_state *mrb, struct RClass *c)
return
path
;
}
struct
RClass
*
MRB_API
struct
RClass
*
mrb_class_real
(
struct
RClass
*
cl
)
{
if
(
cl
==
0
)
...
...
@@ -1302,7 +1302,7 @@ mrb_class_real(struct RClass* cl)
return
cl
;
}
const
char
*
MRB_API
const
char
*
mrb_class_name
(
mrb_state
*
mrb
,
struct
RClass
*
c
)
{
mrb_value
path
=
mrb_class_path
(
mrb
,
c
);
...
...
@@ -1314,7 +1314,7 @@ mrb_class_name(mrb_state *mrb, struct RClass* c)
return
RSTRING_PTR
(
path
);
}
const
char
*
MRB_API
const
char
*
mrb_obj_classname
(
mrb_state
*
mrb
,
mrb_value
obj
)
{
return
mrb_class_name
(
mrb
,
mrb_obj_class
(
mrb
,
obj
));
...
...
@@ -1346,7 +1346,7 @@ mrb_check_inheritable(mrb_state *mrb, struct RClass *super)
* \exception TypeError \a super is not inheritable.
* \exception TypeError \a super is the Class class.
*/
struct
RClass
*
MRB_API
struct
RClass
*
mrb_class_new
(
mrb_state
*
mrb
,
struct
RClass
*
super
)
{
struct
RClass
*
c
;
...
...
@@ -1366,7 +1366,7 @@ mrb_class_new(mrb_state *mrb, struct RClass *super)
/*!
* Creates a new module.
*/
struct
RClass
*
MRB_API
struct
RClass
*
mrb_module_new
(
mrb_state
*
mrb
)
{
struct
RClass
*
m
=
(
struct
RClass
*
)
mrb_obj_alloc
(
mrb
,
MRB_TT_MODULE
,
mrb
->
module_class
);
...
...
@@ -1389,13 +1389,13 @@ mrb_module_new(mrb_state *mrb)
* self.class #=> Object
*/
struct
RClass
*
MRB_API
struct
RClass
*
mrb_obj_class
(
mrb_state
*
mrb
,
mrb_value
obj
)
{
return
mrb_class_real
(
mrb_class
(
mrb
,
obj
));
}
void
MRB_API
void
mrb_alias_method
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
a
,
mrb_sym
b
)
{
struct
RProc
*
m
=
mrb_method_search
(
mrb
,
c
,
b
);
...
...
@@ -1505,13 +1505,13 @@ undef_method(mrb_state *mrb, struct RClass *c, mrb_sym a)
}
}
void
MRB_API
void
mrb_undef_method
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
const
char
*
name
)
{
undef_method
(
mrb
,
c
,
mrb_intern_cstr
(
mrb
,
name
));
}
void
MRB_API
void
mrb_undef_class_method
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
const
char
*
name
)
{
mrb_undef_method
(
mrb
,
mrb_class_ptr
(
mrb_singleton_class
(
mrb
,
mrb_obj_value
(
c
))),
name
);
...
...
@@ -1946,7 +1946,7 @@ mrb_mod_eqq(mrb_state *mrb, mrb_value mod)
return
mrb_bool_value
(
eqq
);
}
mrb_value
MRB_API
mrb_value
mrb_mod_module_function
(
mrb_state
*
mrb
,
mrb_value
mod
)
{
mrb_value
*
argv
;
...
...
src/debug.c
View file @
206f89e2
...
...
@@ -49,7 +49,7 @@ select_line_type(const uint16_t *lines, size_t lines_len)
?
mrb_debug_line_ary
:
mrb_debug_line_flat_map
;
}
char
const
*
MRB_API
char
const
*
mrb_debug_get_filename
(
mrb_irep
*
irep
,
uint32_t
pc
)
{
if
(
irep
&&
pc
<
irep
->
ilen
)
{
...
...
@@ -62,7 +62,7 @@ mrb_debug_get_filename(mrb_irep *irep, uint32_t pc)
return
NULL
;
}
int32_t
MRB_API
int32_t
mrb_debug_get_line
(
mrb_irep
*
irep
,
uint32_t
pc
)
{
if
(
irep
&&
pc
<
irep
->
ilen
)
{
...
...
@@ -106,7 +106,7 @@ mrb_debug_get_line(mrb_irep *irep, uint32_t pc)
return
-
1
;
}
mrb_irep_debug_info
*
MRB_API
mrb_irep_debug_info
*
mrb_debug_info_alloc
(
mrb_state
*
mrb
,
mrb_irep
*
irep
)
{
static
const
mrb_irep_debug_info
initial
=
{
0
,
0
,
NULL
};
...
...
@@ -119,7 +119,7 @@ mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep)
return
ret
;
}
mrb_irep_debug_info_file
*
MRB_API
mrb_irep_debug_info_file
*
mrb_debug_info_append_file
(
mrb_state
*
mrb
,
mrb_irep
*
irep
,
uint32_t
start_pos
,
uint32_t
end_pos
)
{
...
...
@@ -198,7 +198,7 @@ mrb_debug_info_append_file(mrb_state *mrb, mrb_irep *irep,
return
ret
;
}
void
MRB_API
void
mrb_debug_info_free
(
mrb_state
*
mrb
,
mrb_irep_debug_info
*
d
)
{
uint32_t
i
;
...
...
src/error.c
View file @
206f89e2
...
...
@@ -18,14 +18,14 @@
#include "mruby/class.h"
#include "mrb_throw.h"
mrb_value
MRB_API
mrb_value
mrb_exc_new
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
const
char
*
ptr
,
long
len
)
{
mrb_value
arg
=
mrb_str_new
(
mrb
,
ptr
,
len
);
return
mrb_obj_new
(
mrb
,
c
,
1
,
&
arg
);
}
mrb_value
MRB_API
mrb_value
mrb_exc_new_str
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_value
str
)
{
str
=
mrb_str_to_str
(
mrb
,
str
);
...
...
@@ -202,7 +202,7 @@ exc_debug_info(mrb_state *mrb, struct RObject *exc)
}
}
mrb_noreturn
void
MRB_API
mrb_noreturn
void
mrb_exc_raise
(
mrb_state
*
mrb
,
mrb_value
exc
)
{
mrb
->
exc
=
mrb_obj_ptr
(
exc
);
...
...
@@ -216,7 +216,7 @@ mrb_exc_raise(mrb_state *mrb, mrb_value exc)
MRB_THROW
(
mrb
->
jmp
);
}
mrb_noreturn
void
MRB_API
mrb_noreturn
void
mrb_raise
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
const
char
*
msg
)
{
mrb_value
mesg
;
...
...
@@ -224,7 +224,7 @@ mrb_raise(mrb_state *mrb, struct RClass *c, const char *msg)
mrb_exc_raise
(
mrb
,
mrb_exc_new_str
(
mrb
,
c
,
mesg
));
}
mrb_value
MRB_API
mrb_value
mrb_vformat
(
mrb_state
*
mrb
,
const
char
*
format
,
va_list
ap
)
{
const
char
*
p
=
format
;
...
...
@@ -265,7 +265,7 @@ mrb_vformat(mrb_state *mrb, const char *format, va_list ap)
}
}
mrb_value
MRB_API
mrb_value
mrb_format
(
mrb_state
*
mrb
,
const
char
*
format
,
...)
{
va_list
ap
;
...
...
@@ -278,7 +278,7 @@ mrb_format(mrb_state *mrb, const char *format, ...)
return
str
;
}
mrb_noreturn
void
MRB_API
mrb_noreturn
void
mrb_raisef
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
const
char
*
fmt
,
...)
{
va_list
args
;
...
...
@@ -290,7 +290,7 @@ mrb_raisef(mrb_state *mrb, struct RClass *c, const char *fmt, ...)
mrb_exc_raise
(
mrb
,
mrb_exc_new_str
(
mrb
,
c
,
mesg
));
}
mrb_noreturn
void
MRB_API
mrb_noreturn
void
mrb_name_error
(
mrb_state
*
mrb
,
mrb_sym
id
,
const
char
*
fmt
,
...)
{
mrb_value
exc
;
...
...
@@ -306,7 +306,7 @@ mrb_name_error(mrb_state *mrb, mrb_sym id, const char *fmt, ...)
mrb_exc_raise
(
mrb
,
exc
);
}
void
MRB_API
void
mrb_warn
(
mrb_state
*
mrb
,
const
char
*
fmt
,
...)
{
#ifdef ENABLE_STDIO
...
...
@@ -321,7 +321,7 @@ mrb_warn(mrb_state *mrb, const char *fmt, ...)
#endif
}
mrb_noreturn
void
MRB_API
mrb_noreturn
void
mrb_bug
(
mrb_state
*
mrb
,
const
char
*
fmt
,
...)
{
#ifdef ENABLE_STDIO
...
...
@@ -396,13 +396,13 @@ exception_call:
return
mesg
;
}
mrb_value
MRB_API
mrb_value
mrb_make_exception
(
mrb_state
*
mrb
,
int
argc
,
const
mrb_value
*
argv
)
{
return
make_exception
(
mrb
,
argc
,
argv
,
TRUE
);
}
void
MRB_API
void
mrb_sys_fail
(
mrb_state
*
mrb
,
const
char
*
mesg
)
{
struct
RClass
*
sce
;
...
...
@@ -423,7 +423,7 @@ mrb_sys_fail(mrb_state *mrb, const char *mesg)
}
}
mrb_noreturn
void
MRB_API
mrb_noreturn
void
mrb_no_method_error
(
mrb_state
*
mrb
,
mrb_sym
id
,
mrb_int
argc
,
const
mrb_value
*
argv
,
char
const
*
fmt
,
...)
{
mrb_value
exc
;
...
...
src/etc.c
View file @
206f89e2
...
...
@@ -11,7 +11,7 @@
#include "mruby/re.h"
#include "mruby/irep.h"
struct
RData
*
MRB_API
struct
RData
*
mrb_data_object_alloc
(
mrb_state
*
mrb
,
struct
RClass
*
klass
,
void
*
ptr
,
const
mrb_data_type
*
type
)
{
struct
RData
*
data
;
...
...
@@ -23,7 +23,7 @@ mrb_data_object_alloc(mrb_state *mrb, struct RClass *klass, void *ptr, const mrb
return
data
;
}
void
MRB_API
void
mrb_data_check_type
(
mrb_state
*
mrb
,
mrb_value
obj
,
const
mrb_data_type
*
type
)
{
if
(
mrb_special_const_p
(
obj
)
||
(
mrb_type
(
obj
)
!=
MRB_TT_DATA
))
{
...
...
@@ -45,7 +45,7 @@ mrb_data_check_type(mrb_state *mrb, mrb_value obj, const mrb_data_type *type)
}
}
void
*
MRB_API
void
*
mrb_data_check_get_ptr
(
mrb_state
*
mrb
,
mrb_value
obj
,
const
mrb_data_type
*
type
)
{
if
(
mrb_special_const_p
(
obj
)
||
(
mrb_type
(
obj
)
!=
MRB_TT_DATA
))
{
...
...
@@ -57,14 +57,14 @@ mrb_data_check_get_ptr(mrb_state *mrb, mrb_value obj, const mrb_data_type *type)
return
DATA_PTR
(
obj
);
}
void
*
MRB_API
void
*
mrb_data_get_ptr
(
mrb_state
*
mrb
,
mrb_value
obj
,
const
mrb_data_type
*
type
)
{
mrb_data_check_type
(
mrb
,
obj
,
type
);
return
DATA_PTR
(
obj
);
}
mrb_sym
MRB_API
mrb_sym
mrb_obj_to_sym
(
mrb_state
*
mrb
,
mrb_value
name
)
{
mrb_value
tmp
;
...
...
@@ -88,7 +88,7 @@ mrb_obj_to_sym(mrb_state *mrb, mrb_value name)
return
id
;
}
mrb_int
MRB_API
mrb_int
mrb_float_id
(
mrb_float
f
)
{
const
char
*
p
=
(
const
char
*
)
&
f
;
...
...
@@ -104,7 +104,7 @@ mrb_float_id(mrb_float f)
return
id
;
}
mrb_int
MRB_API
mrb_int
mrb_obj_id
(
mrb_value
obj
)
{
mrb_int
tt
=
mrb_type
(
obj
);
...
...
@@ -147,7 +147,7 @@ mrb_obj_id(mrb_value obj)
}
#ifdef MRB_WORD_BOXING
mrb_value
MRB_API
mrb_value
mrb_word_boxing_float_value
(
mrb_state
*
mrb
,
mrb_float
f
)
{
mrb_value
v
;
...
...
@@ -157,7 +157,7 @@ mrb_word_boxing_float_value(mrb_state *mrb, mrb_float f)
return
v
;
}
mrb_value
MRB_API
mrb_value
mrb_word_boxing_float_pool
(
mrb_state
*
mrb
,
mrb_float
f
)
{
struct
RFloat
*
nf
=
(
struct
RFloat
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
RFloat
));
...
...
@@ -167,7 +167,7 @@ mrb_word_boxing_float_pool(mrb_state *mrb, mrb_float f)
return
mrb_obj_value
(
nf
);
}
mrb_value
MRB_API
mrb_value
mrb_word_boxing_cptr_value
(
mrb_state
*
mrb
,
void
*
p
)
{
mrb_value
v
;
...
...
@@ -178,7 +178,7 @@ mrb_word_boxing_cptr_value(mrb_state *mrb, void *p)
}
#endif
/* MRB_WORD_BOXING */
mrb_bool
MRB_API
mrb_bool
mrb_regexp_p
(
mrb_state
*
mrb
,
mrb_value
v
)
{
return
mrb_class_defined
(
mrb
,
REGEXP_CLASS
)
&&
mrb_obj_is_kind_of
(
mrb
,
v
,
mrb_class_get
(
mrb
,
REGEXP_CLASS
));
...
...
src/gc.c
View file @
206f89e2
...
...
@@ -168,7 +168,7 @@ gettimeofday_time(void)
#define GC_STEP_SIZE 1024
void
*
MRB_API
void
*
mrb_realloc_simple
(
mrb_state
*
mrb
,
void
*
p
,
size_t
len
)
{
void
*
p2
;
...
...
@@ -183,7 +183,7 @@ mrb_realloc_simple(mrb_state *mrb, void *p, size_t len)
}
void
*
MRB_API
void
*
mrb_realloc
(
mrb_state
*
mrb
,
void
*
p
,
size_t
len
)
{
void
*
p2
;
...
...
@@ -205,19 +205,19 @@ mrb_realloc(mrb_state *mrb, void *p, size_t len)
return
p2
;
}
void
*
MRB_API
void
*
mrb_malloc
(
mrb_state
*
mrb
,
size_t
len
)
{
return
mrb_realloc
(
mrb
,
0
,
len
);
}
void
*
MRB_API
void
*
mrb_malloc_simple
(
mrb_state
*
mrb
,
size_t
len
)
{
return
mrb_realloc_simple
(
mrb
,
0
,
len
);
}
void
*
MRB_API
void
*
mrb_calloc
(
mrb_state
*
mrb
,
size_t
nelem
,
size_t
len
)
{
void
*
p
;
...
...
@@ -239,7 +239,7 @@ mrb_calloc(mrb_state *mrb, size_t nelem, size_t len)
return
p
;
}
void
MRB_API
void
mrb_free
(
mrb_state
*
mrb
,
void
*
p
)
{
(
mrb
->
allocf
)(
mrb
,
p
,
0
,
mrb
->
allocf_ud
);
...
...
@@ -386,14 +386,14 @@ gc_protect(mrb_state *mrb, struct RBasic *p)
mrb
->
arena
[
mrb
->
arena_idx
++
]
=
p
;
}
void
MRB_API
void
mrb_gc_protect
(
mrb_state
*
mrb
,
mrb_value
obj
)
{
if
(
mrb_special_const_p
(
obj
))
return
;
gc_protect
(
mrb
,
mrb_basic_ptr
(
obj
));
}
struct
RBasic
*
MRB_API
struct
RBasic
*
mrb_obj_alloc
(
mrb_state
*
mrb
,
enum
mrb_vtype
ttype
,
struct
RClass
*
cls
)
{
struct
RBasic
*
p
;
...
...
@@ -989,7 +989,7 @@ clear_all_old(mrb_state *mrb)
mrb
->
atomic_gray_list
=
mrb
->
gray_list
=
NULL
;
}
void
MRB_API
void
mrb_incremental_gc
(
mrb_state
*
mrb
)
{
if
(
mrb
->
gc_disabled
)
return
;
...
...
@@ -1027,7 +1027,7 @@ mrb_incremental_gc(mrb_state *mrb)
}
/* Perform a full gc cycle */
void
MRB_API
void
mrb_full_gc
(
mrb_state
*
mrb
)
{
if
(
mrb
->
gc_disabled
)
return
;
...
...
@@ -1055,19 +1055,19 @@ mrb_full_gc(mrb_state *mrb)
GC_TIME_STOP_AND_REPORT
;
}
void
MRB_API
void
mrb_garbage_collect
(
mrb_state
*
mrb
)
{
mrb_full_gc
(
mrb
);
}
int
MRB_API
int
mrb_gc_arena_save
(
mrb_state
*
mrb
)
{
return
mrb
->
arena_idx
;
}
void
MRB_API
void
mrb_gc_arena_restore
(
mrb_state
*
mrb
,
int
idx
)
{
#ifndef MRB_GC_FIXED_ARENA
...
...
@@ -1092,7 +1092,7 @@ mrb_gc_arena_restore(mrb_state *mrb, int idx)
* Paint obj(Black) -> value(White) to obj(Black) -> value(Gray).
*/
void
MRB_API
void
mrb_field_write_barrier
(
mrb_state
*
mrb
,
struct
RBasic
*
obj
,
struct
RBasic
*
value
)
{
if
(
!
is_black
(
obj
))
return
;
...
...
@@ -1119,7 +1119,7 @@ mrb_field_write_barrier(mrb_state *mrb, struct RBasic *obj, struct RBasic *value
* e.g. Set element on Array.
*/
void
MRB_API
void
mrb_write_barrier
(
mrb_state
*
mrb
,
struct
RBasic
*
obj
)
{
if
(
!
is_black
(
obj
))
return
;
...
...
src/hash.c
View file @
206f89e2
...
...
@@ -144,7 +144,7 @@ mrb_gc_free_hash(mrb_state *mrb, struct RHash *hash)
}
mrb_value
MRB_API
mrb_value
mrb_hash_new_capa
(
mrb_state
*
mrb
,
int
capa
)
{
struct
RHash
*
h
;
...
...
@@ -158,13 +158,13 @@ mrb_hash_new_capa(mrb_state *mrb, int capa)
return
mrb_obj_value
(
h
);
}
mrb_value
MRB_API
mrb_value
mrb_hash_new
(
mrb_state
*
mrb
)
{
return
mrb_hash_new_capa
(
mrb
,
0
);
}
mrb_value
MRB_API
mrb_value
mrb_hash_get
(
mrb_state
*
mrb
,
mrb_value
hash
,
mrb_value
key
)
{
khash_t
(
ht
)
*
h
=
RHASH_TBL
(
hash
);
...
...
@@ -183,7 +183,7 @@ mrb_hash_get(mrb_state *mrb, mrb_value hash, mrb_value key)
return
RHASH_IFNONE
(
hash
);
}
mrb_value
MRB_API
mrb_value
mrb_hash_fetch
(
mrb_state
*
mrb
,
mrb_value
hash
,
mrb_value
key
,
mrb_value
def
)
{
khash_t
(
ht
)
*
h
=
RHASH_TBL
(
hash
);
...
...
@@ -199,7 +199,7 @@ mrb_hash_fetch(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value def)
return
def
;
}
void
MRB_API
void
mrb_hash_set
(
mrb_state
*
mrb
,
mrb_value
hash
,
mrb_value
key
,
mrb_value
val
)
{
khash_t
(
ht
)
*
h
;
...
...
@@ -253,13 +253,13 @@ mrb_hash_dup(mrb_state *mrb, mrb_value hash)
return
mrb_obj_value
(
ret
);
}
mrb_value
MRB_API
mrb_value
mrb_check_hash_type
(
mrb_state
*
mrb
,
mrb_value
hash
)
{
return
mrb_check_convert_type
(
mrb
,
hash
,
MRB_TT_HASH
,
"Hash"
,
"to_hash"
);
}
khash_t
(
ht
)
*
MRB_API
khash_t
(
ht
)
*
mrb_hash_tbl
(
mrb_state
*
mrb
,
mrb_value
hash
)
{
khash_t
(
ht
)
*
h
=
RHASH_TBL
(
hash
);
...
...
@@ -478,7 +478,7 @@ mrb_hash_set_default_proc(mrb_state *mrb, mrb_value hash)
return
ifnone
;
}
mrb_value
MRB_API
mrb_value
mrb_hash_delete_key
(
mrb_state
*
mrb
,
mrb_value
hash
,
mrb_value
key
)
{
khash_t
(
ht
)
*
h
=
RHASH_TBL
(
hash
);
...
...
@@ -588,7 +588,7 @@ mrb_hash_shift(mrb_state *mrb, mrb_value hash)
*
*/
mrb_value
MRB_API
mrb_value
mrb_hash_clear
(
mrb_state
*
mrb
,
mrb_value
hash
)
{
khash_t
(
ht
)
*
h
=
RHASH_TBL
(
hash
);
...
...
@@ -659,7 +659,7 @@ mrb_hash_size_m(mrb_state *mrb, mrb_value self)
* {}.empty? #=> true
*
*/
mrb_value
MRB_API
mrb_value
mrb_hash_empty_p
(
mrb_state
*
mrb
,
mrb_value
self
)
{
khash_t
(
ht
)
*
h
=
RHASH_TBL
(
self
);
...
...
@@ -695,7 +695,7 @@ mrb_hash_to_hash(mrb_state *mrb, mrb_value hash)
*
*/
mrb_value
MRB_API
mrb_value
mrb_hash_keys
(
mrb_state
*
mrb
,
mrb_value
hash
)
{
khash_t
(
ht
)
*
h
=
RHASH_TBL
(
hash
);
...
...
src/kernel.c
View file @
206f89e2
...
...
@@ -49,7 +49,7 @@ mrb_obj_basic_to_s_p(mrb_state *mrb, mrb_value obj)
* [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
* Time.new.inspect #=> "2008-03-08 19:43:39 +0900"
*/
mrb_value
MRB_API
mrb_value
mrb_obj_inspect
(
mrb_state
*
mrb
,
mrb_value
obj
)
{
if
((
mrb_type
(
obj
)
==
MRB_TT_OBJECT
)
&&
mrb_obj_basic_to_s_p
(
mrb
,
obj
))
{
...
...
@@ -311,7 +311,7 @@ init_copy(mrb_state *mrb, mrb_value dest, mrb_value obj)
*
* Some Class(True False Nil Symbol Fixnum Float) Object cannot clone.
*/
mrb_value
MRB_API
mrb_value
mrb_obj_clone
(
mrb_state
*
mrb
,
mrb_value
self
)
{
struct
RObject
*
p
;
...
...
@@ -347,7 +347,7 @@ mrb_obj_clone(mrb_state *mrb, mrb_value self)
* the class.
*/
mrb_value
MRB_API
mrb_value
mrb_obj_dup
(
mrb_state
*
mrb
,
mrb_value
obj
)
{
struct
RBasic
*
p
;
...
...
@@ -427,7 +427,7 @@ mrb_obj_extend_m(mrb_state *mrb, mrb_value self)
* <code>Hash</code>. Any hash value that exceeds the capacity of a
* <code>Fixnum</code> will be truncated before being used.
*/
mrb_value
MRB_API
mrb_value
mrb_obj_hash
(
mrb_state
*
mrb
,
mrb_value
self
)
{
return
mrb_fixnum_value
(
mrb_obj_id
(
self
));
...
...
@@ -451,7 +451,7 @@ mrb_obj_init_copy(mrb_state *mrb, mrb_value self)
/* implementation of instance_eval */
mrb_value
mrb_obj_instance_eval
(
mrb_state
*
,
mrb_value
);
mrb_bool
MRB_API
mrb_bool
mrb_obj_is_instance_of
(
mrb_state
*
mrb
,
mrb_value
obj
,
struct
RClass
*
c
)
{
if
(
mrb_obj_class
(
mrb
,
obj
)
==
c
)
return
TRUE
;
...
...
@@ -855,7 +855,7 @@ mrb_obj_public_methods(mrb_state *mrb, mrb_value self)
* raise "Failed to create socket"
* raise ArgumentError, "No parameters", caller
*/
mrb_value
MRB_API
mrb_value
mrb_f_raise
(
mrb_state
*
mrb
,
mrb_value
self
)
{
mrb_value
a
[
2
],
exc
;
...
...
src/load.c
View file @
206f89e2
...
...
@@ -506,7 +506,7 @@ read_binary_header(const uint8_t *bin, size_t *bin_size, uint16_t *crc)
return
MRB_DUMP_OK
;
}
mrb_irep
*
MRB_API
mrb_irep
*
mrb_read_irep
(
mrb_state
*
mrb
,
const
uint8_t
*
bin
)
{
int
result
;
...
...
@@ -570,7 +570,7 @@ irep_error(mrb_state *mrb)
mrb
->
exc
=
mrb_obj_ptr
(
mrb_exc_new_str_lit
(
mrb
,
E_SCRIPT_ERROR
,
"irep load error"
));
}
mrb_value
MRB_API
mrb_value
mrb_load_irep_cxt
(
mrb_state
*
mrb
,
const
uint8_t
*
bin
,
mrbc_context
*
c
)
{
mrb_irep
*
irep
=
mrb_read_irep
(
mrb
,
bin
);
...
...
@@ -588,7 +588,7 @@ mrb_load_irep_cxt(mrb_state *mrb, const uint8_t *bin, mrbc_context *c)
return
val
;
}
mrb_value
MRB_API
mrb_value
mrb_load_irep
(
mrb_state
*
mrb
,
const
uint8_t
*
bin
)
{
return
mrb_load_irep_cxt
(
mrb
,
bin
,
NULL
);
...
...
@@ -688,7 +688,7 @@ read_section_irep_file(mrb_state *mrb, FILE *fp)
return
read_irep_record_file
(
mrb
,
fp
);
}
mrb_irep
*
MRB_API
mrb_irep
*
mrb_read_irep_file
(
mrb_state
*
mrb
,
FILE
*
fp
)
{
mrb_irep
*
irep
=
NULL
;
...
...
@@ -801,7 +801,7 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp)
void
mrb_codedump_all
(
mrb_state
*
,
struct
RProc
*
);
mrb_value
MRB_API
mrb_value
mrb_load_irep_file_cxt
(
mrb_state
*
mrb
,
FILE
*
fp
,
mrbc_context
*
c
)
{
mrb_irep
*
irep
=
mrb_read_irep_file
(
mrb
,
fp
);
...
...
@@ -820,7 +820,7 @@ mrb_load_irep_file_cxt(mrb_state *mrb, FILE* fp, mrbc_context *c)
return
val
;
}
mrb_value
MRB_API
mrb_value
mrb_load_irep_file
(
mrb_state
*
mrb
,
FILE
*
fp
)
{
return
mrb_load_irep_file_cxt
(
mrb
,
fp
,
NULL
);
...
...
src/numeric.c
View file @
206f89e2
...
...
@@ -27,7 +27,7 @@
#define FLO_EPSILON DBL_EPSILON
#endif
mrb_float
MRB_API
mrb_float
mrb_to_flo
(
mrb_state
*
mrb
,
mrb_value
val
)
{
switch
(
mrb_type
(
val
))
{
...
...
@@ -76,7 +76,7 @@ num_pow(mrb_state *mrb, mrb_value x)
* result.
*/
mrb_value
MRB_API
mrb_value
mrb_num_div
(
mrb_state
*
mrb
,
mrb_value
x
,
mrb_value
y
)
{
return
mrb_float_value
(
mrb
,
mrb_to_flo
(
mrb
,
x
)
/
mrb_to_flo
(
mrb
,
y
));
...
...
@@ -1076,7 +1076,7 @@ fix_to_f(mrb_state *mrb, mrb_value num)
* FloatDomainError: Infinity
*/
/* ------------------------------------------------------------------------*/
mrb_value
MRB_API
mrb_value
mrb_flo_to_fixnum
(
mrb_state
*
mrb
,
mrb_value
x
)
{
mrb_int
z
;
...
...
@@ -1174,7 +1174,7 @@ fix_minus(mrb_state *mrb, mrb_value self)
}
mrb_value
MRB_API
mrb_value
mrb_fixnum_to_str
(
mrb_state
*
mrb
,
mrb_value
x
,
int
base
)
{
char
buf
[
MRB_INT_BIT
+
1
];
...
...
src/object.c
View file @
206f89e2
...
...
@@ -9,7 +9,7 @@
#include "mruby/numeric.h"
#include "mruby/string.h"
mrb_bool
MRB_API
mrb_bool
mrb_obj_eq
(
mrb_state
*
mrb
,
mrb_value
v1
,
mrb_value
v2
)
{
if
(
mrb_type
(
v1
)
!=
mrb_type
(
v2
))
return
FALSE
;
...
...
@@ -31,14 +31,14 @@ mrb_obj_eq(mrb_state *mrb, mrb_value v1, mrb_value v2)
}
}
mrb_bool
MRB_API
mrb_bool
mrb_obj_equal
(
mrb_state
*
mrb
,
mrb_value
v1
,
mrb_value
v2
)
{
/* temporary definition */
return
mrb_obj_eq
(
mrb
,
v1
,
v2
);
}
mrb_bool
MRB_API
mrb_bool
mrb_equal
(
mrb_state
*
mrb
,
mrb_value
obj1
,
mrb_value
obj2
)
{
mrb_value
result
;
...
...
@@ -319,7 +319,7 @@ convert_type(mrb_state *mrb, mrb_value val, const char *tname, const char *metho
return
mrb_funcall_argv
(
mrb
,
val
,
m
,
0
,
0
);
}
mrb_value
MRB_API
mrb_value
mrb_check_to_integer
(
mrb_state
*
mrb
,
mrb_value
val
,
const
char
*
method
)
{
mrb_value
v
;
...
...
@@ -332,7 +332,7 @@ mrb_check_to_integer(mrb_state *mrb, mrb_value val, const char *method)
return
v
;
}
mrb_value
MRB_API
mrb_value
mrb_convert_type
(
mrb_state
*
mrb
,
mrb_value
val
,
enum
mrb_vtype
type
,
const
char
*
tname
,
const
char
*
method
)
{
mrb_value
v
;
...
...
@@ -346,7 +346,7 @@ mrb_convert_type(mrb_state *mrb, mrb_value val, enum mrb_vtype type, const char
return
v
;
}
mrb_value
MRB_API
mrb_value
mrb_check_convert_type
(
mrb_state
*
mrb
,
mrb_value
val
,
enum
mrb_vtype
type
,
const
char
*
tname
,
const
char
*
method
)
{
mrb_value
v
;
...
...
@@ -386,7 +386,7 @@ static const struct types {
{
-
1
,
0
}
};
void
MRB_API
void
mrb_check_type
(
mrb_state
*
mrb
,
mrb_value
x
,
enum
mrb_vtype
t
)
{
const
struct
types
*
type
=
builtin_types
;
...
...
@@ -434,7 +434,7 @@ mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t)
* initial execution context of Ruby programs returns ``main.''
*/
mrb_value
MRB_API
mrb_value
mrb_any_to_s
(
mrb_state
*
mrb
,
mrb_value
obj
)
{
mrb_value
str
=
mrb_str_buf_new
(
mrb
,
20
);
...
...
@@ -475,7 +475,7 @@ mrb_any_to_s(mrb_state *mrb, mrb_value obj)
* b.kind_of? M #=> true
*/
mrb_bool
MRB_API
mrb_bool
mrb_obj_is_kind_of
(
mrb_state
*
mrb
,
mrb_value
obj
,
struct
RClass
*
c
)
{
struct
RClass
*
cl
=
mrb_class
(
mrb
,
obj
);
...
...
@@ -513,7 +513,7 @@ mrb_to_integer(mrb_state *mrb, mrb_value val, const char *method)
return
v
;
}
mrb_value
MRB_API
mrb_value
mrb_to_int
(
mrb_state
*
mrb
,
mrb_value
val
)
{
return
mrb_to_integer
(
mrb
,
val
,
"to_int"
);
...
...
@@ -558,13 +558,13 @@ arg_error:
return
tmp
;
}
mrb_value
MRB_API
mrb_value
mrb_Integer
(
mrb_state
*
mrb
,
mrb_value
val
)
{
return
mrb_convert_to_integer
(
mrb
,
val
,
0
);
}
mrb_value
MRB_API
mrb_value
mrb_Float
(
mrb_state
*
mrb
,
mrb_value
val
)
{
if
(
mrb_nil_p
(
val
))
{
...
...
@@ -585,13 +585,13 @@ mrb_Float(mrb_state *mrb, mrb_value val)
}
}
mrb_value
MRB_API
mrb_value
mrb_inspect
(
mrb_state
*
mrb
,
mrb_value
obj
)
{
return
mrb_obj_as_string
(
mrb
,
mrb_funcall
(
mrb
,
obj
,
"inspect"
,
0
));
}
mrb_bool
MRB_API
mrb_bool
mrb_eql
(
mrb_state
*
mrb
,
mrb_value
obj1
,
mrb_value
obj2
)
{
if
(
mrb_obj_eq
(
mrb
,
obj1
,
obj2
))
return
TRUE
;
...
...
src/print.c
View file @
206f89e2
...
...
@@ -23,7 +23,7 @@ printstr(mrb_state *mrb, mrb_value obj)
#endif
}
void
MRB_API
void
mrb_p
(
mrb_state
*
mrb
,
mrb_value
obj
)
{
#ifdef ENABLE_STDIO
...
...
@@ -33,7 +33,7 @@ mrb_p(mrb_state *mrb, mrb_value obj)
#endif
}
void
MRB_API
void
mrb_print_error
(
mrb_state
*
mrb
)
{
#ifdef ENABLE_STDIO
...
...
@@ -48,7 +48,7 @@ mrb_print_error(mrb_state *mrb)
#endif
}
void
MRB_API
void
mrb_show_version
(
mrb_state
*
mrb
)
{
mrb_value
msg
;
...
...
@@ -58,7 +58,7 @@ mrb_show_version(mrb_state *mrb)
printstr
(
mrb
,
mrb_str_new_lit
(
mrb
,
"
\n
"
));
}
void
MRB_API
void
mrb_show_copyright
(
mrb_state
*
mrb
)
{
mrb_value
msg
;
...
...
src/proc.c
View file @
206f89e2
...
...
@@ -75,7 +75,7 @@ mrb_proc_new_cfunc(mrb_state *mrb, mrb_func_t func)
return
p
;
}
struct
RProc
*
MRB_API
struct
RProc
*
mrb_closure_new_cfunc
(
mrb_state
*
mrb
,
mrb_func_t
func
,
int
nlocals
)
{
struct
RProc
*
p
=
mrb_proc_new_cfunc
(
mrb
,
func
);
...
...
src/range.c
View file @
206f89e2
...
...
@@ -33,7 +33,7 @@ range_check(mrb_state *mrb, mrb_value a, mrb_value b)
}
}
mrb_value
MRB_API
mrb_value
mrb_range_new
(
mrb_state
*
mrb
,
mrb_value
beg
,
mrb_value
end
,
mrb_bool
excl
)
{
struct
RRange
*
r
;
...
...
@@ -234,7 +234,7 @@ mrb_range_include(mrb_state *mrb, mrb_value range)
return
mrb_bool_value
(
include_p
);
}
mrb_bool
MRB_API
mrb_bool
range_beg_len
(
mrb_state
*
mrb
,
mrb_value
range
,
mrb_int
*
begp
,
mrb_int
*
lenp
,
mrb_int
len
,
mrb_bool
trunc
)
{
mrb_int
beg
,
end
,
b
,
e
;
...
...
src/state.c
View file @
206f89e2
...
...
@@ -22,7 +22,7 @@ inspect_main(mrb_state *mrb, mrb_value mod)
return
mrb_str_new_lit
(
mrb
,
"main"
);
}
mrb_state
*
MRB_API
mrb_state
*
mrb_open_core
(
mrb_allocf
f
,
void
*
ud
)
{
static
const
mrb_state
mrb_state_zero
=
{
0
};
...
...
@@ -70,7 +70,7 @@ struct alloca_header {
char
buf
[];
};
void
*
MRB_API
void
*
mrb_alloca
(
mrb_state
*
mrb
,
size_t
size
)
{
struct
alloca_header
*
p
;
...
...
@@ -97,7 +97,7 @@ mrb_alloca_free(mrb_state *mrb)
}
}
mrb_state
*
MRB_API
mrb_state
*
mrb_open
(
void
)
{
mrb_state
*
mrb
=
mrb_open_allocf
(
mrb_default_allocf
,
NULL
);
...
...
@@ -105,7 +105,7 @@ mrb_open(void)
return
mrb
;
}
mrb_state
*
MRB_API
mrb_state
*
mrb_open_allocf
(
mrb_allocf
f
,
void
*
ud
)
{
mrb_state
*
mrb
=
mrb_open_core
(
f
,
ud
);
...
...
@@ -216,7 +216,7 @@ mrb_str_pool(mrb_state *mrb, mrb_value str)
return
mrb_obj_value
(
ns
);
}
void
MRB_API
void
mrb_free_context
(
mrb_state
*
mrb
,
struct
mrb_context
*
c
)
{
if
(
!
c
)
return
;
...
...
@@ -227,7 +227,7 @@ mrb_free_context(mrb_state *mrb, struct mrb_context *c)
mrb_free
(
mrb
,
c
);
}
void
MRB_API
void
mrb_close
(
mrb_state
*
mrb
)
{
if
(
mrb
->
atexit_stack_len
>
0
)
{
...
...
@@ -265,7 +265,7 @@ mrb_add_irep(mrb_state *mrb)
return
irep
;
}
mrb_value
MRB_API
mrb_value
mrb_top_self
(
mrb_state
*
mrb
)
{
if
(
!
mrb
->
top_self
)
{
...
...
@@ -276,7 +276,7 @@ mrb_top_self(mrb_state *mrb)
return
mrb_obj_value
(
mrb
->
top_self
);
}
void
MRB_API
void
mrb_state_atexit
(
mrb_state
*
mrb
,
mrb_atexit_func
f
)
{
#ifdef MRB_FIXED_STATE_ATEXIT_STACK
...
...
src/string.c
View file @
206f89e2
...
...
@@ -29,7 +29,7 @@ typedef struct mrb_shared_string {
static
mrb_value
str_replace
(
mrb_state
*
mrb
,
struct
RString
*
s1
,
struct
RString
*
s2
);
static
mrb_value
mrb_str_subseq
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_int
beg
,
mrb_int
len
);
mrb_int
MRB_API
mrb_int
mrb_str_strlen
(
mrb_state
*
mrb
,
struct
RString
*
s
)
{
mrb_int
i
,
max
=
RSTR_LEN
(
s
);
...
...
@@ -76,7 +76,7 @@ str_decref(mrb_state *mrb, mrb_shared_string *shared)
}
}
void
MRB_API
void
mrb_str_modify
(
mrb_state
*
mrb
,
struct
RString
*
s
)
{
if
(
RSTR_SHARED_P
(
s
))
{
...
...
@@ -120,7 +120,7 @@ mrb_str_modify(mrb_state *mrb, struct RString *s)
}
}
mrb_value
MRB_API
mrb_value
mrb_str_resize
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_int
len
)
{
mrb_int
slen
;
...
...
@@ -186,7 +186,7 @@ mrb_str_new_empty(mrb_state *mrb, mrb_value str)
# define MRB_STR_BUF_MIN_SIZE 128
#endif
mrb_value
MRB_API
mrb_value
mrb_str_buf_new
(
mrb_state
*
mrb
,
size_t
capa
)
{
struct
RString
*
s
;
...
...
@@ -248,7 +248,7 @@ str_buf_cat(mrb_state *mrb, struct RString *s, const char *ptr, size_t len)
RSTR_PTR
(
s
)[
total
]
=
'\0'
;
/* sentinel */
}
mrb_value
MRB_API
mrb_value
mrb_str_new
(
mrb_state
*
mrb
,
const
char
*
p
,
size_t
len
)
{
return
mrb_obj_value
(
str_new
(
mrb
,
p
,
len
));
...
...
@@ -261,7 +261,7 @@ mrb_str_new(mrb_state *mrb, const char *p, size_t len)
* Returns a new string object containing a copy of <i>str</i>.
*/
mrb_value
MRB_API
mrb_value
mrb_str_new_cstr
(
mrb_state
*
mrb
,
const
char
*
p
)
{
struct
RString
*
s
;
...
...
@@ -279,7 +279,7 @@ mrb_str_new_cstr(mrb_state *mrb, const char *p)
return
mrb_obj_value
(
s
);
}
mrb_value
MRB_API
mrb_value
mrb_str_new_static
(
mrb_state
*
mrb
,
const
char
*
p
,
size_t
len
)
{
struct
RString
*
s
;
...
...
@@ -306,7 +306,7 @@ mrb_gc_free_str(mrb_state *mrb, struct RString *str)
mrb_free
(
mrb
,
str
->
as
.
heap
.
ptr
);
}
char
*
MRB_API
const
char
*
mrb_str_to_cstr
(
mrb_state
*
mrb
,
mrb_value
str0
)
{
struct
RString
*
s
;
...
...
@@ -366,7 +366,7 @@ str_make_shared(mrb_state *mrb, struct RString *s)
*
* Returns a new string object containing a copy of <i>str</i>.
*/
void
MRB_API
void
mrb_str_concat
(
mrb_state
*
mrb
,
mrb_value
self
,
mrb_value
other
)
{
struct
RString
*
s1
=
mrb_str_ptr
(
self
),
*
s2
;
...
...
@@ -445,7 +445,7 @@ mrb_str_bytesize(mrb_state *mrb, mrb_value self)
*
* Returns a new string object containing a copy of <i>str</i>.
*/
mrb_value
MRB_API
mrb_value
mrb_str_size
(
mrb_state
*
mrb
,
mrb_value
self
)
{
struct
RString
*
s
=
mrb_str_ptr
(
self
);
...
...
@@ -506,7 +506,7 @@ mrb_str_times(mrb_state *mrb, mrb_value self)
* = 0
* < -1
*/
int
MRB_API
int
mrb_str_cmp
(
mrb_state
*
mrb
,
mrb_value
str1
,
mrb_value
str2
)
{
mrb_int
len
;
...
...
@@ -592,7 +592,7 @@ str_eql(mrb_state *mrb, const mrb_value str1, const mrb_value str2)
return
FALSE
;
}
mrb_bool
MRB_API
mrb_bool
mrb_str_equal
(
mrb_state
*
mrb
,
mrb_value
str1
,
mrb_value
str2
)
{
if
(
mrb_immediate_p
(
str2
))
return
FALSE
;
...
...
@@ -643,7 +643,7 @@ mrb_str_to_str(mrb_state *mrb, mrb_value str)
return
str
;
}
char
*
MRB_API
const
char
*
mrb_string_value_ptr
(
mrb_state
*
mrb
,
mrb_value
ptr
)
{
mrb_value
str
=
mrb_str_to_str
(
mrb
,
ptr
);
...
...
@@ -736,7 +736,7 @@ mrb_str_index(mrb_state *mrb, mrb_value str, mrb_value sub, mrb_int offset)
return
pos
+
offset
;
}
mrb_value
MRB_API
mrb_value
mrb_str_dup
(
mrb_state
*
mrb
,
mrb_value
str
)
{
struct
RString
*
s
=
mrb_str_ptr
(
str
);
...
...
@@ -1435,13 +1435,13 @@ mrb_str_init(mrb_state *mrb, mrb_value self)
*
* 'cat and dog'.to_sym #=> :"cat and dog"
*/
mrb_value
MRB_API
mrb_value
mrb_str_intern
(
mrb_state
*
mrb
,
mrb_value
self
)
{
return
mrb_symbol_value
(
mrb_intern_str
(
mrb
,
self
));
}
/* ---------------------------------- */
mrb_value
MRB_API
mrb_value
mrb_obj_as_string
(
mrb_state
*
mrb
,
mrb_value
obj
)
{
mrb_value
str
;
...
...
@@ -1455,7 +1455,7 @@ mrb_obj_as_string(mrb_state *mrb, mrb_value obj)
return
str
;
}
mrb_value
MRB_API
mrb_value
mrb_ptr_to_str
(
mrb_state
*
mrb
,
void
*
p
)
{
struct
RString
*
p_str
;
...
...
@@ -1485,13 +1485,13 @@ mrb_ptr_to_str(mrb_state *mrb, void *p)
return
mrb_obj_value
(
p_str
);
}
mrb_value
MRB_API
mrb_value
mrb_string_type
(
mrb_state
*
mrb
,
mrb_value
str
)
{
return
mrb_convert_type
(
mrb
,
str
,
MRB_TT_STRING
,
"String"
,
"to_str"
);
}
mrb_value
MRB_API
mrb_value
mrb_check_string_type
(
mrb_state
*
mrb
,
mrb_value
str
)
{
return
mrb_check_convert_type
(
mrb
,
str
,
MRB_TT_STRING
,
"String"
,
"to_str"
);
...
...
@@ -1849,7 +1849,7 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)
return
result
;
}
mrb_value
MRB_API
mrb_value
mrb_cstr_to_inum
(
mrb_state
*
mrb
,
const
char
*
str
,
int
base
,
int
badcheck
)
{
const
char
*
p
;
...
...
@@ -1996,7 +1996,7 @@ bad:
return
mrb_fixnum_value
(
0
);
}
char
*
MRB_API
const
char
*
mrb_string_value_cstr
(
mrb_state
*
mrb
,
mrb_value
*
ptr
)
{
struct
RString
*
ps
=
mrb_str_ptr
(
*
ptr
);
...
...
@@ -2010,10 +2010,10 @@ mrb_string_value_cstr(mrb_state *mrb, mrb_value *ptr)
return
p
;
}
mrb_value
MRB_API
mrb_value
mrb_str_to_inum
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_int
base
,
mrb_bool
badcheck
)
{
char
*
s
;
c
onst
c
har
*
s
;
mrb_int
len
;
str
=
mrb_str_to_str
(
mrb
,
str
);
...
...
@@ -2066,7 +2066,7 @@ mrb_str_to_i(mrb_state *mrb, mrb_value self)
return
mrb_str_to_inum
(
mrb
,
self
,
base
,
FALSE
);
}
double
MRB_API
double
mrb_cstr_to_dbl
(
mrb_state
*
mrb
,
const
char
*
p
,
mrb_bool
badcheck
)
{
char
*
end
;
...
...
@@ -2132,7 +2132,7 @@ bad:
return
d
;
}
double
MRB_API
double
mrb_str_to_dbl
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_bool
badcheck
)
{
char
*
s
;
...
...
@@ -2362,26 +2362,26 @@ mrb_str_dump(mrb_state *mrb, mrb_value str)
return
mrb_obj_value
(
result
);
}
mrb_value
MRB_API
mrb_value
mrb_str_cat
(
mrb_state
*
mrb
,
mrb_value
str
,
const
char
*
ptr
,
size_t
len
)
{
str_buf_cat
(
mrb
,
mrb_str_ptr
(
str
),
ptr
,
len
);
return
str
;
}
mrb_value
MRB_API
mrb_value
mrb_str_cat_cstr
(
mrb_state
*
mrb
,
mrb_value
str
,
const
char
*
ptr
)
{
return
mrb_str_cat
(
mrb
,
str
,
ptr
,
strlen
(
ptr
));
}
mrb_value
MRB_API
mrb_value
mrb_str_cat_str
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_value
str2
)
{
return
mrb_str_cat
(
mrb
,
str
,
RSTRING_PTR
(
str2
),
RSTRING_LEN
(
str2
));
}
mrb_value
MRB_API
mrb_value
mrb_str_append
(
mrb_state
*
mrb
,
mrb_value
str
,
mrb_value
str2
)
{
str2
=
mrb_str_to_str
(
mrb
,
str2
);
...
...
src/symbol.c
View file @
206f89e2
...
...
@@ -69,31 +69,31 @@ sym_intern(mrb_state *mrb, const char *name, size_t len, mrb_bool lit)
return
sym
;
}
mrb_sym
MRB_API
mrb_sym
mrb_intern
(
mrb_state
*
mrb
,
const
char
*
name
,
size_t
len
)
{
return
sym_intern
(
mrb
,
name
,
len
,
FALSE
);
}
mrb_sym
MRB_API
mrb_sym
mrb_intern_static
(
mrb_state
*
mrb
,
const
char
*
name
,
size_t
len
)
{
return
sym_intern
(
mrb
,
name
,
len
,
TRUE
);
}
mrb_sym
MRB_API
mrb_sym
mrb_intern_cstr
(
mrb_state
*
mrb
,
const
char
*
name
)
{
return
mrb_intern
(
mrb
,
name
,
strlen
(
name
));
}
mrb_sym
MRB_API
mrb_sym
mrb_intern_str
(
mrb_state
*
mrb
,
mrb_value
str
)
{
return
mrb_intern
(
mrb
,
RSTRING_PTR
(
str
),
RSTRING_LEN
(
str
));
}
mrb_value
MRB_API
mrb_value
mrb_check_intern
(
mrb_state
*
mrb
,
const
char
*
name
,
size_t
len
)
{
khash_t
(
n2s
)
*
h
=
mrb
->
name2sym
;
...
...
@@ -113,20 +113,20 @@ mrb_check_intern(mrb_state *mrb, const char *name, size_t len)
return
mrb_nil_value
();
}
mrb_value
MRB_API
mrb_value
mrb_check_intern_cstr
(
mrb_state
*
mrb
,
const
char
*
name
)
{
return
mrb_check_intern
(
mrb
,
name
,
(
mrb_int
)
strlen
(
name
));
}
mrb_value
MRB_API
mrb_value
mrb_check_intern_str
(
mrb_state
*
mrb
,
mrb_value
str
)
{
return
mrb_check_intern
(
mrb
,
RSTRING_PTR
(
str
),
RSTRING_LEN
(
str
));
}
/* lenp must be a pointer to a size_t variable */
const
char
*
MRB_API
const
char
*
mrb_sym2name_len
(
mrb_state
*
mrb
,
mrb_sym
sym
,
mrb_int
*
lenp
)
{
khash_t
(
n2s
)
*
h
=
mrb
->
name2sym
;
...
...
@@ -233,7 +233,7 @@ sym_equal(mrb_state *mrb, mrb_value sym1)
*
* :fred.id2name #=> "fred"
*/
mrb_value
static
mrb_value
mrb_sym_to_s
(
mrb_state
*
mrb
,
mrb_value
sym
)
{
mrb_sym
id
=
mrb_symbol
(
sym
);
...
...
@@ -409,7 +409,7 @@ sym_inspect(mrb_state *mrb, mrb_value sym)
return
str
;
}
mrb_value
MRB_API
mrb_value
mrb_sym2str
(
mrb_state
*
mrb
,
mrb_sym
sym
)
{
mrb_int
len
;
...
...
@@ -419,7 +419,7 @@ mrb_sym2str(mrb_state *mrb, mrb_sym sym)
return
mrb_str_new_static
(
mrb
,
name
,
len
);
}
const
char
*
MRB_API
const
char
*
mrb_sym2name
(
mrb_state
*
mrb
,
mrb_sym
sym
)
{
mrb_int
len
;
...
...
src/variable.c
View file @
206f89e2
...
...
@@ -466,7 +466,7 @@ obj_iv_p(mrb_value obj)
}
}
mrb_value
MRB_API
mrb_value
mrb_obj_iv_get
(
mrb_state
*
mrb
,
struct
RObject
*
obj
,
mrb_sym
sym
)
{
mrb_value
v
;
...
...
@@ -476,7 +476,7 @@ mrb_obj_iv_get(mrb_state *mrb, struct RObject *obj, mrb_sym sym)
return
mrb_nil_value
();
}
mrb_value
MRB_API
mrb_value
mrb_iv_get
(
mrb_state
*
mrb
,
mrb_value
obj
,
mrb_sym
sym
)
{
if
(
obj_iv_p
(
obj
))
{
...
...
@@ -485,7 +485,7 @@ mrb_iv_get(mrb_state *mrb, mrb_value obj, mrb_sym sym)
return
mrb_nil_value
();
}
void
MRB_API
void
mrb_obj_iv_set
(
mrb_state
*
mrb
,
struct
RObject
*
obj
,
mrb_sym
sym
,
mrb_value
v
)
{
iv_tbl
*
t
=
obj
->
iv
;
...
...
@@ -497,7 +497,7 @@ mrb_obj_iv_set(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v)
iv_put
(
mrb
,
t
,
sym
,
v
);
}
void
MRB_API
void
mrb_obj_iv_ifnone
(
mrb_state
*
mrb
,
struct
RObject
*
obj
,
mrb_sym
sym
,
mrb_value
v
)
{
iv_tbl
*
t
=
obj
->
iv
;
...
...
@@ -512,7 +512,7 @@ mrb_obj_iv_ifnone(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v)
iv_put
(
mrb
,
t
,
sym
,
v
);
}
void
MRB_API
void
mrb_iv_set
(
mrb_state
*
mrb
,
mrb_value
obj
,
mrb_sym
sym
,
mrb_value
v
)
{
if
(
obj_iv_p
(
obj
))
{
...
...
@@ -523,7 +523,7 @@ mrb_iv_set(mrb_state *mrb, mrb_value obj, mrb_sym sym, mrb_value v)
}
}
mrb_bool
MRB_API
mrb_bool
mrb_obj_iv_defined
(
mrb_state
*
mrb
,
struct
RObject
*
obj
,
mrb_sym
sym
)
{
iv_tbl
*
t
;
...
...
@@ -535,14 +535,14 @@ mrb_obj_iv_defined(mrb_state *mrb, struct RObject *obj, mrb_sym sym)
return
FALSE
;
}
mrb_bool
MRB_API
mrb_bool
mrb_iv_defined
(
mrb_state
*
mrb
,
mrb_value
obj
,
mrb_sym
sym
)
{
if
(
!
obj_iv_p
(
obj
))
return
FALSE
;
return
mrb_obj_iv_defined
(
mrb
,
mrb_obj_ptr
(
obj
),
sym
);
}
void
MRB_API
void
mrb_iv_copy
(
mrb_state
*
mrb
,
mrb_value
dest
,
mrb_value
src
)
{
struct
RObject
*
d
=
mrb_obj_ptr
(
dest
);
...
...
@@ -609,7 +609,7 @@ mrb_obj_iv_inspect(mrb_state *mrb, struct RObject *obj)
return
mrb_any_to_s
(
mrb
,
mrb_obj_value
(
obj
));
}
mrb_value
MRB_API
mrb_value
mrb_iv_remove
(
mrb_state
*
mrb
,
mrb_value
obj
,
mrb_sym
sym
)
{
if
(
obj_iv_p
(
obj
))
{
...
...
@@ -729,7 +729,7 @@ mrb_mod_class_variables(mrb_state *mrb, mrb_value mod)
return
ary
;
}
mrb_value
MRB_API
mrb_value
mrb_mod_cv_get
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
sym
)
{
struct
RClass
*
cls
=
c
;
...
...
@@ -750,13 +750,13 @@ mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym)
return
mrb_nil_value
();
}
mrb_value
MRB_API
mrb_value
mrb_cv_get
(
mrb_state
*
mrb
,
mrb_value
mod
,
mrb_sym
sym
)
{
return
mrb_mod_cv_get
(
mrb
,
mrb_class_ptr
(
mod
),
sym
);
}
void
MRB_API
void
mrb_mod_cv_set
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
sym
,
mrb_value
v
)
{
struct
RClass
*
cls
=
c
;
...
...
@@ -782,13 +782,13 @@ mrb_mod_cv_set(mrb_state *mrb, struct RClass *c, mrb_sym sym, mrb_value v)
iv_put
(
mrb
,
cls
->
iv
,
sym
,
v
);
}
void
MRB_API
void
mrb_cv_set
(
mrb_state
*
mrb
,
mrb_value
mod
,
mrb_sym
sym
,
mrb_value
v
)
{
mrb_mod_cv_set
(
mrb
,
mrb_class_ptr
(
mod
),
sym
,
v
);
}
mrb_bool
MRB_API
mrb_bool
mrb_mod_cv_defined
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_sym
sym
)
{
while
(
c
)
{
...
...
@@ -802,13 +802,13 @@ mrb_mod_cv_defined(mrb_state *mrb, struct RClass * c, mrb_sym sym)
return
FALSE
;
}
mrb_bool
MRB_API
mrb_bool
mrb_cv_defined
(
mrb_state
*
mrb
,
mrb_value
mod
,
mrb_sym
sym
)
{
return
mrb_mod_cv_defined
(
mrb
,
mrb_class_ptr
(
mod
),
sym
);
}
mrb_value
MRB_API
mrb_value
mrb_vm_cv_get
(
mrb_state
*
mrb
,
mrb_sym
sym
)
{
struct
RClass
*
c
=
mrb
->
c
->
ci
->
proc
->
target_class
;
...
...
@@ -818,7 +818,7 @@ mrb_vm_cv_get(mrb_state *mrb, mrb_sym sym)
return
mrb_mod_cv_get
(
mrb
,
c
,
sym
);
}
void
MRB_API
void
mrb_vm_cv_set
(
mrb_state
*
mrb
,
mrb_sym
sym
,
mrb_value
v
)
{
struct
RClass
*
c
=
mrb
->
c
->
ci
->
proc
->
target_class
;
...
...
@@ -827,7 +827,7 @@ mrb_vm_cv_set(mrb_state *mrb, mrb_sym sym, mrb_value v)
mrb_mod_cv_set
(
mrb
,
c
,
sym
,
v
);
}
mrb_bool
MRB_API
mrb_bool
mrb_const_defined
(
mrb_state
*
mrb
,
mrb_value
mod
,
mrb_sym
sym
)
{
struct
RClass
*
m
=
mrb_class_ptr
(
mod
);
...
...
@@ -878,7 +878,7 @@ L_RETRY:
return
mrb_funcall_argv
(
mrb
,
mrb_obj_value
(
base
),
mrb_intern_lit
(
mrb
,
"const_missing"
),
1
,
&
name
);
}
mrb_value
MRB_API
mrb_value
mrb_const_get
(
mrb_state
*
mrb
,
mrb_value
mod
,
mrb_sym
sym
)
{
mod_const_check
(
mrb
,
mod
);
...
...
@@ -910,14 +910,14 @@ mrb_vm_const_get(mrb_state *mrb, mrb_sym sym)
return
const_get
(
mrb
,
c
,
sym
);
}
void
MRB_API
void
mrb_const_set
(
mrb_state
*
mrb
,
mrb_value
mod
,
mrb_sym
sym
,
mrb_value
v
)
{
mod_const_check
(
mrb
,
mod
);
mrb_iv_set
(
mrb
,
mod
,
sym
,
v
);
}
void
void
mrb_vm_const_set
(
mrb_state
*
mrb
,
mrb_sym
sym
,
mrb_value
v
)
{
struct
RClass
*
c
=
mrb
->
c
->
ci
->
proc
->
target_class
;
...
...
@@ -926,20 +926,20 @@ mrb_vm_const_set(mrb_state *mrb, mrb_sym sym, mrb_value v)
mrb_obj_iv_set
(
mrb
,
(
struct
RObject
*
)
c
,
sym
,
v
);
}
void
MRB_API
void
mrb_const_remove
(
mrb_state
*
mrb
,
mrb_value
mod
,
mrb_sym
sym
)
{
mod_const_check
(
mrb
,
mod
);
mrb_iv_remove
(
mrb
,
mod
,
sym
);
}
void
MRB_API
void
mrb_define_const
(
mrb_state
*
mrb
,
struct
RClass
*
mod
,
const
char
*
name
,
mrb_value
v
)
{
mrb_obj_iv_set
(
mrb
,
(
struct
RObject
*
)
mod
,
mrb_intern_cstr
(
mrb
,
name
),
v
);
}
void
MRB_API
void
mrb_define_global_const
(
mrb_state
*
mrb
,
const
char
*
name
,
mrb_value
val
)
{
mrb_define_const
(
mrb
,
mrb
->
object_class
,
name
,
val
);
...
...
@@ -987,7 +987,7 @@ mrb_mod_constants(mrb_state *mrb, mrb_value mod)
return
ary
;
}
mrb_value
MRB_API
mrb_value
mrb_gv_get
(
mrb_state
*
mrb
,
mrb_sym
sym
)
{
mrb_value
v
;
...
...
@@ -1000,7 +1000,7 @@ mrb_gv_get(mrb_state *mrb, mrb_sym sym)
return
mrb_nil_value
();
}
void
MRB_API
void
mrb_gv_set
(
mrb_state
*
mrb
,
mrb_sym
sym
,
mrb_value
v
)
{
iv_tbl
*
t
;
...
...
@@ -1014,7 +1014,7 @@ mrb_gv_set(mrb_state *mrb, mrb_sym sym, mrb_value v)
iv_put
(
mrb
,
t
,
sym
,
v
);
}
void
MRB_API
void
mrb_gv_remove
(
mrb_state
*
mrb
,
mrb_sym
sym
)
{
if
(
!
mrb
->
globals
)
{
...
...
@@ -1086,7 +1086,7 @@ retry:
return
FALSE
;
}
mrb_bool
MRB_API
mrb_bool
mrb_const_defined_at
(
mrb_state
*
mrb
,
struct
RClass
*
klass
,
mrb_sym
id
)
{
return
mrb_const_defined_0
(
mrb
,
klass
,
id
,
TRUE
,
FALSE
);
...
...
src/vm.c
View file @
206f89e2
...
...
@@ -292,7 +292,7 @@ ecall(mrb_state *mrb, int i)
#define MRB_FUNCALL_ARGC_MAX 16
#endif
mrb_value
MRB_API
mrb_value
mrb_funcall
(
mrb_state
*
mrb
,
mrb_value
self
,
const
char
*
name
,
mrb_int
argc
,
...)
{
mrb_value
argv
[
MRB_FUNCALL_ARGC_MAX
];
...
...
@@ -312,7 +312,7 @@ mrb_funcall(mrb_state *mrb, mrb_value self, const char *name, mrb_int argc, ...)
return
mrb_funcall_argv
(
mrb
,
self
,
mid
,
argc
,
argv
);
}
mrb_value
MRB_API
mrb_value
mrb_funcall_with_block
(
mrb_state
*
mrb
,
mrb_value
self
,
mrb_sym
mid
,
mrb_int
argc
,
const
mrb_value
*
argv
,
mrb_value
blk
)
{
mrb_value
val
;
...
...
@@ -404,7 +404,7 @@ mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc
return
val
;
}
mrb_value
MRB_API
mrb_value
mrb_funcall_argv
(
mrb_state
*
mrb
,
mrb_value
self
,
mrb_sym
mid
,
mrb_int
argc
,
const
mrb_value
*
argv
)
{
return
mrb_funcall_with_block
(
mrb
,
self
,
mid
,
argc
,
argv
,
mrb_nil_value
());
...
...
@@ -429,7 +429,7 @@ mrb_funcall_argv(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc, cons
* k = Klass.new
* k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
*/
mrb_value
MRB_API
mrb_value
mrb_f_send
(
mrb_state
*
mrb
,
mrb_value
self
)
{
mrb_sym
name
;
...
...
@@ -573,7 +573,7 @@ mrb_obj_instance_eval(mrb_state *mrb, mrb_value self)
return
eval_under
(
mrb
,
self
,
b
,
c
);
}
mrb_value
MRB_API
mrb_value
mrb_yield_with_class
(
mrb_state
*
mrb
,
mrb_value
b
,
mrb_int
argc
,
const
mrb_value
*
argv
,
mrb_value
self
,
struct
RClass
*
c
)
{
struct
RProc
*
p
;
...
...
@@ -620,7 +620,7 @@ mrb_yield_with_class(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value
return
val
;
}
mrb_value
MRB_API
mrb_value
mrb_yield_argv
(
mrb_state
*
mrb
,
mrb_value
b
,
mrb_int
argc
,
const
mrb_value
*
argv
)
{
struct
RProc
*
p
=
mrb_proc_ptr
(
b
);
...
...
@@ -628,7 +628,7 @@ mrb_yield_argv(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv)
return
mrb_yield_with_class
(
mrb
,
b
,
argc
,
argv
,
p
->
env
->
stack
[
0
],
p
->
target_class
);
}
mrb_value
MRB_API
mrb_value
mrb_yield
(
mrb_state
*
mrb
,
mrb_value
b
,
mrb_value
arg
)
{
struct
RProc
*
p
=
mrb_proc_ptr
(
b
);
...
...
@@ -713,7 +713,7 @@ void mrb_gv_val_set(mrb_state *mrb, mrb_sym sym, mrb_value val);
#define CALL_MAXARGS 127
mrb_value
MRB_API
mrb_value
mrb_context_run
(
mrb_state
*
mrb
,
struct
RProc
*
proc
,
mrb_value
self
,
unsigned
int
stack_keep
)
{
/* mrb_assert(mrb_proc_cfunc_p(proc)) */
...
...
@@ -2360,13 +2360,13 @@ RETRY_TRY_BLOCK:
MRB_END_EXC
(
&
c_jmp
);
}
mrb_value
MRB_API
mrb_value
mrb_run
(
mrb_state
*
mrb
,
struct
RProc
*
proc
,
mrb_value
self
)
{
return
mrb_context_run
(
mrb
,
proc
,
self
,
mrb
->
c
->
ci
->
argc
+
2
);
/* argc + 2 (receiver and block) */
}
mrb_value
MRB_API
mrb_value
mrb_toplevel_run_keep
(
mrb_state
*
mrb
,
struct
RProc
*
proc
,
unsigned
int
stack_keep
)
{
mrb_callinfo
*
ci
;
...
...
@@ -2384,7 +2384,7 @@ mrb_toplevel_run_keep(mrb_state *mrb, struct RProc *proc, unsigned int stack_kee
return
v
;
}
mrb_value
MRB_API
mrb_value
mrb_toplevel_run
(
mrb_state
*
mrb
,
struct
RProc
*
proc
)
{
return
mrb_toplevel_run_keep
(
mrb
,
proc
,
0
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment