summaryrefslogtreecommitdiff
path: root/goruby.c
diff options
context:
space:
mode:
Diffstat (limited to 'goruby.c')
-rw-r--r--goruby.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/goruby.c b/goruby.c
index d16ea11d5e..7cd3a2262b 100644
--- a/goruby.c
+++ b/goruby.c
@@ -1,3 +1,24 @@
void Init_golf(void);
-#define RUBY_MAIN_INIT() Init_golf()
+#define ruby_run_node goruby_run_node
#include "main.c"
+#undef ruby_run_node
+
+RUBY_EXTERN int ruby_run_node(void*);
+RUBY_EXTERN void ruby_init_ext(const char *name, void (*init)(void));
+
+static VALUE
+init_golf(VALUE arg)
+{
+ ruby_init_ext("golf", Init_golf);
+ return arg;
+}
+
+int
+goruby_run_node(void *arg)
+{
+ int state;
+ if (NIL_P(rb_protect(init_golf, Qtrue, &state))) {
+ return state == EXIT_SUCCESS ? EXIT_FAILURE : state;
+ }
+ return ruby_run_node(arg);
+}