Skip to content
Newer
Older
100644 251 lines (203 sloc) 4.61 KB
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
1 // winxedxx_default.cxx
622f3db @NotFound add the get_pmc_keyed vtable function and improve keyed defaults
authored Jun 3, 2012
2 // (C) 2011-2012 Julián Albo
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
3
4 #include "winxedxx_types.h"
5 #include "winxedxx_object.h"
6 #include "winxedxx_default.h"
622f3db @NotFound add the get_pmc_keyed vtable function and improve keyed defaults
authored Jun 3, 2012
7 #include "winxedxx_integer.h"
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
8
9 #include <iostream>
10 #include <sstream>
4e6e131 @NotFound add and sub vtables, remove print vtables
authored May 28, 2012
11 #include <stdexcept>
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
12
13 namespace WinxedXX
14 {
15
16 //*************************************************************
17
4e6e131 @NotFound add and sub vtables, remove print vtables
authored May 28, 2012
18 WxxDefault::WxxDefault()
19 {
20 throw std::runtime_error("Default instantiated");
21 }
22
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
23 WxxDefault::WxxDefault(const std::string &name)
24 {
25 this->name = name;
26 }
27
28 WxxDefault::~WxxDefault()
29 {
30 //std::cerr << "~WxxDefault " << name << "\n";
31 }
32
eadc620 @NotFound init_pmc vtable, use in new keyed, implement in Exception and Integer
authored Jun 4, 2012
33 void WxxDefault::init_pmc(const WxxObjectPtr &arg)
34 {
35 notimplemented("init_pmc");
36 }
37
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
38 std::string WxxDefault::class_name() const
39 {
40 return name;
41 }
42
43 int WxxDefault::is_null() const
44 { return 0; }
45
46 std::string WxxDefault::getname() const { return name; }
47
48 int WxxDefault::instanceof(const std::string &type)
49 {
50 return type == name;
51 }
52
53 int WxxDefault::get_bool()
54 {
55 return get_integer();
56 }
57
58 int WxxDefault::get_integer()
59 {
60 notimplemented("get_integer");
61 return 0;
62 }
63
64 double WxxDefault::get_number()
65 {
66 notimplemented("get_number");
67 return 0;
68 }
69
df1d6bb @NotFound get_pointer and set_pointer vtables, some use in nci
authored Jun 2, 2012
70 void * WxxDefault::get_pointer()
71 {
72 notimplemented("get_pointer");
73 return 0;
74 }
75
76 void WxxDefault::set_pointer(void *)
77 {
78 notimplemented("set_pointer");
79 }
80
576f7d3 @NotFound use more explicit conversions
authored Jun 1, 2012
81 int WxxDefault::elements() const
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
82 {
83 notimplemented("elements");
84 return 0;
85 }
86
87 std::string WxxDefault::get_string()
88 {
89 notimplemented("get_string");
90 return std::string();
91 }
92
93 int WxxDefault::is_equal(const WxxObject &to)
94 {
95 notimplemented("is_equal");
96 return 0;
97 }
98
99 WxxObject & WxxDefault::set(int value)
100 {
101 notimplemented("set");
102 return *this;
103 }
104
105 WxxObject & WxxDefault::set(double value)
106 {
107 notimplemented("set");
108 return *this;
109 }
110
111 WxxObject & WxxDefault::set(const std::string &s)
112 {
113 notimplemented("set");
114 return *this;
115 }
116
117 void WxxDefault::increment()
118 {
119 notimplemented("increment");
120 }
121
122 void WxxDefault::decrement()
123 {
124 notimplemented("decrement");
125 }
126
4e6e131 @NotFound add and sub vtables, remove print vtables
authored May 28, 2012
127 WxxObjectPtr WxxDefault::add(const WxxObjectPtr &value)
128 {
129 notimplemented("add");
aa73220 @NotFound use less object ptr implicit initialization with int
authored Jun 1, 2012
130 return winxedxxnull;
4e6e131 @NotFound add and sub vtables, remove print vtables
authored May 28, 2012
131 }
132
133 WxxObjectPtr WxxDefault::sub(const WxxObjectPtr &value)
134 {
135 notimplemented("sub");
aa73220 @NotFound use less object ptr implicit initialization with int
authored Jun 1, 2012
136 return winxedxxnull;
4e6e131 @NotFound add and sub vtables, remove print vtables
authored May 28, 2012
137 }
138
5276bd7 @NotFound get_integer_keyed and get_number_keyed (int)
authored Jun 2, 2012
139 int WxxDefault::get_integer_keyed(int i)
140 {
141 return get_pmc_keyed(i).get_integer();
142 }
143
144 double WxxDefault::get_number_keyed(int i)
145 {
146 return get_pmc_keyed(i).get_number();
147 }
148
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
149 std::string WxxDefault::get_string_keyed(int i)
150 {
4e6e131 @NotFound add and sub vtables, remove print vtables
authored May 28, 2012
151 return get_pmc_keyed(i).get_string();
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
152 }
153
154 WxxObjectPtr WxxDefault::get_pmc_keyed(int i)
155 {
622f3db @NotFound add the get_pmc_keyed vtable function and improve keyed defaults
authored Jun 3, 2012
156 return get_pmc_keyed(WxxObjectPtr(new WxxInteger(i)));
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
157 }
158
159 WxxObjectPtr WxxDefault::get_pmc_keyed(const std::string &s)
160 {
622f3db @NotFound add the get_pmc_keyed vtable function and improve keyed defaults
authored Jun 3, 2012
161 notimplemented("get_pmc_keyed_str");
162 return winxedxxnull;
163 }
164
165 WxxObjectPtr WxxDefault::get_pmc_keyed(const WxxObjectPtr &key)
166 {
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
167 notimplemented("get_pmc_keyed");
168 return winxedxxnull;
169 }
170
171 void WxxDefault::set_pmc_keyed(int i, const WxxObjectPtr &value)
172 {
622f3db @NotFound add the get_pmc_keyed vtable function and improve keyed defaults
authored Jun 3, 2012
173 notimplemented("set_pmc_keyed_int");
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
174 }
175
843cfbd @NotFound improve a bit set_pmc_keyed string and implement it in Namespace
authored Jun 3, 2012
176 void WxxDefault::set_pmc_keyed(const std::string &s, const WxxObjectPtr &value)
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
177 {
622f3db @NotFound add the get_pmc_keyed vtable function and improve keyed defaults
authored Jun 3, 2012
178 notimplemented("set_pmc_keyed_str");
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
179 }
180 int WxxDefault::exists(const std::string &key)
181 {
182 notimplemented("exists");
183 return 0;
184 }
185
186 WxxObjectPtr & WxxDefault::get_attr_str(const std::string &s)
187 {
188 std::map<std::string, WxxObjectPtr>::iterator attr = attributes.find(s);
189 if (attr == attributes.end())
190 return winxedxxnull;
191 else
192 return attr->second;
193 }
194
195 void WxxDefault::set_attr_str(const std::string &s, const WxxObjectPtr &value)
196 {
d670257 @NotFound improve get and set attributes
authored Jun 14, 2012
197 std::pair <std::map<std::string, WxxObjectPtr>::iterator, bool> found =
198 attributes.insert(std::make_pair(s, value));
199 if (! found.second)
200 found.first->second = value;
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
201 }
202
203 WxxObjectPtr WxxDefault::get_iter()
204 {
205 notimplemented("get_iter");
206 return winxedxxnull;
207 }
208
209 WxxObjectPtr WxxDefault::shift_pmc()
210 {
211 notimplemented("shift_pmc");
212 return winxedxxnull;
213 }
214
bc6a98b @NotFound Improvements in object model:
authored May 31, 2012
215 WxxObjectPtr WxxDefault::get_class()
216 {
217 //notimplemented("get_class");
218 //return winxedxxnull;
219 return this;
220 }
221
222 WxxObjectPtr WxxDefault::instantiate()
223 {
224 notimplemented("instantiate");
225 return winxedxxnull;
226 }
227
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
228 WxxObjectPtr WxxDefault::operator()(WxxObjectArray &args)
229 {
230 notimplemented("invoke");
231 return winxedxxnull;
232 }
233
234 WxxObjectPtr WxxDefault::call_method(const std::string &methname, WxxObjectArray &args)
235 {
236 throw wxx_error("Method '" + methname +
237 "' not found for invocant of class '" + name + "'");
238 return winxedxxnull;
239 }
240
bc6a98b @NotFound Improvements in object model:
authored May 31, 2012
241 void WxxDefault::notimplemented(const std::string &funcname) const
f513284 @NotFound move WxxNull and WxxDefault to its own cxx files
authored Nov 7, 2011
242 {
243 throw wxx_error(funcname + " not implemented in " + name);
244 }
245
246 //*************************************************************
247
248 } // namespace WinxedXX
249
250 // End
Something went wrong with that request. Please try again.