Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 676 lines (574 sloc) 14.621 kB
0c910b8 @NotFound start reorganizing components
authored
1 // winxedxx_util.cxx
35db5af @NotFound refactor new
authored
2 // (C) 2011-2012 Julián Albo
0c910b8 @NotFound start reorganizing components
authored
3
a8a097a @NotFound improve operators ++ and --:
authored
4 #include "winxedxx.h"
21f52be @NotFound more reorganization
authored
5 #include "winxedxx_handle.h"
56e602d @NotFound ByteBuffer
authored
6 #include "winxedxx_ptr.h"
7 #include "winxedxx_bytebuffer.h"
0c910b8 @NotFound start reorganizing components
authored
8
4ab9282 @NotFound make definition of some functions unique:
authored
9 #include <iostream>
0c910b8 @NotFound start reorganizing components
authored
10 #include <sstream>
11
4636d81 @NotFound implement assign int=string and string=int, half-implement builtins d…
authored
12 #include <stdlib.h>
2950c69 @NotFound bultin sleep
authored
13 #include <math.h>
4636d81 @NotFound implement assign int=string and string=int, half-implement builtins d…
authored
14
41c530c @NotFound builtis time and floattime
authored
15 #include <time.h>
16 #include <sys/time.h>
8697f0c @NotFound wait for child process in spawnw
authored
17 #include <sys/types.h>
18 #include <sys/wait.h>
19
0c910b8 @NotFound start reorganizing components
authored
20 namespace WinxedXX
21 {
22
23 WxxObjectPtr winxedxxnull;
24
25 //*************************************************************
26
27 class WxxException : public WxxDefault
28 {
29 public:
15dc476 @NotFound allow new ['Exception']
authored
30 WxxException(const std::string &message = "",
31 int severity = 2, int type = 0);
eadc620 @NotFound init_pmc vtable, use in new keyed, implement in Exception and Integer
authored
32 void init_pmc(const WxxObjectPtr &arg);
0c910b8 @NotFound start reorganizing components
authored
33 std::string get_string();
15dc476 @NotFound allow new ['Exception']
authored
34 WxxObjectPtr get_pmc_keyed(const std::string &str);
0c910b8 @NotFound start reorganizing components
authored
35 private:
36 std::string msg;
37 int sev;
38 int typ;
39 };
40
41 WxxException::WxxException(const std::string &message, int severity, int type) :
42 WxxDefault("Exception"),
43 msg(message),
44 sev(severity),
45 typ(type)
46 {
48831b9 @NotFound use less object ptr implicit initialization with string
authored
47 set_attr_str(std::string("message"), WxxObjectPtr(new WxxString(message)));
0c910b8 @NotFound start reorganizing components
authored
48 set_attr_str(std::string("severity"), WxxObjectPtr(severity));
49 set_attr_str(std::string("type"), WxxObjectPtr(type));
50 }
51
eadc620 @NotFound init_pmc vtable, use in new keyed, implement in Exception and Integer
authored
52 void WxxException::init_pmc(const WxxObjectPtr &arg)
53 {
54 WxxObjectPtr aux;
55 aux = arg.get_pmc_keyed("message");
56 if (! aux.is_null())
57 set_attr_str(std::string("message"), aux);
58 aux = arg.get_pmc_keyed("severity");
59 if (! aux.is_null())
60 set_attr_str(std::string("severity"), aux);
61 aux = arg.get_pmc_keyed("type");
62 if (! aux.is_null())
63 set_attr_str(std::string("type"), aux);
64 }
65
0c910b8 @NotFound start reorganizing components
authored
66 std::string WxxException::get_string()
67 { return msg; }
68
15dc476 @NotFound allow new ['Exception']
authored
69 WxxObjectPtr WxxException::get_pmc_keyed(const std::string &str)
70 {
71 return get_attr_str(str);
72 }
73
0c910b8 @NotFound start reorganizing components
authored
74 //*************************************************************
75
0f38797 @NotFound implement get_integer vtable and refactor casts to int and string
authored
76 int wxx_int_cast(int i) { return i; }
77 int wxx_int_cast(double n) { return n; }
78 int wxx_int_cast(const std::string &str) { return atoi(str.c_str()); }
79 int wxx_int_cast(const WxxObjectPtr &obj) { return obj.get_integer(); }
0c910b8 @NotFound start reorganizing components
authored
80
e99e63f @NotFound implement get_number vtable and refactor casts to float
authored
81
82 double wxx_num_cast(int i) { return i; }
83 double wxx_num_cast(double n) { return n; }
84 double wxx_num_cast(const std::string &str)
64daf6c @NotFound assign string = num and num = string
authored
85 {
e99e63f @NotFound implement get_number vtable and refactor casts to float
authored
86 return atof(str.c_str());
64daf6c @NotFound assign string = num and num = string
authored
87 }
e99e63f @NotFound implement get_number vtable and refactor casts to float
authored
88 double wxx_num_cast(const WxxObjectPtr &obj) { return obj.get_number(); }
89
64daf6c @NotFound assign string = num and num = string
authored
90
0f38797 @NotFound implement get_integer vtable and refactor casts to int and string
authored
91 std::string www_string_cast(int i)
0c910b8 @NotFound start reorganizing components
authored
92 {
93 std::ostringstream oss;
0f38797 @NotFound implement get_integer vtable and refactor casts to int and string
authored
94 oss << i;
0c910b8 @NotFound start reorganizing components
authored
95 return oss.str();
96 }
0f38797 @NotFound implement get_integer vtable and refactor casts to int and string
authored
97 std::string www_string_cast(double n)
4636d81 @NotFound implement assign int=string and string=int, half-implement builtins d…
authored
98 {
0f38797 @NotFound implement get_integer vtable and refactor casts to int and string
authored
99 std::ostringstream oss;
100 oss << n;
101 return oss.str();
4636d81 @NotFound implement assign int=string and string=int, half-implement builtins d…
authored
102 }
0f38797 @NotFound implement get_integer vtable and refactor casts to int and string
authored
103 std::string wxx_string_cast(const std::string &str) { return str; }
104 std::string wxx_string_cast(const WxxObjectPtr &obj) { return obj.get_string(); }
4636d81 @NotFound implement assign int=string and string=int, half-implement builtins d…
authored
105
f0ee1f0 @NotFound implement repeat string and improve a bit test output
authored
106 std::string wxx_repeat_string(std::string s, int n)
107 {
108 std::string result;
109 for (int i = 0; i < n; ++i)
110 result += s;
111 return result;
112 }
113
a8a097a @NotFound improve operators ++ and --:
authored
114 //*********** operators ++ and -- prefix ****************
115
116 int & wxx_preinc(int &i)
117 {
118 return ++i;
119 }
120
121 WxxObjectPtr & wxx_preinc(WxxObjectPtr &o)
122 {
123 return o.increment();
124 }
125
126 int & wxx_predec(int &i)
127 {
128 return --i;
129 }
130
131 WxxObjectPtr & wxx_predec(WxxObjectPtr &o)
132 {
133 return o.decrement();
134 }
135
136 //*********** operators ++ and -- postfix ****************
137
138 // Incorrect implementation for object ptr, but enough for some uses.
139 // It must modify in place the content pointed by the operand,
140 // this makes it point to a new object.
141
142 int wxx_postinc(int &i)
143 {
144 return i++;
145 }
146
147 WxxObjectPtr wxx_postinc(WxxObjectPtr &o)
148 {
149 WxxObjectPtr r(o);
150 o = wxx_add(r, 1);
151 return r;
152 }
153
154 int wxx_postdec(int &i)
155 {
156 return i--;
157 }
158
159 WxxObjectPtr wxx_postdec(WxxObjectPtr &o)
160 {
161 WxxObjectPtr r(o);
162 o = wxx_sub(r, 1);
163 return r;
164 }
165
4ab9282 @NotFound make definition of some functions unique:
authored
166 //*********** operator + ****************
167
168 int wxx_add(int i1, int i2)
169 {
170 return i1 + i2;
171 }
172
173 double wxx_add(double f1, double f2)
174 {
175 return f1 + f2;
176 }
177
178 double wxx_add(double f1, int i2)
179 {
180 return f1 + i2;
181 }
182
183 double wxx_add(int i1, double f2)
184 {
185 return i1 + f2;
186 }
187
188 std::string wxx_add(int i1, std::string s2)
189 {
190 return wxx_string_cast(i1) + s2;
191 }
192
193 std::string wxx_add(std::string s1, int i2)
194 {
195 return s1 + wxx_string_cast(i2);
196 }
197
198 WxxObjectPtr wxx_add(int i1, const WxxObjectPtr &o2)
199 {
200 return i1 + int(o2);
201 }
202
203 WxxObjectPtr wxx_add(const WxxObjectPtr &o1, int i2)
204 {
205 return int(o1) + i2;
206 }
207
8a3a5c6 @NotFound improve operator +
authored
208 WxxObjectPtr wxx_add(WxxObjectPtr &o1, WxxObjectPtr &o2)
209 {
210 return o1.add(o2);
211 }
212
4ab9282 @NotFound make definition of some functions unique:
authored
213 //*********** operator - ****************
214
215 int wxx_sub(int i1, int i2)
216 {
217 return i1 - i2;
218 }
219
220 double wxx_sub(double f1, double f2)
221 {
222 return f1 - f2;
223 }
224
225 double wxx_sub(double f1, int i2)
226 {
227 return f1 - i2;
228 }
229
230 double wxx_sub(int i1, double f2)
231 {
232 return i1 - f2;
233 }
234
235 WxxObjectPtr wxx_sub(int i1, const WxxObjectPtr &o2)
236 {
237 return i1 - int(o2);
238 }
239
240 WxxObjectPtr wxx_sub(const WxxObjectPtr &o1, int i2)
241 {
242 return int(o1) - i2;
243 }
244
7673b6a @NotFound improve operator * and test it
authored
245 //*********** operator * ****************
246
247 int wxx_mul(int i1, int i2)
248 {
249 return i1 * i2;
250 }
251
252 double wxx_mul(double f1, double f2)
253 {
254 return f1 * f2;
255 }
256
257 double wxx_mul(double f1, int i2)
258 {
259 return f1 * i2;
260 }
261
262 double wxx_mul(int i1, double f2)
263 {
264 return i1 * f2;
265 }
266
267 WxxObjectPtr wxx_mul(int i1, const WxxObjectPtr &o2)
268 {
269 return i1 * o2.get_integer();
270 }
271
272 WxxObjectPtr wxx_mul(const WxxObjectPtr &o1, int i2)
273 {
274 return o1.get_integer() * i2;
275 }
276
277 WxxObjectPtr wxx_mul(WxxObjectPtr &o1, WxxObjectPtr &o2)
278 {
279 return o1.get_integer() * o2.get_integer();
280 }
281
d3230b2 @NotFound change implementation of operator / - check divisions by zero
authored
282 //*********** operator / ****************
283
284 static void checkdivzero(int value)
285 {
76ca240 @NotFound hardcode exception type in division by zero
authored
286 // Type and severity hardcoded.
d3230b2 @NotFound change implementation of operator / - check divisions by zero
authored
287 if (value == 0)
76ca240 @NotFound hardcode exception type in division by zero
authored
288 throw wxx_error("Division by zero", 2, 29);
d3230b2 @NotFound change implementation of operator / - check divisions by zero
authored
289 }
290 static void checkdivzero(double value)
291 {
292 if (value == 0)
293 throw wxx_error("Division by zero");
294 }
295
296 int wxx_div(int i1, int i2)
297 {
298 checkdivzero(i2);
299 return i1 / i2;
300 }
301
302 double wxx_div(double f1, double f2)
303 {
304 checkdivzero(f2);
305 return f1 / f2;
306 }
307
308 double wxx_div(double f1, int i2)
309 {
310 checkdivzero(i2);
311 return f1 / i2;
312 }
313
314 double wxx_div(int i1, double f2)
315 {
316 checkdivzero(f2);
317 return i1 / f2;
318 }
319
320 WxxObjectPtr wxx_div(int i1, const WxxObjectPtr &o2)
321 {
322 int i2 = int(o2);
323 checkdivzero(i2);
324 return i1 / i2;
325 }
326
327 WxxObjectPtr wxx_div(const WxxObjectPtr &o1, int i2)
328 {
329 checkdivzero(i2);
330 return int(o1) / i2;
331 }
332
4ab9282 @NotFound make definition of some functions unique:
authored
333 //******************************************************
334
335 int wxx_print(int i) { std::cout << i; return 0; }
336 int wxx_print(const std::string &s) { std::cout << s; return 0; }
337 int wxx_print(double n) { std::cout << n; return 0; }
338 int wxx_print(WxxObjectPtr obj) { std::cout << obj.get_string(); return 0; }
339
340 int wxx_eprint(int i) { std::cerr << i; return 0; }
341 int wxx_eprint(const std::string &s) { std::cerr << s; return 0; }
342 int wxx_eprint(double n) { std::cerr << n; return 0; }
343 int wxx_eprint(WxxObjectPtr obj) { std::cerr << obj.get_string(); return 0; }
344
345 int wxx_instanceof(WxxObjectPtr &obj, const std::string &type)
346 {
347 return obj.instanceof(type);
348 }
349 int wxx_isnull(WxxObjectPtr obj)
350 {
351 return obj.is_null();
352 }
353
354 int wxx_booland(int li, int ri)
355 {
356 return li ? ri : li;
357
358 }
359 int wxx_boolor(int li, int ri)
360 {
361 return li ? li : ri;
362 }
0c910b8 @NotFound start reorganizing components
authored
363
364 WxxObjectPtr wxx_error(const std::string &message)
365 {
366 return WxxObjectPtr((WxxObject *)new WxxException(message));
367 }
368 WxxObjectPtr wxx_error(const std::string &message, int severity)
369 {
370 return WxxObjectPtr((WxxObject *)new WxxException(message, severity));
371 }
372 WxxObjectPtr wxx_error(const std::string &message, int severity, int type)
373 {
374 return WxxObjectPtr((WxxObject *)new WxxException(message, severity, type));
375 }
376
5d84756 @NotFound wxx_die to implemente the die builtin separatedly from wxx_error
authored
377 WxxObjectPtr wxx_die(const std::string &message)
378 {
379 return WxxObjectPtr((WxxObject *)new WxxException(message));
380 }
381
21f52be @NotFound more reorganization
authored
382 WxxObjectPtr wxx_getstdin()
383 {
384 return WxxObjectPtr(new WxxFileHandle(1));
385 }
386 WxxObjectPtr wxx_getstdout()
387 {
388 return WxxObjectPtr(new WxxFileHandle(2));
389 }
390 WxxObjectPtr wxx_getstderr()
391 {
392 return WxxObjectPtr(new WxxFileHandle(3));
393 }
0c910b8 @NotFound start reorganizing components
authored
394
41c530c @NotFound builtis time and floattime
authored
395 int wxx_time()
396 {
397 return time(0);
398 }
399
400 double wxx_floattime()
401 {
402 struct timeval t;
403 gettimeofday(&t, 0);
404 return (double)t.tv_sec + (double)t.tv_usec / 1.0e6;
405 }
406
2950c69 @NotFound bultin sleep
authored
407 int wxx_sleep(int t)
408 {
409 sleep(t);
410 return 0;
411 }
412
413 int wxx_sleep(double t)
414 {
415 if (t >= 1.0) {
416 int seconds = floor(t);
3779652 @NotFound codingstd: no hard tabs
authored
417 sleep(seconds);
418 t -= seconds;
2950c69 @NotFound bultin sleep
authored
419 }
420 usleep(t * 1.0e6);
421 return 0;
422 }
423
d9ad1c7 @NotFound refactor length builtin
authored
424 int wxx_length(const std::string &str)
425 {
426 return str.length();
427 }
428 int wxx_length(const WxxObjectPtr &obj)
429 {
430 return wxx_length(obj.get_string());
431 }
432
2a38b81 @NotFound reimplement 'ord' and add a few tests for it
authored
433 std::string wxx_chr(int code)
434 {
435 return std::string(1, code);
436 }
437
176fec3 @NotFound reimplement 'ord'
authored
438 int wxx_ord(std::string src)
439 {
440 return (unsigned char)src.at(0);
441 }
442 int wxx_ord(std::string src, int pos)
443 {
444 return (unsigned char)src.at(pos);
445 }
446
75086b8 @NotFound refactor substr and add a few tests for it
authored
447 std::string wxx_substr(const std::string &from, int start, int length)
448 {
95a369b @NotFound handle negative arguments in substr
authored
449 if (start < 0)
450 start += length;
451 if (start < 0 || start > length || length < 0)
452 throw wxx_error("Cannot take substr outside string");
75086b8 @NotFound refactor substr and add a few tests for it
authored
453 return from.substr(start, length);
454 }
95a369b @NotFound handle negative arguments in substr
authored
455 std::string wxx_substr(const std::string &from, int start)
456 {
457 return wxx_substr(from, start, from.length());
458 }
75086b8 @NotFound refactor substr and add a few tests for it
authored
459
279785d @NotFound refactor indexof and fix ord
authored
460 int wxx_indexof(const std::string &from, const std::string &search)
461 {
462 return from.find(search);
463 }
464 int wxx_indexof(const std::string &from, const std::string &search, int pos)
465 {
466 return from.find(search, pos);
467 }
468
fb60f56 @NotFound chomp
authored
469 std::string wxx_chomp(const std::string &src)
470 {
471 if (std::string::size_type l = src.size())
472 if (src[l - 1] == '\n')
473 return src.substr(0, l - 1);
474 return src;
475 }
476
4ab9282 @NotFound make definition of some functions unique:
authored
477 WxxObjectPtr wxx_typeof(WxxObjectPtr &thing)
478 {
bc6a98b @NotFound Improvements in object model:
authored
479 return thing.get_class();
4ab9282 @NotFound make definition of some functions unique:
authored
480 }
481
482 std::string wxx_join(const std::string &sep, const WxxObjectPtr &arr)
483 {
484 std::string result;
485 int n = arr.elements();
486 for (int i = 0; i < n; ++i)
487 {
488 if (i > 0)
489 result += sep;
490 result += arr.get_string_keyed(i);
491 }
492 return result;
493 }
494
495 WxxObjectPtr wxx_split(const std::string &sep, std::string src)
496 {
497 WxxObjectPtr result(new WxxStringArray());
498 std::string::size_type l = sep.length();
499 std::string::size_type pos = 0;
500 while ((pos = src.find(sep)) != std::string::npos)
501 {
502 result.push(src.substr(0, pos));
503 src.erase(0, pos + l);
504 }
505 result.push(src);
506 return result;
507 }
508
fb63e42 @NotFound barely implement escape
authored
509 std::string wxx_escape(const std::string &src)
510 {
511 std::ostringstream oss;
512 for (std::string::size_type i = 0; i < src.size(); ++i) {
513 unsigned char c = src[i];
514 switch (c) {
ccb8711 @NotFound partially implement unescape and improve escape
authored
515 case '\n': oss << "\\n"; break;
516 case '\r': oss << "\\n"; break;
517 case '\t': oss << "\\t"; break;
518 case '\\': oss << "\\\\"; break;
fb63e42 @NotFound barely implement escape
authored
519 default:
520 if (c < 0x20 || c >= 0x80)
521 oss << "\\x{" << std::hex << (int) c << "}";
522 else
523 oss << c;
524 }
525 }
526 return oss.str();
527 }
528
ccb8711 @NotFound partially implement unescape and improve escape
authored
529 std::string wxx_unescape(const std::string &src)
530 {
531 const int l = src.length();
532 std::string result = "";
533 for (int i = 0; i < l; ++i) {
534 char c = src[i];
535 switch (c) {
536 case '\\':
537 c = src[++i];
538 switch (c) {
539 case 'n': result += '\n'; break;
540 case 'r': result += '\r'; break;
541 case 't': result += '\t'; break;
542 case '\\': result += '\\'; break;
543 default:
544 throw wxx_error("unescape not fully implemented");
545 }
546 break;
547 default:
548 result += c;
549 }
550 }
551 return result;
552 }
553
35db5af @NotFound refactor new
authored
554 WxxObjectPtr wxx_new(const std::string &name)
555 {
556 //std::cerr << "wxx_new " << name << '\n';
557 return new WxxInstance(name);
558 }
559
560 WxxObjectPtr wxx_new(const std::string &name, WxxObjectArray args)
561 {
562 //std::cerr << "wxx_new " << name << '\n';
563 WxxInstance *instance = new WxxInstance(name);
564 WxxObjectPtr obj(instance);
565 instance->call_method(name, args);
566 return obj;
567 }
568
eadc620 @NotFound init_pmc vtable, use in new keyed, implement in Exception and Integer
authored
569 static WxxObject * new_string(const std::string name)
35db5af @NotFound refactor new
authored
570 {
571 // Sepcial cases for parrot PMC names
7f00fa7 @NotFound incomplete implementation of StringHandle and fake-implement new Bool…
authored
572 if (name == "Integer" || name == "Boolean")
35db5af @NotFound refactor new
authored
573 return new WxxInteger(0);
574 if (name == "Float")
575 return new WxxFloat(0.0);
576 if (name == "String")
577 return new WxxString("");
578 if (name == "Hash")
579 return new WxxHash();
854e0eb @NotFound allow keyed new for parrot string PMC types
authored
580 if (name == "ResizableIntegerArray" || name == "FixedIntegerArray")
581 return new WxxIntegerArray();
582 if (name == "ResizableFloatArray" || name == "FixedFloatArray")
583 return new WxxFloatArray();
584 if (name == "ResizableStringArray" || name == "FixedStringArray")
585 return new WxxStringArray();
586 if (name == "ResizablePMCArray" || name == "FixedPMCArray")
587 return new WxxObjectArray();
15dc476 @NotFound allow new ['Exception']
authored
588 if (name == "Exception")
589 return new WxxException();
35db5af @NotFound refactor new
authored
590 if (name == "FileHandle")
591 return new WxxFileHandle();
7f00fa7 @NotFound incomplete implementation of StringHandle and fake-implement new Bool…
authored
592 if (name == "StringHandle")
593 return new WxxStringHandle();
56e602d @NotFound ByteBuffer
authored
594 if (name == "ByteBuffer")
595 return new WxxByteBuffer();
eadc620 @NotFound init_pmc vtable, use in new keyed, implement in Exception and Integer
authored
596 return 0;
597 }
35db5af @NotFound refactor new
authored
598
eadc620 @NotFound init_pmc vtable, use in new keyed, implement in Exception and Integer
authored
599 WxxObjectPtr wxx_new_string(const std::string &name)
600 {
601 WxxObject * obj = new_string(name);
602 if (obj)
603 return WxxObjectPtr(obj);
604 else
605 return wxx_new(name);
606 }
607
608 WxxObjectPtr wxx_new_string(const std::string &name, WxxObjectPtr arg)
609 {
610 WxxObject * obj = new_string(name);
611 if (! obj)
612 obj = new WxxInstance(name);
613 obj->init_pmc(arg);
614 return WxxObjectPtr(obj);
35db5af @NotFound refactor new
authored
615 }
616
1511b37 @NotFound improve operator new:
authored
617 WxxObjectPtr wxx_new_obj(const WxxObjectPtr &clobj)
9780168 @NotFound improve operator new:
authored
618 {
1511b37 @NotFound improve operator new:
authored
619 return clobj.instantiate();
9780168 @NotFound improve operator new:
authored
620 }
621
1511b37 @NotFound improve operator new:
authored
622 WxxObjectPtr wxx_new_obj(const WxxObjectPtr &clobj,
623 const std::string &constructor)
624 {
625 WxxObjectPtr obj = clobj.instantiate();
626 obj.call_method(constructor);
627 return obj;
628 }
629
630 WxxObjectPtr wxx_new_obj(const WxxObjectPtr &clobj,
631 const std::string &constructor, WxxObjectArray args)
632 {
633 WxxObjectPtr obj = clobj.instantiate();
634 obj.call_method(constructor, args);
635 return obj;
636 }
637
638
fd64b59 @NotFound refactor builtin open
authored
639 WxxObjectPtr wxx_open(const std::string &filename)
640 {
641 WxxFileHandle *handle = new WxxFileHandle();
642 return handle->open(filename);
643 }
644
645 WxxObjectPtr wxx_open(const std::string &filename, const std::string &mode)
646 {
647 WxxFileHandle *handle = new WxxFileHandle();
648 return handle->open(filename, mode);
649 }
650
0c910b8 @NotFound start reorganizing components
authored
651 WxxObjectPtr wxx_spawnw(WxxObjectPtr obj)
652 {
653 int len = obj.elements();
654 std::string args[len + 1];
655 const char *argv[len + 1];
656 for (int i = 0; i < len; ++i) {
576f7d3 @NotFound use more explicit conversions
authored
657 args[i] = obj.get_string_keyed(i);
0c910b8 @NotFound start reorganizing components
authored
658 argv[i] = args[i].c_str();
659 }
660 argv[len] = 0;
8697f0c @NotFound wait for child process in spawnw
authored
661 int pid = fork();
662 switch (pid) {
663 case 0:
0c910b8 @NotFound start reorganizing components
authored
664 execvp(argv[0], (char**)argv);
8697f0c @NotFound wait for child process in spawnw
authored
665 case -1:
666 throw wxx_error("fork failed in spawnw");
667 default:
668 waitpid(pid, NULL, 0);
669 }
aa73220 @NotFound use less object ptr implicit initialization with int
authored
670 return WxxObjectPtr(new WxxInteger(0));
0c910b8 @NotFound start reorganizing components
authored
671 }
672
673 } // namespace WinxedXX
674
675 // End
Something went wrong with that request. Please try again.