/
rbxti.hpp
144 lines (104 loc) · 4.1 KB
/
rbxti.hpp
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#ifndef RUBINIUS_RBXTI_HPP
#define RUBINIUS_RBXTI_HPP
#include <stdint.h>
namespace rbxti {
class InternalObject {};
class InternalSymbol : public InternalObject {};
class InternalTable : public InternalObject {};
class InternalMethod : public InternalObject {};
class InternalMachineCode : public InternalObject {};
class InternalModule : public InternalObject {};
class InternalString : public InternalObject {};
class InternalInteger : public InternalObject {};
class InternalArray : public InternalObject {};
typedef InternalObject* robject;
typedef InternalSymbol* rsymbol;
typedef InternalTable* rtable;
typedef InternalMethod* rmethod;
typedef InternalMachineCode* rmachine_code;
typedef InternalModule* rmodule;
typedef InternalString* rstring;
typedef InternalInteger* rinteger;
typedef InternalArray* rarray;
typedef int64_t r_mint;
class Env;
class EnvPrivate;
const static int GCYoung = 1;
const static int GCMature = 2;
const static int GCFinalizer = 4;
typedef robject (*results_func)(Env* env);
typedef void (*enable_func)(Env* env);
typedef void* (*enter_method)(Env* env, robject recv, rsymbol name, rmodule mod, rmethod code);
typedef void* (*enter_block)(Env* env, rsymbol name, rmodule module, rmethod code);
typedef void (*leave_func)(Env* env, void* tag);
typedef void* (*enter_gc)(Env* env, int level);
typedef void* (*enter_script)(Env* env, rmethod code);
typedef void (*shutdown_func)(Env* env);
typedef void (*thread_start_func)(Env* env);
typedef void (*thread_stop_func)(Env* env);
typedef void (*at_gc_func)(Env* env);
typedef void (*at_ip_func)(Env* env, rmachine_code code, int ip);
class Env {
public:
EnvPrivate* private_;
long config_get_int(const char* name);
void config_set(const char* name, const char* val);
////
rsymbol cast_to_rsymbol (robject obj);
rtable cast_to_rtable (robject obj);
rmethod cast_to_rmethod (robject obj);
rmodule cast_to_rmodule (robject obj);
rstring cast_to_rstring (robject obj);
rinteger cast_to_rinteger (robject obj);
rarray cast_to_rarray (robject obj);
void* global_tool_data();
void set_global_tool_data(void* d);
int thread_tool_new_id();
void* thread_tool_data(int id);
void thread_tool_set_data(int id, void* data);
int current_thread_id();
void enable_thread_tooling();
void disable_thread_tooling();
rinteger integer_new(r_mint val);
r_mint integer_value(rinteger i);
rsymbol symbol(const char* data);
void symbol_cstr(rsymbol sym, char* data, int size);
rstring symbol_to_string(rsymbol sym);
r_mint symbol_id(rsymbol sym);
rstring string_new(const char* data);
rstring to_s(robject obj);
rsymbol string_to_symbol(rstring str);
rsymbol module_name(rmodule mod);
bool module_is_metaclass(rmodule mod);
robject metaclass_attached_instance(rmodule mod);
bool is_nil(robject obj);
robject nil();
rsymbol method_file(rmethod cm);
r_mint method_line(rmethod cm);
r_mint method_id(rmethod cm);
rtable table_new();
robject table_fetch(rtable tbl, robject key, bool* fetched);
void table_store(rtable tbl, robject key, robject val);
rarray array_new(int size);
void array_set(rarray ary, int idx, robject obj);
robject array_get(rarray ary, int idx);
uint64_t time_current_ns();
////
void set_tool_enter_method(enter_method func);
void set_tool_leave_method(leave_func func);
void set_tool_enter_block(enter_block func);
void set_tool_leave_block(leave_func func);
void set_tool_enter_gc(enter_gc func);
void set_tool_leave_gc(leave_func func);
void set_tool_enter_script(enter_script func);
void set_tool_leave_script(leave_func func);
void set_tool_results(results_func func);
void set_tool_enable(enable_func func);
void set_tool_shutdown(shutdown_func func);
void set_tool_thread_start(thread_start_func func);
void set_tool_thread_stop(thread_stop_func func);
void set_tool_at_gc(at_gc_func func);
void set_tool_at_ip(at_ip_func func);
};
}
#endif