mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
add extern "C" guards; close #126
This commit is contained in:
@@ -28,6 +28,10 @@
|
||||
#ifndef MRUBY_H
|
||||
#define MRUBY_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "mrbconf.h"
|
||||
|
||||
@@ -584,4 +588,8 @@ int mrb_sourceline(void);
|
||||
void ruby_default_signal(int sig);
|
||||
mrb_value mrb_attr_get(mrb_state *mrb, mrb_value obj, mrb_sym id);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* MRUBY_H */
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#ifndef MRUBY_ARRAY_H
|
||||
#define MRUBY_ARRAY_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct RArray {
|
||||
MRUBY_OBJECT_HEADER;
|
||||
size_t len;
|
||||
@@ -45,4 +49,8 @@ mrb_value mrb_ary_tmp_new(mrb_state *mrb, long capa);
|
||||
mrb_value mrb_ary_sort(mrb_state *mrb, mrb_value ary);
|
||||
mrb_value mrb_ary_shift(mrb_state *mrb, mrb_value self);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* MRUBY_ARRAY_H */
|
||||
|
||||
@@ -4,6 +4,13 @@
|
||||
** See Copyright Notice in mruby.h
|
||||
*/
|
||||
|
||||
#ifndef MRUBY_CDUMP_H
|
||||
#define MRUBY_CDUMP_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "mruby.h"
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -12,3 +19,9 @@ int mrb_cdump_irep(mrb_state *mrb, int n, FILE *f,const char *initname);
|
||||
/* error code */
|
||||
#define MRB_CDUMP_OK 0
|
||||
#define MRB_CDUMP_GENERAL_FAILURE -1
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* MRUBY_CDUMP_H */
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#ifndef MRUBY_CLASS_H
|
||||
#define MRUBY_CLASS_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct RClass {
|
||||
MRUBY_OBJECT_HEADER;
|
||||
struct kh_iv *iv;
|
||||
@@ -76,4 +80,8 @@ struct RClass* mrb_class_real(struct RClass* cl);
|
||||
|
||||
void mrb_obj_call_init(mrb_state *mrb, mrb_value obj, int argc, mrb_value *argv);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* MRUBY_CLASS_H */
|
||||
|
||||
@@ -4,6 +4,13 @@
|
||||
** See Copyright Notice in mruby.h
|
||||
*/
|
||||
|
||||
#ifndef MRUBY_DUMP_H
|
||||
#define MRUBY_DUMP_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "mruby.h"
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -122,3 +129,9 @@ bin_to_uint16(unsigned char bin[])
|
||||
return (uint16_t)bin[0] << 8 |
|
||||
(uint16_t)bin[1];
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* MRUBY_DUMP_H */
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#ifndef MRUBY_HASH_H
|
||||
#define MRUBY_HASH_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct RHash {
|
||||
MRUBY_OBJECT_HEADER;
|
||||
struct kh_iv *iv;
|
||||
@@ -60,4 +64,8 @@ struct kh_ht * mrb_hash_tbl(mrb_state *mrb, mrb_value hash);
|
||||
void mrb_reset_random_seed(void);
|
||||
mrb_value mrb_obj_is_proc(mrb_value proc);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* MRUBY_HASH_H */
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#ifndef MRUBY_IREP_H
|
||||
#define MRUBY_IREP_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct mrb_irep {
|
||||
int idx;
|
||||
|
||||
@@ -26,4 +30,8 @@ typedef struct mrb_irep {
|
||||
|
||||
void mrb_add_irep(mrb_state *mrb, int n);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* MRUBY_IREP_H */
|
||||
|
||||
@@ -4,6 +4,13 @@
|
||||
** See Copyright Notice in mruby.h
|
||||
*/
|
||||
|
||||
#ifndef KHASH_H
|
||||
#define KHASH_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -203,3 +210,8 @@ typedef const char *kh_cstr_t;
|
||||
#define KHASH_MAP_INIT_STR(name, khval_t) \
|
||||
KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_str_hash_func, kh_str_hash_equal)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* KHASH_H */
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#ifndef MRUBY_NUMERIC_H
|
||||
#define MRUBY_NUMERIC_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#define RSHIFT(x,y) ((x)>>(int)(y))
|
||||
@@ -18,4 +22,8 @@ mrb_value mrb_flt2big(mrb_state *mrb, mrb_float d);
|
||||
void mrb_num_zerodiv(mrb_state *mrb);
|
||||
mrb_value mrb_fix2str(mrb_state *mrb, mrb_value x, int base);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* MRUBY_NUMERIC_H */
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#ifndef MRUBY_OBJECT_H
|
||||
#define MRUBY_OBJECT_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MRUBY_OBJECT_HEADER \
|
||||
enum mrb_vtype tt:8; \
|
||||
int color:3;\
|
||||
@@ -49,4 +53,9 @@ struct RObject {
|
||||
#define ROBJECT(v) ((struct RObject*)((v).value.p))
|
||||
#define ROBJECT_IVPTR(v) (((struct RObject*)((v).value.p))->iv)
|
||||
#define ROBJECT_NUMIV(v) (ROBJECT_IVPTR(v) ? ROBJECT_IVPTR(v)->size : 0)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* MRUBY_OBJECT_H */
|
||||
|
||||
@@ -7,9 +7,12 @@
|
||||
#ifndef MRUBY_PROC_H
|
||||
#define MRUBY_PROC_H
|
||||
|
||||
#include "mruby.h"
|
||||
#include "irep.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct REnv {
|
||||
MRUBY_OBJECT_HEADER;
|
||||
mrb_value *stack;
|
||||
@@ -47,4 +50,8 @@ 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*);
|
||||
|
||||
#endif /* MRUBY_STRING_H */
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* MRUBY_PROC_H */
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#ifndef MRUBY_RANGE_H
|
||||
#define MRUBY_RANGE_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct RRange {
|
||||
MRUBY_OBJECT_HEADER;
|
||||
struct mrb_range_edges {
|
||||
@@ -22,4 +26,8 @@ struct RRange {
|
||||
mrb_value mrb_range_new(mrb_state*, mrb_value, mrb_value, int);
|
||||
mrb_int mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp, mrb_int len, mrb_int err);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* MRUBY_RANGE_H */
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#ifndef MRUBY_STRING_H
|
||||
#define MRUBY_STRING_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_ENCODING
|
||||
#include "encoding.h"
|
||||
#endif
|
||||
@@ -130,4 +134,8 @@ int mrb_symname_p(const char *name);
|
||||
mrb_value mrb_tainted_str_new(mrb_state *mrb, const char *ptr, long len);
|
||||
int mrb_str_cmp(mrb_state *mrb, mrb_value str1, mrb_value str2);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* MRUBY_STRING_H */
|
||||
|
||||
+11
-3
@@ -4,8 +4,12 @@
|
||||
** See Copyright Notice in mruby.h
|
||||
*/
|
||||
|
||||
#ifndef MSTRUCT_H
|
||||
#define MSTRUCT_H
|
||||
#ifndef MRUBY_STRUCT_H
|
||||
#define MRUBY_STRUCT_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct RStruct {
|
||||
struct RBasic basic;
|
||||
@@ -19,4 +23,8 @@ struct RStruct {
|
||||
mrb_value mrb_yield_values(int n, ...);
|
||||
mrb_value mrb_mod_module_eval(mrb_state *mrb, int argc, mrb_value *argv, mrb_value mod);
|
||||
|
||||
#endif //MSTRUCT_H
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* MRUBY_STRUCT_H */
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#ifndef MRUBY_VARIABLE_H
|
||||
#define MRUBY_VARIABLE_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct global_variable {
|
||||
int counter;
|
||||
mrb_value *data;
|
||||
@@ -44,4 +48,8 @@ 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);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* MRUBY_VARIABLE_H */
|
||||
|
||||
Reference in New Issue
Block a user