-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathcfunc_platform.c
More file actions
51 lines (42 loc) · 1.11 KB
/
cfunc_platform.c
File metadata and controls
51 lines (42 loc) · 1.11 KB
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
//
// CFunc::call method
//
// See Copyright Notice in cfunc.h
//
#include "cfunc_platform.h"
#include "mruby/string.h"
#include "mruby/class.h"
static mrb_value
cfunc_platform_is_posix(mrb_state *mrb, mrb_value self)
{
#ifdef __USE_POSIX
return mrb_true_value();
#else
return mrb_false_value();
#endif
}
static mrb_value
cfunc_platform_is_win32(mrb_state *mrb, mrb_value self)
{
#ifdef _WIN32
return mrb_true_value();
#else
return mrb_false_value();
#endif
}
static mrb_value
cfunc_platform_is_darwin(mrb_state *mrb, mrb_value self)
{
#ifdef __APPLE__
return mrb_true_value();
#else
return mrb_false_value();
#endif
}
void init_cfunc_platform(mrb_state *mrb, struct RClass* module)
{
struct RClass *struct_class = mrb_define_class_under(mrb, module, "Platform", mrb->object_class);
mrb_define_class_method(mrb, struct_class, "is_posix?", cfunc_platform_is_posix, MRB_ARGS_NONE());
mrb_define_class_method(mrb, struct_class, "is_win32?", cfunc_platform_is_win32, MRB_ARGS_NONE());
mrb_define_class_method(mrb, struct_class, "is_darwin?", cfunc_platform_is_darwin, MRB_ARGS_NONE());
}