summaryrefslogtreecommitdiff
path: root/jni/ruby/prelude.c
blob: 738cfb522861a4b6ac282d13a4781400c4d40b66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* -*-c-*-
 THIS FILE WAS AUTOGENERATED BY template/prelude.c.tmpl. DO NOT EDIT.

 sources: ./prelude, ./enc/prelude, ./gem_prelude
*/
#include "ruby/ruby.h"
#include "internal.h"
#include "vm_core.h"


static const char prelude_name0[] = "<internal:prelude>";
static const char prelude_code0[] =
"class Thread\n"
"  MUTEX_FOR_THREAD_EXCLUSIVE = Mutex.new\n"
"\n"
"\n"
"\n"
"\n"
"\n"
"\n"
"\n"
"  def self.exclusive\n"
"    MUTEX_FOR_THREAD_EXCLUSIVE.synchronize{\n"
"      yield\n"
"    }\n"
"  end\n"
"end\n"
;

static const char prelude_name1[] = "<internal:enc/prelude>";
static const char prelude_code1[] =
"begin\n"
"  require 'unicode_normalize'\n"
"rescue LoadError\n"
"end\n"
;

static const char prelude_name2[] = "<internal:gem_prelude>";
static const char prelude_code2[] =
"require 'rubygems.rb' if defined?(Gem)\n"
;


static void
prelude_eval(VALUE code, VALUE name, VALUE line)
{
    rb_iseq_eval(rb_iseq_compile_with_option(code, name, Qnil, line, 0, Qtrue));
}

void
Init_prelude(void)
{
    prelude_eval(
      rb_usascii_str_new(prelude_code0, sizeof(prelude_code0) - 1),
      rb_usascii_str_new(prelude_name0, sizeof(prelude_name0) - 1),
      INT2FIX(1));
    prelude_eval(
      rb_usascii_str_new(prelude_code1, sizeof(prelude_code1) - 1),
      rb_usascii_str_new(prelude_name1, sizeof(prelude_name1) - 1),
      INT2FIX(1));
    prelude_eval(
      rb_usascii_str_new(prelude_code2, sizeof(prelude_code2) - 1),
      rb_usascii_str_new(prelude_name2, sizeof(prelude_name2) - 1),
      INT2FIX(1));

#if 0
    puts(prelude_code0);
    puts(prelude_code1);
    puts(prelude_code2);
#endif
}