summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro Matsumoto <[email protected]>2012-05-18 02:02:49 +0900
committerYukihiro Matsumoto <[email protected]>2012-05-18 02:02:49 +0900
commita4d3579e311554ffe55e7beed9650520beee616d (patch)
tree4e31d510b6da3c27b18144767388ecf3d8dfa6b4
parente67c03529d4faaf0a5be0bc34596e20904b485e9 (diff)
downloadmruby-a4d3579e311554ffe55e7beed9650520beee616d.tar.gz
mruby-a4d3579e311554ffe55e7beed9650520beee616d.zip
add extern "C" guards; close #126
-rw-r--r--include/mruby.h8
-rw-r--r--include/mruby/array.h8
-rw-r--r--include/mruby/cdump.h13
-rw-r--r--include/mruby/class.h8
-rw-r--r--include/mruby/dump.h13
-rw-r--r--include/mruby/hash.h8
-rw-r--r--include/mruby/irep.h8
-rw-r--r--include/mruby/khash.h12
-rw-r--r--include/mruby/numeric.h8
-rw-r--r--include/mruby/object.h9
-rw-r--r--include/mruby/proc.h11
-rw-r--r--include/mruby/range.h8
-rw-r--r--include/mruby/string.h8
-rw-r--r--include/mruby/struct.h14
-rw-r--r--include/mruby/variable.h8
15 files changed, 139 insertions, 5 deletions
diff --git a/include/mruby.h b/include/mruby.h
index f3eb16a01..299ad1721 100644
--- a/include/mruby.h
+++ b/include/mruby.h
@@ -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 */
diff --git a/include/mruby/array.h b/include/mruby/array.h
index 6b7c9aa04..5c3098ebe 100644
--- a/include/mruby/array.h
+++ b/include/mruby/array.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 */
diff --git a/include/mruby/cdump.h b/include/mruby/cdump.h
index c07bc3d7d..15108d51f 100644
--- a/include/mruby/cdump.h
+++ b/include/mruby/cdump.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 */
diff --git a/include/mruby/class.h b/include/mruby/class.h
index 62829bd68..e3fa75ff8 100644
--- a/include/mruby/class.h
+++ b/include/mruby/class.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 */
diff --git a/include/mruby/dump.h b/include/mruby/dump.h
index 7508eb38d..f098ad737 100644
--- a/include/mruby/dump.h
+++ b/include/mruby/dump.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 */
diff --git a/include/mruby/hash.h b/include/mruby/hash.h
index 3a15ecd1d..acc8181ad 100644
--- a/include/mruby/hash.h
+++ b/include/mruby/hash.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 */
diff --git a/include/mruby/irep.h b/include/mruby/irep.h
index 2d25d0c4a..d92aef9a0 100644
--- a/include/mruby/irep.h
+++ b/include/mruby/irep.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 */
diff --git a/include/mruby/khash.h b/include/mruby/khash.h
index 0485bf9f3..9950dbc80 100644
--- a/include/mruby/khash.h
+++ b/include/mruby/khash.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 */
diff --git a/include/mruby/numeric.h b/include/mruby/numeric.h
index 8f74bd498..1bea51152 100644
--- a/include/mruby/numeric.h
+++ b/include/mruby/numeric.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 */
diff --git a/include/mruby/object.h b/include/mruby/object.h
index 0c3f3a6dd..495c34083 100644
--- a/include/mruby/object.h
+++ b/include/mruby/object.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 */
diff --git a/include/mruby/proc.h b/include/mruby/proc.h
index 033dcaedf..52dc5a98e 100644
--- a/include/mruby/proc.h
+++ b/include/mruby/proc.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 */
diff --git a/include/mruby/range.h b/include/mruby/range.h
index 1b07ca197..b95838375 100644
--- a/include/mruby/range.h
+++ b/include/mruby/range.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 */
diff --git a/include/mruby/string.h b/include/mruby/string.h
index 8e259dfe3..7050957bd 100644
--- a/include/mruby/string.h
+++ b/include/mruby/string.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 */
diff --git a/include/mruby/struct.h b/include/mruby/struct.h
index 46012cc43..1aee64883 100644
--- a/include/mruby/struct.h
+++ b/include/mruby/struct.h
@@ -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 */
diff --git a/include/mruby/variable.h b/include/mruby/variable.h
index eb21ceeba..880d6217e 100644
--- a/include/mruby/variable.h
+++ b/include/mruby/variable.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 */