Commit e47f0fc0 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2959 from sagmor/api-documentation

C API documentation
parents 73dc32c6 4c8205db
...@@ -100,15 +100,4 @@ ...@@ -100,15 +100,4 @@
# define TRUE 1 # define TRUE 1
#endif #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 */ #endif /* MRUBYCONF_H */
This diff is collapsed.
...@@ -7,9 +7,16 @@ ...@@ -7,9 +7,16 @@
#ifndef MRUBY_ARRAY_H #ifndef MRUBY_ARRAY_H
#define MRUBY_ARRAY_H #define MRUBY_ARRAY_H
#if defined(__cplusplus) #include "mruby/common.h"
extern "C" {
#endif /**
* @file mruby/array.h
* @defgroup mruby_array Array class
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
typedef struct mrb_shared_array { typedef struct mrb_shared_array {
int refcnt; int refcnt;
...@@ -41,15 +48,93 @@ struct RArray { ...@@ -41,15 +48,93 @@ struct RArray {
void mrb_ary_decref(mrb_state*, mrb_shared_array*); void mrb_ary_decref(mrb_state*, mrb_shared_array*);
MRB_API void mrb_ary_modify(mrb_state*, struct RArray*); 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_capa(mrb_state*, mrb_int);
/**
* Initializes a new array.
*
* Equivalent to:
*
* Array.new
*
* @param mrb
* The MRuby state reference.
* @returns
* The initialized array
*/
MRB_API mrb_value mrb_ary_new(mrb_state *mrb); 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_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 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 void mrb_ary_concat(mrb_state*, mrb_value, mrb_value);
MRB_API mrb_value mrb_ary_splat(mrb_state*, 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);
/**
* Pushes value into array.
*
* Equivalent to:
*
* ary << value
*
* @param mrb
* The MRuby state reference.
* @param ary
* The array in which the value will be pushed
* @param value
* The value to be pushed into array
*/
MRB_API void mrb_ary_push(mrb_state *mrb, mrb_value array, mrb_value value);
/**
* Pops the last element from the array.
*
* Equivalent to:
*
* ary.pop
*
* @param mrb
* The MRuby state reference.
* @param ary
* The array from which the value will be poped.
* @returns
* The poped value.
*/
MRB_API mrb_value mrb_ary_pop(mrb_state *mrb, mrb_value ary); MRB_API mrb_value mrb_ary_pop(mrb_state *mrb, mrb_value ary);
/**
* Returns a reference to an element of the array on the given index.
*
* Equivalent to:
*
* ary[n]
*
* @param mrb
* The MRuby state reference.
* @param ary
* The target array.
* @param n
* The array index being referenced
* @returns
* The referenced value.
*/
MRB_API mrb_value mrb_ary_ref(mrb_state *mrb, mrb_value ary, mrb_int n); MRB_API mrb_value mrb_ary_ref(mrb_state *mrb, mrb_value ary, mrb_int n);
/**
* Sets a value on an array at the given index
*
* Equivalent to:
*
* ary[n] = val
*
* @param mrb
* The MRuby state reference.
* @param ary
* The target array.
* @param n
* The array index being referenced.
* @param val
* The value being setted.
*/
MRB_API void mrb_ary_set(mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val); 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 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_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_unshift(mrb_state *mrb, mrb_value self, mrb_value item);
...@@ -67,8 +152,7 @@ mrb_ary_len(mrb_state *mrb, mrb_value ary) ...@@ -67,8 +152,7 @@ mrb_ary_len(mrb_state *mrb, mrb_value ary)
return RARRAY_LEN(ary); return RARRAY_LEN(ary);
} }
#if defined(__cplusplus) /** @} */
} /* extern "C" { */ MRB_END_DECL
#endif
#endif /* MRUBY_ARRAY_H */ #endif /* MRUBY_ARRAY_H */
...@@ -7,9 +7,15 @@ ...@@ -7,9 +7,15 @@
#ifndef MRUBY_CLASS_H #ifndef MRUBY_CLASS_H
#define MRUBY_CLASS_H #define MRUBY_CLASS_H
#if defined(__cplusplus) #include "mruby/common.h"
extern "C" {
#endif /**
* @file mruby/class.h
* @defgroup mruby_class Class class
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
struct RClass { struct RClass {
MRB_OBJECT_HEADER; MRB_OBJECT_HEADER;
...@@ -81,8 +87,7 @@ void mrb_gc_mark_mt(mrb_state*, struct RClass*); ...@@ -81,8 +87,7 @@ void mrb_gc_mark_mt(mrb_state*, struct RClass*);
size_t mrb_gc_mark_mt_size(mrb_state*, struct RClass*); size_t mrb_gc_mark_mt_size(mrb_state*, struct RClass*);
void mrb_gc_free_mt(mrb_state*, struct RClass*); void mrb_gc_free_mt(mrb_state*, struct RClass*);
#if defined(__cplusplus) /** @} */
} /* extern "C" { */ MRB_END_DECL
#endif
#endif /* MRUBY_CLASS_H */ #endif /* MRUBY_CLASS_H */
/*
** mruby/common.h - mruby common platform definitions
**
** See Copyright Notice in mruby.h
*/
#ifndef MRUBY_COMMON_H
#define MRUBY_COMMON_H
/**
* @file mruby/common.h
* @defgroup mruby_common Shared compiler macros
* @ingroup mruby
* @{
*/
#ifdef __cplusplus
# define MRB_BEGIN_DECL extern "C" {
# define MRB_END_DECL }
#else
/** Start declarations in C mode */
# define MRB_BEGIN_DECL
/** End declarations in C mode */
# define MRB_END_DECL
#endif
/** Declare a function that never returns. */
#if __STDC_VERSION__ >= 201112L
# define mrb_noreturn _Noreturn
#elif defined __GNUC__ && !defined __STRICT_ANSI__
# define mrb_noreturn __attribute__((noreturn))
#elif defined _MSC_VER
# define mrb_noreturn __declspec(noreturn)
#else
# define mrb_noreturn
#endif
/** Mark a function as deprecated. */
#if defined __GNUC__ && !defined __STRICT_ANSI__
# define mrb_deprecated __attribute__((deprecated))
#elif defined _MSC_VER
# define mrb_deprecated __declspec(deprecated)
#else
# define mrb_deprecated
#endif
/** Declare a function as always inlined. */
#if defined(_MSC_VER)
# define MRB_INLINE static __inline
#else
# define MRB_INLINE static inline
#endif
/** Declare a public MRuby API function. */
#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 /* MRUBY_COMMON_H */
...@@ -7,9 +7,15 @@ ...@@ -7,9 +7,15 @@
#ifndef MRUBY_COMPILE_H #ifndef MRUBY_COMPILE_H
#define MRUBY_COMPILE_H #define MRUBY_COMPILE_H
#if defined(__cplusplus) #include "mruby/common.h"
extern "C" {
#endif /**
* @file mruby/compile.h
* @defgroup mruby_compile Compiler
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
#include "mruby.h" #include "mruby.h"
...@@ -183,8 +189,7 @@ MRB_API mrb_value mrb_load_file_cxt(mrb_state*,FILE*, mrbc_context *cxt); ...@@ -183,8 +189,7 @@ MRB_API mrb_value mrb_load_file_cxt(mrb_state*,FILE*, 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_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); MRB_API mrb_value mrb_load_nstring_cxt(mrb_state *mrb, const char *s, int len, mrbc_context *cxt);
#if defined(__cplusplus) /** @} */
} /* extern "C" { */ MRB_END_DECL
#endif
#endif /* MRUBY_COMPILE_H */ #endif /* MRUBY_COMPILE_H */
...@@ -7,12 +7,27 @@ ...@@ -7,12 +7,27 @@
#ifndef MRUBY_DATA_H #ifndef MRUBY_DATA_H
#define MRUBY_DATA_H #define MRUBY_DATA_H
#if defined(__cplusplus) #include "mruby/common.h"
extern "C" {
#endif
/**
* @file mruby/data.h
* @defgroup mruby_data Custom C wrapped data.
*
* Defining Ruby wrappers around native objects.
*
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
/**
* Custom data type description.
*/
typedef struct mrb_data_type { typedef struct mrb_data_type {
/** data type name */
const char *struct_name; const char *struct_name;
/** data type release function pointer */
void (*dfree)(mrb_state *mrb, void*); void (*dfree)(mrb_state *mrb, void*);
} mrb_data_type; } mrb_data_type;
...@@ -59,8 +74,7 @@ mrb_data_init(mrb_value v, void *ptr, const mrb_data_type *type) ...@@ -59,8 +74,7 @@ mrb_data_init(mrb_value v, void *ptr, const mrb_data_type *type)
DATA_TYPE(v) = type; DATA_TYPE(v) = type;
} }
#if defined(__cplusplus) /** @} */
} /* extern "C" { */ MRB_END_DECL
#endif
#endif /* MRUBY_DATA_H */ #endif /* MRUBY_DATA_H */
...@@ -7,9 +7,15 @@ ...@@ -7,9 +7,15 @@
#ifndef MRUBY_DEBUG_H #ifndef MRUBY_DEBUG_H
#define MRUBY_DEBUG_H #define MRUBY_DEBUG_H
#if defined(__cplusplus) #include "mruby/common.h"
extern "C" {
#endif /**
* @file mruby/debug.h
* @defgroup mruby_debug Debugging.
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
typedef enum mrb_debug_line_type { typedef enum mrb_debug_line_type {
mrb_debug_line_ary = 0, mrb_debug_line_ary = 0,
...@@ -58,8 +64,7 @@ MRB_API mrb_irep_debug_info_file *mrb_debug_info_append_file( ...@@ -58,8 +64,7 @@ MRB_API mrb_irep_debug_info_file *mrb_debug_info_append_file(
MRB_API mrb_irep_debug_info *mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep); 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); MRB_API void mrb_debug_info_free(mrb_state *mrb, mrb_irep_debug_info *d);
#if defined(__cplusplus) /** @} */
} /* extern "C" { */ MRB_END_DECL
#endif
#endif /* MRUBY_DEBUG_H */ #endif /* MRUBY_DEBUG_H */
...@@ -7,12 +7,17 @@ ...@@ -7,12 +7,17 @@
#ifndef MRUBY_DUMP_H #ifndef MRUBY_DUMP_H
#define MRUBY_DUMP_H #define MRUBY_DUMP_H
#if defined(__cplusplus)
extern "C" {
#endif
#include "mruby.h" #include "mruby.h"
#include "mruby/irep.h" #include "mruby/irep.h"
#include "mruby/common.h"
/**
* @file mruby/dump.h
* @defgroup mruby_dump Dumping compiled mruby script.
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
#define DUMP_DEBUG_INFO 1 #define DUMP_DEBUG_INFO 1
#define DUMP_ENDIAN_BIG 2 #define DUMP_ENDIAN_BIG 2
...@@ -185,11 +190,10 @@ bin_to_uint8(const uint8_t *bin) ...@@ -185,11 +190,10 @@ bin_to_uint8(const uint8_t *bin)
return (uint8_t)bin[0]; return (uint8_t)bin[0];
} }
#if defined(__cplusplus) /** @} */
} /* extern "C" { */ MRB_END_DECL
#endif
/* crc.c */ /** @internal crc.c */
uint16_t uint16_t
calc_crc_16_ccitt(const uint8_t *src, size_t nbytes, uint16_t crc); calc_crc_16_ccitt(const uint8_t *src, size_t nbytes, uint16_t crc);
......
...@@ -7,9 +7,15 @@ ...@@ -7,9 +7,15 @@
#ifndef MRUBY_ERROR_H #ifndef MRUBY_ERROR_H
#define MRUBY_ERROR_H #define MRUBY_ERROR_H
#if defined(__cplusplus) #include "mruby/common.h"
extern "C" {
#endif /**
* @file mruby/error.h
* @defgroup mruby_error Error handling.
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
struct RException { struct RException {
MRB_OBJECT_HEADER; MRB_OBJECT_HEADER;
...@@ -39,8 +45,7 @@ MRB_API mrb_value mrb_rescue_exceptions(mrb_state *mrb, mrb_func_t body, mrb_val ...@@ -39,8 +45,7 @@ MRB_API mrb_value mrb_rescue_exceptions(mrb_state *mrb, mrb_func_t body, mrb_val
mrb_func_t rescue, mrb_value r_data, mrb_func_t rescue, mrb_value r_data,
mrb_int len, struct RClass **classes); mrb_int len, struct RClass **classes);
#if defined(__cplusplus) /** @} */
} /* extern "C" { */ MRB_END_DECL
#endif
#endif /* MRUBY_ERROR_H */ #endif /* MRUBY_ERROR_H */
...@@ -7,16 +7,21 @@ ...@@ -7,16 +7,21 @@
#ifndef MRUBY_GC_H #ifndef MRUBY_GC_H
#define MRUBY_GC_H #define MRUBY_GC_H
#if defined(__cplusplus) #include "mruby/common.h"
extern "C" {
#endif /**
* @file mruby/gc.h
* @defgroup mruby_gc Uncommon memory management stuffs.
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
typedef void (mrb_each_object_callback)(mrb_state *mrb, struct RBasic *obj, void *data); 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_objspace_each_objects(mrb_state *mrb, mrb_each_object_callback *callback, void *data);
MRB_API 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" { */ MRB_END_DECL
#endif
#endif /* MRUBY_GC_H */ #endif /* MRUBY_GC_H */
...@@ -7,9 +7,15 @@ ...@@ -7,9 +7,15 @@
#ifndef MRUBY_HASH_H #ifndef MRUBY_HASH_H
#define MRUBY_HASH_H #define MRUBY_HASH_H
#if defined(__cplusplus) #include "mruby/common.h"
extern "C" {
#endif /**
* @file mruby/hash.h
* @defgroup mruby_hash Hash class
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
struct RHash { struct RHash {
MRB_OBJECT_HEADER; MRB_OBJECT_HEADER;
...@@ -47,8 +53,7 @@ void mrb_gc_mark_hash(mrb_state*, struct RHash*); ...@@ -47,8 +53,7 @@ void mrb_gc_mark_hash(mrb_state*, struct RHash*);
size_t mrb_gc_mark_hash_size(mrb_state*, struct RHash*); size_t mrb_gc_mark_hash_size(mrb_state*, struct RHash*);
void mrb_gc_free_hash(mrb_state*, struct RHash*); void mrb_gc_free_hash(mrb_state*, struct RHash*);
#if defined(__cplusplus) /** @} */
} /* extern "C" { */ MRB_END_DECL
#endif
#endif /* MRUBY_HASH_H */ #endif /* MRUBY_HASH_H */
...@@ -7,12 +7,17 @@ ...@@ -7,12 +7,17 @@
#ifndef MRUBY_IREP_H #ifndef MRUBY_IREP_H
#define MRUBY_IREP_H #define MRUBY_IREP_H
#if defined(__cplusplus) #include "mruby/common.h"
extern "C" {
#endif
#include "mruby/compile.h" #include "mruby/compile.h"
/**
* @file mruby/irep.h
* @defgroup mruby_irep Compiled mruby scripts.
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
enum irep_pool_type { enum irep_pool_type {
IREP_TT_STRING, IREP_TT_STRING,
IREP_TT_FIXNUM, IREP_TT_FIXNUM,
...@@ -53,8 +58,7 @@ void mrb_irep_free(mrb_state*, struct mrb_irep*); ...@@ -53,8 +58,7 @@ void mrb_irep_free(mrb_state*, struct mrb_irep*);
void mrb_irep_incref(mrb_state*, struct mrb_irep*); void mrb_irep_incref(mrb_state*, struct mrb_irep*);
void mrb_irep_decref(mrb_state*, struct mrb_irep*); void mrb_irep_decref(mrb_state*, struct mrb_irep*);
#if defined(__cplusplus) /** @} */
} /* extern "C" { */ MRB_END_DECL
#endif
#endif /* MRUBY_IREP_H */ #endif /* MRUBY_IREP_H */
...@@ -7,12 +7,18 @@ ...@@ -7,12 +7,18 @@
#ifndef MRUBY_KHASH_H #ifndef MRUBY_KHASH_H
#define MRUBY_KHASH_H #define MRUBY_KHASH_H
#if defined(__cplusplus) #include <string.h>
extern "C" {
#endif
#include "mruby.h" #include "mruby.h"
#include <string.h> #include "mruby/common.h"
/**
* @file mruby/khash.h
* @defgroup mruby_khash khash definitions used in mruby's hash table.
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
typedef uint32_t khint_t; typedef uint32_t khint_t;
typedef khint_t khiter_t; typedef khint_t khiter_t;
...@@ -266,8 +272,7 @@ static inline khint_t __ac_X31_hash_string(const char *s) ...@@ -266,8 +272,7 @@ static inline khint_t __ac_X31_hash_string(const char *s)
typedef const char *kh_cstr_t; typedef const char *kh_cstr_t;
#if defined(__cplusplus) /** @} */
} /* extern "C" { */ MRB_END_DECL
#endif
#endif /* MRUBY_KHASH_H */ #endif /* MRUBY_KHASH_H */
...@@ -7,9 +7,18 @@ ...@@ -7,9 +7,18 @@
#ifndef MRUBY_NUMERIC_H #ifndef MRUBY_NUMERIC_H
#define MRUBY_NUMERIC_H #define MRUBY_NUMERIC_H
#if defined(__cplusplus) #include "mruby/common.h"
extern "C" {
#endif /**
* @file mruby/numeric.h
* @defgroup mruby_numeric Numeric class and it's sub-classes.
*
* Numeric, Integer, Float, Fixnum classes
*
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
#define POSFIXABLE(f) ((f) <= MRB_INT_MAX) #define POSFIXABLE(f) ((f) <= MRB_INT_MAX)
#define NEGFIXABLE(f) ((f) >= MRB_INT_MIN) #define NEGFIXABLE(f) ((f) >= MRB_INT_MIN)
...@@ -104,8 +113,7 @@ mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference) ...@@ -104,8 +113,7 @@ mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference)
#undef MRB_UINT_MAKE #undef MRB_UINT_MAKE
#undef MRB_UINT_MAKE2 #undef MRB_UINT_MAKE2
#if defined(__cplusplus) /** @} */
} /* extern "C" { */ MRB_END_DECL
#endif
#endif /* MRUBY_NUMERIC_H */ #endif /* MRUBY_NUMERIC_H */
...@@ -7,11 +7,16 @@ ...@@ -7,11 +7,16 @@
#ifndef MRUBY_PROC_H #ifndef MRUBY_PROC_H
#define MRUBY_PROC_H #define MRUBY_PROC_H
#include "mruby/common.h"
#include "mruby/irep.h" #include "mruby/irep.h"
#if defined(__cplusplus) /**
extern "C" { * @file mruby/proc.h
#endif * @defgroup mruby_proc Proc class
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
struct REnv { struct REnv {
MRB_OBJECT_HEADER; MRB_OBJECT_HEADER;
...@@ -69,8 +74,7 @@ MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state*, mrb_int); ...@@ -69,8 +74,7 @@ MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state*, mrb_int);
#include "mruby/khash.h" #include "mruby/khash.h"
KHASH_DECLARE(mt, mrb_sym, struct RProc*, TRUE) KHASH_DECLARE(mt, mrb_sym, struct RProc*, TRUE)
#if defined(__cplusplus) /** @} */
} /* extern "C" { */ MRB_END_DECL
#endif
#endif /* MRUBY_PROC_H */ #endif /* MRUBY_PROC_H */
...@@ -7,9 +7,15 @@ ...@@ -7,9 +7,15 @@
#ifndef MRUBY_RANGE_H #ifndef MRUBY_RANGE_H
#define MRUBY_RANGE_H #define MRUBY_RANGE_H
#if defined(__cplusplus) #include "mruby/common.h"
extern "C" {
#endif /**
* @file mruby/range.h
* @defgroup mruby_range Range class
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
typedef struct mrb_range_edges { typedef struct mrb_range_edges {
mrb_value beg; mrb_value beg;
...@@ -29,8 +35,7 @@ MRB_API mrb_value mrb_range_new(mrb_state*, mrb_value, mrb_value, mrb_bool); ...@@ -29,8 +35,7 @@ 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_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)); 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) /** @} */
} /* extern "C" { */ MRB_END_DECL
#endif
#endif /* MRUBY_RANGE_H */ #endif /* MRUBY_RANGE_H */
...@@ -7,9 +7,15 @@ ...@@ -7,9 +7,15 @@
#ifndef MRUBY_STRING_H #ifndef MRUBY_STRING_H
#define MRUBY_STRING_H #define MRUBY_STRING_H
#if defined(__cplusplus) #include "mruby/common.h"
extern "C" {
#endif /**
* @file mruby/string.h
* @defgroup mrb_string String class
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
extern const char mrb_digitmap[]; extern const char mrb_digitmap[];
...@@ -120,8 +126,7 @@ void mrb_regexp_check(mrb_state *mrb, mrb_value obj); ...@@ -120,8 +126,7 @@ void mrb_regexp_check(mrb_state *mrb, mrb_value obj);
#define mrb_str_buf_cat(mrb, str, ptr, len) mrb_str_cat(mrb, str, ptr, len) #define mrb_str_buf_cat(mrb, str, ptr, len) mrb_str_cat(mrb, str, ptr, len)
#define mrb_str_buf_append(mrb, str, str2) mrb_str_cat_str(mrb, str, str2) #define mrb_str_buf_append(mrb, str, str2) mrb_str_cat_str(mrb, str, str2)
#if defined(__cplusplus) /** @} */
} /* extern "C" { */ MRB_END_DECL
#endif
#endif /* MRUBY_STRING_H */ #endif /* MRUBY_STRING_H */
...@@ -7,6 +7,19 @@ ...@@ -7,6 +7,19 @@
#ifndef MRUBY_VALUE_H #ifndef MRUBY_VALUE_H
#define MRUBY_VALUE_H #define MRUBY_VALUE_H
#include "mruby/common.h"
/**
* @file mruby/value.h
* @defgroup mruby_value Value definitions
*
* @ref mrb_value functions and macros.
*
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
typedef uint32_t mrb_sym; typedef uint32_t mrb_sym;
typedef uint8_t mrb_bool; typedef uint8_t mrb_bool;
struct mrb_state; struct mrb_state;
...@@ -163,8 +176,14 @@ mrb_obj_value(void *p) ...@@ -163,8 +176,14 @@ mrb_obj_value(void *p)
return v; return v;
} }
static inline mrb_value
mrb_nil_value(void) /**
* Get a nil mrb_value object.
*
* @return
* nil mrb_value object reference.
*/
MRB_INLINE mrb_value mrb_nil_value(void)
{ {
mrb_value v; mrb_value v;
SET_NIL_VALUE(v); SET_NIL_VALUE(v);
...@@ -226,4 +245,7 @@ mrb_ro_data_p(const char *p) ...@@ -226,4 +245,7 @@ mrb_ro_data_p(const char *p)
# define mrb_ro_data_p(p) FALSE # define mrb_ro_data_p(p) FALSE
#endif #endif
/** @} */
MRB_END_DECL
#endif /* MRUBY_VALUE_H */ #endif /* MRUBY_VALUE_H */
...@@ -7,9 +7,15 @@ ...@@ -7,9 +7,15 @@
#ifndef MRUBY_VARIABLE_H #ifndef MRUBY_VARIABLE_H
#define MRUBY_VARIABLE_H #define MRUBY_VARIABLE_H
#if defined(__cplusplus) #include "mruby/common.h"
extern "C" {
#endif /**
* @file mruby/variable.h
* @defgroup mruby_variable Functions to access to mruby variables.
* @ingroup mruby
* @{
*/
MRB_BEGIN_DECL
typedef struct global_variable { typedef struct global_variable {
int counter; int counter;
...@@ -74,8 +80,7 @@ void mrb_gc_mark_iv(mrb_state*, struct RObject*); ...@@ -74,8 +80,7 @@ void mrb_gc_mark_iv(mrb_state*, struct RObject*);
size_t mrb_gc_mark_iv_size(mrb_state*, struct RObject*); size_t mrb_gc_mark_iv_size(mrb_state*, struct RObject*);
void mrb_gc_free_iv(mrb_state*, struct RObject*); void mrb_gc_free_iv(mrb_state*, struct RObject*);
#if defined(__cplusplus) /** @} */
} /* extern "C" { */ MRB_END_DECL
#endif
#endif /* MRUBY_VARIABLE_H */ #endif /* MRUBY_VARIABLE_H */
...@@ -7,6 +7,17 @@ ...@@ -7,6 +7,17 @@
#ifndef MRUBY_VERSION_H #ifndef MRUBY_VERSION_H
#define MRUBY_VERSION_H #define MRUBY_VERSION_H
#include "mruby/common.h"
/**
* @file mruby/version.h
* @brief MRuby version macros
* @defgroup mrb_string MRuby version macros
* @ingroup MRuby
* @{
*/
MRB_BEGIN_DECL
#define MRB_STRINGIZE0(expr) #expr #define MRB_STRINGIZE0(expr) #expr
#define MRB_STRINGIZE(expr) MRB_STRINGIZE0(expr) #define MRB_STRINGIZE(expr) MRB_STRINGIZE0(expr)
...@@ -39,4 +50,7 @@ ...@@ -39,4 +50,7 @@
MRB_STRINGIZE(MRUBY_RELEASE_YEAR)" " \ MRB_STRINGIZE(MRUBY_RELEASE_YEAR)" " \
MRUBY_AUTHOR \ MRUBY_AUTHOR \
/** @} */
MRB_END_DECL
#endif /* MRUBY_VERSION_H */ #endif /* MRUBY_VERSION_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment