Skip to content

Commit

Permalink
Force mruby to compile when treated as C++
Browse files Browse the repository at this point in the history
This commit includes changes to parse.y. The parser is regenerated with:

```
/usr/local/opt/bison/bin/bison -o artichoke-backend/vendor/mruby/mrbgems/mruby-compiler/core/y.tab.c artichoke-backend/vendor/mruby/mrbgems/mruby-compiler/core/parse.y
sed -i '' -e 's#artichoke-backend/vendor/mruby/##g' artichoke-backend/vendor/mruby/mrbgems/mruby-compiler/core/y.tab.c
```
  • Loading branch information
lopopolo committed Nov 8, 2022
1 parent 2c5c59b commit 59e1fb4
Show file tree
Hide file tree
Showing 41 changed files with 1,330 additions and 1,001 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include "mruby/string.h"
#include "mruby/proc.h"

#ifdef __cplusplus
extern "C" {
#endif

static mrb_value
mrb_mod_name(mrb_state *mrb, mrb_value self)
{
Expand Down Expand Up @@ -71,3 +75,7 @@ void
mrb_mruby_class_ext_gem_final(mrb_state *mrb)
{
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include <ctype.h>
#include <string.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef MRB_CODEGEN_LEVEL_MAX
#define MRB_CODEGEN_LEVEL_MAX 256
#endif
Expand Down Expand Up @@ -3941,3 +3945,7 @@ mrb_irep_remove_lv(mrb_state *mrb, mrb_irep *irep)
mrb_irep_remove_lv(mrb, (mrb_irep*)irep->reps[i]);
}
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include <mruby/presym.h>
#include "node.h"

#ifdef __cplusplus
extern "C" {
#endif

#define YYLEX_PARAM p

typedef mrb_ast_node node;
Expand Down Expand Up @@ -7826,3 +7830,7 @@ mrb_parser_foreach_top_variable(mrb_state *mrb, struct mrb_parser_state *p, mrb_
}
}
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
2,010 changes: 1,009 additions & 1,001 deletions artichoke-backend/vendor/mruby/mrbgems/mruby-compiler/core/y.tab.c

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions artichoke-backend/vendor/mruby/mrbgems/mruby-eval/src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include <mruby/presym.h>
#include <mruby/variable.h>

#ifdef __cplusplus
extern "C" {
#endif

struct REnv *mrb_env_new(mrb_state *mrb, struct mrb_context *c, mrb_callinfo *ci, int nstacks, mrb_value *stack, struct RClass *tc);
mrb_value mrb_exec_irep(mrb_state *mrb, mrb_value self, struct RProc *p);
mrb_value mrb_obj_instance_eval(mrb_state *mrb, mrb_value self);
Expand Down Expand Up @@ -232,3 +236,7 @@ void
mrb_mruby_eval_gem_final(mrb_state* mrb)
{
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include <mruby/class.h>
#include <mruby/proc.h>

#ifdef __cplusplus
extern "C" {
#endif

#define fiber_ptr(o) ((struct RFiber*)mrb_ptr(o))

#define FIBER_STACK_INIT_SIZE 64
Expand Down Expand Up @@ -433,3 +437,7 @@ void
mrb_mruby_fiber_gem_final(mrb_state* mrb)
{
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include "mruby/string.h"
#include "mruby/presym.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
NOEX_PUBLIC = 0x00,
NOEX_NOSUPER = 0x01,
Expand Down Expand Up @@ -674,3 +678,7 @@ void
mrb_mruby_metaprog_gem_final(mrb_state* mrb)
{
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include "mruby/string.h"
#include "mruby/presym.h"

#ifdef __cplusplus
extern "C" {
#endif

mrb_noreturn void mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value args);
mrb_value mrb_exec_irep(mrb_state *mrb, mrb_value self, struct RProc *p);

Expand Down Expand Up @@ -555,3 +559,7 @@ void
mrb_mruby_method_gem_final(mrb_state* mrb)
{
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
8 changes: 8 additions & 0 deletions artichoke-backend/vendor/mruby/mrbgems/mruby-pack/src/pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include <errno.h>
#include <string.h>

#ifdef __cplusplus
extern "C" {
#endif

#define INT_OVERFLOW_P(n) ((n) < MRB_INT_MIN || (n) > MRB_INT_MAX)
#define UINT_OVERFLOW_P(n) ((n) > MRB_INT_MAX)

Expand Down Expand Up @@ -1605,3 +1609,7 @@ void
mrb_mruby_pack_gem_final(mrb_state *mrb)
{
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include <mruby/debug.h>
#include <mruby/presym.h>

#ifdef __cplusplus
extern "C" {
#endif

static mrb_value
mrb_proc_lambda_p(mrb_state *mrb, mrb_value self)
{
Expand Down Expand Up @@ -200,3 +204,7 @@ void
mrb_mruby_proc_ext_gem_final(mrb_state* mrb)
{
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#include <string.h>
#include <ctype.h>

#ifdef __cplusplus
extern "C" {
#endif

#define BIT_DIGITS(N) (((N)*146)/485 + 1) /* log2(10) =~ 146/485 */
#define BITSPERDIG MRB_INT_BIT
#define EXTENDSIGN(n, l) (((~0U << (n)) >> (((n)*(l)) % BITSPERDIG)) & ~(~0U << (n)))
Expand Down Expand Up @@ -1112,3 +1116,7 @@ void
mrb_mruby_sprintf_gem_final(mrb_state *mrb)
{
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
8 changes: 8 additions & 0 deletions artichoke-backend/vendor/mruby/src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#include <mruby/presym.h>
#include "value_array.h"

#ifdef __cplusplus
extern "C" {
#endif

#define ARY_DEFAULT_LEN 4
#define ARY_SHRINK_RATIO 5 /* must be larger than 2 */
#define ARY_C_MAX_SIZE (SIZE_MAX / sizeof(mrb_value))
Expand Down Expand Up @@ -1369,3 +1373,7 @@ mrb_init_array(mrb_state *mrb)
mrb_define_method(mrb, a, "__svalue", mrb_ary_svalue, MRB_ARGS_NONE());
#endif
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
8 changes: 8 additions & 0 deletions artichoke-backend/vendor/mruby/src/backtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#include <mruby/data.h>
#include <mruby/presym.h>

#ifdef __cplusplus
extern "C" {
#endif

struct backtrace_location {
int32_t lineno;
mrb_sym method_id;
Expand Down Expand Up @@ -263,3 +267,7 @@ mrb_get_backtrace(mrb_state *mrb)
{
return mrb_unpack_backtrace(mrb, packed_backtrace(mrb));
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
8 changes: 8 additions & 0 deletions artichoke-backend/vendor/mruby/src/cdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

#include <string.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef MRB_NO_STDIO

#ifndef MRB_NO_FLOAT
Expand Down Expand Up @@ -466,3 +470,7 @@ mrb_dump_irep_cstruct(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE
return MRB_DUMP_OK;
}
#endif

#ifdef __cplusplus
} /* extern "C" { */
#endif
8 changes: 8 additions & 0 deletions artichoke-backend/vendor/mruby/src/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include <mruby/opcode.h>
#include <mruby/presym.h>

#ifdef __cplusplus
extern "C" {
#endif

union mt_ptr {
struct RProc *proc;
mrb_func_t func;
Expand Down Expand Up @@ -2990,3 +2994,7 @@ mrb_init_class(mrb_state *mrb)
mrb_define_singleton_method(mrb, mrb->top_self, "to_s", inspect_main, MRB_ARGS_NONE());
mrb_define_singleton_method(mrb, mrb->top_self, "define_method", top_define_method, MRB_ARGS_ARG(1,1));
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
8 changes: 8 additions & 0 deletions artichoke-backend/vendor/mruby/src/codedump.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include <mruby/proc.h>
#include <mruby/dump.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef MRB_NO_STDIO
static void
print_r(mrb_state *mrb, const mrb_irep *irep, size_t n)
Expand Down Expand Up @@ -633,3 +637,7 @@ mrb_codedump_all(mrb_state *mrb, struct RProc *proc)
codedump_recur(mrb, proc->body.irep);
#endif
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
8 changes: 8 additions & 0 deletions artichoke-backend/vendor/mruby/src/compar.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@

#include <mruby.h>

#ifdef __cplusplus
extern "C" {
#endif

void
mrb_init_comparable(mrb_state *mrb)
{
mrb_define_module(mrb, "Comparable"); /* 15.3.3 */
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
8 changes: 8 additions & 0 deletions artichoke-backend/vendor/mruby/src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include <mruby/irep.h>
#include <mruby/debug.h>

#ifdef __cplusplus
extern "C" {
#endif

static mrb_irep_debug_info_file*
get_file(mrb_irep_debug_info *info, uint32_t pc)
{
Expand Down Expand Up @@ -242,3 +246,7 @@ mrb_debug_info_free(mrb_state *mrb, mrb_irep_debug_info *d)
}
mrb_free(mrb, d);
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
8 changes: 8 additions & 0 deletions artichoke-backend/vendor/mruby/src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include <mruby/endian.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

static size_t get_irep_record_size_1(mrb_state *mrb, const mrb_irep *irep);

#if UINT32_MAX > SIZE_MAX
Expand Down Expand Up @@ -937,3 +941,7 @@ mrb_dump_irep_cfunc(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE *f
}

#endif /* MRB_NO_STDIO */

#ifdef __cplusplus
} /* extern "C" { */
#endif
8 changes: 8 additions & 0 deletions artichoke-backend/vendor/mruby/src/enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include <mruby.h>
#include <mruby/proc.h>

#ifdef __cplusplus
extern "C" {
#endif

/* internal method `__update_hash(oldhash, index, itemhash)` */
static mrb_value
enum_update_hash(mrb_state *mrb, mrb_value self)
Expand All @@ -28,3 +32,7 @@ mrb_init_enumerable(mrb_state *mrb)
enumerable = mrb_define_module(mrb, "Enumerable"); /* 15.3.2 */
mrb_define_module_function(mrb, enumerable, "__update_hash", enum_update_hash, MRB_ARGS_REQ(3));
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
8 changes: 8 additions & 0 deletions artichoke-backend/vendor/mruby/src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#include <mruby/throw.h>
#include <mruby/presym.h>

#ifdef __cplusplus
extern "C" {
#endif

static void
exc_mesg_set(mrb_state *mrb, struct RException *exc, mrb_value mesg)
{
Expand Down Expand Up @@ -694,3 +698,7 @@ mrb_init_exception(mrb_state *mrb)
mrb->arena_err = mrb_obj_ptr(mrb_exc_new_lit(mrb, nomem_error, "arena overflow error"));
#endif
}

#ifdef __cplusplus
} /* extern "C" { */
#endif
8 changes: 8 additions & 0 deletions artichoke-backend/vendor/mruby/src/etc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include <mruby/class.h>
#include <mruby/numeric.h>

#ifdef __cplusplus
extern "C" {
#endif

MRB_API struct RData*
mrb_data_object_alloc(mrb_state *mrb, struct RClass *klass, void *ptr, const mrb_data_type *type)
{
Expand Down Expand Up @@ -268,3 +272,7 @@ mrb_msvc_snprintf(char *s, size_t n, const char *format, ...)
}

#endif /* defined _MSC_VER && _MSC_VER < 1900 */

#ifdef __cplusplus
} /* extern "C" { */
#endif

0 comments on commit 59e1fb4

Please sign in to comment.