-
Notifications
You must be signed in to change notification settings - Fork 1
/
winxedxx_types.h
170 lines (144 loc) · 5.04 KB
/
winxedxx_types.h
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#ifndef INCLUDE_WINXEDXX_TYPES_H
#define INCLUDE_WINXEDXX_TYPES_H
// winxedxx_types.h
// (C) 2011 Julián Albo
#include <string>
#include <map>
namespace WinxedXX
{
class WxxRefcounted
{
protected:
WxxRefcounted();
WxxRefcounted(size_t initial);
virtual ~WxxRefcounted();
public:
void incref();
void decref();
private:
size_t refcount;
};
class WxxObject;
class WxxObjectArray;
class WxxLibrary;
class WxxInnerFunction;
class WxxNamespace;
class WxxFunctionVars : public WxxRefcounted
{
protected:
WxxFunctionVars() : WxxRefcounted(1)
{
}
};
class WxxDataHolder
{
public:
WxxDataHolder(WxxFunctionVars *newdata) : data(newdata) { data->incref(); }
~WxxDataHolder() { data->decref(); }
private:
WxxFunctionVars *data;
};
class WxxObjectPtr
{
public:
WxxObjectPtr();
WxxObjectPtr(int value);
WxxObjectPtr(double value);
WxxObjectPtr(const std::string &value);
WxxObjectPtr(const WxxObjectPtr &old);
WxxObjectPtr(WxxObject * obj);
WxxObjectPtr(WxxObjectPtr (*)(const WxxObjectArray&));
WxxObjectPtr(WxxNamespace * obj);
WxxObjectPtr(WxxInnerFunction * obj);
~WxxObjectPtr();
std::string class_name() const;
WxxObjectPtr & set(int value);
WxxObjectPtr & set(double value);
WxxObjectPtr & set(const std::string &s);
WxxObjectPtr &operator = (const WxxObjectPtr &from);
WxxObjectPtr & operator = (int i);
WxxObjectPtr & operator = (double value);
WxxObjectPtr & operator = (const std::string &s);
int is_equal(const WxxObjectPtr &from) const;
int is_same(const WxxObjectPtr &from) const;
operator int() const;
operator bool() const;
operator double() const;
operator std::string() const;
WxxObjectPtr & increment();
WxxObjectPtr & decrement();
int is_null() const;
int instanceof(const std::string &type) const;
std::string get_string() const;
int get_integer() const;
double get_number() const;
void *get_pointer() const;
void set_pointer(void *p) const;
int elements() const;
WxxObjectPtr add(const WxxObjectPtr &value);
WxxObjectPtr sub(const WxxObjectPtr &value);
std::string get_string_keyed(int i) const;
WxxObjectPtr get_pmc_keyed(int i) const;
WxxObjectPtr get_pmc_keyed(const std::string &s) const;
WxxObjectPtr get_pmc_keyed(const WxxObjectPtr &key) const;
void set_pmc_keyed(int i, const WxxObjectPtr &value) const;
void set_pmc_keyed(const std::string &s, const WxxObjectPtr &value) const;
void set_pmc_keyed(const WxxObjectPtr &key, const WxxObjectPtr &value) const;
int exists(const std::string &key) const;
WxxObjectPtr & get_attr_str(const std::string &s) const;
void set_attr_str(const std::string &s, const WxxObjectPtr &value) const;
void push(WxxObjectPtr obj) const;
void push(int i) const;
void push(double value) const;
void push(const std::string &str) const;
WxxObjectPtr get_iter() const;
WxxObjectPtr shift_pmc() const;
WxxObjectPtr get_class() const;
WxxObjectPtr instantiate() const;
WxxObjectPtr operator()(const WxxObjectArray &args) const;
WxxObjectPtr call_method(const std::string &methname) const;
WxxObjectPtr call_method(const std::string &methname, WxxObjectArray &args) const;
WxxLibrary *getlib() const;
private:
WxxObject *object;
};
extern WxxObjectPtr winxedxxnull;
class WxxInnerFunction : public WxxRefcounted
{
public:
virtual WxxObjectPtr operator()(const WxxObjectArray &args) = 0;
};
WxxObjectPtr wxx_error(const std::string &message);
WxxObjectPtr wxx_error(const std::string &message, int severity);
WxxObjectPtr wxx_error(const std::string &message, int severity, int type);
WxxObjectPtr wxx_die(const std::string &message);
int wxx_time();
double wxx_floattime();
int wxx_sleep(int t);
int wxx_sleep(double t);
int wxx_length(const std::string &str);
int wxx_length(const WxxObjectPtr &obj);
std::string wxx_chr(int code);
int wxx_ord(std::string src);
int wxx_ord(std::string src, int pos);
std::string wxx_substr(const std::string &from, int start);
std::string wxx_substr(const std::string &from, int start, int length);
int wxx_indexof(const std::string &from, const std::string &search);
int wxx_indexof(const std::string &from, const std::string &search, int pos);
std::string wxx_chomp(const std::string &src);
std::string wxx_escape(const std::string &src);
std::string wxx_unescape(const std::string &src);
WxxObjectPtr wxx_new(const std::string &name);
WxxObjectPtr wxx_new(const std::string &name, WxxObjectArray args);
WxxObjectPtr wxx_new_string(const std::string &name);
WxxObjectPtr wxx_new_string(const std::string &name, WxxObjectPtr arg);
WxxObjectPtr wxx_new_obj(const WxxObjectPtr &clobj);
WxxObjectPtr wxx_new_obj(const WxxObjectPtr &clobj,
const std::string &constructor);
WxxObjectPtr wxx_new_obj(const WxxObjectPtr &clobj,
const std::string &constructor, WxxObjectArray args);
WxxObjectPtr wxx_open(const std::string &filename);
WxxObjectPtr wxx_open(const std::string &filename, const std::string &mode);
} // namespace WinxedXX
#endif
// End of winxedxx_types.h