139
134
// The object will be interpreted as a rectangle. Any Rectangle
140
135
// properties that the object has (width, height, x, y) are used.
141
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
145
ptr->get_member(NSV::PROP_X, &x);
146
ptr->get_member(NSV::PROP_Y, &y);
147
ptr->get_member(NSV::PROP_WIDTH, &w);
148
ptr->get_member(NSV::PROP_HEIGHT, &h);
150
boost::intrusive_ptr<as_object> obj = new Rectangle_as;
152
obj->set_member(NSV::PROP_X, x);
153
obj->set_member(NSV::PROP_Y, y);
154
obj->set_member(NSV::PROP_WIDTH, w);
155
obj->set_member(NSV::PROP_HEIGHT, h);
157
return as_value(obj.get()); // will keep alive
136
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
140
ptr->get_member(NSV::PROP_X, &x);
141
ptr->get_member(NSV::PROP_Y, &y);
142
ptr->get_member(NSV::PROP_WIDTH, &w);
143
ptr->get_member(NSV::PROP_HEIGHT, &h);
145
boost::intrusive_ptr<as_object> obj = new Rectangle_as;
147
obj->set_member(NSV::PROP_X, x);
148
obj->set_member(NSV::PROP_Y, y);
149
obj->set_member(NSV::PROP_WIDTH, w);
150
obj->set_member(NSV::PROP_HEIGHT, h);
152
return as_value(obj.get()); // will keep alive
161
156
Rectangle_contains(const fn_call& fn)
163
//fn.arg(0) => x coordinate
164
//fn.arg(1) => y coordinate
166
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
168
as_value rect_x_as, rect_width_as, rect_y_as, rect_height_as;
170
ptr->get_member(NSV::PROP_X, &rect_x_as);
171
ptr->get_member(NSV::PROP_WIDTH, &rect_width_as);
172
ptr->get_member(NSV::PROP_Y, &rect_y_as);
173
ptr->get_member(NSV::PROP_HEIGHT, &rect_height_as);
177
IF_VERBOSE_ASCODING_ERRORS(
178
std::stringstream ss;
180
log_aserror("flash.geom.Rectangle(%s): %s", ss.str(), _("missing arguments"));
185
const as_value& x_as = fn.arg(0);
186
const as_value& y_as = fn.arg(1);
187
if ( x_as.is_null() || x_as.is_undefined() ||
188
y_as.is_null() || y_as.is_undefined() )
190
IF_VERBOSE_ASCODING_ERRORS(
191
std::stringstream ss;
193
log_aserror("flash.geom.Rectangle(%s): %s", ss.str(), _("invalid arguments"));
198
as_value rect_x1_as = rect_x_as;
199
rect_x1_as.newAdd(rect_width_as);
201
as_value rect_y1_as = rect_y_as;
202
rect_y1_as.newAdd(rect_height_as);
204
if ( rect_x_as.is_null() || rect_x_as.is_undefined() ||
205
rect_y_as.is_null() || rect_y_as.is_undefined() ||
206
rect_x1_as.is_null() || rect_x1_as.is_undefined() ||
207
rect_y1_as.is_null() || rect_y1_as.is_undefined() )
209
IF_VERBOSE_ASCODING_ERRORS(
210
std::stringstream ss;
212
log_aserror("flash.geom.Rectangle(%s): %s", ss.str(), _("invalid rectangle"));
217
//Points are contained within the Rectangle IFF they lie
218
//on the top or left borders of the rectangle, but not the right or
219
//bottom borders, or they are not on a border but between all.
221
// NOTE: order of tests is important, see actionscript.all/Rectangle.as
223
as_value ret = x_as.newLessThan(rect_x_as);
224
if ( ret.is_undefined() ) return as_value();
225
if ( ret.to_bool() ) return as_value(false);
227
ret = x_as.newLessThan(rect_x1_as);
228
if ( ret.is_undefined() ) return as_value();
229
if ( ! ret.to_bool() ) return as_value(false);
231
ret = y_as.newLessThan(rect_y_as);
232
if ( ret.is_undefined() ) return as_value();
233
if ( ret.to_bool() ) return as_value(false);
235
ret = y_as.newLessThan(rect_y1_as);
236
if ( ret.is_undefined() ) return as_value();
237
if ( ! ret.to_bool() ) return as_value(false);
239
return as_value(true);
158
//fn.arg(0) => x coordinate
159
//fn.arg(1) => y coordinate
161
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
163
as_value rect_x_as, rect_width_as, rect_y_as, rect_height_as;
165
ptr->get_member(NSV::PROP_X, &rect_x_as);
166
ptr->get_member(NSV::PROP_WIDTH, &rect_width_as);
167
ptr->get_member(NSV::PROP_Y, &rect_y_as);
168
ptr->get_member(NSV::PROP_HEIGHT, &rect_height_as);
172
IF_VERBOSE_ASCODING_ERRORS(
173
std::stringstream ss;
175
log_aserror("flash.geom.Rectangle(%s): %s", ss.str(),
176
_("missing arguments"));
181
const as_value& x_as = fn.arg(0);
182
const as_value& y_as = fn.arg(1);
183
if ( x_as.is_null() || x_as.is_undefined() ||
184
y_as.is_null() || y_as.is_undefined() )
186
IF_VERBOSE_ASCODING_ERRORS(
187
std::stringstream ss;
189
log_aserror("flash.geom.Rectangle(%s): %s", ss.str(), _("invalid arguments"));
194
as_value rect_x1_as = rect_x_as;
195
rect_x1_as.newAdd(rect_width_as);
197
as_value rect_y1_as = rect_y_as;
198
rect_y1_as.newAdd(rect_height_as);
200
if ( rect_x_as.is_null() || rect_x_as.is_undefined() ||
201
rect_y_as.is_null() || rect_y_as.is_undefined() ||
202
rect_x1_as.is_null() || rect_x1_as.is_undefined() ||
203
rect_y1_as.is_null() || rect_y1_as.is_undefined() )
205
IF_VERBOSE_ASCODING_ERRORS(
206
std::stringstream ss;
208
log_aserror("flash.geom.Rectangle(%s): %s", ss.str(), _("invalid rectangle"));
213
//Points are contained within the Rectangle IFF they lie
214
//on the top or left borders of the rectangle, but not the right or
215
//bottom borders, or they are not on a border but between all.
217
// NOTE: order of tests is important, see actionscript.all/Rectangle.as
219
as_value ret = x_as.newLessThan(rect_x_as);
220
if ( ret.is_undefined() ) return as_value();
221
if ( ret.to_bool() ) return as_value(false);
223
ret = x_as.newLessThan(rect_x1_as);
224
if ( ret.is_undefined() ) return as_value();
225
if ( ! ret.to_bool() ) return as_value(false);
227
ret = y_as.newLessThan(rect_y_as);
228
if ( ret.is_undefined() ) return as_value();
229
if ( ret.to_bool() ) return as_value(false);
231
ret = y_as.newLessThan(rect_y1_as);
232
if ( ret.is_undefined() ) return as_value();
233
if ( ! ret.to_bool() ) return as_value(false);
235
return as_value(true);
244
240
Rectangle_containsPoint(const fn_call& fn)
246
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
248
LOG_ONCE( log_unimpl (__FUNCTION__) );
242
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
244
LOG_ONCE( log_unimpl (__FUNCTION__) );
253
249
Rectangle_containsRectangle(const fn_call& fn)
255
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
257
LOG_ONCE( log_unimpl (__FUNCTION__) );
251
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
253
LOG_ONCE( log_unimpl (__FUNCTION__) );
262
258
Rectangle_equals(const fn_call& fn)
264
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
266
LOG_ONCE( log_unimpl (__FUNCTION__) );
260
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
262
LOG_ONCE( log_unimpl (__FUNCTION__) );
271
267
Rectangle_inflate(const fn_call& fn)
273
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
275
LOG_ONCE( log_unimpl (__FUNCTION__) );
269
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
271
LOG_ONCE( log_unimpl (__FUNCTION__) );
280
276
Rectangle_inflatePoint(const fn_call& fn)
282
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
284
LOG_ONCE( log_unimpl (__FUNCTION__) );
278
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
280
LOG_ONCE( log_unimpl (__FUNCTION__) );
289
285
Rectangle_intersection(const fn_call& fn)
291
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
293
LOG_ONCE( log_unimpl (__FUNCTION__) );
287
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
289
LOG_ONCE( log_unimpl (__FUNCTION__) );
298
294
Rectangle_intersects(const fn_call& fn)
300
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
302
LOG_ONCE( log_unimpl (__FUNCTION__) );
296
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
298
LOG_ONCE( log_unimpl (__FUNCTION__) );
307
303
Rectangle_isEmpty(const fn_call& fn)
309
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
312
ptr->get_member(NSV::PROP_WIDTH, &w);
313
if ( w.is_undefined() || w.is_null() ) return as_value(true);
316
ptr->get_member(NSV::PROP_HEIGHT, &h);
317
if ( h.is_undefined() || h.is_null() ) return as_value(true);
319
double wn = w.to_number();
320
if ( ! utility::isFinite(wn) || wn <= 0 ) return as_value(true);
322
double hn = h.to_number();
323
if ( ! utility::isFinite(hn) || hn <= 0 ) return as_value(true);
325
log_debug("Width: %g, Height: %g", wn, hn);
327
return as_value(false);
305
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
308
ptr->get_member(NSV::PROP_WIDTH, &w);
309
if ( w.is_undefined() || w.is_null() ) return as_value(true);
312
ptr->get_member(NSV::PROP_HEIGHT, &h);
313
if ( h.is_undefined() || h.is_null() ) return as_value(true);
315
double wn = w.to_number();
316
if (!isFinite(wn) || wn <= 0) return as_value(true);
318
double hn = h.to_number();
319
if (!isFinite(hn) || hn <= 0) return as_value(true);
321
log_debug("Width: %g, Height: %g", wn, hn);
323
return as_value(false);
331
327
Rectangle_offset(const fn_call& fn)
333
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
335
LOG_ONCE( log_unimpl (__FUNCTION__) );
329
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
331
LOG_ONCE( log_unimpl (__FUNCTION__) );
340
336
Rectangle_offsetPoint(const fn_call& fn)
342
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
344
LOG_ONCE( log_unimpl (__FUNCTION__) );
338
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
340
LOG_ONCE( log_unimpl (__FUNCTION__) );
349
345
Rectangle_setEmpty(const fn_call& fn)
351
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
353
LOG_ONCE( log_unimpl (__FUNCTION__) );
347
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
349
LOG_ONCE( log_unimpl (__FUNCTION__) );
358
354
Rectangle_toString(const fn_call& fn)
360
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
364
ptr->get_member(NSV::PROP_X, &x);
365
ptr->get_member(NSV::PROP_Y, &y);
366
ptr->get_member(NSV::PROP_WIDTH, &w);
367
ptr->get_member(NSV::PROP_HEIGHT, &h);
369
std::stringstream ss;
370
ss << "(x=" << x.to_string()
371
<< ", y=" << y.to_string()
372
<< ", w=" << w.to_string()
373
<< ", h=" << h.to_string()
376
return as_value(ss.str());
356
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
360
ptr->get_member(NSV::PROP_X, &x);
361
ptr->get_member(NSV::PROP_Y, &y);
362
ptr->get_member(NSV::PROP_WIDTH, &w);
363
ptr->get_member(NSV::PROP_HEIGHT, &h);
365
std::stringstream ss;
366
ss << "(x=" << x.to_string()
367
<< ", y=" << y.to_string()
368
<< ", w=" << w.to_string()
369
<< ", h=" << h.to_string()
372
return as_value(ss.str());
380
376
Rectangle_union(const fn_call& fn)
382
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
384
LOG_ONCE( log_unimpl (__FUNCTION__) );
378
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
380
LOG_ONCE( log_unimpl (__FUNCTION__) );
389
385
Rectangle_bottom_getset(const fn_call& fn)
391
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
395
if ( ! fn.nargs ) // getter
398
ptr->get_member(NSV::PROP_Y, &ret);
399
ptr->get_member(NSV::PROP_HEIGHT, &height);
405
ptr->get_member(NSV::PROP_Y, &y);
407
as_value bottom = fn.arg(0);
408
as_value newh = bottom.subtract(y);
409
ptr->set_member(NSV::PROP_HEIGHT, newh);
387
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
391
if ( ! fn.nargs ) // getter
394
ptr->get_member(NSV::PROP_Y, &ret);
395
ptr->get_member(NSV::PROP_HEIGHT, &height);
401
ptr->get_member(NSV::PROP_Y, &y);
403
as_value bottom = fn.arg(0);
404
as_value newh = bottom.subtract(y);
405
ptr->set_member(NSV::PROP_HEIGHT, newh);
416
412
Rectangle_bottomRight_getset(const fn_call& fn)
418
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
422
if ( ! fn.nargs ) // getter
425
ptr->get_member(NSV::PROP_X, &x);
426
ptr->get_member(NSV::PROP_Y, &y);
427
ptr->get_member(NSV::PROP_WIDTH, &w);
428
ptr->get_member(NSV::PROP_HEIGHT, &h);
430
as_value right = x.newAdd(w);
431
as_value bottom = y.newAdd(h);
433
as_function* pointCtor = getFlashGeomPointConstructor();
435
as_environment& env = fn.env();
437
std::auto_ptr< std::vector<as_value> > args ( new std::vector<as_value> );
438
args->push_back(right);
439
args->push_back(bottom);
441
ret = pointCtor->constructInstance(env, args);
445
IF_VERBOSE_ASCODING_ERRORS(
446
log_aserror(_("Attempt to set read-only property %s"), "Rectangle.bottomRight");
414
boost::intrusive_ptr<Rectangle_as> ptr =
415
ensureType<Rectangle_as>(fn.this_ptr);
420
ptr->get_member(NSV::PROP_X, &x);
421
ptr->get_member(NSV::PROP_Y, &y);
422
ptr->get_member(NSV::PROP_WIDTH, &w);
423
ptr->get_member(NSV::PROP_HEIGHT, &h);
425
as_value right = x.newAdd(w);
426
as_value bottom = y.newAdd(h);
428
as_value point(fn.env().find_object("flash.geom.Point"));
430
boost::intrusive_ptr<as_function> pointCtor = point.to_as_function();
433
log_error("Failed to construct flash.geom.Point!");
438
args += right, bottom;
440
as_value ret = pointCtor->constructInstance(fn.env(), args);
444
IF_VERBOSE_ASCODING_ERRORS(
445
log_aserror(_("Attempt to set read-only property %s"),
446
"Rectangle.bottomRight");
454
453
Rectangle_left_getset(const fn_call& fn)
456
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
460
if ( ! fn.nargs ) // getter
462
ptr->get_member(NSV::PROP_X, &ret);
467
ptr->get_member(NSV::PROP_X, &oldx);
469
as_value newx = fn.arg(0);
470
ptr->set_member(NSV::PROP_X, newx);
473
ptr->get_member(NSV::PROP_WIDTH, &w);
475
w.newAdd(oldx.subtract(newx));
476
ptr->set_member(NSV::PROP_WIDTH, w);
455
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
459
if ( ! fn.nargs ) // getter
461
ptr->get_member(NSV::PROP_X, &ret);
466
ptr->get_member(NSV::PROP_X, &oldx);
468
as_value newx = fn.arg(0);
469
ptr->set_member(NSV::PROP_X, newx);
472
ptr->get_member(NSV::PROP_WIDTH, &w);
474
w.newAdd(oldx.subtract(newx));
475
ptr->set_member(NSV::PROP_WIDTH, w);
483
482
Rectangle_right_getset(const fn_call& fn)
485
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
489
if ( ! fn.nargs ) // getter
492
ptr->get_member(NSV::PROP_X, &ret);
493
ptr->get_member(NSV::PROP_WIDTH, &width);
499
ptr->get_member(NSV::PROP_X, &x);
501
as_value right = fn.arg(0);
502
as_value neww = right.subtract(x);
503
ptr->set_member(NSV::PROP_WIDTH, neww);
484
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
488
if ( ! fn.nargs ) // getter
491
ptr->get_member(NSV::PROP_X, &ret);
492
ptr->get_member(NSV::PROP_WIDTH, &width);
498
ptr->get_member(NSV::PROP_X, &x);
500
as_value right = fn.arg(0);
501
as_value neww = right.subtract(x);
502
ptr->set_member(NSV::PROP_WIDTH, neww);
510
509
Rectangle_size_getset(const fn_call& fn)
512
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
516
if ( ! fn.nargs ) // getter
519
ptr->get_member(NSV::PROP_WIDTH, &w);
520
ptr->get_member(NSV::PROP_HEIGHT, &h);
522
as_function* pointCtor = getFlashGeomPointConstructor();
524
as_environment& env = fn.env();
526
std::auto_ptr< std::vector<as_value> > args ( new std::vector<as_value> );
530
ret = pointCtor->constructInstance(env, args);
534
IF_VERBOSE_ASCODING_ERRORS(
535
log_aserror(_("Attempt to set read-only property %s"), "Rectangle.size");
511
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
515
if ( ! fn.nargs ) // getter
518
ptr->get_member(NSV::PROP_WIDTH, &w);
519
ptr->get_member(NSV::PROP_HEIGHT, &h);
521
as_value point(fn.env().find_object("flash.geom.Point"));
523
boost::intrusive_ptr<as_function> pointCtor = point.to_as_function();
526
log_error("Failed to construct flash.geom.Point!");
533
ret = pointCtor->constructInstance(fn.env(), args);
537
IF_VERBOSE_ASCODING_ERRORS(
538
log_aserror(_("Attempt to set read-only property %s"), "Rectangle.size");
543
546
Rectangle_top_getset(const fn_call& fn)
545
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
549
if ( ! fn.nargs ) // getter
551
ptr->get_member(NSV::PROP_Y, &ret);
556
ptr->get_member(NSV::PROP_Y, &oldy);
558
as_value newy = fn.arg(0);
559
ptr->set_member(NSV::PROP_Y, newy);
562
ptr->get_member(NSV::PROP_HEIGHT, &h);
564
h.newAdd(oldy.subtract(newy));
565
ptr->set_member(NSV::PROP_HEIGHT, h);
548
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
552
if ( ! fn.nargs ) // getter
554
ptr->get_member(NSV::PROP_Y, &ret);
559
ptr->get_member(NSV::PROP_Y, &oldy);
561
as_value newy = fn.arg(0);
562
ptr->set_member(NSV::PROP_Y, newy);
565
ptr->get_member(NSV::PROP_HEIGHT, &h);
567
h.newAdd(oldy.subtract(newy));
568
ptr->set_member(NSV::PROP_HEIGHT, h);
572
575
Rectangle_topLeft_getset(const fn_call& fn)
574
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
578
if ( ! fn.nargs ) // getter
581
ptr->get_member(NSV::PROP_X, &x);
582
ptr->get_member(NSV::PROP_Y, &y);
584
as_function* pointCtor = getFlashGeomPointConstructor();
586
as_environment& env = fn.env();
588
std::auto_ptr< std::vector<as_value> > args ( new std::vector<as_value> );
592
ret = pointCtor->constructInstance(env, args);
597
IF_VERBOSE_ASCODING_ERRORS(
598
log_aserror(_("Attempt to set read-only property %s"), "Rectangle.topLeft");
577
boost::intrusive_ptr<Rectangle_as> ptr = ensureType<Rectangle_as>(fn.this_ptr);
581
if ( ! fn.nargs ) // getter
584
ptr->get_member(NSV::PROP_X, &x);
585
ptr->get_member(NSV::PROP_Y, &y);
587
as_value point(fn.env().find_object("flash.geom.Point"));
589
boost::intrusive_ptr<as_function> pointCtor = point.to_as_function();
592
log_error("Failed to construct flash.geom.Point!");
599
ret = pointCtor->constructInstance(fn.env(), args);
604
IF_VERBOSE_ASCODING_ERRORS(
605
log_aserror(_("Attempt to set read-only property %s"), "Rectangle.topLeft");
607
614
Rectangle_ctor(const fn_call& fn)
609
boost::intrusive_ptr<as_object> obj = new Rectangle_as;
627
if ( fn.nargs < 2 ) break;
629
if ( fn.nargs < 3 ) break;
631
if ( fn.nargs < 4 ) break;
633
if ( fn.nargs < 5 ) break;
634
IF_VERBOSE_ASCODING_ERRORS(
635
std::stringstream ss;
637
log_aserror("flash.geom.Rectangle(%s): %s", ss.str(), _("arguments after the first four discarded"));
642
obj->set_member(NSV::PROP_X, x);
643
obj->set_member(NSV::PROP_Y, y);
644
obj->set_member(NSV::PROP_WIDTH, w);
645
obj->set_member(NSV::PROP_HEIGHT, h);
647
return as_value(obj.get()); // will keep alive
650
static as_value get_flash_geom_rectangle_constructor(const fn_call& /*fn*/)
652
log_debug("Loading flash.geom.Rectangle class");
654
builtin_function* cl =
655
new builtin_function(&Rectangle_ctor, getRectangleInterface());
659
boost::intrusive_ptr<as_object> init_Rectangle_instance()
661
return boost::intrusive_ptr<as_object>(new Rectangle_as);
616
boost::intrusive_ptr<as_object> obj = new Rectangle_as;
634
if ( fn.nargs < 2 ) break;
636
if ( fn.nargs < 3 ) break;
638
if ( fn.nargs < 4 ) break;
640
if ( fn.nargs < 5 ) break;
641
IF_VERBOSE_ASCODING_ERRORS(
642
std::stringstream ss;
644
log_aserror("flash.geom.Rectangle(%s): %s", ss.str(), _("arguments after the first four discarded"));
649
obj->set_member(NSV::PROP_X, x);
650
obj->set_member(NSV::PROP_Y, y);
651
obj->set_member(NSV::PROP_WIDTH, w);
652
obj->set_member(NSV::PROP_HEIGHT, h);
654
return as_value(obj.get()); // will keep alive
658
get_flash_geom_rectangle_constructor(const fn_call& fn)
660
log_debug("Loading flash.geom.Rectangle class");
662
as_object* proto = getRectangleInterface();
663
Global_as* gl = getGlobal(fn);
664
return gl->createClass(&Rectangle_ctor, proto);
665
void Rectangle_class_init(as_object& where)
669
rectangle_class_init(as_object& where, const ObjectURI& uri)
667
// Register _global.Rectangle
668
string_table& st = where.getVM().getStringTable();
669
where.init_destructive_property(st.find("Rectangle"), get_flash_geom_rectangle_constructor);
671
// TODO: this may not be correct, but it should be enumerable.
673
where.init_destructive_property(getName(uri),
674
get_flash_geom_rectangle_constructor, flags, getNamespace(uri));
672
677
} // end of gnash namespace