ruby2d 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/assets/README.md +8 -0
- data/assets/ios/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
- data/assets/ios/Assets.xcassets/Contents.json +6 -0
- data/assets/ios/Base.lproj/LaunchScreen.storyboard +27 -0
- data/assets/ios/Info.plist +43 -0
- data/assets/ios/MRuby.framework/Headers/mrbconf.h +145 -0
- data/assets/ios/MRuby.framework/Headers/mruby.h +1279 -0
- data/assets/ios/MRuby.framework/Headers/mruby/array.h +279 -0
- data/assets/ios/MRuby.framework/Headers/mruby/boxing_nan.h +102 -0
- data/assets/ios/MRuby.framework/Headers/mruby/boxing_no.h +56 -0
- data/assets/ios/MRuby.framework/Headers/mruby/boxing_word.h +136 -0
- data/assets/ios/MRuby.framework/Headers/mruby/class.h +94 -0
- data/assets/ios/MRuby.framework/Headers/mruby/common.h +72 -0
- data/assets/ios/MRuby.framework/Headers/mruby/compile.h +194 -0
- data/assets/ios/MRuby.framework/Headers/mruby/data.h +75 -0
- data/assets/ios/MRuby.framework/Headers/mruby/debug.h +66 -0
- data/assets/ios/MRuby.framework/Headers/mruby/dump.h +196 -0
- data/assets/ios/MRuby.framework/Headers/mruby/error.h +75 -0
- data/assets/ios/MRuby.framework/Headers/mruby/gc.h +91 -0
- data/assets/ios/MRuby.framework/Headers/mruby/hash.h +182 -0
- data/assets/ios/MRuby.framework/Headers/mruby/irep.h +62 -0
- data/assets/ios/MRuby.framework/Headers/mruby/istruct.h +47 -0
- data/assets/ios/MRuby.framework/Headers/mruby/khash.h +274 -0
- data/assets/ios/MRuby.framework/Headers/mruby/numeric.h +161 -0
- data/assets/ios/MRuby.framework/Headers/mruby/object.h +45 -0
- data/assets/ios/MRuby.framework/Headers/mruby/opcode.h +161 -0
- data/assets/ios/MRuby.framework/Headers/mruby/proc.h +131 -0
- data/assets/ios/MRuby.framework/Headers/mruby/range.h +49 -0
- data/assets/ios/MRuby.framework/Headers/mruby/re.h +16 -0
- data/assets/ios/MRuby.framework/Headers/mruby/string.h +440 -0
- data/assets/ios/MRuby.framework/Headers/mruby/throw.h +55 -0
- data/assets/ios/MRuby.framework/Headers/mruby/value.h +309 -0
- data/assets/ios/MRuby.framework/Headers/mruby/variable.h +138 -0
- data/assets/ios/MRuby.framework/Headers/mruby/version.h +110 -0
- data/assets/ios/MRuby.framework/Info.plist +20 -0
- data/assets/ios/MRuby.framework/MRuby +0 -0
- data/assets/ios/MyApp.xcodeproj/project.pbxproj +362 -0
- data/assets/ios/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/assets/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +30 -0
- data/assets/ios/MyApp.xcodeproj/project.xcworkspace/xcuserdata/Tom.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- data/assets/ios/MyApp.xcodeproj/xcuserdata/Tom.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- data/assets/ios/main.c +1 -0
- data/assets/opal.js +8434 -6329
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +12 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json +6 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json +17 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +12 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json +6 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +12 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json +6 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +12 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json +6 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json +17 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +12 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json +6 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +12 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json +6 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json +32 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +12 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +12 -0
- data/assets/tvos/Assets.xcassets/Contents.json +6 -0
- data/assets/tvos/Assets.xcassets/LaunchImage.launchimage/Contents.json +15 -0
- data/assets/tvos/Info.plist +30 -0
- data/assets/tvos/MRuby.framework/Headers/mrbconf.h +145 -0
- data/assets/tvos/MRuby.framework/Headers/mruby.h +1279 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/array.h +279 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/boxing_nan.h +102 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/boxing_no.h +56 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/boxing_word.h +136 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/class.h +94 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/common.h +72 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/compile.h +194 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/data.h +75 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/debug.h +66 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/dump.h +196 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/error.h +75 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/gc.h +91 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/hash.h +182 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/irep.h +62 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/istruct.h +47 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/khash.h +274 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/numeric.h +161 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/object.h +45 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/opcode.h +161 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/proc.h +131 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/range.h +49 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/re.h +16 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/string.h +440 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/throw.h +55 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/value.h +309 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/variable.h +138 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/version.h +110 -0
- data/assets/tvos/MRuby.framework/Info.plist +20 -0
- data/assets/tvos/MRuby.framework/MRuby +0 -0
- data/assets/tvos/MyApp.xcodeproj/project.pbxproj +344 -0
- data/assets/tvos/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/assets/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +30 -0
- data/assets/tvos/main.c +1 -0
- data/bin/ruby2d +219 -64
- data/ext/ruby2d/extconf.rb +1 -1
- data/ext/ruby2d/ruby2d.c +117 -19
- data/lib/ruby2d/color.rb +1 -1
- data/lib/ruby2d/version.rb +1 -1
- data/lib/ruby2d/window.rb +16 -10
- metadata +102 -5
@@ -0,0 +1,94 @@
|
|
1
|
+
/*
|
2
|
+
** mruby/class.h - Class class
|
3
|
+
**
|
4
|
+
** See Copyright Notice in mruby.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#ifndef MRUBY_CLASS_H
|
8
|
+
#define MRUBY_CLASS_H
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Class class
|
14
|
+
*/
|
15
|
+
MRB_BEGIN_DECL
|
16
|
+
|
17
|
+
struct RClass {
|
18
|
+
MRB_OBJECT_HEADER;
|
19
|
+
struct iv_tbl *iv;
|
20
|
+
struct kh_mt *mt;
|
21
|
+
struct RClass *super;
|
22
|
+
};
|
23
|
+
|
24
|
+
#define mrb_class_ptr(v) ((struct RClass*)(mrb_ptr(v)))
|
25
|
+
#define RCLASS_SUPER(v) (((struct RClass*)(mrb_ptr(v)))->super)
|
26
|
+
#define RCLASS_IV_TBL(v) (((struct RClass*)(mrb_ptr(v)))->iv)
|
27
|
+
#define RCLASS_M_TBL(v) (((struct RClass*)(mrb_ptr(v)))->mt)
|
28
|
+
|
29
|
+
static inline struct RClass*
|
30
|
+
mrb_class(mrb_state *mrb, mrb_value v)
|
31
|
+
{
|
32
|
+
switch (mrb_type(v)) {
|
33
|
+
case MRB_TT_FALSE:
|
34
|
+
if (mrb_fixnum(v))
|
35
|
+
return mrb->false_class;
|
36
|
+
return mrb->nil_class;
|
37
|
+
case MRB_TT_TRUE:
|
38
|
+
return mrb->true_class;
|
39
|
+
case MRB_TT_SYMBOL:
|
40
|
+
return mrb->symbol_class;
|
41
|
+
case MRB_TT_FIXNUM:
|
42
|
+
return mrb->fixnum_class;
|
43
|
+
#ifndef MRB_WITHOUT_FLOAT
|
44
|
+
case MRB_TT_FLOAT:
|
45
|
+
return mrb->float_class;
|
46
|
+
#endif
|
47
|
+
case MRB_TT_CPTR:
|
48
|
+
return mrb->object_class;
|
49
|
+
case MRB_TT_ENV:
|
50
|
+
return NULL;
|
51
|
+
default:
|
52
|
+
return mrb_obj_ptr(v)->c;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
/* TODO: figure out where to put user flags */
|
57
|
+
/* flags bits >= 18 is reserved */
|
58
|
+
#define MRB_FLAG_IS_PREPENDED (1 << 19)
|
59
|
+
#define MRB_FLAG_IS_ORIGIN (1 << 20)
|
60
|
+
#define MRB_CLASS_ORIGIN(c) do {\
|
61
|
+
if (c->flags & MRB_FLAG_IS_PREPENDED) {\
|
62
|
+
c = c->super;\
|
63
|
+
while (!(c->flags & MRB_FLAG_IS_ORIGIN)) {\
|
64
|
+
c = c->super;\
|
65
|
+
}\
|
66
|
+
}\
|
67
|
+
} while (0)
|
68
|
+
#define MRB_FLAG_IS_INHERITED (1 << 21)
|
69
|
+
#define MRB_INSTANCE_TT_MASK (0xFF)
|
70
|
+
#define MRB_SET_INSTANCE_TT(c, tt) c->flags = ((c->flags & ~MRB_INSTANCE_TT_MASK) | (char)tt)
|
71
|
+
#define MRB_INSTANCE_TT(c) (enum mrb_vtype)(c->flags & MRB_INSTANCE_TT_MASK)
|
72
|
+
|
73
|
+
MRB_API struct RClass* mrb_define_class_id(mrb_state*, mrb_sym, struct RClass*);
|
74
|
+
MRB_API struct RClass* mrb_define_module_id(mrb_state*, mrb_sym);
|
75
|
+
MRB_API struct RClass *mrb_vm_define_class(mrb_state*, mrb_value, mrb_value, mrb_sym);
|
76
|
+
MRB_API struct RClass *mrb_vm_define_module(mrb_state*, mrb_value, mrb_sym);
|
77
|
+
MRB_API void mrb_define_method_raw(mrb_state*, struct RClass*, mrb_sym, mrb_method_t);
|
78
|
+
MRB_API void mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t func, mrb_aspec aspec);
|
79
|
+
MRB_API void mrb_alias_method(mrb_state *mrb, struct RClass *c, mrb_sym a, mrb_sym b);
|
80
|
+
|
81
|
+
MRB_API mrb_method_t mrb_method_search_vm(mrb_state*, struct RClass**, mrb_sym);
|
82
|
+
MRB_API mrb_method_t mrb_method_search(mrb_state*, struct RClass*, mrb_sym);
|
83
|
+
|
84
|
+
MRB_API struct RClass* mrb_class_real(struct RClass* cl);
|
85
|
+
|
86
|
+
void mrb_class_name_class(mrb_state*, struct RClass*, struct RClass*, mrb_sym);
|
87
|
+
mrb_value mrb_class_find_path(mrb_state*, struct RClass*);
|
88
|
+
void mrb_gc_mark_mt(mrb_state*, struct RClass*);
|
89
|
+
size_t mrb_gc_mark_mt_size(mrb_state*, struct RClass*);
|
90
|
+
void mrb_gc_free_mt(mrb_state*, struct RClass*);
|
91
|
+
|
92
|
+
MRB_END_DECL
|
93
|
+
|
94
|
+
#endif /* MRUBY_CLASS_H */
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/*
|
2
|
+
**"common.h - mruby common platform definition"
|
3
|
+
**
|
4
|
+
** See Copyright Notice in mruby.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#ifndef MRUBY_COMMON_H
|
8
|
+
#define MRUBY_COMMON_H
|
9
|
+
|
10
|
+
|
11
|
+
#ifdef __cplusplus
|
12
|
+
#ifdef MRB_ENABLE_CXX_ABI
|
13
|
+
#define MRB_BEGIN_DECL
|
14
|
+
#define MRB_END_DECL
|
15
|
+
#else
|
16
|
+
# define MRB_BEGIN_DECL extern "C" {
|
17
|
+
# define MRB_END_DECL }
|
18
|
+
#endif
|
19
|
+
#else
|
20
|
+
/** Start declarations in C mode */
|
21
|
+
# define MRB_BEGIN_DECL
|
22
|
+
/** End declarations in C mode */
|
23
|
+
# define MRB_END_DECL
|
24
|
+
#endif
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Shared compiler macros
|
28
|
+
*/
|
29
|
+
MRB_BEGIN_DECL
|
30
|
+
|
31
|
+
/** Declare a function that never returns. */
|
32
|
+
#if __STDC_VERSION__ >= 201112L
|
33
|
+
# define mrb_noreturn _Noreturn
|
34
|
+
#elif defined __GNUC__ && !defined __STRICT_ANSI__
|
35
|
+
# define mrb_noreturn __attribute__((noreturn))
|
36
|
+
#elif defined _MSC_VER
|
37
|
+
# define mrb_noreturn __declspec(noreturn)
|
38
|
+
#else
|
39
|
+
# define mrb_noreturn
|
40
|
+
#endif
|
41
|
+
|
42
|
+
/** Mark a function as deprecated. */
|
43
|
+
#if defined __GNUC__ && !defined __STRICT_ANSI__
|
44
|
+
# define mrb_deprecated __attribute__((deprecated))
|
45
|
+
#elif defined _MSC_VER
|
46
|
+
# define mrb_deprecated __declspec(deprecated)
|
47
|
+
#else
|
48
|
+
# define mrb_deprecated
|
49
|
+
#endif
|
50
|
+
|
51
|
+
/** Declare a function as always inlined. */
|
52
|
+
#if defined(_MSC_VER)
|
53
|
+
# define MRB_INLINE static __inline
|
54
|
+
#else
|
55
|
+
# define MRB_INLINE static inline
|
56
|
+
#endif
|
57
|
+
|
58
|
+
|
59
|
+
/** Declare a public MRuby API function. */
|
60
|
+
#if defined(MRB_BUILD_AS_DLL)
|
61
|
+
#if defined(MRB_CORE) || defined(MRB_LIB)
|
62
|
+
# define MRB_API __declspec(dllexport)
|
63
|
+
#else
|
64
|
+
# define MRB_API __declspec(dllimport)
|
65
|
+
#endif
|
66
|
+
#else
|
67
|
+
# define MRB_API extern
|
68
|
+
#endif
|
69
|
+
|
70
|
+
MRB_END_DECL
|
71
|
+
|
72
|
+
#endif /* MRUBY_COMMON_H */
|
@@ -0,0 +1,194 @@
|
|
1
|
+
/*
|
2
|
+
** mruby/compile.h - mruby parser
|
3
|
+
**
|
4
|
+
** See Copyright Notice in mruby.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#ifndef MRUBY_COMPILE_H
|
8
|
+
#define MRUBY_COMPILE_H
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
|
12
|
+
/**
|
13
|
+
* MRuby Compiler
|
14
|
+
*/
|
15
|
+
MRB_BEGIN_DECL
|
16
|
+
|
17
|
+
#include <mruby.h>
|
18
|
+
|
19
|
+
struct mrb_jmpbuf;
|
20
|
+
|
21
|
+
struct mrb_parser_state;
|
22
|
+
/* load context */
|
23
|
+
typedef struct mrbc_context {
|
24
|
+
mrb_sym *syms;
|
25
|
+
int slen;
|
26
|
+
char *filename;
|
27
|
+
short lineno;
|
28
|
+
int (*partial_hook)(struct mrb_parser_state*);
|
29
|
+
void *partial_data;
|
30
|
+
struct RClass *target_class;
|
31
|
+
mrb_bool capture_errors:1;
|
32
|
+
mrb_bool dump_result:1;
|
33
|
+
mrb_bool no_exec:1;
|
34
|
+
mrb_bool keep_lv:1;
|
35
|
+
mrb_bool no_optimize:1;
|
36
|
+
|
37
|
+
size_t parser_nerr;
|
38
|
+
} mrbc_context;
|
39
|
+
|
40
|
+
MRB_API mrbc_context* mrbc_context_new(mrb_state *mrb);
|
41
|
+
MRB_API void mrbc_context_free(mrb_state *mrb, mrbc_context *cxt);
|
42
|
+
MRB_API const char *mrbc_filename(mrb_state *mrb, mrbc_context *c, const char *s);
|
43
|
+
MRB_API void mrbc_partial_hook(mrb_state *mrb, mrbc_context *c, int (*partial_hook)(struct mrb_parser_state*), void*data);
|
44
|
+
|
45
|
+
/* AST node structure */
|
46
|
+
typedef struct mrb_ast_node {
|
47
|
+
struct mrb_ast_node *car, *cdr;
|
48
|
+
uint16_t lineno, filename_index;
|
49
|
+
} mrb_ast_node;
|
50
|
+
|
51
|
+
/* lexer states */
|
52
|
+
enum mrb_lex_state_enum {
|
53
|
+
EXPR_BEG, /* ignore newline, +/- is a sign. */
|
54
|
+
EXPR_END, /* newline significant, +/- is an operator. */
|
55
|
+
EXPR_ENDARG, /* ditto, and unbound braces. */
|
56
|
+
EXPR_ENDFN, /* ditto, and unbound braces. */
|
57
|
+
EXPR_ARG, /* newline significant, +/- is an operator. */
|
58
|
+
EXPR_CMDARG, /* newline significant, +/- is an operator. */
|
59
|
+
EXPR_MID, /* newline significant, +/- is an operator. */
|
60
|
+
EXPR_FNAME, /* ignore newline, no reserved words. */
|
61
|
+
EXPR_DOT, /* right after '.' or '::', no reserved words. */
|
62
|
+
EXPR_CLASS, /* immediate after 'class', no here document. */
|
63
|
+
EXPR_VALUE, /* alike EXPR_BEG but label is disallowed. */
|
64
|
+
EXPR_MAX_STATE
|
65
|
+
};
|
66
|
+
|
67
|
+
/* saved error message */
|
68
|
+
struct mrb_parser_message {
|
69
|
+
int lineno;
|
70
|
+
int column;
|
71
|
+
char* message;
|
72
|
+
};
|
73
|
+
|
74
|
+
#define STR_FUNC_PARSING 0x01
|
75
|
+
#define STR_FUNC_EXPAND 0x02
|
76
|
+
#define STR_FUNC_REGEXP 0x04
|
77
|
+
#define STR_FUNC_WORD 0x08
|
78
|
+
#define STR_FUNC_SYMBOL 0x10
|
79
|
+
#define STR_FUNC_ARRAY 0x20
|
80
|
+
#define STR_FUNC_HEREDOC 0x40
|
81
|
+
#define STR_FUNC_XQUOTE 0x80
|
82
|
+
|
83
|
+
enum mrb_string_type {
|
84
|
+
str_not_parsing = (0),
|
85
|
+
str_squote = (STR_FUNC_PARSING),
|
86
|
+
str_dquote = (STR_FUNC_PARSING|STR_FUNC_EXPAND),
|
87
|
+
str_regexp = (STR_FUNC_PARSING|STR_FUNC_REGEXP|STR_FUNC_EXPAND),
|
88
|
+
str_sword = (STR_FUNC_PARSING|STR_FUNC_WORD|STR_FUNC_ARRAY),
|
89
|
+
str_dword = (STR_FUNC_PARSING|STR_FUNC_WORD|STR_FUNC_ARRAY|STR_FUNC_EXPAND),
|
90
|
+
str_ssym = (STR_FUNC_PARSING|STR_FUNC_SYMBOL),
|
91
|
+
str_ssymbols = (STR_FUNC_PARSING|STR_FUNC_SYMBOL|STR_FUNC_ARRAY),
|
92
|
+
str_dsymbols = (STR_FUNC_PARSING|STR_FUNC_SYMBOL|STR_FUNC_ARRAY|STR_FUNC_EXPAND),
|
93
|
+
str_heredoc = (STR_FUNC_PARSING|STR_FUNC_HEREDOC),
|
94
|
+
str_xquote = (STR_FUNC_PARSING|STR_FUNC_XQUOTE|STR_FUNC_EXPAND),
|
95
|
+
};
|
96
|
+
|
97
|
+
/* heredoc structure */
|
98
|
+
struct mrb_parser_heredoc_info {
|
99
|
+
mrb_bool allow_indent:1;
|
100
|
+
mrb_bool line_head:1;
|
101
|
+
enum mrb_string_type type;
|
102
|
+
const char *term;
|
103
|
+
int term_len;
|
104
|
+
mrb_ast_node *doc;
|
105
|
+
};
|
106
|
+
|
107
|
+
#define MRB_PARSER_TOKBUF_MAX 65536
|
108
|
+
#define MRB_PARSER_TOKBUF_SIZE 256
|
109
|
+
|
110
|
+
/* parser structure */
|
111
|
+
struct mrb_parser_state {
|
112
|
+
mrb_state *mrb;
|
113
|
+
struct mrb_pool *pool;
|
114
|
+
mrb_ast_node *cells;
|
115
|
+
const char *s, *send;
|
116
|
+
#ifndef MRB_DISABLE_STDIO
|
117
|
+
FILE *f;
|
118
|
+
#endif
|
119
|
+
mrbc_context *cxt;
|
120
|
+
char const *filename;
|
121
|
+
int lineno;
|
122
|
+
int column;
|
123
|
+
|
124
|
+
enum mrb_lex_state_enum lstate;
|
125
|
+
mrb_ast_node *lex_strterm; /* (type nest_level beg . end) */
|
126
|
+
|
127
|
+
unsigned int cond_stack;
|
128
|
+
unsigned int cmdarg_stack;
|
129
|
+
int paren_nest;
|
130
|
+
int lpar_beg;
|
131
|
+
int in_def, in_single;
|
132
|
+
mrb_bool cmd_start:1;
|
133
|
+
mrb_ast_node *locals;
|
134
|
+
|
135
|
+
mrb_ast_node *pb;
|
136
|
+
char *tokbuf;
|
137
|
+
char buf[MRB_PARSER_TOKBUF_SIZE];
|
138
|
+
int tidx;
|
139
|
+
int tsiz;
|
140
|
+
|
141
|
+
mrb_ast_node *all_heredocs; /* list of mrb_parser_heredoc_info* */
|
142
|
+
mrb_ast_node *heredocs_from_nextline;
|
143
|
+
mrb_ast_node *parsing_heredoc;
|
144
|
+
mrb_ast_node *lex_strterm_before_heredoc;
|
145
|
+
mrb_bool heredoc_end_now:1; /* for mirb */
|
146
|
+
|
147
|
+
void *ylval;
|
148
|
+
|
149
|
+
size_t nerr;
|
150
|
+
size_t nwarn;
|
151
|
+
mrb_ast_node *tree;
|
152
|
+
|
153
|
+
mrb_bool no_optimize:1;
|
154
|
+
mrb_bool capture_errors:1;
|
155
|
+
struct mrb_parser_message error_buffer[10];
|
156
|
+
struct mrb_parser_message warn_buffer[10];
|
157
|
+
|
158
|
+
mrb_sym* filename_table;
|
159
|
+
size_t filename_table_length;
|
160
|
+
int current_filename_index;
|
161
|
+
|
162
|
+
struct mrb_jmpbuf* jmp;
|
163
|
+
};
|
164
|
+
|
165
|
+
MRB_API struct mrb_parser_state* mrb_parser_new(mrb_state*);
|
166
|
+
MRB_API void mrb_parser_free(struct mrb_parser_state*);
|
167
|
+
MRB_API void mrb_parser_parse(struct mrb_parser_state*,mrbc_context*);
|
168
|
+
|
169
|
+
MRB_API void mrb_parser_set_filename(struct mrb_parser_state*, char const*);
|
170
|
+
MRB_API char const* mrb_parser_get_filename(struct mrb_parser_state*, uint16_t idx);
|
171
|
+
|
172
|
+
/* utility functions */
|
173
|
+
#ifndef MRB_DISABLE_STDIO
|
174
|
+
MRB_API struct mrb_parser_state* mrb_parse_file(mrb_state*,FILE*,mrbc_context*);
|
175
|
+
#endif
|
176
|
+
MRB_API struct mrb_parser_state* mrb_parse_string(mrb_state*,const char*,mrbc_context*);
|
177
|
+
MRB_API struct mrb_parser_state* mrb_parse_nstring(mrb_state*,const char*,size_t,mrbc_context*);
|
178
|
+
MRB_API struct RProc* mrb_generate_code(mrb_state*, struct mrb_parser_state*);
|
179
|
+
MRB_API mrb_value mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c);
|
180
|
+
|
181
|
+
/* program load functions */
|
182
|
+
#ifndef MRB_DISABLE_STDIO
|
183
|
+
MRB_API mrb_value mrb_load_file(mrb_state*,FILE*);
|
184
|
+
MRB_API mrb_value mrb_load_file_cxt(mrb_state*,FILE*, mrbc_context *cxt);
|
185
|
+
#endif
|
186
|
+
MRB_API mrb_value mrb_load_string(mrb_state *mrb, const char *s);
|
187
|
+
MRB_API mrb_value mrb_load_nstring(mrb_state *mrb, const char *s, size_t len);
|
188
|
+
MRB_API mrb_value mrb_load_string_cxt(mrb_state *mrb, const char *s, mrbc_context *cxt);
|
189
|
+
MRB_API mrb_value mrb_load_nstring_cxt(mrb_state *mrb, const char *s, size_t len, mrbc_context *cxt);
|
190
|
+
|
191
|
+
/** @} */
|
192
|
+
MRB_END_DECL
|
193
|
+
|
194
|
+
#endif /* MRUBY_COMPILE_H */
|
@@ -0,0 +1,75 @@
|
|
1
|
+
/*
|
2
|
+
** mruby/data.h - Data class
|
3
|
+
**
|
4
|
+
** See Copyright Notice in mruby.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#ifndef MRUBY_DATA_H
|
8
|
+
#define MRUBY_DATA_H
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Custom C wrapped data.
|
14
|
+
*
|
15
|
+
* Defining Ruby wrappers around native objects.
|
16
|
+
*/
|
17
|
+
MRB_BEGIN_DECL
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Custom data type description.
|
21
|
+
*/
|
22
|
+
typedef struct mrb_data_type {
|
23
|
+
/** data type name */
|
24
|
+
const char *struct_name;
|
25
|
+
|
26
|
+
/** data type release function pointer */
|
27
|
+
void (*dfree)(mrb_state *mrb, void*);
|
28
|
+
} mrb_data_type;
|
29
|
+
|
30
|
+
struct RData {
|
31
|
+
MRB_OBJECT_HEADER;
|
32
|
+
struct iv_tbl *iv;
|
33
|
+
const mrb_data_type *type;
|
34
|
+
void *data;
|
35
|
+
};
|
36
|
+
|
37
|
+
MRB_API struct RData *mrb_data_object_alloc(mrb_state *mrb, struct RClass* klass, void *datap, const mrb_data_type *type);
|
38
|
+
|
39
|
+
#define Data_Wrap_Struct(mrb,klass,type,ptr)\
|
40
|
+
mrb_data_object_alloc(mrb,klass,ptr,type)
|
41
|
+
|
42
|
+
#define Data_Make_Struct(mrb,klass,strct,type,sval,data) do { \
|
43
|
+
sval = mrb_malloc(mrb, sizeof(strct)); \
|
44
|
+
{ static const strct zero = { 0 }; *sval = zero; };\
|
45
|
+
data = Data_Wrap_Struct(mrb,klass,type,sval);\
|
46
|
+
} while (0)
|
47
|
+
|
48
|
+
#define RDATA(obj) ((struct RData *)(mrb_ptr(obj)))
|
49
|
+
#define DATA_PTR(d) (RDATA(d)->data)
|
50
|
+
#define DATA_TYPE(d) (RDATA(d)->type)
|
51
|
+
MRB_API void mrb_data_check_type(mrb_state *mrb, mrb_value, const mrb_data_type*);
|
52
|
+
MRB_API void *mrb_data_get_ptr(mrb_state *mrb, mrb_value, const mrb_data_type*);
|
53
|
+
#define DATA_GET_PTR(mrb,obj,dtype,type) (type*)mrb_data_get_ptr(mrb,obj,dtype)
|
54
|
+
MRB_API void *mrb_data_check_get_ptr(mrb_state *mrb, mrb_value, const mrb_data_type*);
|
55
|
+
#define DATA_CHECK_GET_PTR(mrb,obj,dtype,type) (type*)mrb_data_check_get_ptr(mrb,obj,dtype)
|
56
|
+
|
57
|
+
/* obsolete functions and macros */
|
58
|
+
#define mrb_data_check_and_get(mrb,obj,dtype) mrb_data_get_ptr(mrb,obj,dtype)
|
59
|
+
#define mrb_get_datatype(mrb,val,type) mrb_data_get_ptr(mrb, val, type)
|
60
|
+
#define mrb_check_datatype(mrb,val,type) mrb_data_get_ptr(mrb, val, type)
|
61
|
+
#define Data_Get_Struct(mrb,obj,type,sval) do {\
|
62
|
+
*(void**)&sval = mrb_data_get_ptr(mrb, obj, type); \
|
63
|
+
} while (0)
|
64
|
+
|
65
|
+
static inline void
|
66
|
+
mrb_data_init(mrb_value v, void *ptr, const mrb_data_type *type)
|
67
|
+
{
|
68
|
+
mrb_assert(mrb_type(v) == MRB_TT_DATA);
|
69
|
+
DATA_PTR(v) = ptr;
|
70
|
+
DATA_TYPE(v) = type;
|
71
|
+
}
|
72
|
+
|
73
|
+
MRB_END_DECL
|
74
|
+
|
75
|
+
#endif /* MRUBY_DATA_H */
|
@@ -0,0 +1,66 @@
|
|
1
|
+
/*
|
2
|
+
** mruby/debug.h - mruby debug info
|
3
|
+
**
|
4
|
+
** See Copyright Notice in mruby.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#ifndef MRUBY_DEBUG_H
|
8
|
+
#define MRUBY_DEBUG_H
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
|
12
|
+
/**
|
13
|
+
* MRuby Debugging.
|
14
|
+
*/
|
15
|
+
MRB_BEGIN_DECL
|
16
|
+
|
17
|
+
typedef enum mrb_debug_line_type {
|
18
|
+
mrb_debug_line_ary = 0,
|
19
|
+
mrb_debug_line_flat_map = 1
|
20
|
+
} mrb_debug_line_type;
|
21
|
+
|
22
|
+
typedef struct mrb_irep_debug_info_line {
|
23
|
+
uint32_t start_pos;
|
24
|
+
uint16_t line;
|
25
|
+
} mrb_irep_debug_info_line;
|
26
|
+
|
27
|
+
typedef struct mrb_irep_debug_info_file {
|
28
|
+
uint32_t start_pos;
|
29
|
+
const char *filename;
|
30
|
+
mrb_sym filename_sym;
|
31
|
+
uint32_t line_entry_count;
|
32
|
+
mrb_debug_line_type line_type;
|
33
|
+
union {
|
34
|
+
void *ptr;
|
35
|
+
mrb_irep_debug_info_line *flat_map;
|
36
|
+
uint16_t *ary;
|
37
|
+
} lines;
|
38
|
+
} mrb_irep_debug_info_file;
|
39
|
+
|
40
|
+
typedef struct mrb_irep_debug_info {
|
41
|
+
uint32_t pc_count;
|
42
|
+
uint16_t flen;
|
43
|
+
mrb_irep_debug_info_file **files;
|
44
|
+
} mrb_irep_debug_info;
|
45
|
+
|
46
|
+
/*
|
47
|
+
* get line from irep's debug info and program counter
|
48
|
+
* @return returns NULL if not found
|
49
|
+
*/
|
50
|
+
MRB_API const char *mrb_debug_get_filename(mrb_irep *irep, ptrdiff_t pc);
|
51
|
+
|
52
|
+
/*
|
53
|
+
* get line from irep's debug info and program counter
|
54
|
+
* @return returns -1 if not found
|
55
|
+
*/
|
56
|
+
MRB_API int32_t mrb_debug_get_line(mrb_irep *irep, ptrdiff_t pc);
|
57
|
+
|
58
|
+
MRB_API mrb_irep_debug_info_file *mrb_debug_info_append_file(
|
59
|
+
mrb_state *mrb, mrb_irep *irep,
|
60
|
+
uint32_t start_pos, uint32_t end_pos);
|
61
|
+
MRB_API mrb_irep_debug_info *mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep);
|
62
|
+
MRB_API void mrb_debug_info_free(mrb_state *mrb, mrb_irep_debug_info *d);
|
63
|
+
|
64
|
+
MRB_END_DECL
|
65
|
+
|
66
|
+
#endif /* MRUBY_DEBUG_H */
|