gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r11584: Replace the various ensureTy


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11584: Replace the various ensureType functions with a single function template
Date: Thu, 22 Oct 2009 17:41:38 +0200
User-agent: Bazaar (1.16.1)

------------------------------------------------------------
revno: 11584 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2009-10-22 17:41:38 +0200
message:
  Replace the various ensureType functions with a single function template
  ensure<> and some functors.
  
  This is because there may be more variations needed in the short term, but
  ultimately most of the ensure<>s ought to disappear for compatibility. For
  this reason its signature is now more restrictive.
  
  Minor fixes to TextField.
modified:
  libcore/Button.cpp
  libcore/DisplayObject.cpp
  libcore/TextField.cpp
  libcore/Video.cpp
  libcore/as_function.cpp
  libcore/as_object.h
  libcore/asobj/Array_as.cpp
  libcore/asobj/Boolean_as.cpp
  libcore/asobj/Color_as.cpp
  libcore/asobj/Date_as.cpp
  libcore/asobj/Error_as.cpp
  libcore/asobj/Globals.cpp
  libcore/asobj/LoadVars_as.cpp
  libcore/asobj/LoadableObject.cpp
  libcore/asobj/MovieClipLoader.cpp
  libcore/asobj/Number_as.cpp
  libcore/asobj/Object.cpp
  libcore/asobj/QName_as.cpp
  libcore/asobj/Selection_as.cpp
  libcore/asobj/String_as.cpp
  libcore/asobj/TextFormat_as.cpp
  libcore/asobj/flash/display/BitmapData_as.cpp
  libcore/asobj/flash/display/DisplayObjectContainer_as.cpp
  libcore/asobj/flash/display/DisplayObject_as.cpp
  libcore/asobj/flash/display/Graphics_as.cpp
  libcore/asobj/flash/display/LoaderInfo_as.cpp
  libcore/asobj/flash/display/Loader_as.cpp
  libcore/asobj/flash/display/MovieClip_as.cpp
  libcore/asobj/flash/display/Sprite_as.cpp
  libcore/asobj/flash/display/Stage_as.cpp
  libcore/asobj/flash/filters/BevelFilter_as.cpp
  libcore/asobj/flash/filters/BitmapFilter_as.cpp
  libcore/asobj/flash/filters/BlurFilter_as.cpp
  libcore/asobj/flash/filters/ColorMatrixFilter_as.cpp
  libcore/asobj/flash/filters/ConvolutionFilter_as.cpp
  libcore/asobj/flash/filters/DisplacementMapFilter_as.cpp
  libcore/asobj/flash/filters/DropShadowFilter_as.cpp
  libcore/asobj/flash/filters/GlowFilter_as.cpp
  libcore/asobj/flash/filters/GradientBevelFilter_as.cpp
  libcore/asobj/flash/filters/GradientGlowFilter_as.cpp
  libcore/asobj/flash/geom/ColorTransform_as.cpp
  libcore/asobj/flash/geom/Matrix_as.cpp
  libcore/asobj/flash/geom/Point_as.cpp
  libcore/asobj/flash/geom/Rectangle_as.cpp
  libcore/asobj/flash/geom/Transform_as.cpp
  libcore/asobj/flash/media/Camera_as.cpp
  libcore/asobj/flash/media/Microphone_as.cpp
  libcore/asobj/flash/media/SoundChannel_as.cpp
  libcore/asobj/flash/media/SoundMixer_as.cpp
  libcore/asobj/flash/media/Sound_as.cpp
  libcore/asobj/flash/net/LocalConnection_as.cpp
  libcore/asobj/flash/net/NetConnection_as.cpp
  libcore/asobj/flash/net/NetStream_as.cpp
  libcore/asobj/flash/net/SharedObject_as.cpp
  libcore/asobj/flash/net/Socket_as.cpp
  libcore/asobj/flash/net/URLLoader_as.cpp
  libcore/asobj/flash/net/URLStream_as.cpp
  libcore/asobj/flash/net/URLVariables_as.cpp
  libcore/asobj/flash/net/XMLSocket_as.cpp
  libcore/asobj/flash/printing/PrintJob_as.cpp
  libcore/asobj/flash/sampler/StackFrame_as.cpp
  libcore/asobj/flash/system/ApplicationDomain_as.cpp
  libcore/asobj/flash/system/IME_as.cpp
  libcore/asobj/flash/system/Security_as.cpp
  libcore/asobj/flash/system/System_as.cpp
  libcore/asobj/flash/text/Font_as.cpp
  libcore/asobj/flash/text/StyleSheet_as.cpp
  libcore/asobj/flash/text/TextSnapshot_as.cpp
  libcore/asobj/flash/ui/ContextMenuItem_as.cpp
  libcore/asobj/flash/ui/ContextMenu_as.cpp
  libcore/asobj/flash/ui/Keyboard_as.cpp
  libcore/asobj/flash/xml/XMLDocument_as.cpp
  libcore/asobj/flash/xml/XMLNode_as.cpp
  libcore/asobj/gen-asclass.pl
  libcore/vm/fn_call.h
  testsuite/actionscript.all/TextField.as
=== modified file 'libcore/Button.cpp'
--- a/libcore/Button.cpp        2009-10-21 07:10:41 +0000
+++ b/libcore/Button.cpp        2009-10-22 14:56:18 +0000
@@ -1023,7 +1023,7 @@
 as_value
 button_blendMode(const fn_call& fn)
 {
-    as_object* obj = ensureType<Button>(fn.this_ptr);
+    as_object* obj = ensure<ThisIs<Button> >(fn);
     UNUSED(obj);
     return as_value();
 }
@@ -1031,7 +1031,7 @@
 as_value
 button_cacheAsBitmap(const fn_call& fn)
 {
-    as_object* obj = ensureType<Button>(fn.this_ptr);
+    as_object* obj = ensure<ThisIs<Button> >(fn);
     UNUSED(obj);
     return as_value();
 }
@@ -1039,7 +1039,7 @@
 as_value
 button_filters(const fn_call& fn)
 {
-    as_object* obj = ensureType<Button>(fn.this_ptr);
+    as_object* obj = ensure<ThisIs<Button> >(fn);
     UNUSED(obj);
     return as_value();
 }
@@ -1047,7 +1047,7 @@
 as_value
 button_scale9Grid(const fn_call& fn)
 {
-    as_object* obj = ensureType<Button>(fn.this_ptr);
+    as_object* obj = ensure<ThisIs<Button> >(fn);
     UNUSED(obj);
     return as_value();
 }
@@ -1055,7 +1055,7 @@
 as_value
 button_getTabIndex(const fn_call& fn)
 {
-    as_object* obj = ensureType<Button>(fn.this_ptr);
+    as_object* obj = ensure<ThisIs<Button> >(fn);
     UNUSED(obj);
     return as_value();
 }
@@ -1063,7 +1063,7 @@
 as_value
 button_setTabIndex(const fn_call& fn)
 {
-    as_object* obj = ensureType<Button>(fn.this_ptr);
+    as_object* obj = ensure<ThisIs<Button> >(fn);
     UNUSED(obj);
     return as_value();
 }
@@ -1071,7 +1071,7 @@
 as_value
 button_getDepth(const fn_call& fn)
 {
-    as_object* obj = ensureType<Button>(fn.this_ptr);
+    as_object* obj = ensure<ThisIs<Button> >(fn);
     UNUSED(obj);
     return as_value();
 }

=== modified file 'libcore/DisplayObject.cpp'
--- a/libcore/DisplayObject.cpp 2009-10-21 07:10:41 +0000
+++ b/libcore/DisplayObject.cpp 2009-10-22 14:56:18 +0000
@@ -242,7 +242,7 @@
 as_value
 DisplayObject::blendMode(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObject> ch = 
ensureType<DisplayObject>(fn.this_ptr);
+    boost::intrusive_ptr<DisplayObject> ch = ensure<ThisIs<DisplayObject> 
>(fn);
 
     // This is AS-correct, but doesn't do anything.
     // TODO: implement in the renderers!

=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp     2009-10-22 12:31:08 +0000
+++ b/libcore/TextField.cpp     2009-10-22 14:59:00 +0000
@@ -2871,7 +2871,7 @@
 as_value
 textfield_createTextField(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> ptr = ensureType<MovieClip>(fn.this_ptr);
+    boost::intrusive_ptr<MovieClip> ptr = ensure<ThisIs<MovieClip> >(fn);
     
     // name, depth, x, y, width, height
     if (fn.nargs < 6) {
@@ -2934,7 +2934,7 @@
 as_value
 textfield_background(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> ptr = ensure<ThisIs<TextField> >(fn);
 
     if (fn.nargs == 0) {
         return as_value(ptr->getDrawBackground());
@@ -2949,7 +2949,7 @@
 as_value
 textfield_border(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> ptr = ensure<ThisIs<TextField> >(fn);
 
     if (fn.nargs == 0) {
         return as_value(ptr->getDrawBorder());
@@ -2964,7 +2964,7 @@
 as_value
 textfield_backgroundColor(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> ptr = ensure<ThisIs<TextField> >(fn);
 
     if (fn.nargs == 0) {
         return as_value(ptr->getBackgroundColor().toRGB());
@@ -2981,7 +2981,7 @@
 as_value
 textfield_borderColor(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> ptr = ensure<ThisIs<TextField> >(fn);
 
     if (fn.nargs == 0) {
         return as_value(ptr->getBorderColor().toRGB());
@@ -2999,7 +2999,7 @@
 as_value
 textfield_textColor(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> ptr = ensure<ThisIs<TextField> >(fn);
 
     if (!fn.nargs) {
         // Getter
@@ -3017,7 +3017,7 @@
 as_value
 textfield_embedFonts(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> ptr = ensure<ThisIs<TextField> >(fn);
 
     if (!fn.nargs) {
         // Getter
@@ -3032,7 +3032,7 @@
 as_value
 textfield_wordWrap(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> ptr = ensure<ThisIs<TextField> >(fn);
 
     if (fn.nargs == 0) {
         return as_value(ptr->doWordWrap());
@@ -3047,7 +3047,7 @@
 as_value
 textfield_html(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> ptr = ensure<ThisIs<TextField> >(fn);
 
     if (fn.nargs == 0) {
         return as_value(ptr->doHtml());
@@ -3062,7 +3062,7 @@
 as_value
 textfield_selectable(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> ptr = ensure<ThisIs<TextField> >(fn);
 
     if ( fn.nargs == 0 ) // getter
     {
@@ -3079,7 +3079,7 @@
 as_value
 textfield_length(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> ptr = ensure<ThisIs<TextField> >(fn);
 
     if ( fn.nargs == 0 ) // getter
     {
@@ -3100,7 +3100,7 @@
 as_value
 textfield_textHeight(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> ptr = ensure<ThisIs<TextField> >(fn);
 
     if ( fn.nargs == 0 ) // getter
     {
@@ -3126,7 +3126,7 @@
 as_value
 textfield_textWidth(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> ptr = ensure<ThisIs<TextField> >(fn);
 
     if ( fn.nargs == 0 ) // getter
     {
@@ -3152,7 +3152,7 @@
 as_value
 textfield_autoSize(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> ptr = ensure<ThisIs<TextField> >(fn);
 
     if ( fn.nargs == 0 ) // getter
     {
@@ -3186,7 +3186,7 @@
 as_value
 textfield_type(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> ptr = ensure<ThisIs<TextField> >(fn);
 
     if (!fn.nargs)
     {
@@ -3213,7 +3213,7 @@
 as_value
 textfield_variable(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
 
     if (!fn.nargs)
     {
@@ -3244,7 +3244,7 @@
 textfield_getDepth(const fn_call& fn)
 {
     // Unlike MovieClip.getDepth this works only for TextFields.
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
     const int n = text->get_depth();
     return as_value(n);
 }
@@ -3252,7 +3252,7 @@
 as_value
 textfield_getFontList(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
     UNUSED(text);
 
     LOG_ONCE(log_unimpl("TextField.getFontList()"));
@@ -3263,7 +3263,7 @@
 as_value
 textfield_getNewTextFormat(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
     UNUSED(text);
 
     LOG_ONCE(log_unimpl("TextField.getNewTextFormat()"));
@@ -3280,7 +3280,7 @@
 as_value
 textfield_getTextFormat(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
 
     Global_as* gl = getGlobal(fn);
     as_function* ctor = gl->getMember(NSV::CLASS_TEXT_FORMAT).to_as_function();
@@ -3327,7 +3327,7 @@
 textfield_setTextFormat(const fn_call& fn)
 {
 
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
 
     if ( ! fn.nargs )
     {
@@ -3392,7 +3392,7 @@
 as_value
 textfield_setNewTextFormat(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
     //UNUSED(text);
 
     LOG_ONCE( log_unimpl("TextField.setNewTextFormat(), we'll delegate "
@@ -3405,7 +3405,7 @@
 as_value
 textfield_password(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
 
     if (!fn.nargs)
     {
@@ -3420,7 +3420,7 @@
 as_value
 textfield_multiline(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
 
     if (!fn.nargs) {
         // Getter
@@ -3434,7 +3434,7 @@
 as_value
 textfield_restrict(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
 
     if (!fn.nargs) {
         // Getter
@@ -3454,7 +3454,7 @@
 as_value
 textfield_bottomScroll(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
     UNUSED(text);
 
     LOG_ONCE(log_unimpl("TextField.bottomScroll is not complete"));
@@ -3474,7 +3474,7 @@
 as_value
 textfield_maxhscroll(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
     UNUSED(text);
 
         LOG_ONCE(log_unimpl("TextField.maxhscroll is not complete"));
@@ -3500,7 +3500,7 @@
 as_value
 textfield_maxChars(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
 
     if (!fn.nargs)
     {
@@ -3521,7 +3521,7 @@
 as_value
 textfield_text(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> ptr = ensure<ThisIs<TextField> >(fn);
     if (!fn.nargs)
     {
         // Getter
@@ -3541,7 +3541,7 @@
 as_value
 textfield_htmlText(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> ptr = ensure<ThisIs<TextField> >(fn);
     if (!fn.nargs)
     {
         // Getter
@@ -3567,7 +3567,7 @@
 as_value
 textfield_replaceSel(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
 
     if (!fn.nargs) {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -3593,7 +3593,7 @@
 as_value
 textfield_scroll(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
     UNUSED(text);
 
     if (!fn.nargs)
@@ -3610,7 +3610,7 @@
 as_value
 textfield_hscroll(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
     UNUSED(text);
 
     LOG_ONCE(log_unimpl("TextField._hscroll is not complete"));
@@ -3629,7 +3629,7 @@
 as_value
 textfield_maxscroll(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
     UNUSED(text);
 
     LOG_ONCE(log_unimpl("TextField.maxscroll is not complete"));
@@ -3648,7 +3648,7 @@
 as_value
 textfield_replaceText(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
     UNUSED(text);
 
     LOG_ONCE(log_unimpl("TextField.replaceText()"));
@@ -3659,7 +3659,7 @@
 as_value
 textfield_removeTextField(const fn_call& fn)
 {
-    boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+    boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
 
     text->removeTextField();
 
@@ -3691,7 +3691,13 @@
         return as_value(obj);
     }
 
-    as_object* obj = ensureType<as_object>(fn.this_ptr);
+    as_object* obj = ensure<ValidThis>(fn);
+    
+    // It's not clear why this happens. Attaching a relay would have the
+    // same effect as both following statements.
+    obj->setArray(false);
+    obj->setRelay(0);
+
     as_object* proto = obj->get_prototype();
 
     if (proto) {

=== modified file 'libcore/Video.cpp'
--- a/libcore/Video.cpp 2009-10-14 08:47:08 +0000
+++ b/libcore/Video.cpp 2009-10-22 14:56:18 +0000
@@ -384,7 +384,7 @@
 as_value
 video_attach(const fn_call& fn)
 {
-       boost::intrusive_ptr<Video> video = ensureType<Video>(fn.this_ptr);
+       boost::intrusive_ptr<Video> video = ensure<ThisIs<Video> >(fn);
 
        if (fn.nargs < 1)
        {
@@ -412,7 +412,7 @@
 as_value
 video_deblocking(const fn_call& fn)
 {
-       boost::intrusive_ptr<Video> video = ensureType<Video>(fn.this_ptr);
+       boost::intrusive_ptr<Video> video = ensure<ThisIs<Video> >(fn);
     UNUSED(video);
 
     log_unimpl("Video.deblocking");
@@ -422,7 +422,7 @@
 as_value
 video_smoothing(const fn_call& fn)
 {
-       boost::intrusive_ptr<Video> video = ensureType<Video>(fn.this_ptr);
+       boost::intrusive_ptr<Video> video = ensure<ThisIs<Video> >(fn);
 
     if (!fn.nargs) return as_value(video->smoothing());
 
@@ -436,21 +436,21 @@
 as_value
 video_width(const fn_call& fn)
 {
-       boost::intrusive_ptr<Video> video = ensureType<Video>(fn.this_ptr);
+       boost::intrusive_ptr<Video> video = ensure<ThisIs<Video> >(fn);
     return as_value(video->width());
 }
 
 as_value
 video_height(const fn_call& fn)
 {
-       boost::intrusive_ptr<Video> video = ensureType<Video>(fn.this_ptr);
+       boost::intrusive_ptr<Video> video = ensure<ThisIs<Video> >(fn);
     return as_value(video->height());
 }
 
 as_value
 video_clear(const fn_call& fn)
 {
-       boost::intrusive_ptr<Video> video = ensureType<Video>(fn.this_ptr);
+       boost::intrusive_ptr<Video> video = ensure<ThisIs<Video> >(fn);
 
     video->clear();
     return as_value();

=== modified file 'libcore/as_function.cpp'
--- a/libcore/as_function.cpp   2009-10-22 09:26:18 +0000
+++ b/libcore/as_function.cpp   2009-10-22 14:56:18 +0000
@@ -272,8 +272,7 @@
 {
 
        // Get function body 
-       boost::intrusive_ptr<as_function> function_obj =
-        ensureType<as_function>(fn.this_ptr);
+       as_function* function_obj = ensure<ThisIs<as_function> >(fn);
 
        // Copy new function call from old one, we'll modify 
        // the copy only if needed
@@ -334,8 +333,7 @@
 {
 
        // Get function body 
-       boost::intrusive_ptr<as_function> function_obj = 
-        ensureType<as_function>(fn.this_ptr);
+       as_function* function_obj = ensure<ThisIs<as_function> >(fn);
 
        // Copy new function call from old one, we'll modify 
        // the copy only if needed

=== modified file 'libcore/as_object.h'
--- a/libcore/as_object.h       2009-10-21 13:16:04 +0000
+++ b/libcore/as_object.h       2009-10-22 14:56:18 +0000
@@ -984,12 +984,14 @@
         return _relay.get();
     }
 
+    /// Return true if this object should be treated as an array.
     bool array() const {
         return _array;
     }
 
-    void setArray() {
-        _array = true;
+    /// Set whether this object should be treated as an array.
+    void setArray(bool array = true) {
+        _array = array;
     }
 
     /// Return true if this is a DisplayObject.
@@ -1199,33 +1201,6 @@
     return o.ns;
 }
 
-
-/// Template which does a dynamic cast for as_object pointers.
-//
-/// It throws an exception if the dynamic cast fails.
-///
-/// @tparam T the class to which the obj pointer should be cast.
-/// @param obj the pointer to be cast.
-/// @return If the cast succeeds, the pointer cast to the requested type.
-template <typename T>
-T*
-ensureType(as_object* obj)
-{
-    T* ret = dynamic_cast<T*>(obj);
-
-    if (!ret) {
-        std::string target = typeName(ret);
-        std::string source = typeName(obj);
-
-        std::string msg = "builtin method or gettersetter for " +
-            target + " called from " + source + " instance.";
-
-        throw ActionTypeError(msg);
-    }
-    return ret;
-}
-
-
 /// Check whether the object is an instance of a known type.
 //
 /// This is used to check the type of certain objects when it can't be
@@ -1254,35 +1229,6 @@
 /// @return         The DisplayObject if the object is one, otherwise 0.
 DisplayObject* getDisplayObject(as_object* obj);
 
-/// Ensure that the object is of a particular native type.
-//
-/// This checks that the object's relay member is the expected type.
-/// If not, the function throws an exception, which results in an undefined
-/// value being returned from the AS function.
-/// @tparam T   The expected native type.
-/// @param obj  The object whose type should be tested.
-/// @return     If the cast succeeds, the pointer cast to the requested type,
-///             otherwise the function does not return.
-template<typename T>
-T*
-ensureNativeType(as_object* obj)
-{
-    if (!obj) throw ActionTypeError();
-
-    T* ret = dynamic_cast<T*>(obj->relay());
-
-    if (!ret) {
-        std::string target = typeName(ret);
-        std::string source = typeName(obj);
-
-        std::string msg = "Function for " + target + "object called from "
-            + source + " instance.";
-
-        throw ActionTypeError(msg);
-    }
-    return ret;
-}
-
 /// Get the VM from an as_object
 VM& getVM(const as_object& o);
 

=== modified file 'libcore/asobj/Array_as.cpp'
--- a/libcore/asobj/Array_as.cpp        2009-10-22 07:14:33 +0000
+++ b/libcore/asobj/Array_as.cpp        2009-10-22 14:56:18 +0000
@@ -933,7 +933,7 @@
 as_value
 array_splice(const fn_call& fn)
 {
-    as_object* array = ensureType<as_object>(fn.this_ptr);
+    as_object* array = ensure<ValidThis>(fn);
     
     if (fn.nargs < 1) {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -1010,7 +1010,7 @@
 as_value
 array_sort(const fn_call& fn)
 {
-    as_object* array = ensureType<as_object>(fn.this_ptr);
+    as_object* array = ensure<ValidThis>(fn);
     
     const int version = getSWFVersion(*array);
     
@@ -1080,7 +1080,7 @@
 as_value
 array_sortOn(const fn_call& fn)
 {
-    as_object* array = ensureType<as_object>(fn.this_ptr);
+    as_object* array = ensure<ValidThis>(fn);
 
     bool do_unique = false, do_index = false;
     boost::uint8_t flags = 0;
@@ -1212,7 +1212,7 @@
 as_value
 array_push(const fn_call& fn)
 {
-    as_object* array = ensureType<as_object>(fn.this_ptr);
+    as_object* array = ensure<ValidThis>(fn);
  
     if (!fn.nargs) return as_value();
 
@@ -1232,7 +1232,7 @@
 array_unshift(const fn_call& fn)
 {
 
-    as_object* array = ensureType<as_object>(fn.this_ptr);
+    as_object* array = ensure<ValidThis>(fn);
  
     if (!fn.nargs) return as_value();
 
@@ -1265,7 +1265,7 @@
 array_pop(const fn_call& fn)
 {
 
-    as_object* array = ensureType<as_object>(fn.this_ptr);
+    as_object* array = ensure<ValidThis>(fn);
 
     const size_t size = arrayLength(*array);
     if (size < 1) return as_value();
@@ -1283,7 +1283,7 @@
 as_value
 array_shift(const fn_call& fn)
 {
-    as_object* array = ensureType<as_object>(fn.this_ptr);
+    as_object* array = ensure<ValidThis>(fn);
 
     const size_t size = arrayLength(*array);
     // An array with no elements has nothing to return.
@@ -1307,7 +1307,7 @@
 as_value
 array_reverse(const fn_call& fn)
 {
-    as_object* array = ensureType<as_object>(fn.this_ptr);
+    as_object* array = ensure<ValidThis>(fn);
 
     const size_t size = arrayLength(*array);
     // An array with 0 or 1 elements has nothing to reverse.
@@ -1329,7 +1329,7 @@
 as_value
 array_join(const fn_call& fn)
 {
-    as_object* array = ensureType<as_object>(fn.this_ptr);
+    as_object* array = ensure<ValidThis>(fn);
 
     const int version = getSWFVersion(fn);
     const std::string separator =
@@ -1342,7 +1342,7 @@
 as_value
 array_toString(const fn_call& fn)
 {
-    as_object* array = ensureType<as_object>(fn.this_ptr);
+    as_object* array = ensure<ValidThis>(fn);
     return join(array, ",");
 }
 
@@ -1354,7 +1354,7 @@
 as_value
 array_concat(const fn_call& fn)
 {
-    as_object* array = ensureType<as_object>(fn.this_ptr);
+    as_object* array = ensure<ValidThis>(fn);
 
     Global_as* gl = getGlobal(fn);
     as_object* newarray = gl->createArray();
@@ -1392,7 +1392,7 @@
 as_value
 array_slice(const fn_call& fn)
 {
-    as_object* array = ensureType<as_object>(fn.this_ptr);
+    as_object* array = ensure<ValidThis>(fn);
 
     if (fn.nargs > 2) {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -1422,7 +1422,7 @@
 array_new(const fn_call& fn)
 {
 
-    as_object* ao = fn.isInstantiation() ? ensureType<as_object>(fn.this_ptr) :
+    as_object* ao = fn.isInstantiation() ? ensure<ValidThis>(fn) :
                                            getGlobal(fn)->createArray();
 
     ao->setRelay(0);

=== modified file 'libcore/asobj/Boolean_as.cpp'
--- a/libcore/asobj/Boolean_as.cpp      2009-08-27 06:30:46 +0000
+++ b/libcore/asobj/Boolean_as.cpp      2009-10-22 14:56:18 +0000
@@ -104,7 +104,7 @@
 as_value
 boolean_tostring(const fn_call& fn)
 {
-    Boolean_as* obj = ensureNativeType<Boolean_as>(fn.this_ptr);
+    Boolean_as* obj = ensure<ThisIsNative<Boolean_as> >(fn);
     if (obj->value()) return as_value("true");
     return as_value("false");
 }
@@ -113,7 +113,7 @@
 as_value
 boolean_valueof(const fn_call& fn) 
 {
-    Boolean_as* obj = ensureNativeType<Boolean_as>(fn.this_ptr);
+    Boolean_as* obj = ensure<ThisIsNative<Boolean_as> >(fn);
     return as_value(obj->value());
 }
 

=== modified file 'libcore/asobj/Color_as.cpp'
--- a/libcore/asobj/Color_as.cpp        2009-10-21 05:50:22 +0000
+++ b/libcore/asobj/Color_as.cpp        2009-10-22 14:56:18 +0000
@@ -104,7 +104,7 @@
 as_value
 color_getrgb(const fn_call& fn)
 {
-       boost::intrusive_ptr<as_object> obj = 
ensureType<as_object>(fn.this_ptr);
+       boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
 
     MovieClip* sp = getTarget(obj.get(), fn);
     if (!sp) return as_value();
@@ -123,7 +123,7 @@
 as_value
 color_gettransform(const fn_call& fn)
 {
-       boost::intrusive_ptr<as_object> obj = 
ensureType<as_object>(fn.this_ptr);
+       boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
 
     MovieClip* sp = getTarget(obj.get(), fn);
     if (!sp) return as_value();
@@ -151,7 +151,7 @@
 as_value
 color_setrgb(const fn_call& fn)
 {
-       boost::intrusive_ptr<as_object> obj = 
ensureType<as_object>(fn.this_ptr);
+       boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
        
     if (!fn.nargs) {
                IF_VERBOSE_ASCODING_ERRORS(
@@ -184,7 +184,7 @@
 as_value
 color_settransform(const fn_call& fn)
 {
-       boost::intrusive_ptr<as_object> obj = 
ensureType<as_object>(fn.this_ptr);
+       boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
 
        if (!fn.nargs) {
                IF_VERBOSE_ASCODING_ERRORS(

=== modified file 'libcore/asobj/Date_as.cpp'
--- a/libcore/asobj/Date_as.cpp 2009-08-27 06:30:46 +0000
+++ b/libcore/asobj/Date_as.cpp 2009-10-22 14:56:18 +0000
@@ -538,7 +538,7 @@
 as_value
 date_getYear(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return timeElement(localTime, &GnashTime::year, date->getTimeValue());
 }
 
@@ -547,7 +547,7 @@
 as_value
 date_getFullYear(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return timeElement(
             localTime, &GnashTime::year, date->getTimeValue(), 1900);
 }
@@ -557,7 +557,7 @@
 as_value
 date_getMonth(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return timeElement(localTime, &GnashTime::month, date->getTimeValue());
 }
 
@@ -566,7 +566,7 @@
 as_value
 date_getDate(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return timeElement(localTime, &GnashTime::monthday, date->getTimeValue());
 }
 
@@ -576,7 +576,7 @@
 as_value
 date_getDay(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return timeElement(localTime, &GnashTime::weekday, date->getTimeValue());
 }
 
@@ -586,7 +586,7 @@
 as_value
 date_getHours(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return timeElement(localTime, &GnashTime::hour, date->getTimeValue());
 }
 
@@ -597,7 +597,7 @@
 as_value
 date_getMinutes(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return timeElement(localTime, &GnashTime::minute, date->getTimeValue());
 }
 
@@ -607,7 +607,7 @@
 as_value
 date_getSeconds(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return timeElement(localTime, &GnashTime::second, date->getTimeValue());
 }
 
@@ -619,7 +619,7 @@
 as_value
 date_getMilliseconds(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return timeElement(
             localTime, &GnashTime::millisecond, date->getTimeValue());
 }
@@ -630,7 +630,7 @@
 as_value
 date_getUTCFullYear(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return timeElement(universalTime, &GnashTime::year,
            date->getTimeValue(), 1900);
 }
@@ -638,21 +638,21 @@
 as_value
 date_getUTCYear(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return timeElement(universalTime, &GnashTime::year, date->getTimeValue());
 }
 
 as_value
 date_getUTCMonth(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return timeElement(universalTime, &GnashTime::month, date->getTimeValue());
 }
 
 as_value
 date_getutcdate(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return timeElement(
             universalTime, &GnashTime::monthday, date->getTimeValue());
 }
@@ -661,7 +661,7 @@
 as_value
 date_getUTCDay(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return timeElement(
                 universalTime, &GnashTime::weekday, date->getTimeValue());
 }
@@ -669,7 +669,7 @@
 as_value
 date_getUTCHours(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return timeElement(
                 universalTime, &GnashTime::hour, date->getTimeValue());
 }
@@ -677,7 +677,7 @@
 as_value
 date_getUTCMinutes(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return timeElement(universalTime, &GnashTime::minute, 
date->getTimeValue());
 }
 
@@ -700,7 +700,7 @@
 as_value
 date_getTimezoneOffset(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return as_value(-localTimeZoneOffset(date->getTimeValue()));
 }
 
@@ -722,7 +722,7 @@
 as_value
 date_setTime(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
 
     if (fn.nargs < 1 || fn.arg(0).is_undefined()) {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -834,7 +834,7 @@
 as_value
 date_setfullyear(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
 
     if (fn.nargs < 1) {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -885,7 +885,7 @@
 as_value
 date_setYear(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
 
     // assert(fn.nargs == 1);
     if (fn.nargs < 1) {
@@ -939,7 +939,7 @@
 as_value
 date_setmonth(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
 
     // assert(fn.nargs >= 1 && fn.nargs <= 2);
     if (fn.nargs < 1) {
@@ -995,7 +995,7 @@
 as_value
 date_setDate(const fn_call& fn)
 {
-  Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+  Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
 
   if (fn.nargs < 1) {
       IF_VERBOSE_ASCODING_ERRORS(
@@ -1035,7 +1035,7 @@
 as_value
 date_setHours(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
 
     // assert(fn.nargs >= 1 && fn.nargs <= 4);
     if (fn.nargs < 1) {
@@ -1080,7 +1080,7 @@
 as_value
 date_setMinutes(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
 
     //assert(fn.nargs >= 1 && fn.nargs <= 3);
     if (fn.nargs < 1) {
@@ -1121,7 +1121,7 @@
 as_value
 date_setSeconds(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
 
     // assert(fn.nargs >= 1 && fn.nargs <= 2);
     if (fn.nargs < 1) {
@@ -1160,7 +1160,7 @@
 as_value
 date_setMilliseconds(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
 
     if (fn.nargs < 1) {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -1202,7 +1202,7 @@
 as_value
 date_tostring(const fn_call& fn) 
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return as_value(date->toString());
 }
 
@@ -1345,7 +1345,7 @@
 /// number of milliseconds.
 as_value date_getTime(const fn_call& fn)
 {
-    Date_as* date = ensureNativeType<Date_as>(fn.this_ptr);
+    Date_as* date = ensure<ThisIsNative<Date_as> >(fn);
     return as_value(date->getTimeValue());
 }
 

=== modified file 'libcore/asobj/Error_as.cpp'
--- a/libcore/asobj/Error_as.cpp        2009-10-07 06:18:09 +0000
+++ b/libcore/asobj/Error_as.cpp        2009-10-22 14:56:18 +0000
@@ -70,7 +70,7 @@
 as_value
 error_toString(const fn_call& fn)
 {
-       boost::intrusive_ptr<as_object> ptr = 
ensureType<as_object>(fn.this_ptr);
+       boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     string_table& st = getStringTable(*ptr);
     as_value message;

=== modified file 'libcore/asobj/Globals.cpp'
--- a/libcore/asobj/Globals.cpp 2009-10-21 13:16:25 +0000
+++ b/libcore/asobj/Globals.cpp 2009-10-22 14:56:18 +0000
@@ -1220,7 +1220,7 @@
 as_value
 local_errorConstructor(const fn_call& fn)
 {
-    as_object* obj = ensureType<as_object>(fn.this_ptr);
+    as_object* obj = ensure<ValidThis>(fn);
     const as_value& arg = fn.nargs ? fn.arg(0) : as_value();
     string_table& st = getStringTable(fn);
     obj->set_member(st.find("message"), arg);

=== modified file 'libcore/asobj/LoadVars_as.cpp'
--- a/libcore/asobj/LoadVars_as.cpp     2009-08-21 11:42:13 +0000
+++ b/libcore/asobj/LoadVars_as.cpp     2009-10-22 14:56:18 +0000
@@ -124,7 +124,7 @@
 as_value
 loadvars_tostring(const fn_call& fn)
 {
-       boost::intrusive_ptr<as_object> ptr = 
ensureType<as_object>(fn.this_ptr);
+       boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
        typedef PropertyList::SortedPropertyList VarMap;
        VarMap vars;

=== modified file 'libcore/asobj/LoadableObject.cpp'
--- a/libcore/asobj/LoadableObject.cpp  2009-10-14 16:10:50 +0000
+++ b/libcore/asobj/LoadableObject.cpp  2009-10-22 14:56:18 +0000
@@ -353,7 +353,7 @@
 as_value
 LoadableObject::loadableobject_getBytesLoaded(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     as_value bytesLoaded;
     string_table& st = getStringTable(fn);
@@ -364,7 +364,7 @@
 as_value
 LoadableObject::loadableobject_getBytesTotal(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     as_value bytesTotal;
     string_table& st = getStringTable(fn);
@@ -472,7 +472,7 @@
 as_value
 loadableobject_decode(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     if (!fn.nargs) return as_value(false);
 
@@ -521,7 +521,7 @@
 as_value
 loadableobject_sendAndLoad(const fn_call& fn)
 {
-    LoadableObject* ptr = ensureNativeType<LoadableObject>(fn.this_ptr);
+    LoadableObject* ptr = ensure<ThisIsNative<LoadableObject> >(fn);
 
     if ( fn.nargs < 2 )
     {
@@ -573,7 +573,7 @@
 as_value
 loadableobject_load(const fn_call& fn)
 {
-    LoadableObject* obj = ensureNativeType<LoadableObject>(fn.this_ptr);
+    LoadableObject* obj = ensure<ThisIsNative<LoadableObject> >(fn);
 
     if ( fn.nargs < 1 )
     {
@@ -606,7 +606,7 @@
 as_value
 loadableobject_send(const fn_call& fn)
 {
-    LoadableObject* ptr = ensureNativeType<LoadableObject>(fn.this_ptr);
+    LoadableObject* ptr = ensure<ThisIsNative<LoadableObject> >(fn);
  
     std::ostringstream os;
     fn.dump_args(os);

=== modified file 'libcore/asobj/MovieClipLoader.cpp'
--- a/libcore/asobj/MovieClipLoader.cpp 2009-10-14 18:37:43 +0000
+++ b/libcore/asobj/MovieClipLoader.cpp 2009-10-22 14:56:18 +0000
@@ -273,8 +273,7 @@
 moviecliploader_loadclip(const fn_call& fn)
 {
 
-       boost::intrusive_ptr<MovieClipLoader> ptr =
-        ensureType<MovieClipLoader>(fn.this_ptr);
+    MovieClipLoader* ptr = ensure<ThisIs<MovieClipLoader> >(fn);
   
        if ( fn.nargs < 2 )
        {
@@ -346,9 +345,6 @@
 moviecliploader_getprogress(const fn_call& fn)
 {
 
-       boost::intrusive_ptr<MovieClipLoader> ptr =
-        ensureType<MovieClipLoader>(fn.this_ptr);
-  
        if ( ! fn.nargs )
        {
                IF_VERBOSE_ASCODING_ERRORS(

=== modified file 'libcore/asobj/Number_as.cpp'
--- a/libcore/asobj/Number_as.cpp       2009-08-27 06:30:46 +0000
+++ b/libcore/asobj/Number_as.cpp       2009-10-22 14:56:18 +0000
@@ -64,7 +64,7 @@
 {
     // Number.toString must only work for number object, not generic ones.
     // This is so trace(Number.prototype) doesn't return 0 ...
-    Number_as* obj = ensureNativeType<Number_as>(fn.this_ptr);
+    Number_as* obj = ensure<ThisIsNative<Number_as> >(fn);
 
     double val = obj->value();
     unsigned radix = 10;
@@ -91,7 +91,7 @@
 {
     // Number.valueOf must only work for number object, not generic ones.
     // This is so trace(Number.prototype == Object) return true in swf5 ?
-    Number_as* obj = ensureNativeType<Number_as>(fn.this_ptr);
+    Number_as* obj = ensure<ThisIsNative<Number_as> >(fn);
 
     return obj->value();
 }

=== modified file 'libcore/asobj/Object.cpp'
--- a/libcore/asobj/Object.cpp  2009-10-14 08:47:08 +0000
+++ b/libcore/asobj/Object.cpp  2009-10-22 14:56:18 +0000
@@ -377,7 +377,7 @@
 as_value
 object_hasOwnProperty(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
 
        //assert(fn.result->is_undefined());
        if ( fn.nargs < 1 )
@@ -405,7 +405,7 @@
 as_value
 object_isPropertyEnumerable(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
 
        //assert(fn.result->is_undefined());
        if ( fn.nargs < 1 )

=== modified file 'libcore/asobj/QName_as.cpp'
--- a/libcore/asobj/QName_as.cpp        2009-10-14 08:47:08 +0000
+++ b/libcore/asobj/QName_as.cpp        2009-10-22 14:56:18 +0000
@@ -98,7 +98,7 @@
 as_value
 qname_ctor(const fn_call& fn)
 {
-    as_object* obj = ensureType<as_object>(fn.this_ptr);
+    as_object* obj = ensure<ValidThis>(fn);
     attachQNameInterface(*obj);
     return as_value(); 
 }

=== modified file 'libcore/asobj/Selection_as.cpp'
--- a/libcore/asobj/Selection_as.cpp    2009-10-21 07:10:41 +0000
+++ b/libcore/asobj/Selection_as.cpp    2009-10-22 14:56:18 +0000
@@ -105,7 +105,7 @@
 as_value
 selection_getBeginIndex(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
     
     movie_root& mr = getRoot(fn);
     DisplayObject* focus = mr.getFocus();
@@ -127,7 +127,7 @@
 as_value
 selection_getCaretIndex(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     movie_root& mr = getRoot(fn);
     DisplayObject* focus = mr.getFocus();
@@ -143,7 +143,7 @@
 as_value
 selection_getEndIndex(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     movie_root& mr = getRoot(fn);
     DisplayObject* focus = mr.getFocus();
@@ -160,7 +160,7 @@
 as_value
 selection_getFocus(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
     
     movie_root& mr = getRoot(fn);
 
@@ -196,7 +196,7 @@
 selection_setFocus(const fn_call& fn)
 {
 
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     /// Handle invalid arguments: must be one argument, or no action is
     /// taken.
@@ -243,7 +243,7 @@
 as_value
 selection_setSelection(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     movie_root& mr = getRoot(fn);
     DisplayObject* focus = mr.getFocus();

=== modified file 'libcore/asobj/String_as.cpp'
--- a/libcore/asobj/String_as.cpp       2009-10-14 14:31:24 +0000
+++ b/libcore/asobj/String_as.cpp       2009-10-22 14:56:18 +0000
@@ -157,7 +157,7 @@
 as_value
 string_concat(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     as_value val(fn.this_ptr);
 
     std::string str;
@@ -175,7 +175,7 @@
 as_value
 string_slice(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     as_value val(fn.this_ptr);
     
     std::string str;
@@ -231,7 +231,7 @@
 as_value
 string_split(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     as_value val(fn.this_ptr);
     
     std::string str;
@@ -347,7 +347,7 @@
 as_value
 string_lastIndexOf(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     as_value val(fn.this_ptr);
     
     std::string str;
@@ -384,7 +384,7 @@
 as_value
 string_substr(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     as_value val(fn.this_ptr);
     
     std::string str;
@@ -423,7 +423,7 @@
 as_value
 string_substring(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     as_value val(fn.this_ptr);
     
     std::string str;
@@ -476,7 +476,7 @@
 as_value
 string_indexOf(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     as_value val(fn.this_ptr);
  
     /// Do not return before this, because the toString method should always
@@ -568,7 +568,7 @@
 as_value
 string_charCodeAt(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     as_value val(fn.this_ptr);
     
     std::string str;
@@ -605,7 +605,7 @@
 as_value
 string_charAt(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     as_value val(fn.this_ptr);
     
     std::string str;
@@ -640,7 +640,7 @@
 as_value
 string_toUpperCase(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     as_value val(fn.this_ptr);
 
     std::string str;
@@ -678,7 +678,7 @@
 as_value
 string_toLowerCase(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     as_value val(fn.this_ptr);
     
     std::string str;
@@ -715,7 +715,7 @@
 as_value
 string_oldToLower(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     as_value val(fn.this_ptr);
 
     // This should use the C locale; extended DisplayObjects are
@@ -728,7 +728,7 @@
 as_value
 string_oldToUpper(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     as_value val(fn.this_ptr);
 
     // This should use the C locale; extended DisplayObjects are
@@ -750,7 +750,7 @@
 as_value
 string_toString(const fn_call& fn)
 {
-    String_as* str = ensureNativeType<String_as>(fn.this_ptr);
+    String_as* str = ensure<ThisIsNative<String_as> >(fn);
     return as_value(str->value());
 }
 

=== modified file 'libcore/asobj/TextFormat_as.cpp'
--- a/libcore/asobj/TextFormat_as.cpp   2009-10-15 07:30:20 +0000
+++ b/libcore/asobj/TextFormat_as.cpp   2009-10-22 14:56:18 +0000
@@ -176,7 +176,7 @@
 textformat_new(const fn_call& fn)
 {
 
-    as_object* obj = ensureType<as_object>(fn.this_ptr);
+    as_object* obj = ensure<ValidThis>(fn);
 
     std::auto_ptr<TextFormat_as> tf(new TextFormat_as);
 
@@ -240,7 +240,7 @@
 as_value
 textformat_display(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
 
        as_value ret;
 
@@ -262,7 +262,7 @@
 as_value
 textformat_bullet(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
 
        as_value ret;
 
@@ -294,7 +294,7 @@
 as_value
 textformat_tabStops(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
        
     if (!fn.nargs) {
                LOG_ONCE( log_unimpl("Getter for textformat_tabStops") );
@@ -319,7 +319,7 @@
 as_value
 textformat_blockIndent(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
 
        as_value ret;
 
@@ -341,7 +341,7 @@
 as_value
 textformat_leading(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
 
        as_value ret;
 
@@ -361,7 +361,7 @@
 as_value
 textformat_indent(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
 
        as_value ret;
 
@@ -381,7 +381,7 @@
 as_value
 textformat_rightMargin(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
 
        as_value ret;
 
@@ -401,7 +401,7 @@
 as_value
 textformat_leftMargin(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
 
        as_value ret;
 
@@ -423,7 +423,7 @@
 as_value
 textformat_align(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
 
        as_value ret;
 
@@ -445,7 +445,7 @@
 as_value
 textformat_underline(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
 
        as_value ret;
 
@@ -465,7 +465,7 @@
 as_value
 textformat_italic(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
 
        as_value ret;
 
@@ -485,7 +485,7 @@
 as_value
 textformat_bold(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
 
        as_value ret;
 
@@ -505,7 +505,7 @@
 as_value
 textformat_target(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
 
        as_value ret;
 
@@ -525,7 +525,7 @@
 as_value
 textformat_url(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
 
        as_value ret;
 
@@ -545,7 +545,7 @@
 as_value
 textformat_color(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
 
        as_value ret;
 
@@ -567,7 +567,7 @@
 as_value
 textformat_size(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
 
        as_value ret;
 
@@ -587,7 +587,7 @@
 as_value
 textformat_font(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
 
        as_value ret;
 
@@ -608,7 +608,7 @@
 as_value
 textformat_getTextExtent(const fn_call& fn)
 {
-    TextFormat_as* relay = ensureNativeType<TextFormat_as>(fn.this_ptr);
+    TextFormat_as* relay = ensure<ThisIsNative<TextFormat_as> >(fn);
     UNUSED(relay);
        LOG_ONCE( log_unimpl("TextFormat.getTextExtent") );
        return as_value();

=== modified file 'libcore/asobj/flash/display/BitmapData_as.cpp'
--- a/libcore/asobj/flash/display/BitmapData_as.cpp     2009-10-14 08:47:08 
+0000
+++ b/libcore/asobj/flash/display/BitmapData_as.cpp     2009-10-22 14:56:18 
+0000
@@ -240,7 +240,7 @@
 as_value
 bitmapdata_applyFilter(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -249,7 +249,7 @@
 as_value
 bitmapdata_clone(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -258,7 +258,7 @@
 as_value
 bitmapdata_colorTransform(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -267,7 +267,7 @@
 as_value
 bitmapdata_copyChannel(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -276,7 +276,7 @@
 as_value
 bitmapdata_copyPixels(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -287,7 +287,7 @@
 {
     // Should free the memory storing the bitmap.
     // All properties afterwards are -1 (even the rectangle)
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
     ptr->dispose();
        return as_value();
 }
@@ -295,7 +295,7 @@
 as_value
 bitmapdata_draw(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
 
     std::ostringstream os;
     fn.dump_args(os);
@@ -337,7 +337,7 @@
 as_value
 bitmapdata_fillRect(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
 
     if (fn.nargs < 2) return as_value();
     
@@ -378,7 +378,7 @@
 as_value
 bitmapdata_floodFill(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -387,7 +387,7 @@
 as_value
 bitmapdata_generateFilterRect(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -396,7 +396,7 @@
 as_value
 bitmapdata_getColorBoundsRect(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -405,7 +405,7 @@
 as_value
 bitmapdata_getPixel(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
 
     if (fn.nargs < 2)
     {
@@ -423,7 +423,7 @@
 as_value
 bitmapdata_getPixel32(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
 
     if (fn.nargs < 2)
     {
@@ -442,7 +442,7 @@
 as_value
 bitmapdata_hitTest(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -451,7 +451,7 @@
 as_value
 bitmapdata_merge(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -460,7 +460,7 @@
 as_value
 bitmapdata_noise(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -469,7 +469,7 @@
 as_value
 bitmapdata_paletteMap(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -478,7 +478,7 @@
 as_value
 bitmapdata_perlinNoise(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -487,7 +487,7 @@
 as_value
 bitmapdata_pixelDissolve(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -496,7 +496,7 @@
 as_value
 bitmapdata_scroll(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -505,7 +505,7 @@
 as_value
 bitmapdata_setPixel(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
 
     if (fn.nargs < 3) {
         return as_value();
@@ -529,7 +529,7 @@
 as_value
 bitmapdata_setPixel32(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
 
     if (fn.nargs < 3) {
         return as_value();
@@ -553,7 +553,7 @@
 as_value
 bitmapdata_threshold(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -562,7 +562,7 @@
 as_value
 bitmapdata_height(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
 
     // Read-only
     if (fn.nargs) return as_value();
@@ -576,7 +576,7 @@
 as_value
 bitmapdata_rectangle(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
 
     // Returns the immutable rectangle of the bitmap or -1 if dispose()
     // has been called.
@@ -603,7 +603,7 @@
 as_value
 bitmapdata_transparent(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
 
     // Read-only
     if (fn.nargs) return as_value();
@@ -616,7 +616,7 @@
 as_value
 bitmapdata_width(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
 
     // Read-only
     if (fn.nargs) return as_value();
@@ -631,7 +631,7 @@
 as_value
 bitmapdata_loadBitmap(const fn_call& fn)
 {
-       BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+       BitmapData_as* ptr = ensure<ThisIsNative<BitmapData_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -653,7 +653,7 @@
 as_value
 bitmapdata_ctor(const fn_call& fn)
 {
-    as_object* ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
        if (fn.nargs < 2) {
         IF_VERBOSE_ASCODING_ERRORS(
              log_aserror("BitmapData constructor requires at least two "

=== modified file 'libcore/asobj/flash/display/DisplayObjectContainer_as.cpp'
--- a/libcore/asobj/flash/display/DisplayObjectContainer_as.cpp 2009-10-14 
08:47:08 +0000
+++ b/libcore/asobj/flash/display/DisplayObjectContainer_as.cpp 2009-10-22 
14:56:18 +0000
@@ -125,8 +125,7 @@
 as_value
 displayobjectcontainer_addChild(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObjectContainer> ptr =
-        ensureType<DisplayObjectContainer>(fn.this_ptr);
+    DisplayObjectContainer* ptr = ensure<ThisIs<DisplayObjectContainer> >(fn);
 
     as_value ret;
 
@@ -171,8 +170,7 @@
 as_value
 displayobjectcontainer_addChildAt(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObjectContainer> ptr =
-        ensureType<DisplayObjectContainer>(fn.this_ptr);
+    DisplayObjectContainer* ptr = ensure<ThisIs<DisplayObjectContainer> >(fn);
 
     as_value ret;
 
@@ -223,8 +221,7 @@
 as_value
 displayobjectcontainer_areInaccessibleObjectsUnderPoint(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObjectContainer> ptr =
-        ensureType<DisplayObjectContainer>(fn.this_ptr);
+    DisplayObjectContainer* ptr = ensure<ThisIs<DisplayObjectContainer> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -233,8 +230,7 @@
 as_value
 displayobjectcontainer_contains(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObjectContainer> ptr =
-        ensureType<DisplayObjectContainer>(fn.this_ptr);
+    DisplayObjectContainer* ptr = ensure<ThisIs<DisplayObjectContainer> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -243,8 +239,7 @@
 as_value
 displayobjectcontainer_getChildAt(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObjectContainer> ptr =
-        ensureType<DisplayObjectContainer>(fn.this_ptr);
+    DisplayObjectContainer* ptr = ensure<ThisIs<DisplayObjectContainer> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -253,8 +248,7 @@
 as_value
 displayobjectcontainer_getChildByName(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObjectContainer> ptr =
-        ensureType<DisplayObjectContainer>(fn.this_ptr);
+    DisplayObjectContainer* ptr = ensure<ThisIs<DisplayObjectContainer> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -263,16 +257,14 @@
 as_value
 displayobjectcontainer_numChildren(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObjectContainer> ptr =
-        ensureType<DisplayObjectContainer>(fn.this_ptr);
+    DisplayObjectContainer* ptr = ensure<ThisIs<DisplayObjectContainer> >(fn);
     return as_value(ptr->numChildren());
 }
 
 as_value
 displayobjectcontainer_getChildIndex(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObjectContainer> ptr =
-        ensureType<DisplayObjectContainer>(fn.this_ptr);
+    DisplayObjectContainer* ptr = ensure<ThisIs<DisplayObjectContainer> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -281,8 +273,7 @@
 as_value
 displayobjectcontainer_getObjectsUnderPoint(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObjectContainer> ptr =
-        ensureType<DisplayObjectContainer>(fn.this_ptr);
+    DisplayObjectContainer* ptr = ensure<ThisIs<DisplayObjectContainer> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -291,8 +282,7 @@
 as_value
 displayobjectcontainer_removeChild(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObjectContainer> ptr =
-        ensureType<DisplayObjectContainer>(fn.this_ptr);
+    DisplayObjectContainer* ptr = ensure<ThisIs<DisplayObjectContainer> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -301,8 +291,7 @@
 as_value
 displayobjectcontainer_removeChildAt(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObjectContainer> ptr =
-        ensureType<DisplayObjectContainer>(fn.this_ptr);
+    DisplayObjectContainer* ptr = ensure<ThisIs<DisplayObjectContainer> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -311,8 +300,7 @@
 as_value
 displayobjectcontainer_setChildIndex(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObjectContainer> ptr =
-        ensureType<DisplayObjectContainer>(fn.this_ptr);
+    DisplayObjectContainer* ptr = ensure<ThisIs<DisplayObjectContainer> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -321,8 +309,7 @@
 as_value
 displayobjectcontainer_swapChildren(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObjectContainer> ptr =
-        ensureType<DisplayObjectContainer>(fn.this_ptr);
+    DisplayObjectContainer* ptr = ensure<ThisIs<DisplayObjectContainer> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -331,8 +318,7 @@
 as_value
 displayobjectcontainer_swapChildrenAt(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObjectContainer> ptr =
-        ensureType<DisplayObjectContainer>(fn.this_ptr);
+    DisplayObjectContainer* ptr = ensure<ThisIs<DisplayObjectContainer> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/display/DisplayObject_as.cpp'
--- a/libcore/asobj/flash/display/DisplayObject_as.cpp  2009-07-29 05:40:20 
+0000
+++ b/libcore/asobj/flash/display/DisplayObject_as.cpp  2009-10-22 14:56:18 
+0000
@@ -118,8 +118,7 @@
 as_value
 displayobject_getRect(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObject_as> ptr =
-        ensureType<DisplayObject_as>(fn.this_ptr);
+    DisplayObject_as* ptr = ensure<ThisIs<DisplayObject_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -128,8 +127,7 @@
 as_value
 displayobject_globalToLocal(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObject_as> ptr =
-        ensureType<DisplayObject_as>(fn.this_ptr);
+    DisplayObject_as* ptr = ensure<ThisIs<DisplayObject_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -138,8 +136,7 @@
 as_value
 displayobject_hitTestObject(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObject_as> ptr =
-        ensureType<DisplayObject_as>(fn.this_ptr);
+    DisplayObject_as* ptr = ensure<ThisIs<DisplayObject_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -148,8 +145,7 @@
 as_value
 displayobject_hitTestPoint(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObject_as> ptr =
-        ensureType<DisplayObject_as>(fn.this_ptr);
+    DisplayObject_as* ptr = ensure<ThisIs<DisplayObject_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -158,8 +154,7 @@
 as_value
 displayobject_localToGlobal(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObject_as> ptr =
-        ensureType<DisplayObject_as>(fn.this_ptr);
+    DisplayObject_as* ptr = ensure<ThisIs<DisplayObject_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -168,8 +163,7 @@
 as_value
 displayobject_added(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObject_as> ptr =
-        ensureType<DisplayObject_as>(fn.this_ptr);
+    DisplayObject_as* ptr = ensure<ThisIs<DisplayObject_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -178,8 +172,7 @@
 as_value
 displayobject_addedToStage(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObject_as> ptr =
-        ensureType<DisplayObject_as>(fn.this_ptr);
+    DisplayObject_as* ptr = ensure<ThisIs<DisplayObject_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -188,8 +181,7 @@
 as_value
 displayobject_enterFrame(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObject_as> ptr =
-        ensureType<DisplayObject_as>(fn.this_ptr);
+    DisplayObject_as* ptr = ensure<ThisIs<DisplayObject_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -198,8 +190,7 @@
 as_value
 displayobject_removed(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObject_as> ptr =
-        ensureType<DisplayObject_as>(fn.this_ptr);
+    DisplayObject_as* ptr = ensure<ThisIs<DisplayObject_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -208,8 +199,7 @@
 as_value
 displayobject_removedFromStage(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObject_as> ptr =
-        ensureType<DisplayObject_as>(fn.this_ptr);
+    DisplayObject_as* ptr = ensure<ThisIs<DisplayObject_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -218,8 +208,7 @@
 as_value
 displayobject_render(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObject_as> ptr =
-        ensureType<DisplayObject_as>(fn.this_ptr);
+    DisplayObject_as* ptr = ensure<ThisIs<DisplayObject_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/display/Graphics_as.cpp'
--- a/libcore/asobj/flash/display/Graphics_as.cpp       2009-07-29 05:40:20 
+0000
+++ b/libcore/asobj/flash/display/Graphics_as.cpp       2009-10-22 14:56:18 
+0000
@@ -121,8 +121,7 @@
 as_value
 graphics_beginFill(const fn_call& fn)
 {
-    boost::intrusive_ptr<Graphics_as> ptr =
-        ensureType<Graphics_as>(fn.this_ptr);
+    Graphics_as* ptr = ensure<ThisIs<Graphics_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -131,8 +130,7 @@
 as_value
 graphics_beginGradientFill(const fn_call& fn)
 {
-    boost::intrusive_ptr<Graphics_as> ptr =
-        ensureType<Graphics_as>(fn.this_ptr);
+    Graphics_as* ptr = ensure<ThisIs<Graphics_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -141,8 +139,7 @@
 as_value
 graphics_clear(const fn_call& fn)
 {
-    boost::intrusive_ptr<Graphics_as> ptr =
-        ensureType<Graphics_as>(fn.this_ptr);
+    Graphics_as* ptr = ensure<ThisIs<Graphics_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -151,8 +148,7 @@
 as_value
 graphics_curveTo(const fn_call& fn)
 {
-    boost::intrusive_ptr<Graphics_as> ptr =
-        ensureType<Graphics_as>(fn.this_ptr);
+    Graphics_as* ptr = ensure<ThisIs<Graphics_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -161,8 +157,7 @@
 as_value
 graphics_drawCircle(const fn_call& fn)
 {
-    boost::intrusive_ptr<Graphics_as> ptr =
-        ensureType<Graphics_as>(fn.this_ptr);
+    Graphics_as* ptr = ensure<ThisIs<Graphics_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -171,8 +166,7 @@
 as_value
 graphics_drawEllipse(const fn_call& fn)
 {
-    boost::intrusive_ptr<Graphics_as> ptr =
-        ensureType<Graphics_as>(fn.this_ptr);
+    Graphics_as* ptr = ensure<ThisIs<Graphics_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -181,8 +175,7 @@
 as_value
 graphics_drawRect(const fn_call& fn)
 {
-    boost::intrusive_ptr<Graphics_as> ptr =
-        ensureType<Graphics_as>(fn.this_ptr);
+    Graphics_as* ptr = ensure<ThisIs<Graphics_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -191,8 +184,7 @@
 as_value
 graphics_drawRoundRect(const fn_call& fn)
 {
-    boost::intrusive_ptr<Graphics_as> ptr =
-        ensureType<Graphics_as>(fn.this_ptr);
+    Graphics_as* ptr = ensure<ThisIs<Graphics_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -201,8 +193,7 @@
 as_value
 graphics_endFill(const fn_call& fn)
 {
-    boost::intrusive_ptr<Graphics_as> ptr =
-        ensureType<Graphics_as>(fn.this_ptr);
+    Graphics_as* ptr = ensure<ThisIs<Graphics_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -211,8 +202,7 @@
 as_value
 graphics_lineGradientStyle(const fn_call& fn)
 {
-    boost::intrusive_ptr<Graphics_as> ptr =
-        ensureType<Graphics_as>(fn.this_ptr);
+    Graphics_as* ptr = ensure<ThisIs<Graphics_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -221,8 +211,7 @@
 as_value
 graphics_lineStyle(const fn_call& fn)
 {
-    boost::intrusive_ptr<Graphics_as> ptr =
-        ensureType<Graphics_as>(fn.this_ptr);
+    Graphics_as* ptr = ensure<ThisIs<Graphics_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -231,8 +220,7 @@
 as_value
 graphics_lineTo(const fn_call& fn)
 {
-    boost::intrusive_ptr<Graphics_as> ptr =
-        ensureType<Graphics_as>(fn.this_ptr);
+    Graphics_as* ptr = ensure<ThisIs<Graphics_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -241,8 +229,7 @@
 as_value
 graphics_moveTo(const fn_call& fn)
 {
-    boost::intrusive_ptr<Graphics_as> ptr =
-        ensureType<Graphics_as>(fn.this_ptr);
+    Graphics_as* ptr = ensure<ThisIs<Graphics_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/display/LoaderInfo_as.cpp'
--- a/libcore/asobj/flash/display/LoaderInfo_as.cpp     2009-07-29 05:40:20 
+0000
+++ b/libcore/asobj/flash/display/LoaderInfo_as.cpp     2009-10-22 14:56:18 
+0000
@@ -109,8 +109,7 @@
 as_value
 loaderinfo_complete(const fn_call& fn)
 {
-    boost::intrusive_ptr<LoaderInfo_as> ptr =
-        ensureType<LoaderInfo_as>(fn.this_ptr);
+    LoaderInfo_as* ptr = ensure<ThisIs<LoaderInfo_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -119,8 +118,7 @@
 as_value
 loaderinfo_httpStatus(const fn_call& fn)
 {
-    boost::intrusive_ptr<LoaderInfo_as> ptr =
-        ensureType<LoaderInfo_as>(fn.this_ptr);
+    LoaderInfo_as* ptr = ensure<ThisIs<LoaderInfo_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -129,8 +127,7 @@
 as_value
 loaderinfo_init(const fn_call& fn)
 {
-    boost::intrusive_ptr<LoaderInfo_as> ptr =
-        ensureType<LoaderInfo_as>(fn.this_ptr);
+    LoaderInfo_as* ptr = ensure<ThisIs<LoaderInfo_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -139,8 +136,7 @@
 as_value
 loaderinfo_ioError(const fn_call& fn)
 {
-    boost::intrusive_ptr<LoaderInfo_as> ptr =
-        ensureType<LoaderInfo_as>(fn.this_ptr);
+    LoaderInfo_as* ptr = ensure<ThisIs<LoaderInfo_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -149,8 +145,7 @@
 as_value
 loaderinfo_open(const fn_call& fn)
 {
-    boost::intrusive_ptr<LoaderInfo_as> ptr =
-        ensureType<LoaderInfo_as>(fn.this_ptr);
+    LoaderInfo_as* ptr = ensure<ThisIs<LoaderInfo_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -159,8 +154,7 @@
 as_value
 loaderinfo_progress(const fn_call& fn)
 {
-    boost::intrusive_ptr<LoaderInfo_as> ptr =
-        ensureType<LoaderInfo_as>(fn.this_ptr);
+    LoaderInfo_as* ptr = ensure<ThisIs<LoaderInfo_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -169,8 +163,7 @@
 as_value
 loaderinfo_unload(const fn_call& fn)
 {
-    boost::intrusive_ptr<LoaderInfo_as> ptr =
-        ensureType<LoaderInfo_as>(fn.this_ptr);
+    LoaderInfo_as* ptr = ensure<ThisIs<LoaderInfo_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/display/Loader_as.cpp'
--- a/libcore/asobj/flash/display/Loader_as.cpp 2009-08-20 08:57:16 +0000
+++ b/libcore/asobj/flash/display/Loader_as.cpp 2009-10-22 14:56:18 +0000
@@ -93,8 +93,7 @@
 as_value
 loader_load(const fn_call& fn)
 {
-    boost::intrusive_ptr<Loader_as> ptr =
-        ensureType<Loader_as>(fn.this_ptr);
+    Loader_as* ptr = ensure<ThisIs<Loader_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -103,8 +102,7 @@
 as_value
 loader_loadBytes(const fn_call& fn)
 {
-    boost::intrusive_ptr<Loader_as> ptr =
-        ensureType<Loader_as>(fn.this_ptr);
+    Loader_as* ptr = ensure<ThisIs<Loader_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -113,8 +111,7 @@
 as_value
 loader_unload(const fn_call& fn)
 {
-    boost::intrusive_ptr<Loader_as> ptr =
-        ensureType<Loader_as>(fn.this_ptr);
+    Loader_as* ptr = ensure<ThisIs<Loader_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/display/MovieClip_as.cpp'
--- a/libcore/asobj/flash/display/MovieClip_as.cpp      2009-10-21 07:10:41 
+0000
+++ b/libcore/asobj/flash/display/MovieClip_as.cpp      2009-10-22 14:56:18 
+0000
@@ -353,7 +353,7 @@
 as_value
 movieclip_createEmptyMovieClip(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> ptr = ensureType<MovieClip>(fn.this_ptr);
+    boost::intrusive_ptr<MovieClip> ptr = ensure<ThisIs<MovieClip> >(fn);
 
     if (fn.nargs != 2) {
         if (fn.nargs < 2) {
@@ -391,8 +391,7 @@
 as_value
 movieclip_play(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     movieclip->setPlayState(MovieClip::PLAYSTATE_PLAY);
     return as_value();
@@ -401,8 +400,7 @@
 as_value
 movieclip_stop(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     movieclip->setPlayState(MovieClip::PLAYSTATE_STOP);
 
@@ -414,8 +412,7 @@
 as_value
 movieclip_removeMovieClip(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
     movieclip->removeMovieClip();
     return as_value();
 }
@@ -424,8 +421,7 @@
 as_value
 movieclip_cacheAsBitmap(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
     UNUSED(movieclip);
     LOG_ONCE( log_unimpl(_("MovieClip.cacheAsBitmap()")) );
     return as_value();
@@ -435,8 +431,7 @@
 as_value
 movieclip_filters(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
     UNUSED(movieclip);
     LOG_ONCE(log_unimpl(_("MovieClip.filters()")));
     return as_value();
@@ -446,8 +441,7 @@
 as_value
 movieclip_forceSmoothing(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
     UNUSED(movieclip);
     LOG_ONCE(log_unimpl(_("MovieClip.forceSmoothing()")));
     return as_value();
@@ -457,8 +451,7 @@
 as_value
 movieclip_opaqueBackground(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
     UNUSED(movieclip);
     LOG_ONCE(log_unimpl(_("MovieClip.opaqueBackground()")));
     return as_value();
@@ -468,8 +461,7 @@
 as_value
 movieclip_scale9Grid(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
     UNUSED(movieclip);
     LOG_ONCE(log_unimpl(_("MovieClip.scale9Grid()")));
     return as_value();
@@ -479,8 +471,7 @@
 as_value
 movieclip_scrollRect(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
     UNUSED(movieclip);
     LOG_ONCE(log_unimpl(_("MovieClip.scrollRect()")));
     return as_value();
@@ -490,8 +481,7 @@
 as_value
 movieclip_tabIndex(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
     UNUSED(movieclip);
     LOG_ONCE(log_unimpl(_("MovieClip.tabIndex()")));
     return as_value();
@@ -503,8 +493,7 @@
 as_value
 movieclip_attachMovie(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     if (fn.nargs < 3 || fn.nargs > 4)
     {
@@ -566,12 +555,7 @@
     
     boost::int32_t depthValue = static_cast<boost::int32_t>(depth);
 
-    boost::intrusive_ptr<DisplayObject> newch =
-        exported_movie->createDisplayObject(movieclip.get());
-
-#ifndef GNASH_USE_GC
-    assert(newch->get_ref_count() > 0);
-#endif // ndef GNASH_USE_GC
+    DisplayObject* newch = exported_movie->createDisplayObject(movieclip);
 
     newch->set_name(newname);
     newch->setDynamic();
@@ -600,7 +584,7 @@
         return as_value();
     }
 
-    return as_value(newch.get());
+    return as_value(newch);
 }
 
 
@@ -608,8 +592,7 @@
 as_value
 movieclip_attachAudio(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     if (!fn.nargs)
     {
@@ -629,7 +612,7 @@
         return as_value();
     }
 
-    ns->setAudioController(movieclip.get());
+    ns->setAudioController(movieclip);
 
     LOG_ONCE( log_unimpl("MovieClip.attachAudio() - TESTING") );
     return as_value();
@@ -640,8 +623,7 @@
 as_value
 movieclip_attachVideo(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
     UNUSED(movieclip);
 
     LOG_ONCE( log_unimpl("MovieClip.attachVideo()") );
@@ -653,8 +635,7 @@
 movieclip_getDepth(const fn_call& fn)
 {
     // Unlike TextField.getDepth this works for any DisplayObject
-    boost::intrusive_ptr<DisplayObject> movieclip = 
-        ensureType<DisplayObject>(fn.this_ptr);
+    DisplayObject* movieclip = ensure<ThisIs<DisplayObject> >(fn);
 
     const int n = movieclip->get_depth();
 
@@ -668,7 +649,7 @@
 movieclip_swapDepths(const fn_call& fn)
 {
 
-    MovieClip* movieclip = ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     const int this_depth = movieclip->get_depth();
 
@@ -803,8 +784,7 @@
 as_value
 movieclip_duplicateMovieClip(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
     
     if (fn.nargs < 2)
     {
@@ -853,8 +833,7 @@
 as_value
 movieclip_gotoAndPlay(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     if (fn.nargs < 1)
     {
@@ -883,8 +862,7 @@
 
 as_value movieclip_gotoAndStop(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     if (fn.nargs < 1)
     {
@@ -913,8 +891,7 @@
 
 as_value movieclip_nextFrame(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     const size_t frame_count = movieclip->get_frame_count();
     const size_t current_frame = movieclip->get_current_frame();
@@ -929,8 +906,7 @@
 as_value
 movieclip_prevFrame(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     const size_t current_frame = movieclip->get_current_frame();
     if (current_frame > 0)
@@ -944,8 +920,7 @@
 as_value
 movieclip_getBytesLoaded(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     return as_value(movieclip->get_bytes_loaded());
 }
@@ -953,8 +928,7 @@
 as_value
 movieclip_getBytesTotal(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     // @@ horrible uh ?
     return as_value(movieclip->get_bytes_total());
@@ -967,8 +941,7 @@
 as_value
 movieclip_loadMovie(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     as_value val;
     if (fn.nargs > 1) {
@@ -1024,8 +997,7 @@
 as_value
 movieclip_loadVariables(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     // This always calls MovieClip.meth, even when there are no
     // arguments.
@@ -1072,8 +1044,7 @@
 as_value
 movieclip_unloadMovie(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     movieclip->unloadMovie();
 
@@ -1083,8 +1054,7 @@
 as_value
 movieclip_hitTest(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     switch (fn.nargs)
     {
@@ -1150,8 +1120,7 @@
 as_value
 movieclip_getNextHighestDepth(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     int nextdepth = movieclip->getNextHighestDepth();
     return as_value(static_cast<double>(nextdepth));
@@ -1161,7 +1130,7 @@
 as_value
 movieclip_getInstanceAtDepth(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> mc = ensureType<MovieClip>(fn.this_ptr);
+    boost::intrusive_ptr<MovieClip> mc = ensure<ThisIs<MovieClip> >(fn);
 
     if (fn.nargs < 1 || fn.arg(0).is_undefined()) {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -1190,8 +1159,7 @@
 as_value
 movieclip_getURL(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> movieclip =
-        ensureType<as_object>(fn.this_ptr);
+    as_object* movieclip = ensure<ThisIs<as_object> >(fn);
 
     std::string urlstr;
     std::string target;
@@ -1289,7 +1257,7 @@
 as_value
 movieclip_getTextSnapshot(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> obj = ensureType<MovieClip>(fn.this_ptr);
+    boost::intrusive_ptr<MovieClip> obj = ensure<ThisIs<MovieClip> >(fn);
 
     // If not found, construction fails.
     as_value textSnapshot(fn.env().find_object("TextSnapshot"));
@@ -1319,8 +1287,7 @@
 as_value
 movieclip_getBounds(const fn_call& fn)
 {
-    boost::intrusive_ptr<DisplayObject> movieclip =
-        ensureType<DisplayObject>(fn.this_ptr);
+    DisplayObject* movieclip = ensure<ThisIs<DisplayObject> >(fn);
 
     SWFRect bounds = movieclip->getBounds();
 
@@ -1371,8 +1338,7 @@
 as_value
 movieclip_globalToLocal(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-            ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     as_value ret;
 
@@ -1434,8 +1400,7 @@
 as_value
 movieclip_localToGlobal(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-            ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     as_value ret;
 
@@ -1500,8 +1465,7 @@
     // swfdec/test/image/mask-textfield-6.swf shows that setMask should also
     // work against TextFields, we have no tests for other DisplayObject types 
so
     // we generalize it for any DisplayObject.
-    boost::intrusive_ptr<DisplayObject> maskee = 
-        ensureType<DisplayObject>(fn.this_ptr);
+    DisplayObject* maskee = ensure<ThisIs<DisplayObject> >(fn);
 
     if ( ! fn.nargs )
     {
@@ -1543,8 +1507,7 @@
 as_value
 movieclip_endFill(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-            ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     IF_VERBOSE_ASCODING_ERRORS(
     if ( fn.nargs )
@@ -1564,8 +1527,7 @@
 as_value
 movieclip_lineTo(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-            ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     if ( fn.nargs < 2 )
     {
@@ -1619,8 +1581,7 @@
 as_value
 movieclip_moveTo(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     if ( fn.nargs < 2 )
     {
@@ -1680,8 +1641,7 @@
 as_value
 movieclip_lineStyle(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-            ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     if ( ! fn.nargs )
     {
@@ -1831,8 +1791,7 @@
 as_value
 movieclip_curveTo(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip =
-            ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     if ( fn.nargs < 4 )
     {
@@ -1913,8 +1872,7 @@
 as_value
 movieclip_clear(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     IF_VERBOSE_ASCODING_ERRORS(
     if ( fn.nargs )
@@ -1936,8 +1894,7 @@
 as_value
 movieclip_beginFill(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     if ( fn.nargs < 1 )
     {
@@ -1986,8 +1943,7 @@
 as_value
 movieclip_beginGradientFill(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     if ( fn.nargs < 5 )
     {
@@ -2240,11 +2196,10 @@
 as_value
 movieclip_startDrag(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* movieclip = ensure<ThisIs<MovieClip> >(fn);
 
     drag_state st;
-    st.setCharacter( movieclip.get() );
+    st.setCharacter(movieclip);
 
     // mark this DisplayObject is transformed.
     movieclip->transformedByScript();
@@ -2312,11 +2267,9 @@
 as_value
 movieclip_stopDrag(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> movieclip = 
-        ensureType<MovieClip>(fn.this_ptr);
-
+    // Should this be a MovieClip only function? It isn't
+    // necessary.
     getRoot(fn).stop_drag();
-
     return as_value();
 }
 
@@ -2324,8 +2277,7 @@
 as_value
 movieclip_beginBitmapFill(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> ptr = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* ptr = ensure<ThisIs<MovieClip> >(fn);
     UNUSED(ptr);
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
@@ -2335,8 +2287,7 @@
 as_value
 movieclip_getRect(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> ptr = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* ptr = ensure<ThisIs<MovieClip> >(fn);
     UNUSED(ptr);
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
@@ -2346,8 +2297,7 @@
 as_value
 movieclip_lineGradientStyle(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> ptr = 
-        ensureType<MovieClip>(fn.this_ptr);
+    MovieClip* ptr = ensure<ThisIs<MovieClip> >(fn);
     UNUSED(ptr);
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
@@ -2360,7 +2310,7 @@
 
     GNASH_REPORT_FUNCTION;
 
-    boost::intrusive_ptr<MovieClip> ptr = ensureType<MovieClip>(fn.this_ptr);
+    boost::intrusive_ptr<MovieClip> ptr = ensure<ThisIs<MovieClip> >(fn);
 
     if (fn.nargs < 2) {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -2400,7 +2350,7 @@
 as_value
 movieclip_transform(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> ptr = ensureType<MovieClip>(fn.this_ptr);
+    boost::intrusive_ptr<MovieClip> ptr = ensure<ThisIs<MovieClip> >(fn);
 
     // If not found, construction fails.
     as_value transform(fn.env().find_object("flash.geom.Transform"));
@@ -2434,7 +2384,7 @@
 as_value
 movieclip_lockroot(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> ptr = ensureType<MovieClip>(fn.this_ptr);
+    boost::intrusive_ptr<MovieClip> ptr = ensure<ThisIs<MovieClip> >(fn);
 
     if (!fn.nargs) {
         return as_value(ptr->getLockRoot());
@@ -2479,7 +2429,7 @@
 as_value
 movieclip_addFrameScript(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> ptr = ensureType<MovieClip>(fn.this_ptr);
+    boost::intrusive_ptr<MovieClip> ptr = ensure<ThisIs<MovieClip> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -2488,7 +2438,7 @@
 as_value
 movieclip_nextScene(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> ptr = ensureType<MovieClip>(fn.this_ptr);
+    boost::intrusive_ptr<MovieClip> ptr = ensure<ThisIs<MovieClip> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -2497,7 +2447,7 @@
 as_value
 movieclip_prevScene(const fn_call& fn)
 {
-    boost::intrusive_ptr<MovieClip> ptr = ensureType<MovieClip>(fn.this_ptr);
+    boost::intrusive_ptr<MovieClip> ptr = ensure<ThisIs<MovieClip> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/display/Sprite_as.cpp'
--- a/libcore/asobj/flash/display/Sprite_as.cpp 2009-08-20 08:57:16 +0000
+++ b/libcore/asobj/flash/display/Sprite_as.cpp 2009-10-22 14:56:18 +0000
@@ -88,8 +88,7 @@
 as_value
 sprite_stopDrag(const fn_call& fn)
 {
-    boost::intrusive_ptr<Sprite_as> ptr =
-        ensureType<Sprite_as>(fn.this_ptr);
+    Sprite_as* ptr = ensure<ThisIs<Sprite_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/display/Stage_as.cpp'
--- a/libcore/asobj/flash/display/Stage_as.cpp  2009-09-14 10:24:53 +0000
+++ b/libcore/asobj/flash/display/Stage_as.cpp  2009-10-22 14:56:18 +0000
@@ -120,8 +120,6 @@
 stage_scalemode(const fn_call& fn)
 {
 
-    boost::intrusive_ptr<as_object> obj=ensureType<as_object>(fn.this_ptr);
-
     movie_root& m = getRoot(fn);
 
        if ( fn.nargs == 0 ) // getter
@@ -151,7 +149,6 @@
 as_value
 stage_width(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj=ensureType<as_object>(fn.this_ptr);
 
        if ( fn.nargs > 0 ) // setter
        {
@@ -169,7 +166,6 @@
 as_value
 stage_height(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj=ensureType<as_object>(fn.this_ptr);
 
        if ( fn.nargs > 0 ) // setter
        {
@@ -190,8 +186,6 @@
 as_value
 stage_align(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj=ensureType<as_object>(fn.this_ptr); 
- 
     movie_root& m = getRoot(fn);
     
        if ( fn.nargs == 0 ) // getter
@@ -213,7 +207,6 @@
 as_value
 stage_showMenu(const fn_call& fn)
 {
-       boost::intrusive_ptr<as_object> obj = 
ensureType<as_object>(fn.this_ptr);
 
     movie_root& m = getRoot(fn);
 
@@ -233,7 +226,6 @@
 as_value
 stage_displaystate(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj=ensureType<as_object>(fn.this_ptr);
 
     movie_root& m = getRoot(fn);
 

=== modified file 'libcore/asobj/flash/filters/BevelFilter_as.cpp'
--- a/libcore/asobj/flash/filters/BevelFilter_as.cpp    2009-09-22 09:08:30 
+0000
+++ b/libcore/asobj/flash/filters/BevelFilter_as.cpp    2009-10-22 14:56:18 
+0000
@@ -95,7 +95,7 @@
 as_value
 bevelfilter_distance(const fn_call& fn)
 {
-    BevelFilter_as* ptr = ensureNativeType<BevelFilter_as>(fn.this_ptr);
+    BevelFilter_as* ptr = ensure<ThisIsNative<BevelFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_distance );
     }
@@ -108,7 +108,7 @@
 as_value
 bevelfilter_angle(const fn_call& fn)
 {
-    BevelFilter_as* ptr = ensureNativeType<BevelFilter_as>(fn.this_ptr);
+    BevelFilter_as* ptr = ensure<ThisIsNative<BevelFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_angle);
     }
@@ -120,7 +120,7 @@
 as_value
 bevelfilter_highlightColor(const fn_call& fn)
 {
-    BevelFilter_as* ptr = ensureNativeType<BevelFilter_as>(fn.this_ptr);
+    BevelFilter_as* ptr = ensure<ThisIsNative<BevelFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_highlightColor );
     }
@@ -132,7 +132,7 @@
 as_value
 bevelfilter_highlightAlpha(const fn_call& fn)
 {
-    BevelFilter_as* ptr = ensureNativeType<BevelFilter_as>(fn.this_ptr);
+    BevelFilter_as* ptr = ensure<ThisIsNative<BevelFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_highlightAlpha );
     }
@@ -144,7 +144,7 @@
 as_value
 bevelfilter_shadowColor(const fn_call& fn)
 {
-    BevelFilter_as* ptr = ensureNativeType<BevelFilter_as>(fn.this_ptr);
+    BevelFilter_as* ptr = ensure<ThisIsNative<BevelFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_shadowColor );
     }
@@ -156,7 +156,7 @@
 as_value
 bevelfilter_shadowAlpha(const fn_call& fn)
 {
-    BevelFilter_as* ptr = ensureNativeType<BevelFilter_as>(fn.this_ptr);
+    BevelFilter_as* ptr = ensure<ThisIsNative<BevelFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_shadowAlpha );
     }
@@ -168,7 +168,7 @@
 as_value
 bevelfilter_blurX(const fn_call& fn)
 {
-    BevelFilter_as* ptr = ensureNativeType<BevelFilter_as>(fn.this_ptr);
+    BevelFilter_as* ptr = ensure<ThisIsNative<BevelFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_blurX );
     }
@@ -180,7 +180,7 @@
 as_value
 bevelfilter_blurY(const fn_call& fn)
 {
-    BevelFilter_as* ptr = ensureNativeType<BevelFilter_as>(fn.this_ptr);
+    BevelFilter_as* ptr = ensure<ThisIsNative<BevelFilter_as> >(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_blurY );
     }
@@ -192,7 +192,7 @@
 as_value
 bevelfilter_strength(const fn_call& fn)
 {
-    BevelFilter_as* ptr = ensureNativeType<BevelFilter_as>(fn.this_ptr);
+    BevelFilter_as* ptr = ensure<ThisIsNative<BevelFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_strength );
     }
@@ -204,7 +204,7 @@
 as_value
 bevelfilter_quality(const fn_call& fn)
 {
-    BevelFilter_as* ptr = ensureNativeType<BevelFilter_as>(fn.this_ptr);
+    BevelFilter_as* ptr = ensure<ThisIsNative<BevelFilter_as> >(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_quality );
     }
@@ -216,7 +216,7 @@
 as_value
 bevelfilter_knockout(const fn_call& fn)
 {
-    BevelFilter_as* ptr = ensureNativeType<BevelFilter_as>(fn.this_ptr);
+    BevelFilter_as* ptr = ensure<ThisIsNative<BevelFilter_as> >(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_knockout );
     }
@@ -228,7 +228,7 @@
 as_value
 bevelfilter_type(const fn_call& fn)
 {
-    BevelFilter_as* ptr = ensureNativeType<BevelFilter_as>(fn.this_ptr);
+    BevelFilter_as* ptr = ensure<ThisIsNative<BevelFilter_as> >(fn);
 
     if (fn.nargs == 0)
     {
@@ -272,7 +272,7 @@
 as_value
 bevelfilter_new(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     obj->setRelay(new BevelFilter_as);
     return as_value();
 }

=== modified file 'libcore/asobj/flash/filters/BitmapFilter_as.cpp'
--- a/libcore/asobj/flash/filters/BitmapFilter_as.cpp   2009-09-29 09:56:29 
+0000
+++ b/libcore/asobj/flash/filters/BitmapFilter_as.cpp   2009-10-22 14:56:18 
+0000
@@ -131,7 +131,7 @@
 as_value
 bitmapfilter_new(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     obj->setRelay(new BitmapFilter_as);
     return as_value();
 }
@@ -140,7 +140,7 @@
 as_value
 bitmapfilter_clone(const fn_call& fn)
 {
-    BitmapFilter_as* relay = ensureNativeType<BitmapFilter_as>(fn.this_ptr);
+    BitmapFilter_as* relay = ensure<ThisIsNative<BitmapFilter_as> >(fn);
     UNUSED(relay);
     return as_value();
 }

=== modified file 'libcore/asobj/flash/filters/BlurFilter_as.cpp'
--- a/libcore/asobj/flash/filters/BlurFilter_as.cpp     2009-09-22 09:08:52 
+0000
+++ b/libcore/asobj/flash/filters/BlurFilter_as.cpp     2009-10-22 14:56:18 
+0000
@@ -63,7 +63,7 @@
 as_value
 blurfilter_blurX(const fn_call& fn)
 {
-    BlurFilter_as* ptr = ensureNativeType<BlurFilter_as>(fn.this_ptr);
+    BlurFilter_as* ptr = ensure<ThisIsNative<BlurFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_blurX );
     }
@@ -75,7 +75,7 @@
 as_value
 blurfilter_blurY(const fn_call& fn)
 {
-    BlurFilter_as* ptr = ensureNativeType<BlurFilter_as>(fn.this_ptr);
+    BlurFilter_as* ptr = ensure<ThisIsNative<BlurFilter_as> >(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_blurY );
     }
@@ -87,7 +87,7 @@
 as_value
 blurfilter_quality(const fn_call& fn)
 {
-    BlurFilter_as* ptr = ensureNativeType<BlurFilter_as>(fn.this_ptr);
+    BlurFilter_as* ptr = ensure<ThisIsNative<BlurFilter_as> >(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_quality );
     }
@@ -99,7 +99,7 @@
 as_value
 blurfilter_new(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     obj->setRelay(new BlurFilter_as);
     return as_value();
 }

=== modified file 'libcore/asobj/flash/filters/ColorMatrixFilter_as.cpp'
--- a/libcore/asobj/flash/filters/ColorMatrixFilter_as.cpp      2009-09-22 
09:09:10 +0000
+++ b/libcore/asobj/flash/filters/ColorMatrixFilter_as.cpp      2009-10-22 
14:56:18 +0000
@@ -61,7 +61,7 @@
 as_value
 colormatrixfilter_matrix(const fn_call& fn)
 {
-    ColorMatrixFilter_as* ptr = 
ensureNativeType<ColorMatrixFilter_as>(fn.this_ptr);
+    ColorMatrixFilter_as* ptr = ensure<ThisIsNative<ColorMatrixFilter_as> 
>(fn);
     UNUSED(ptr);
     return as_value();
 }
@@ -69,7 +69,7 @@
 as_value
 colormatrixfilter_new(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     obj->setRelay(new ColorMatrixFilter_as);
     return as_value();
 }

=== modified file 'libcore/asobj/flash/filters/ConvolutionFilter_as.cpp'
--- a/libcore/asobj/flash/filters/ConvolutionFilter_as.cpp      2009-09-22 
08:09:17 +0000
+++ b/libcore/asobj/flash/filters/ConvolutionFilter_as.cpp      2009-10-22 
14:56:18 +0000
@@ -86,7 +86,7 @@
 as_value
 convolutionfilter_matrixX(const fn_call& fn)
 {
-    ConvolutionFilter_as* ptr = 
ensureNativeType<ConvolutionFilter_as>(fn.this_ptr);
+    ConvolutionFilter_as* ptr = ensure<ThisIsNative<ConvolutionFilter_as> 
>(fn);
     UNUSED(ptr);
     log_unimpl(__PRETTY_FUNCTION__);
     return as_value();
@@ -95,7 +95,7 @@
 as_value
 convolutionfilter_matrixY(const fn_call& fn)
 {
-    ConvolutionFilter_as* ptr = 
ensureNativeType<ConvolutionFilter_as>(fn.this_ptr);
+    ConvolutionFilter_as* ptr = ensure<ThisIsNative<ConvolutionFilter_as> 
>(fn);
     UNUSED(ptr);
     log_unimpl(__PRETTY_FUNCTION__);
     return as_value();
@@ -104,7 +104,7 @@
 as_value
 convolutionfilter_divisor(const fn_call& fn)
 {
-    ConvolutionFilter_as* ptr = 
ensureNativeType<ConvolutionFilter_as>(fn.this_ptr);
+    ConvolutionFilter_as* ptr = ensure<ThisIsNative<ConvolutionFilter_as> 
>(fn);
     UNUSED(ptr);
     log_unimpl(__PRETTY_FUNCTION__);
     return as_value();
@@ -113,7 +113,7 @@
 as_value
 convolutionfilter_bias(const fn_call& fn)
 {
-    ConvolutionFilter_as* ptr = 
ensureNativeType<ConvolutionFilter_as>(fn.this_ptr);
+    ConvolutionFilter_as* ptr = ensure<ThisIsNative<ConvolutionFilter_as> 
>(fn);
     UNUSED(ptr);
     log_unimpl(__PRETTY_FUNCTION__);
     return as_value();
@@ -122,7 +122,7 @@
 as_value
 convolutionfilter_preserveAlpha(const fn_call& fn)
 {
-    ConvolutionFilter_as* ptr = 
ensureNativeType<ConvolutionFilter_as>(fn.this_ptr);
+    ConvolutionFilter_as* ptr = ensure<ThisIsNative<ConvolutionFilter_as> 
>(fn);
     UNUSED(ptr);
     log_unimpl(__PRETTY_FUNCTION__);
     return as_value();
@@ -131,7 +131,7 @@
 as_value
 convolutionfilter_clamp(const fn_call& fn)
 {
-    ConvolutionFilter_as* ptr = 
ensureNativeType<ConvolutionFilter_as>(fn.this_ptr);
+    ConvolutionFilter_as* ptr = ensure<ThisIsNative<ConvolutionFilter_as> 
>(fn);
     UNUSED(ptr);
     log_unimpl(__PRETTY_FUNCTION__);
     return as_value();
@@ -140,7 +140,7 @@
 as_value
 convolutionfilter_color(const fn_call& fn)
 {
-    ConvolutionFilter_as* ptr = 
ensureNativeType<ConvolutionFilter_as>(fn.this_ptr);
+    ConvolutionFilter_as* ptr = ensure<ThisIsNative<ConvolutionFilter_as> 
>(fn);
     UNUSED(ptr);
     log_unimpl(__PRETTY_FUNCTION__);
     return as_value();
@@ -149,7 +149,7 @@
 as_value
 convolutionfilter_alpha(const fn_call& fn)
 {
-    ConvolutionFilter_as* ptr = 
ensureNativeType<ConvolutionFilter_as>(fn.this_ptr);
+    ConvolutionFilter_as* ptr = ensure<ThisIsNative<ConvolutionFilter_as> 
>(fn);
     UNUSED(ptr);
     log_unimpl(__PRETTY_FUNCTION__);
     return as_value();
@@ -158,7 +158,7 @@
 as_value
 convolutionfilter_matrix(const fn_call& fn)
 {
-    ConvolutionFilter_as* ptr = 
ensureNativeType<ConvolutionFilter_as>(fn.this_ptr);
+    ConvolutionFilter_as* ptr = ensure<ThisIsNative<ConvolutionFilter_as> 
>(fn);
     UNUSED(ptr);
     log_unimpl(__PRETTY_FUNCTION__);
     return as_value();
@@ -167,7 +167,7 @@
 as_value
 convolutionfilter_new(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     obj->setRelay(new ConvolutionFilter_as);
     return as_value();
 }

=== modified file 'libcore/asobj/flash/filters/DisplacementMapFilter_as.cpp'
--- a/libcore/asobj/flash/filters/DisplacementMapFilter_as.cpp  2009-09-24 
06:09:43 +0000
+++ b/libcore/asobj/flash/filters/DisplacementMapFilter_as.cpp  2009-10-22 
14:56:18 +0000
@@ -89,8 +89,8 @@
 as_value
 displacementmapfilter_clone(const fn_call& fn)
 {
-       DisplacementMapFilter_as* ptr = 
-        ensureNativeType<DisplacementMapFilter_as>(fn.this_ptr);
+       DisplacementMapFilter_as* ptr =
+        ensure<ThisIsNative<DisplacementMapFilter_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -99,8 +99,8 @@
 as_value
 displacementmapfilter_alpha(const fn_call& fn)
 {
-       DisplacementMapFilter_as* ptr = 
-        ensureNativeType<DisplacementMapFilter_as>(fn.this_ptr);
+       DisplacementMapFilter_as* ptr =
+        ensure<ThisIsNative<DisplacementMapFilter_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -109,8 +109,8 @@
 as_value
 displacementmapfilter_color(const fn_call& fn)
 {
-       DisplacementMapFilter_as* ptr = 
-        ensureNativeType<DisplacementMapFilter_as>(fn.this_ptr);
+       DisplacementMapFilter_as* ptr =
+        ensure<ThisIsNative<DisplacementMapFilter_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -119,8 +119,8 @@
 as_value
 displacementmapfilter_componentX(const fn_call& fn)
 {
-       DisplacementMapFilter_as* ptr = 
-        ensureNativeType<DisplacementMapFilter_as>(fn.this_ptr);
+       DisplacementMapFilter_as* ptr =
+        ensure<ThisIsNative<DisplacementMapFilter_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -129,8 +129,8 @@
 as_value
 displacementmapfilter_componentY(const fn_call& fn)
 {
-       DisplacementMapFilter_as* ptr = 
-        ensureNativeType<DisplacementMapFilter_as>(fn.this_ptr);
+       DisplacementMapFilter_as* ptr =
+        ensure<ThisIsNative<DisplacementMapFilter_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -139,8 +139,8 @@
 as_value
 displacementmapfilter_mapBitmap(const fn_call& fn)
 {
-       DisplacementMapFilter_as* ptr = 
-        ensureNativeType<DisplacementMapFilter_as>(fn.this_ptr);
+       DisplacementMapFilter_as* ptr =
+        ensure<ThisIsNative<DisplacementMapFilter_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -149,8 +149,8 @@
 as_value
 displacementmapfilter_mapPoint(const fn_call& fn)
 {
-       DisplacementMapFilter_as* ptr = 
-        ensureNativeType<DisplacementMapFilter_as>(fn.this_ptr);
+       DisplacementMapFilter_as* ptr =
+        ensure<ThisIsNative<DisplacementMapFilter_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -159,8 +159,8 @@
 as_value
 displacementmapfilter_mode(const fn_call& fn)
 {
-       DisplacementMapFilter_as* ptr = 
-        ensureNativeType<DisplacementMapFilter_as>(fn.this_ptr);
+       DisplacementMapFilter_as* ptr =
+        ensure<ThisIsNative<DisplacementMapFilter_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -169,8 +169,8 @@
 as_value
 displacementmapfilter_scaleX(const fn_call& fn)
 {
-       DisplacementMapFilter_as* ptr = 
-        ensureNativeType<DisplacementMapFilter_as>(fn.this_ptr);
+       DisplacementMapFilter_as* ptr =
+        ensure<ThisIsNative<DisplacementMapFilter_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -179,8 +179,8 @@
 as_value
 displacementmapfilter_scaleY(const fn_call& fn)
 {
-       DisplacementMapFilter_as* ptr = 
-        ensureNativeType<DisplacementMapFilter_as>(fn.this_ptr);
+       DisplacementMapFilter_as* ptr =
+        ensure<ThisIsNative<DisplacementMapFilter_as> >(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -189,7 +189,7 @@
 as_value
 displacementmapfilter_ctor(const fn_call& fn)
 {
-       boost::intrusive_ptr<as_object> obj = 
ensureType<as_object>(fn.this_ptr);
+       boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
        obj->setRelay(new DisplacementMapFilter_as);
     return as_value(); 
 }

=== modified file 'libcore/asobj/flash/filters/DropShadowFilter_as.cpp'
--- a/libcore/asobj/flash/filters/DropShadowFilter_as.cpp       2009-09-22 
09:09:19 +0000
+++ b/libcore/asobj/flash/filters/DropShadowFilter_as.cpp       2009-10-22 
14:56:18 +0000
@@ -92,7 +92,7 @@
 as_value
 dropshadowfilter_distance(const fn_call& fn)
 {
-    DropShadowFilter_as* ptr = 
ensureNativeType<DropShadowFilter_as>(fn.this_ptr);
+    DropShadowFilter_as* ptr = ensure<ThisIsNative<DropShadowFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_distance );
     }
@@ -105,7 +105,7 @@
 as_value
 dropshadowfilter_color(const fn_call& fn)
 {
-    DropShadowFilter_as* ptr = 
ensureNativeType<DropShadowFilter_as>(fn.this_ptr);
+    DropShadowFilter_as* ptr = ensure<ThisIsNative<DropShadowFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_color);
     }
@@ -117,7 +117,7 @@
 as_value
 dropshadowfilter_alpha(const fn_call& fn)
 {
-    DropShadowFilter_as* ptr = 
ensureNativeType<DropShadowFilter_as>(fn.this_ptr);
+    DropShadowFilter_as* ptr = ensure<ThisIsNative<DropShadowFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_alpha);
     }
@@ -129,7 +129,7 @@
 as_value
 dropshadowfilter_angle(const fn_call& fn)
 {
-    DropShadowFilter_as* ptr = 
ensureNativeType<DropShadowFilter_as>(fn.this_ptr);
+    DropShadowFilter_as* ptr = ensure<ThisIsNative<DropShadowFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_angle);
     }
@@ -141,7 +141,7 @@
 as_value
 dropshadowfilter_blurX(const fn_call& fn)
 {
-    DropShadowFilter_as* ptr = 
ensureNativeType<DropShadowFilter_as>(fn.this_ptr);
+    DropShadowFilter_as* ptr = ensure<ThisIsNative<DropShadowFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_blurX );
     }
@@ -153,7 +153,7 @@
 as_value
 dropshadowfilter_blurY(const fn_call& fn)
 {
-    DropShadowFilter_as* ptr = 
ensureNativeType<DropShadowFilter_as>(fn.this_ptr);
+    DropShadowFilter_as* ptr = ensure<ThisIsNative<DropShadowFilter_as> >(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_blurY );
     }
@@ -165,7 +165,7 @@
 as_value
 dropshadowfilter_strength(const fn_call& fn)
 {
-    DropShadowFilter_as* ptr = 
ensureNativeType<DropShadowFilter_as>(fn.this_ptr);
+    DropShadowFilter_as* ptr = ensure<ThisIsNative<DropShadowFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_strength );
     }
@@ -177,7 +177,7 @@
 as_value
 dropshadowfilter_quality(const fn_call& fn)
 {
-    DropShadowFilter_as* ptr = 
ensureNativeType<DropShadowFilter_as>(fn.this_ptr);
+    DropShadowFilter_as* ptr = ensure<ThisIsNative<DropShadowFilter_as> >(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_quality );
     }
@@ -189,7 +189,7 @@
 as_value
 dropshadowfilter_knockout(const fn_call& fn)
 {
-    DropShadowFilter_as* ptr = 
ensureNativeType<DropShadowFilter_as>(fn.this_ptr);
+    DropShadowFilter_as* ptr = ensure<ThisIsNative<DropShadowFilter_as> >(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_knockout );
     }
@@ -201,7 +201,7 @@
 as_value
 dropshadowfilter_inner(const fn_call& fn)
 {
-    DropShadowFilter_as* ptr = 
ensureNativeType<DropShadowFilter_as>(fn.this_ptr);
+    DropShadowFilter_as* ptr = ensure<ThisIsNative<DropShadowFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_inner );
     }
@@ -214,7 +214,7 @@
 as_value
 dropshadowfilter_hideObject(const fn_call& fn)
 {
-    DropShadowFilter_as* ptr = 
ensureNativeType<DropShadowFilter_as>(fn.this_ptr);
+    DropShadowFilter_as* ptr = ensure<ThisIsNative<DropShadowFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_hideObject );
     }
@@ -226,7 +226,7 @@
 as_value
 dropshadowfilter_new(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     obj->setRelay(new DropShadowFilter_as);
     return as_value();
 }

=== modified file 'libcore/asobj/flash/filters/GlowFilter_as.cpp'
--- a/libcore/asobj/flash/filters/GlowFilter_as.cpp     2009-09-22 09:09:28 
+0000
+++ b/libcore/asobj/flash/filters/GlowFilter_as.cpp     2009-10-22 14:56:18 
+0000
@@ -83,7 +83,7 @@
 as_value
 glowfilter_inner(const fn_call& fn)
 {
-    GlowFilter_as* ptr = ensureNativeType<GlowFilter_as>(fn.this_ptr);
+    GlowFilter_as* ptr = ensure<ThisIsNative<GlowFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_inner );
     }
@@ -95,7 +95,7 @@
 as_value
 glowfilter_color(const fn_call& fn)
 {
-    GlowFilter_as* ptr = ensureNativeType<GlowFilter_as>(fn.this_ptr);
+    GlowFilter_as* ptr = ensure<ThisIsNative<GlowFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_color );
     }
@@ -107,7 +107,7 @@
 as_value
 glowfilter_alpha(const fn_call& fn)
 {
-    GlowFilter_as* ptr = ensureNativeType<GlowFilter_as>(fn.this_ptr);
+    GlowFilter_as* ptr = ensure<ThisIsNative<GlowFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_alpha );
     }
@@ -119,7 +119,7 @@
 as_value
 glowfilter_blurX(const fn_call& fn)
 {
-    GlowFilter_as* ptr = ensureNativeType<GlowFilter_as>(fn.this_ptr);
+    GlowFilter_as* ptr = ensure<ThisIsNative<GlowFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_blurX );
     }
@@ -131,7 +131,7 @@
 as_value
 glowfilter_blurY(const fn_call& fn)
 {
-    GlowFilter_as* ptr = ensureNativeType<GlowFilter_as>(fn.this_ptr);
+    GlowFilter_as* ptr = ensure<ThisIsNative<GlowFilter_as> >(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_blurY );
     }
@@ -143,7 +143,7 @@
 as_value
 glowfilter_strength(const fn_call& fn)
 {
-    GlowFilter_as* ptr = ensureNativeType<GlowFilter_as>(fn.this_ptr);
+    GlowFilter_as* ptr = ensure<ThisIsNative<GlowFilter_as> >(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_strength );
     }
@@ -155,7 +155,7 @@
 as_value
 glowfilter_quality(const fn_call& fn)
 {
-    GlowFilter_as* ptr = ensureNativeType<GlowFilter_as>(fn.this_ptr);
+    GlowFilter_as* ptr = ensure<ThisIsNative<GlowFilter_as> >(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_quality );
     }
@@ -167,7 +167,7 @@
 as_value
 glowfilter_knockout(const fn_call& fn)
 {
-    GlowFilter_as* ptr = ensureNativeType<GlowFilter_as>(fn.this_ptr);
+    GlowFilter_as* ptr = ensure<ThisIsNative<GlowFilter_as> >(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_knockout );
     }
@@ -179,7 +179,7 @@
 as_value
 glowfilter_new(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     obj->setRelay(new GlowFilter_as);
     return as_value();
 }

=== modified file 'libcore/asobj/flash/filters/GradientBevelFilter_as.cpp'
--- a/libcore/asobj/flash/filters/GradientBevelFilter_as.cpp    2009-09-22 
09:09:43 +0000
+++ b/libcore/asobj/flash/filters/GradientBevelFilter_as.cpp    2009-10-22 
14:56:18 +0000
@@ -92,7 +92,7 @@
 as_value
 gradientbevelfilter_distance(const fn_call& fn)
 {
-    GradientBevelFilter_as* ptr = 
ensureNativeType<GradientBevelFilter_as>(fn.this_ptr);
+    GradientBevelFilter_as* ptr = ensure<ThisIsNative<GradientBevelFilter_as> 
>(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_distance );
     }
@@ -105,7 +105,7 @@
 as_value
 gradientbevelfilter_angle(const fn_call& fn)
 {
-    GradientBevelFilter_as* ptr = 
ensureNativeType<GradientBevelFilter_as>(fn.this_ptr);
+    GradientBevelFilter_as* ptr = ensure<ThisIsNative<GradientBevelFilter_as> 
>(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_angle);
     }
@@ -117,7 +117,7 @@
 as_value
 gradientbevelfilter_alphas(const fn_call& fn)
 {
-    GradientBevelFilter_as* ptr = 
ensureNativeType<GradientBevelFilter_as>(fn.this_ptr);
+    GradientBevelFilter_as* ptr = ensure<ThisIsNative<GradientBevelFilter_as> 
>(fn);
     UNUSED(ptr);
     return as_value();
 }
@@ -125,7 +125,7 @@
 as_value
 gradientbevelfilter_colors(const fn_call& fn)
 {
-    GradientBevelFilter_as* ptr = 
ensureNativeType<GradientBevelFilter_as>(fn.this_ptr);
+    GradientBevelFilter_as* ptr = ensure<ThisIsNative<GradientBevelFilter_as> 
>(fn);
     UNUSED(ptr);
     return as_value();
 }
@@ -133,7 +133,7 @@
 as_value
 gradientbevelfilter_ratios(const fn_call& fn)
 {
-    GradientBevelFilter_as* ptr = 
ensureNativeType<GradientBevelFilter_as>(fn.this_ptr);
+    GradientBevelFilter_as* ptr = ensure<ThisIsNative<GradientBevelFilter_as> 
>(fn);
     UNUSED(ptr);
     return as_value();
 }
@@ -141,7 +141,7 @@
 as_value
 gradientbevelfilter_blurX(const fn_call& fn)
 {
-    GradientBevelFilter_as* ptr = 
ensureNativeType<GradientBevelFilter_as>(fn.this_ptr);
+    GradientBevelFilter_as* ptr = ensure<ThisIsNative<GradientBevelFilter_as> 
>(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_blurX );
     }
@@ -153,7 +153,7 @@
 as_value
 gradientbevelfilter_blurY(const fn_call& fn)
 {
-    GradientBevelFilter_as* ptr = 
ensureNativeType<GradientBevelFilter_as>(fn.this_ptr);
+    GradientBevelFilter_as* ptr = ensure<ThisIsNative<GradientBevelFilter_as> 
>(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_blurY );
     }
@@ -165,7 +165,7 @@
 as_value
 gradientbevelfilter_strength(const fn_call& fn)
 {
-    GradientBevelFilter_as* ptr = 
ensureNativeType<GradientBevelFilter_as>(fn.this_ptr);
+    GradientBevelFilter_as* ptr = ensure<ThisIsNative<GradientBevelFilter_as> 
>(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_strength );
     }
@@ -177,7 +177,7 @@
 as_value
 gradientbevelfilter_quality(const fn_call& fn)
 {
-    GradientBevelFilter_as* ptr = 
ensureNativeType<GradientBevelFilter_as>(fn.this_ptr);
+    GradientBevelFilter_as* ptr = ensure<ThisIsNative<GradientBevelFilter_as> 
>(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_quality );
     }
@@ -189,7 +189,7 @@
 as_value
 gradientbevelfilter_knockout(const fn_call& fn)
 {
-    GradientBevelFilter_as* ptr = 
ensureNativeType<GradientBevelFilter_as>(fn.this_ptr);
+    GradientBevelFilter_as* ptr = ensure<ThisIsNative<GradientBevelFilter_as> 
>(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_knockout );
     }
@@ -201,7 +201,7 @@
 as_value
 gradientbevelfilter_type(const fn_call& fn)
 {
-    GradientBevelFilter_as* ptr = 
ensureNativeType<GradientBevelFilter_as>(fn.this_ptr);
+    GradientBevelFilter_as* ptr = ensure<ThisIsNative<GradientBevelFilter_as> 
>(fn);
 
     if (fn.nargs == 0)
     {
@@ -245,7 +245,7 @@
 as_value
 gradientbevelfilter_new(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     obj->setRelay(new GradientBevelFilter_as);
     return as_value();
 }

=== modified file 'libcore/asobj/flash/filters/GradientGlowFilter_as.cpp'
--- a/libcore/asobj/flash/filters/GradientGlowFilter_as.cpp     2009-09-22 
09:09:48 +0000
+++ b/libcore/asobj/flash/filters/GradientGlowFilter_as.cpp     2009-10-22 
14:56:18 +0000
@@ -93,7 +93,7 @@
 as_value
 gradientglowfilter_distance(const fn_call& fn)
 {
-    GradientGlowFilter_as* ptr = 
ensureNativeType<GradientGlowFilter_as>(fn.this_ptr);
+    GradientGlowFilter_as* ptr = ensure<ThisIsNative<GradientGlowFilter_as> 
>(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_distance );
     }
@@ -106,7 +106,7 @@
 as_value
 gradientglowfilter_angle(const fn_call& fn)
 {
-    GradientGlowFilter_as* ptr = 
ensureNativeType<GradientGlowFilter_as>(fn.this_ptr);
+    GradientGlowFilter_as* ptr = ensure<ThisIsNative<GradientGlowFilter_as> 
>(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_angle);
     }
@@ -118,7 +118,7 @@
 as_value
 gradientglowfilter_colors(const fn_call& fn)
 {
-    GradientGlowFilter_as* ptr = 
ensureNativeType<GradientGlowFilter_as>(fn.this_ptr);
+    GradientGlowFilter_as* ptr = ensure<ThisIsNative<GradientGlowFilter_as> 
>(fn);
 
     UNUSED(ptr);
     return as_value();
@@ -127,7 +127,7 @@
 as_value
 gradientglowfilter_alphas(const fn_call& fn)
 {
-    GradientGlowFilter_as* ptr = 
ensureNativeType<GradientGlowFilter_as>(fn.this_ptr);
+    GradientGlowFilter_as* ptr = ensure<ThisIsNative<GradientGlowFilter_as> 
>(fn);
     UNUSED(ptr);
     return as_value();
 }
@@ -135,7 +135,7 @@
 as_value
 gradientglowfilter_ratios(const fn_call& fn)
 {
-    GradientGlowFilter_as* ptr = 
ensureNativeType<GradientGlowFilter_as>(fn.this_ptr);
+    GradientGlowFilter_as* ptr = ensure<ThisIsNative<GradientGlowFilter_as> 
>(fn);
     UNUSED(ptr);
     return as_value();
 }
@@ -143,7 +143,7 @@
 as_value
 gradientglowfilter_blurX(const fn_call& fn)
 {
-    GradientGlowFilter_as* ptr = 
ensureNativeType<GradientGlowFilter_as>(fn.this_ptr);
+    GradientGlowFilter_as* ptr = ensure<ThisIsNative<GradientGlowFilter_as> 
>(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_blurX );
     }
@@ -155,7 +155,7 @@
 as_value
 gradientglowfilter_blurY(const fn_call& fn)
 {
-    GradientGlowFilter_as* ptr = 
ensureNativeType<GradientGlowFilter_as>(fn.this_ptr);
+    GradientGlowFilter_as* ptr = ensure<ThisIsNative<GradientGlowFilter_as> 
>(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_blurY );
     }
@@ -167,7 +167,7 @@
 as_value
 gradientglowfilter_strength(const fn_call& fn)
 {
-    GradientGlowFilter_as* ptr = 
ensureNativeType<GradientGlowFilter_as>(fn.this_ptr);
+    GradientGlowFilter_as* ptr = ensure<ThisIsNative<GradientGlowFilter_as> 
>(fn);
     if (fn.nargs == 0) {
         return as_value(ptr->m_strength );
     }
@@ -179,7 +179,7 @@
 as_value
 gradientglowfilter_quality(const fn_call& fn)
 {
-    GradientGlowFilter_as* ptr = 
ensureNativeType<GradientGlowFilter_as>(fn.this_ptr);
+    GradientGlowFilter_as* ptr = ensure<ThisIsNative<GradientGlowFilter_as> 
>(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_quality );
     }
@@ -191,7 +191,7 @@
 as_value
 gradientglowfilter_knockout(const fn_call& fn)
 {
-    GradientGlowFilter_as* ptr = 
ensureNativeType<GradientGlowFilter_as>(fn.this_ptr);
+    GradientGlowFilter_as* ptr = ensure<ThisIsNative<GradientGlowFilter_as> 
>(fn);
     if (fn.nargs == 0) {
                return as_value(ptr->m_knockout );
     }
@@ -203,7 +203,7 @@
 as_value
 gradientglowfilter_type(const fn_call& fn)
 {
-    GradientGlowFilter_as* ptr = 
ensureNativeType<GradientGlowFilter_as>(fn.this_ptr);
+    GradientGlowFilter_as* ptr = ensure<ThisIsNative<GradientGlowFilter_as> 
>(fn);
 
     if (fn.nargs == 0)
     {
@@ -247,7 +247,7 @@
 as_value
 gradientglowfilter_new(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     obj->setRelay(new GradientGlowFilter_as);
     return as_value();
 }

=== modified file 'libcore/asobj/flash/geom/ColorTransform_as.cpp'
--- a/libcore/asobj/flash/geom/ColorTransform_as.cpp    2009-10-14 08:47:08 
+0000
+++ b/libcore/asobj/flash/geom/ColorTransform_as.cpp    2009-10-22 14:56:18 
+0000
@@ -142,7 +142,7 @@
 as_value
 colortransform_alphaMultiplier(const fn_call& fn)
 {
-       ColorTransform_as* relay = 
ensureNativeType<ColorTransform_as>(fn.this_ptr);
+       ColorTransform_as* relay = ensure<ThisIsNative<ColorTransform_as> >(fn);
 
     if (!fn.nargs) {
         return as_value(relay->getAlphaMultiplier());
@@ -155,7 +155,7 @@
 as_value
 colortransform_alphaOffset(const fn_call& fn)
 {
-       ColorTransform_as* relay = 
ensureNativeType<ColorTransform_as>(fn.this_ptr);
+       ColorTransform_as* relay = ensure<ThisIsNative<ColorTransform_as> >(fn);
     if (!fn.nargs) {
         return as_value(relay->getAlphaOffset());
     }
@@ -167,7 +167,7 @@
 as_value
 colortransform_blueMultiplier(const fn_call& fn)
 {
-       ColorTransform_as* relay = 
ensureNativeType<ColorTransform_as>(fn.this_ptr);
+       ColorTransform_as* relay = ensure<ThisIsNative<ColorTransform_as> >(fn);
     if (!fn.nargs) {
         return as_value(relay->getBlueMultiplier());
     }
@@ -179,7 +179,7 @@
 as_value
 colortransform_blueOffset(const fn_call& fn)
 {
-       ColorTransform_as* relay = 
ensureNativeType<ColorTransform_as>(fn.this_ptr);
+       ColorTransform_as* relay = ensure<ThisIsNative<ColorTransform_as> >(fn);
     if (!fn.nargs) {
         return as_value(relay->getBlueOffset());
     }
@@ -191,7 +191,7 @@
 as_value
 colortransform_greenMultiplier(const fn_call& fn)
 {
-       ColorTransform_as* relay = 
ensureNativeType<ColorTransform_as>(fn.this_ptr);
+       ColorTransform_as* relay = ensure<ThisIsNative<ColorTransform_as> >(fn);
     if (!fn.nargs) {
         return as_value(relay->getGreenMultiplier());
     }
@@ -203,7 +203,7 @@
 as_value
 colortransform_greenOffset(const fn_call& fn)
 {
-       ColorTransform_as* relay = 
ensureNativeType<ColorTransform_as>(fn.this_ptr);
+       ColorTransform_as* relay = ensure<ThisIsNative<ColorTransform_as> >(fn);
     
     if (!fn.nargs) {
         return as_value(relay->getGreenOffset());
@@ -216,7 +216,7 @@
 as_value
 colortransform_redMultiplier(const fn_call& fn)
 {
-       ColorTransform_as* relay = 
ensureNativeType<ColorTransform_as>(fn.this_ptr);
+       ColorTransform_as* relay = ensure<ThisIsNative<ColorTransform_as> >(fn);
 
     if (!fn.nargs) {
         return as_value(relay->getRedMultiplier());
@@ -229,7 +229,7 @@
 as_value
 colortransform_redOffset(const fn_call& fn)
 {
-       ColorTransform_as* relay = 
ensureNativeType<ColorTransform_as>(fn.this_ptr);
+       ColorTransform_as* relay = ensure<ThisIsNative<ColorTransform_as> >(fn);
     if (!fn.nargs)
     {
         // Getter
@@ -245,7 +245,7 @@
 as_value
 colortransform_concat(const fn_call& fn)
 {
-       ColorTransform_as* relay = 
ensureNativeType<ColorTransform_as>(fn.this_ptr);
+       ColorTransform_as* relay = ensure<ThisIsNative<ColorTransform_as> >(fn);
        UNUSED(relay);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -255,7 +255,7 @@
 colortransform_toString(const fn_call& fn)
 {
 
-    as_object* ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
 
     string_table& st = getStringTable(fn);
 
@@ -293,7 +293,7 @@
 as_value
 colortransform_rgb(const fn_call& fn)
 {
-       ColorTransform_as* relay = 
ensureNativeType<ColorTransform_as>(fn.this_ptr);
+       ColorTransform_as* relay = ensure<ThisIsNative<ColorTransform_as> >(fn);
 
     if (!fn.nargs)
     {
@@ -330,7 +330,7 @@
 colortransform_ctor(const fn_call& fn)
 {
 
-    as_object* obj = ensureType<as_object>(fn.this_ptr);
+    as_object* obj = ensure<ValidThis>(fn);
 
     // Default arguments.
     if (fn.nargs < 8)

=== modified file 'libcore/asobj/flash/geom/Matrix_as.cpp'
--- a/libcore/asobj/flash/geom/Matrix_as.cpp    2009-10-14 08:47:08 +0000
+++ b/libcore/asobj/flash/geom/Matrix_as.cpp    2009-10-22 14:56:18 +0000
@@ -131,7 +131,7 @@
 as_object*
 instanceOfMatrix(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
 
     as_function* ctor = getClassConstructor(fn, "flash.geom.Matrix");
     if (obj->instanceOf(ctor)) return obj.get();
@@ -144,7 +144,7 @@
 {
     // It doesn't matter whether it is a matrix or not; a new Matrix
     // is created using any Matrix properties the object may have.
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     as_value a, b, c, d, tx, ty;
     ptr->get_member(NSV::PROP_A, &a);
@@ -174,7 +174,7 @@
 matrix_concat(const fn_call& fn)
 {
     // Doesn't have to be a Matrix.
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     if (fn.nargs < 1)
     {
@@ -242,7 +242,7 @@
 matrix_createBox(const fn_call& fn)
 {
     // Doesn't have to be a Matrix
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     if (fn.nargs < 2)
     {
@@ -375,7 +375,7 @@
 matrix_deltaTransformPoint(const fn_call& fn)
 {
     // Doesn't have to be a Matrix
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     if (fn.nargs < 1)
     {
@@ -438,7 +438,7 @@
 matrix_identity(const fn_call& fn)
 {
     // Doesn't have to be a Matrix
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     ptr->set_member(NSV::PROP_A, 1.0);
     ptr->set_member(NSV::PROP_B, 0.0);
@@ -462,7 +462,7 @@
 {
 
     // Doesn't have to be a Matrix
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     MatrixType currentMatrix;
     
@@ -652,7 +652,7 @@
 matrix_toString(const fn_call& fn)
 {
     // Doesn't have to be a Matrix
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     as_value a, b, c, d, tx, ty;
 
@@ -681,7 +681,7 @@
 matrix_transformPoint(const fn_call& fn)
 {
     // Doesn't have to be a Matrix
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     if (fn.nargs < 1)
     {
@@ -747,7 +747,7 @@
 matrix_translate(const fn_call& fn)
 {
     // Doesn't have to be a Matrix
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
     
     if (fn.nargs < 2)
     {
@@ -864,7 +864,7 @@
 as_value
 matrix_ctor(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> obj = ensure<ThisIs<as_object> >(fn);
     
     as_value a, b, c, d, tx, ty;
 

=== modified file 'libcore/asobj/flash/geom/Point_as.cpp'
--- a/libcore/asobj/flash/geom/Point_as.cpp     2009-10-14 08:47:08 +0000
+++ b/libcore/asobj/flash/geom/Point_as.cpp     2009-10-22 14:56:18 +0000
@@ -104,7 +104,7 @@
 as_value
 point_add(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     as_value x, y;
     ptr->get_member(NSV::PROP_X, &x);
@@ -167,7 +167,7 @@
 as_value
 point_clone(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     as_value x, y;
     ptr->get_member(NSV::PROP_X, &x);
@@ -179,7 +179,7 @@
 as_value
 point_equals(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     if ( ! fn.nargs )
     {
@@ -225,7 +225,7 @@
 as_value
 point_normalize(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     as_value argval;
 
@@ -279,7 +279,7 @@
 as_value
 point_offset(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     as_value x, y;
     ptr->get_member(NSV::PROP_X, &x);
@@ -305,7 +305,7 @@
 as_value
 point_subtract(const fn_call& fn)
 {
-    as_object* ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
 
     as_value x, y;
     ptr->get_member(NSV::PROP_X, &x);
@@ -367,7 +367,7 @@
 as_value
 point_toString(const fn_call& fn)
 {
-    as_object* ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
 
     as_value x, y;
     ptr->get_member(NSV::PROP_X, &x);
@@ -386,7 +386,7 @@
 as_value
 point_length(const fn_call& fn)
 {
-    as_object* ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
 
     if ( ! fn.nargs ) // getter
     {
@@ -605,7 +605,7 @@
 point_ctor(const fn_call& fn)
 {
 
-    as_object* obj = ensureType<as_object>(fn.this_ptr);
+    as_object* obj = ensure<ValidThis>(fn);
 
     as_value x;
     as_value y;

=== modified file 'libcore/asobj/flash/geom/Rectangle_as.cpp'
--- a/libcore/asobj/flash/geom/Rectangle_as.cpp 2009-10-14 08:47:08 +0000
+++ b/libcore/asobj/flash/geom/Rectangle_as.cpp 2009-10-22 14:56:18 +0000
@@ -124,7 +124,7 @@
 {
     // The object will be interpreted as a rectangle. Any Rectangle
     // properties that the object has (width, height, x, y) are used.
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
 
     as_value x, y, w, h;
 
@@ -148,7 +148,7 @@
     //fn.arg(0) => x coordinate
     //fn.arg(1) => y coordinate
 
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
 
     as_value rect_x_as, rect_width_as, rect_y_as, rect_height_as;
 
@@ -231,7 +231,7 @@
 as_value
 Rectangle_containsPoint(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
     UNUSED(ptr);
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
@@ -240,7 +240,7 @@
 as_value
 Rectangle_containsRectangle(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
     UNUSED(ptr);
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
@@ -249,7 +249,7 @@
 as_value
 Rectangle_equals(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
     UNUSED(ptr);
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
@@ -258,7 +258,7 @@
 as_value
 Rectangle_inflate(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
     UNUSED(ptr);
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
@@ -267,7 +267,7 @@
 as_value
 Rectangle_inflatePoint(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
     UNUSED(ptr);
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
@@ -276,7 +276,7 @@
 as_value
 Rectangle_intersection(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
     UNUSED(ptr);
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
@@ -285,7 +285,7 @@
 as_value
 Rectangle_intersects(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
     UNUSED(ptr);
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
@@ -294,7 +294,7 @@
 as_value
 Rectangle_isEmpty(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
 
     as_value w;
     ptr->get_member(NSV::PROP_WIDTH, &w);
@@ -318,7 +318,7 @@
 as_value
 Rectangle_offset(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
     UNUSED(ptr);
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
@@ -327,7 +327,7 @@
 as_value
 Rectangle_offsetPoint(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
     UNUSED(ptr);
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
@@ -336,7 +336,7 @@
 as_value
 Rectangle_setEmpty(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
     UNUSED(ptr);
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
@@ -345,7 +345,7 @@
 as_value
 Rectangle_toString(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
 
     as_value x, y, w, h;
 
@@ -367,7 +367,7 @@
 as_value
 Rectangle_union(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
     UNUSED(ptr);
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
@@ -376,7 +376,7 @@
 as_value
 Rectangle_bottom(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
 
     as_value ret;
 
@@ -405,8 +405,7 @@
 as_value
 Rectangle_bottomRight(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = 
-        ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
 
     if (!fn.nargs) {
 
@@ -447,7 +446,7 @@
 as_value
 Rectangle_left(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
 
     as_value ret;
 
@@ -478,7 +477,7 @@
 as_value
 Rectangle_right(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
 
     as_value ret;
 
@@ -507,7 +506,7 @@
 as_value
 Rectangle_size(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
 
     as_value ret;
 
@@ -541,7 +540,7 @@
 as_value
 Rectangle_top(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
 
     as_value ret;
 
@@ -572,7 +571,7 @@
 as_value
 Rectangle_topLeft(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
 
     as_value ret;
 
@@ -609,7 +608,7 @@
 Rectangle_ctor(const fn_call& fn)
 {
 
-    as_object* obj = ensureType<as_object>(fn.this_ptr);
+    as_object* obj = ensure<ValidThis>(fn);
 
     as_value x;
     as_value y;

=== modified file 'libcore/asobj/flash/geom/Transform_as.cpp'
--- a/libcore/asobj/flash/geom/Transform_as.cpp 2009-10-14 08:47:08 +0000
+++ b/libcore/asobj/flash/geom/Transform_as.cpp 2009-10-22 15:41:38 +0000
@@ -116,7 +116,7 @@
 
     const double factor = 256.0;
 
-    Transform_as* relay = ensureNativeType<Transform_as>(fn.this_ptr);
+    Transform_as* relay = ensure<ThisIsNative<Transform_as> >(fn);
 
     if (!fn.nargs) {
 
@@ -201,7 +201,7 @@
 as_value
 transform_concatenatedColorTransform(const fn_call& fn)
 {
-    Transform_as* relay = ensureNativeType<Transform_as>(fn.this_ptr);
+    Transform_as* relay = ensure<ThisIsNative<Transform_as> >(fn);
     UNUSED(relay);
     LOG_ONCE(log_unimpl (__FUNCTION__));
     return as_value();
@@ -210,7 +210,7 @@
 as_value
 transform_concatenatedMatrix(const fn_call& fn)
 {
-    Transform_as* relay = ensureNativeType<Transform_as>(fn.this_ptr);
+    Transform_as* relay = ensure<ThisIsNative<Transform_as> >(fn);
     UNUSED(relay);
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
@@ -227,7 +227,7 @@
     // would that work?)?
     // This should work by passing a new matrix, in which case we should just
     // set our _movieClip's matrix from the AS matrix.
-    Transform_as* relay = ensureNativeType<Transform_as>(fn.this_ptr);
+    Transform_as* relay = ensure<ThisIsNative<Transform_as> >(fn);
 
     if (!fn.nargs)
     {
@@ -310,7 +310,7 @@
 as_value
 transform_pixelBounds(const fn_call& fn)
 {
-    Transform_as* relay = ensureNativeType<Transform_as>(fn.this_ptr);
+    Transform_as* relay = ensure<ThisIsNative<Transform_as> >(fn);
     UNUSED(relay);
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
@@ -321,6 +321,7 @@
 as_value
 transform_ctor(const fn_call& fn)
 {
+    as_object* obj = ensure<ValidThis>(fn);
 
     if (!fn.nargs) {
 
@@ -342,10 +343,12 @@
     }
 
     // TODO: does this have to be a MovieClip or can it be any DisplayObject?
-    boost::intrusive_ptr<MovieClip> mc =
-        ensureType<MovieClip>(fn.arg(0).to_object(*getGlobal(fn)));
-
-    as_object* obj = ensureType<as_object>(fn.this_ptr);
+    as_object* o = fn.arg(0).to_object(*getGlobal(fn));
+    if (!o) return as_value();
+
+    MovieClip* mc = o->to_movie();
+    if (!mc) return as_value();
+
     obj->setRelay(new Transform_as(*mc));
 
     return as_value(); 

=== modified file 'libcore/asobj/flash/media/Camera_as.cpp'
--- a/libcore/asobj/flash/media/Camera_as.cpp   2009-10-14 14:50:52 +0000
+++ b/libcore/asobj/flash/media/Camera_as.cpp   2009-10-22 14:56:18 +0000
@@ -288,7 +288,7 @@
 as_value
 camera_setmode(const fn_call& fn)
 {
-    boost::intrusive_ptr<Camera_as> ptr = ensureType<Camera_as>(fn.this_ptr);
+    boost::intrusive_ptr<Camera_as> ptr = ensure<ThisIs<Camera_as> >(fn);
     
     const size_t nargs = fn.nargs;
 
@@ -310,7 +310,7 @@
 camera_setmotionlevel(const fn_call& fn)
 {
     log_unimpl ("Camera::motionLevel can be set, but it's not implemented");
-    boost::intrusive_ptr<Camera_as> ptr = ensureType<Camera_as>
+    boost::intrusive_ptr<Camera_as> ptr = ensure<ThisIs<Camera_as> >(fn);
         (fn.this_ptr);
     
     const size_t nargs = fn.nargs;
@@ -330,8 +330,7 @@
 camera_setquality(const fn_call& fn)
 {
     log_unimpl ("Camera::quality can be set, but it's not implemented");
-    boost::intrusive_ptr<Camera_as> ptr = ensureType<Camera_as>
-        (fn.this_ptr);
+    boost::intrusive_ptr<Camera_as> ptr = ensure<ThisIs<Camera_as> >(fn);
 
     const size_t nargs = fn.nargs;
 
@@ -349,7 +348,7 @@
 as_value
 camera_activitylevel(const fn_call& fn)
 {
-    boost::intrusive_ptr<Camera_as> ptr = ensureType<Camera_as>(fn.this_ptr);
+    boost::intrusive_ptr<Camera_as> ptr = ensure<ThisIs<Camera_as> >(fn);
 
     if (!fn.nargs) {
         log_unimpl("Camera::activityLevel only has default value");
@@ -366,7 +365,7 @@
 as_value
 camera_bandwidth(const fn_call& fn)
 {
-    boost::intrusive_ptr<Camera_as> ptr = ensureType<Camera_as>(fn.this_ptr);
+    boost::intrusive_ptr<Camera_as> ptr = ensure<ThisIs<Camera_as> >(fn);
 
     if (!fn.nargs) {
         log_unimpl("Camera::bandwidth only has default value");
@@ -383,7 +382,7 @@
 as_value
 camera_currentFps(const fn_call& fn)
 {
-    boost::intrusive_ptr<Camera_as> ptr = ensureType<Camera_as>(fn.this_ptr);
+    boost::intrusive_ptr<Camera_as> ptr = ensure<ThisIs<Camera_as> >(fn);
 
     if (!fn.nargs) {
         return as_value(ptr->currentFPS());
@@ -399,7 +398,7 @@
 as_value
 camera_fps(const fn_call& fn)
 {
-    boost::intrusive_ptr<Camera_as> ptr = ensureType<Camera_as>(fn.this_ptr);
+    boost::intrusive_ptr<Camera_as> ptr = ensure<ThisIs<Camera_as> >(fn);
 
     if (!fn.nargs) {
         return as_value(ptr->fps());
@@ -415,7 +414,7 @@
 as_value
 camera_height(const fn_call& fn)
 {
-    boost::intrusive_ptr<Camera_as> ptr = ensureType<Camera_as>(fn.this_ptr);
+    boost::intrusive_ptr<Camera_as> ptr = ensure<ThisIs<Camera_as> >(fn);
 
     if (!fn.nargs) {
         return as_value(ptr->height());
@@ -431,7 +430,7 @@
 as_value
 camera_index(const fn_call& fn)
 {
-    boost::intrusive_ptr<Camera_as> ptr = ensureType<Camera_as>(fn.this_ptr);
+    boost::intrusive_ptr<Camera_as> ptr = ensure<ThisIs<Camera_as> >(fn);
 
     if (!fn.nargs) 
     {
@@ -454,7 +453,7 @@
 as_value
 camera_motionLevel(const fn_call& fn)
 {
-    boost::intrusive_ptr<Camera_as> ptr = ensureType<Camera_as>(fn.this_ptr);
+    boost::intrusive_ptr<Camera_as> ptr = ensure<ThisIs<Camera_as> >(fn);
 
     if (!fn.nargs) {
         log_unimpl("Camera::motionLevel only has default value");
@@ -471,7 +470,7 @@
 as_value
 camera_motionTimeout(const fn_call& fn)
 {
-    boost::intrusive_ptr<Camera_as> ptr = ensureType<Camera_as>(fn.this_ptr);
+    boost::intrusive_ptr<Camera_as> ptr = ensure<ThisIs<Camera_as> >(fn);
 
     if (!fn.nargs) {
         log_unimpl("Camera::motionTimeout");
@@ -488,7 +487,7 @@
 as_value
 camera_muted(const fn_call& fn)
 {
-    boost::intrusive_ptr<Camera_as> ptr = ensureType<Camera_as>(fn.this_ptr);
+    boost::intrusive_ptr<Camera_as> ptr = ensure<ThisIs<Camera_as> >(fn);
 
     if (!fn.nargs) {
         log_unimpl("Camera.muted");
@@ -505,7 +504,7 @@
 as_value
 camera_name(const fn_call& fn)
 {
-    boost::intrusive_ptr<Camera_as> ptr = ensureType<Camera_as>(fn.this_ptr);
+    boost::intrusive_ptr<Camera_as> ptr = ensure<ThisIs<Camera_as> >(fn);
 
     if (!fn.nargs) {
         return as_value(ptr->name());
@@ -547,7 +546,7 @@
 as_value
 camera_quality(const fn_call& fn)
 {
-    boost::intrusive_ptr<Camera_as> ptr = ensureType<Camera_as>(fn.this_ptr);
+    boost::intrusive_ptr<Camera_as> ptr = ensure<ThisIs<Camera_as> >(fn);
 
     if (!fn.nargs) {
         log_unimpl("Camera::quality has only default values");
@@ -570,7 +569,7 @@
 as_value
 camera_setLoopback(const fn_call& fn)
 {
-    boost::intrusive_ptr<Camera_as> ptr = ensureType<Camera_as>(fn.this_ptr);
+    boost::intrusive_ptr<Camera_as> ptr = ensure<ThisIs<Camera_as> >(fn);
     
     if (!fn.nargs) {
         // TODO: log AS error.
@@ -603,8 +602,7 @@
 as_value
 camera_width(const fn_call& fn)
 {
-    boost::intrusive_ptr<Camera_as> ptr =
-        ensureType<Camera_as>(fn.this_ptr);
+    boost::intrusive_ptr<Camera_as> ptr = ensure<ThisIs<Camera_as> >(fn);
 
     if (!fn.nargs) {
         return as_value(ptr->width());

=== modified file 'libcore/asobj/flash/media/Microphone_as.cpp'
--- a/libcore/asobj/flash/media/Microphone_as.cpp       2009-10-14 14:50:52 
+0000
+++ b/libcore/asobj/flash/media/Microphone_as.cpp       2009-10-22 14:56:18 
+0000
@@ -138,12 +138,12 @@
 }
 
 #ifdef USE_GST
-class microphone_as_object: public as_object, public media::gst::AudioInputGst
+class Microphone_as: public as_object, public media::gst::AudioInputGst
 {
 
 public:
 
-       microphone_as_object()
+       Microphone_as()
                :
                as_object(getMicrophoneInterface())
        {
@@ -156,12 +156,12 @@
 // FIXME: this should be USE_FFMPEG, but Microphone has no ffmpeg
 // support yet.
 #ifndef USE_GST
-class microphone_as_object: public as_object, public media::AudioInput
+class Microphone_as: public as_object, public media::AudioInput
 {
 
 public:
 
-       microphone_as_object()
+       Microphone_as()
                :
                as_object(getMicrophoneInterface())
        {
@@ -184,11 +184,11 @@
 microphone_get(const fn_call& /*fn*/)
 {
     static size_t newcount = 0;
-    static boost::intrusive_ptr<microphone_as_object> permaMicPtr;
-    boost::intrusive_ptr<microphone_as_object> ptr;
+    static boost::intrusive_ptr<Microphone_as> permaMicPtr;
+    boost::intrusive_ptr<Microphone_as> ptr;
     if (newcount == 0) {
         log_debug("creating a new microphone_as object");
-        ptr = new microphone_as_object;
+        ptr = new Microphone_as;
         newcount++;
         permaMicPtr = ptr;
         return as_value(ptr);
@@ -201,21 +201,19 @@
 as_value
 microphone_getMicrophone(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr
-        = ensureType<microphone_as_object> (fn.this_ptr);
+    Microphone_as* ptr = ensure<ThisIs<Microphone_as> >(fn);
     int numargs = fn.nargs;
     if (numargs > 0) {
         log_debug("%s: the mic is automatically chosen from gnashrc", 
__FUNCTION__);
     }
-    return as_value(ptr.get()); //will keep alive
+    return as_value(ptr); 
 }
 
 
 as_value 
 microphone_setgain(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr =
-        ensureType<microphone_as_object> (fn.this_ptr);
+    Microphone_as* ptr = ensure<ThisIs<Microphone_as> >(fn);
     
     int numargs = fn.nargs;
     if (numargs != 1) {
@@ -264,8 +262,7 @@
 as_value
 microphone_setrate(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr =
-        ensureType<microphone_as_object> (fn.this_ptr);
+    Microphone_as* ptr = ensure<ThisIs<Microphone_as> >(fn);
     
     int numargs = fn.nargs;
     const int32_t argument = fn.arg(0).to_int();
@@ -306,8 +303,7 @@
 as_value
 microphone_activityLevel(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr =
-        ensureType<microphone_as_object> (fn.this_ptr);
+    Microphone_as* ptr = ensure<ThisIs<Microphone_as> >(fn);
         
     if ( fn.nargs == 0 ) // getter
     {
@@ -327,8 +323,7 @@
 as_value
 microphone_gain(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr =
-        ensureType<microphone_as_object> (fn.this_ptr);
+    Microphone_as* ptr = ensure<ThisIs<Microphone_as> >(fn);
         
     if ( fn.nargs == 0 ) // getter
     {
@@ -341,7 +336,10 @@
         gain = round(gain);
         return as_value(gain);
     }
+#else
+    UNUSED(ptr);
 #endif
+
         log_unimpl("FFMPEG not implemented. Returning a number");
         return as_value(50.0);
     }
@@ -358,8 +356,7 @@
 as_value
 microphone_index(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr =
-        ensureType<microphone_as_object> (fn.this_ptr);
+    Microphone_as* ptr = ensure<ThisIs<Microphone_as> >(fn);
     
     if ( fn.nargs == 0 ) // getter
     {
@@ -378,8 +375,7 @@
 as_value
 microphone_muted(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr =
-        ensureType<microphone_as_object> (fn.this_ptr);
+    Microphone_as* ptr = ensure<ThisIs<Microphone_as> >(fn);
     
     if ( fn.nargs == 0 ) // getter
     {
@@ -399,8 +395,7 @@
 as_value
 microphone_name(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr =
-        ensureType<microphone_as_object> (fn.this_ptr);
+    Microphone_as* ptr = ensure<ThisIs<Microphone_as> >(fn);
         
     if ( fn.nargs == 0 ) // getter
     {
@@ -450,14 +445,14 @@
 as_value
 microphone_rate(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr =
-        ensureType<microphone_as_object> (fn.this_ptr);
+    Microphone_as* ptr = ensure<ThisIs<Microphone_as> >(fn);
     
     if ( fn.nargs == 0 ) // getter
     {
 #ifdef USE_GST
         return as_value(ptr->get_rate()/1000);
 #else
+        UNUSED(ptr);
         log_unimpl("FFMPEG is unsupported, returning default val");
         return as_value(8);
 #endif
@@ -475,8 +470,7 @@
 as_value
 microphone_silenceLevel(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr =
-        ensureType<microphone_as_object> (fn.this_ptr);
+    Microphone_as* ptr = ensure<ThisIs<Microphone_as> >(fn);
 
     if ( fn.nargs == 0 ) // getter
     {
@@ -496,8 +490,7 @@
 as_value
 microphone_silenceTimeout(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr =
-        ensureType<microphone_as_object> (fn.this_ptr);
+    Microphone_as* ptr = ensure<ThisIs<Microphone_as> >(fn);
         
     if ( fn.nargs == 0 ) // getter
     {
@@ -517,8 +510,7 @@
 as_value
 microphone_useEchoSuppression(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr =
-        ensureType<microphone_as_object> (fn.this_ptr);
+    Microphone_as* ptr = ensure<ThisIs<Microphone_as> >(fn);
     
     if ( fn.nargs == 0 ) // getter
     {
@@ -543,8 +535,7 @@
     log_unimpl ("Microphone::setSilenceLevel can be set, but it's not "
             "implemented");
 
-    boost::intrusive_ptr<microphone_as_object> ptr =
-        ensureType<microphone_as_object> (fn.this_ptr);
+    Microphone_as* ptr = ensure<ThisIs<Microphone_as> >(fn);
     
     int numargs = fn.nargs;
     if (numargs > 2) {
@@ -593,8 +584,7 @@
 {
     log_unimpl ("Microphone::setUseEchoSuppression can be set, but it's not "
             "implemented");
-    boost::intrusive_ptr<microphone_as_object> ptr =
-        ensureType<microphone_as_object> (fn.this_ptr);
+    Microphone_as* ptr = ensure<ThisIs<Microphone_as> >(fn);
     
     int numargs = fn.nargs;
     if (numargs > 1) {

=== modified file 'libcore/asobj/flash/media/SoundChannel_as.cpp'
--- a/libcore/asobj/flash/media/SoundChannel_as.cpp     2009-08-20 08:57:16 
+0000
+++ b/libcore/asobj/flash/media/SoundChannel_as.cpp     2009-10-22 14:56:18 
+0000
@@ -88,8 +88,7 @@
 as_value
 soundchannel_soundComplete(const fn_call& fn)
 {
-    boost::intrusive_ptr<SoundChannel_as> ptr =
-        ensureType<SoundChannel_as>(fn.this_ptr);
+    SoundChannel_as* ptr = ensure<ThisIs<SoundChannel_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/media/SoundMixer_as.cpp'
--- a/libcore/asobj/flash/media/SoundMixer_as.cpp       2009-08-20 08:57:16 
+0000
+++ b/libcore/asobj/flash/media/SoundMixer_as.cpp       2009-10-22 14:56:18 
+0000
@@ -90,8 +90,7 @@
 as_value
 soundmixer_computeSpectrum(const fn_call& fn)
 {
-    boost::intrusive_ptr<SoundMixer_as> ptr =
-        ensureType<SoundMixer_as>(fn.this_ptr);
+    SoundMixer_as* ptr = ensure<ThisIs<SoundMixer_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -100,8 +99,7 @@
 as_value
 soundmixer_stopAll(const fn_call& fn)
 {
-    boost::intrusive_ptr<SoundMixer_as> ptr =
-        ensureType<SoundMixer_as>(fn.this_ptr);
+    SoundMixer_as* ptr = ensure<ThisIs<SoundMixer_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/media/Sound_as.cpp'
--- a/libcore/asobj/flash/media/Sound_as.cpp    2009-10-14 08:47:08 +0000
+++ b/libcore/asobj/flash/media/Sound_as.cpp    2009-10-22 14:56:18 +0000
@@ -834,7 +834,7 @@
     IF_VERBOSE_ACTION (
     log_action(_("-- start sound"));
     )
-    Sound_as* so = ensureNativeType<Sound_as>(fn.this_ptr);
+    Sound_as* so = ensure<ThisIsNative<Sound_as> >(fn);
     int loop = 0;
     double secondOffset = 0;
 
@@ -859,7 +859,7 @@
     IF_VERBOSE_ACTION (
     log_action(_("-- stop sound "));
     )
-    Sound_as* so = ensureNativeType<Sound_as>(fn.this_ptr);
+    Sound_as* so = ensure<ThisIsNative<Sound_as> >(fn);
 
     int si = -1;
 
@@ -912,7 +912,7 @@
         return as_value();
     }
 
-    Sound_as* so = ensureNativeType<Sound_as>(fn.this_ptr);
+    Sound_as* so = ensure<ThisIsNative<Sound_as> >(fn);
 
     const std::string& name = fn.arg(0).to_string();
     if (name.empty()) {
@@ -960,7 +960,7 @@
 as_value
 sound_getbytesloaded(const fn_call& fn)
 {
-    Sound_as* so = ensureNativeType<Sound_as>(fn.this_ptr);
+    Sound_as* so = ensure<ThisIsNative<Sound_as> >(fn);
     long loaded = so->getBytesLoaded();
     if (loaded < 0) return as_value();
     return as_value(loaded);
@@ -969,7 +969,7 @@
 as_value
 sound_getbytestotal(const fn_call& fn)
 {
-    Sound_as* so = ensureNativeType<Sound_as>(fn.this_ptr);
+    Sound_as* so = ensure<ThisIsNative<Sound_as> >(fn);
     long total = so->getBytesTotal();
     if (total < 0) return as_value();
     return as_value(total);
@@ -1021,7 +1021,7 @@
 sound_getvolume(const fn_call& fn)
 {
 
-    Sound_as* so = ensureNativeType<Sound_as>(fn.this_ptr);
+    Sound_as* so = ensure<ThisIsNative<Sound_as> >(fn);
 
     if ( fn.nargs )
     {
@@ -1039,7 +1039,7 @@
 as_value
 sound_loadsound(const fn_call& fn)
 {
-    Sound_as* so = ensureNativeType<Sound_as>(fn.this_ptr);
+    Sound_as* so = ensure<ThisIsNative<Sound_as> >(fn);
 
     if (!fn.nargs)
     {
@@ -1096,7 +1096,7 @@
         return as_value();
     }
 
-    Sound_as* so = ensureNativeType<Sound_as>(fn.this_ptr);    
+    Sound_as* so = ensure<ThisIsNative<Sound_as> >(fn);
     int volume = (int) fn.arg(0).to_number();
 
     so->setVolume(volume);
@@ -1106,7 +1106,7 @@
 as_value
 sound_duration(const fn_call& fn)
 {
-    Sound_as* so = ensureNativeType<Sound_as>(fn.this_ptr);
+    Sound_as* so = ensure<ThisIsNative<Sound_as> >(fn);
     return as_value(so->getDuration());
 }
 
@@ -1133,7 +1133,7 @@
 as_value
 sound_position(const fn_call& fn)
 {
-    Sound_as* so = ensureNativeType<Sound_as>(fn.this_ptr);
+    Sound_as* so = ensure<ThisIsNative<Sound_as> >(fn);
 
     return as_value(so->getPosition());
 }
@@ -1142,7 +1142,7 @@
 as_value
 sound_load(const fn_call& fn)
 {
-    Sound_as* ptr = ensureNativeType<Sound_as>(fn.this_ptr);
+    Sound_as* ptr = ensure<ThisIsNative<Sound_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -1151,7 +1151,7 @@
 as_value
 sound_play(const fn_call& fn)
 {
-    Sound_as* ptr = ensureNativeType<Sound_as>(fn.this_ptr);
+    Sound_as* ptr = ensure<ThisIsNative<Sound_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -1160,7 +1160,7 @@
 as_value
 sound_complete(const fn_call& fn)
 {
-    Sound_as* ptr = ensureNativeType<Sound_as>(fn.this_ptr);
+    Sound_as* ptr = ensure<ThisIsNative<Sound_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -1169,7 +1169,7 @@
 as_value
 sound_id3(const fn_call& fn)
 {
-    Sound_as* ptr = ensureNativeType<Sound_as>(fn.this_ptr);
+    Sound_as* ptr = ensure<ThisIsNative<Sound_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -1178,7 +1178,7 @@
 as_value
 sound_ioError(const fn_call& fn)
 {
-    Sound_as* ptr = ensureNativeType<Sound_as>(fn.this_ptr);
+    Sound_as* ptr = ensure<ThisIsNative<Sound_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -1187,7 +1187,7 @@
 as_value
 sound_open(const fn_call& fn)
 {
-    Sound_as* ptr = ensureNativeType<Sound_as>(fn.this_ptr);
+    Sound_as* ptr = ensure<ThisIsNative<Sound_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -1196,7 +1196,7 @@
 as_value
 sound_progress(const fn_call& fn)
 {
-    Sound_as* ptr = ensureNativeType<Sound_as>(fn.this_ptr);
+    Sound_as* ptr = ensure<ThisIsNative<Sound_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/net/LocalConnection_as.cpp'
--- a/libcore/asobj/flash/net/LocalConnection_as.cpp    2009-10-14 08:47:08 
+0000
+++ b/libcore/asobj/flash/net/LocalConnection_as.cpp    2009-10-22 14:56:18 
+0000
@@ -265,7 +265,7 @@
 localconnection_new(const fn_call& fn)
 {
     // TODO: this doesn't happen on construction.
-    as_object* obj = ensureType<as_object>(fn.this_ptr);
+    as_object* obj = ensure<ValidThis>(fn);
     obj->setRelay(new LocalConnection_as(obj));
     return as_value();
 }
@@ -274,9 +274,7 @@
 as_value
 localconnection_close(const fn_call& fn)
 {
-    LocalConnection_as* relay =
-        ensureNativeType<LocalConnection_as>(fn.this_ptr);
-    
+    LocalConnection_as* relay = ensure<ThisIsNative<LocalConnection_as> >(fn);
     relay->close();
     return as_value();
 }
@@ -285,8 +283,7 @@
 as_value
 localconnection_connect(const fn_call& fn)
 {
-    LocalConnection_as* relay =
-        ensureNativeType<LocalConnection_as>(fn.this_ptr);
+    LocalConnection_as* relay = ensure<ThisIsNative<LocalConnection_as> >(fn);
 
     // If already connected, don't try again until close() is called.
     if (relay->getconnected()) return false;
@@ -325,9 +322,7 @@
 as_value
 localconnection_domain(const fn_call& fn)
 {
-    LocalConnection_as* relay =
-        ensureNativeType<LocalConnection_as>(fn.this_ptr);
-
+    LocalConnection_as* relay = ensure<ThisIsNative<LocalConnection_as> >(fn);
     return as_value(relay->domain());
 }
 
@@ -337,9 +332,7 @@
 as_value
 localconnection_send(const fn_call& fn)
 {
-    LocalConnection_as* relay =
-        ensureNativeType<LocalConnection_as>(fn.this_ptr);
-
+    LocalConnection_as* relay = ensure<ThisIsNative<LocalConnection_as> >(fn);
     // At least 2 args (connection name, function) required.
 
    log_debug(_("The number of args is %d \n"), fn.nargs) ;

=== modified file 'libcore/asobj/flash/net/NetConnection_as.cpp'
--- a/libcore/asobj/flash/net/NetConnection_as.cpp      2009-09-24 16:32:22 
+0000
+++ b/libcore/asobj/flash/net/NetConnection_as.cpp      2009-10-22 14:56:18 
+0000
@@ -1019,7 +1019,7 @@
 as_value
 netconnection_call(const fn_call& fn)
 {
-    NetConnection_as* ptr = ensureNativeType<NetConnection_as>(fn.this_ptr); 
+    NetConnection_as* ptr = ensure<ThisIsNative<NetConnection_as> >(fn);
 
     if (fn.nargs < 1)
     {
@@ -1062,7 +1062,7 @@
 as_value
 netconnection_close(const fn_call& fn)
 {
-    NetConnection_as* ptr = ensureNativeType<NetConnection_as>(fn.this_ptr); 
+    NetConnection_as* ptr = ensure<ThisIsNative<NetConnection_as> >(fn);
 
     ptr->close();
 
@@ -1074,7 +1074,7 @@
 as_value
 netconnection_isConnected(const fn_call& fn)
 {
-    NetConnection_as* ptr = ensureNativeType<NetConnection_as>(fn.this_ptr); 
+    NetConnection_as* ptr = ensure<ThisIsNative<NetConnection_as> >(fn);
 
     return as_value(ptr->isConnected());
 }
@@ -1082,7 +1082,7 @@
 as_value
 netconnection_uri(const fn_call& fn)
 {
-    NetConnection_as* ptr = ensureNativeType<NetConnection_as>(fn.this_ptr); 
+    NetConnection_as* ptr = ensure<ThisIsNative<NetConnection_as> >(fn);
 
     return as_value(ptr->getURI());
 }
@@ -1135,7 +1135,7 @@
 netconnection_connect(const fn_call& fn)
 {
 
-    NetConnection_as* ptr = ensureNativeType<NetConnection_as>(fn.this_ptr); 
+    NetConnection_as* ptr = ensure<ThisIsNative<NetConnection_as> >(fn);
     
     if (fn.nargs < 1)
     {
@@ -1176,7 +1176,7 @@
 as_value
 netconnection_addHeader(const fn_call& fn)
 {
-    NetConnection_as* ptr = ensureNativeType<NetConnection_as>(fn.this_ptr); 
+    NetConnection_as* ptr = ensure<ThisIsNative<NetConnection_as> >(fn);
     UNUSED(ptr);
 
     log_unimpl("NetConnection.addHeader()");

=== modified file 'libcore/asobj/flash/net/NetStream_as.cpp'
--- a/libcore/asobj/flash/net/NetStream_as.cpp  2009-10-14 08:47:08 +0000
+++ b/libcore/asobj/flash/net/NetStream_as.cpp  2009-10-22 14:56:18 +0000
@@ -1602,7 +1602,7 @@
 as_value
 netstream_close(const fn_call& fn)
 {
-    NetStream_as* ns = ensureNativeType<NetStream_as>(fn.this_ptr);
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
     ns->close();
     return as_value();
 }
@@ -1610,8 +1610,7 @@
 as_value
 netstream_pause(const fn_call& fn)
 {
-    NetStream_as* ns = 
-        ensureNativeType<NetStream_as>(fn.this_ptr);
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
     
     // mode: -1 ==> toogle, 0==> pause, 1==> play
     NetStream_as::PauseMode mode = NetStream_as::pauseModeToggle;
@@ -1629,8 +1628,7 @@
 as_value
 netstream_play(const fn_call& fn)
 {
-    NetStream_as* ns =
-        ensureNativeType<NetStream_as>(fn.this_ptr);
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
 
     if (!fn.nargs)
     {
@@ -1657,9 +1655,7 @@
 as_value
 netstream_seek(const fn_call& fn)
 {
-    NetStream_as* ns = 
-        ensureNativeType<NetStream_as>(fn.this_ptr);
-
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
     boost::uint32_t time = 0;
     if (fn.nargs > 0)
     {
@@ -1676,8 +1672,7 @@
 
     //GNASH_REPORT_FUNCTION;
 
-    NetStream_as* ns =
-        ensureNativeType<NetStream_as>(fn.this_ptr);
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
 
     // TODO: should we do anything if given no args ?
     //       are we sure setting bufferTime to 0 is what we have to do ?
@@ -1697,8 +1692,7 @@
 as_value
 netstream_attachAudio(const fn_call& fn)
 {
-    NetStream_as* ns =
-        ensureNativeType<NetStream_as>(fn.this_ptr);
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
     UNUSED(ns);
 
     LOG_ONCE(log_unimpl("NetStream.attachAudio"));
@@ -1709,8 +1703,7 @@
 as_value
 netstream_attachVideo(const fn_call& fn)
 {
-    NetStream_as* ns =
-        ensureNativeType<NetStream_as>(fn.this_ptr);
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
     UNUSED(ns);
 
     LOG_ONCE(log_unimpl("NetStream.attachVideo"));
@@ -1721,8 +1714,7 @@
 as_value
 netstream_publish(const fn_call& fn)
 {
-    NetStream_as* ns = 
-        ensureNativeType<NetStream_as>(fn.this_ptr);
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
     UNUSED(ns);
 
     LOG_ONCE(log_unimpl("NetStream.publish"));
@@ -1733,8 +1725,7 @@
 as_value
 netstream_receiveAudio(const fn_call& fn)
 {
-    NetStream_as* ns =
-        ensureNativeType<NetStream_as>(fn.this_ptr);
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
     UNUSED(ns);
 
     LOG_ONCE(log_unimpl("NetStream.receiveAudio"));
@@ -1745,8 +1736,7 @@
 as_value
 netstream_receiveVideo(const fn_call& fn)
 {
-    NetStream_as* ns =
-        ensureNativeType<NetStream_as>(fn.this_ptr);
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
     UNUSED(ns);
 
     LOG_ONCE(log_unimpl("NetStream.receiveVideo"));
@@ -1757,8 +1747,7 @@
 as_value
 netstream_send(const fn_call& fn)
 {
-    NetStream_as* ns =
-        ensureNativeType<NetStream_as>(fn.this_ptr);
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
     UNUSED(ns);
 
     LOG_ONCE(log_unimpl("NetStream.send"));
@@ -1772,8 +1761,7 @@
 {
     //GNASH_REPORT_FUNCTION;
 
-    NetStream_as* ns =
-        ensureNativeType<NetStream_as>(fn.this_ptr);
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
 
     assert(fn.nargs == 0); // we're a getter
     return as_value(double(ns->time()/1000.0));
@@ -1783,9 +1771,7 @@
 as_value
 netstream_bytesloaded(const fn_call& fn)
 {
-    NetStream_as* ns =
-        ensureNativeType<NetStream_as>(fn.this_ptr);
-
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
     if ( ! ns->isConnected() )
     {
         return as_value();
@@ -1798,9 +1784,7 @@
 as_value
 netstream_bytestotal(const fn_call& fn)
 {
-    NetStream_as* ns = 
-        ensureNativeType<NetStream_as>(fn.this_ptr);
-
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
     if ( ! ns->isConnected() )
     {
         return as_value();
@@ -1813,9 +1797,7 @@
 as_value
 netstream_currentFPS(const fn_call& fn)
 {
-    NetStream_as* ns = 
-        ensureNativeType<NetStream_as>(fn.this_ptr);
-
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
     if ( ! ns->isConnected() )
     {
         return as_value();
@@ -1830,8 +1812,7 @@
 as_value
 netstream_bufferLength(const fn_call& fn)
 {
-    NetStream_as* ns = 
-        ensureNativeType<NetStream_as>(fn.this_ptr);
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
 
     // NetStream_as::bufferLength returns milliseconds, we want
     // to return *fractional* seconds.
@@ -1843,9 +1824,7 @@
 as_value
 netstream_bufferTime(const fn_call& fn)
 {
-    NetStream_as* ns =
-        ensureNativeType<NetStream_as>(fn.this_ptr);
-
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
     // We return bufferTime in seconds
     double ret = ns->bufferTime() / 1000.0;
     return as_value(ret);
@@ -1855,7 +1834,7 @@
 as_value
 netstream_liveDelay(const fn_call& fn)
 {
-    NetStream_as* ns = ensureNativeType<NetStream_as>(fn.this_ptr);
+    NetStream_as* ns = ensure<ThisIsNative<NetStream_as> >(fn);
     UNUSED(ns);
 
     LOG_ONCE(log_unimpl("NetStream.liveDelay getter/setter"));

=== modified file 'libcore/asobj/flash/net/SharedObject_as.cpp'
--- a/libcore/asobj/flash/net/SharedObject_as.cpp       2009-10-16 14:17:00 
+0000
+++ b/libcore/asobj/flash/net/SharedObject_as.cpp       2009-10-22 14:56:18 
+0000
@@ -820,8 +820,7 @@
 as_value
 sharedobject_clear(const fn_call& fn)
 {
-    boost::intrusive_ptr<SharedObject_as> obj = 
-        ensureType<SharedObject_as>(fn.this_ptr);
+    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
     UNUSED(obj);
     
     LOG_ONCE(log_unimpl (__FUNCTION__));
@@ -832,8 +831,7 @@
 as_value
 sharedobject_setdirty(const fn_call& fn)
 {
-    boost::intrusive_ptr<SharedObject_as> obj = 
-        ensureType<SharedObject_as>(fn.this_ptr);
+    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
     UNUSED(obj);
     
     LOG_ONCE(log_unimpl (__FUNCTION__));
@@ -845,8 +843,7 @@
 sharedobject_setproperty(const fn_call& fn)
 {
     GNASH_REPORT_FUNCTION;    
-    boost::intrusive_ptr<SharedObject_as> obj = 
-        ensureType<SharedObject_as>(fn.this_ptr);
+    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
     UNUSED(obj);
     
     LOG_ONCE(log_unimpl (__FUNCTION__));
@@ -859,8 +856,7 @@
 {
     GNASH_REPORT_FUNCTION;    
 
-    boost::intrusive_ptr<SharedObject_as> obj =
-        ensureType<SharedObject_as>(fn.this_ptr);
+    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
 
     if (fn.nargs < 1) {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -915,8 +911,7 @@
 as_value
 sharedobject_close(const fn_call& fn)
 {
-    boost::intrusive_ptr<SharedObject_as> obj =
-        ensureType<SharedObject_as>(fn.this_ptr);
+    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
 
     obj->close();
 
@@ -926,8 +921,7 @@
 as_value
 sharedobject_setFps(const fn_call& fn)
 {
-    boost::intrusive_ptr<SharedObject_as> obj =
-        ensureType<SharedObject_as>(fn.this_ptr);
+    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
     UNUSED(obj);
 
     LOG_ONCE(log_unimpl("SharedObject.setFps"));
@@ -939,8 +933,7 @@
 {
     GNASH_REPORT_FUNCTION;
 
-    boost::intrusive_ptr<SharedObject_as> obj =
-        ensureType<SharedObject_as>(fn.this_ptr);
+    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
 
     if (obj->isConnected() == false) {
        obj->connectToServer(obj->getURI());
@@ -954,8 +947,7 @@
 {    
     GNASH_REPORT_FUNCTION;
 
-    boost::intrusive_ptr<SharedObject_as> obj =
-        ensureType<SharedObject_as>(fn.this_ptr);
+    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
 
     IF_VERBOSE_ASCODING_ERRORS(
         if (fn.nargs > 1)
@@ -1073,8 +1065,7 @@
 as_value
 sharedobject_deleteAll(const fn_call& fn)
 {
-    boost::intrusive_ptr<SharedObject_as> obj =
-        ensureType<SharedObject_as>(fn.this_ptr);
+    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
 
     UNUSED(obj);
 
@@ -1089,8 +1080,7 @@
 sharedobject_getDiskUsage(const fn_call& fn)
 {
  //    GNASH_REPORT_FUNCTION;
-    boost::intrusive_ptr<SharedObject_as> obj =
-        ensureType<SharedObject_as>(fn.this_ptr);
+    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
 
     UNUSED(obj);
 
@@ -1103,16 +1093,14 @@
 sharedobject_data(const fn_call& fn)
 { 
 //    GNASH_REPORT_FUNCTION;
-    boost::intrusive_ptr<SharedObject_as> obj =
-        ensureType<SharedObject_as>(fn.this_ptr);
+    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
     return as_value(obj->data());
 }
 
 as_value
 sharedobject_getsize(const fn_call& fn)
 {
-    boost::intrusive_ptr<SharedObject_as> obj =
-        ensureType<SharedObject_as>(fn.this_ptr);
+    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
     return as_value(obj->size());
 }
 

=== modified file 'libcore/asobj/flash/net/Socket_as.cpp'
--- a/libcore/asobj/flash/net/Socket_as.cpp     2009-07-29 05:40:20 +0000
+++ b/libcore/asobj/flash/net/Socket_as.cpp     2009-10-22 14:56:18 +0000
@@ -160,8 +160,7 @@
 as_value
 socket_connect(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -170,8 +169,7 @@
 as_value
 socket_flush(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -180,8 +178,7 @@
 as_value
 socket_readBoolean(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -190,8 +187,7 @@
 as_value
 socket_readByte(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -200,8 +196,7 @@
 as_value
 socket_readBytes(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -210,8 +205,7 @@
 as_value
 socket_readDouble(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -220,8 +214,7 @@
 as_value
 socket_readFloat(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -230,8 +223,7 @@
 as_value
 socket_readInt(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -240,8 +232,7 @@
 as_value
 socket_readMultiByte(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -250,8 +241,7 @@
 as_value
 socket_readObject(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -260,8 +250,7 @@
 as_value
 socket_readShort(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -270,8 +259,7 @@
 as_value
 socket_readUnsignedByte(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -280,8 +268,7 @@
 as_value
 socket_readUnsignedInt(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -290,8 +277,7 @@
 as_value
 socket_readUnsignedShort(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -300,8 +286,7 @@
 as_value
 socket_readUTF(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -310,8 +295,7 @@
 as_value
 socket_readUTFBytes(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -320,8 +304,7 @@
 as_value
 socket_writeBoolean(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -330,8 +313,7 @@
 as_value
 socket_writeByte(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -340,8 +322,7 @@
 as_value
 socket_writeBytes(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -350,8 +331,7 @@
 as_value
 socket_writeDouble(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -360,8 +340,7 @@
 as_value
 socket_writeFloat(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -370,8 +349,7 @@
 as_value
 socket_writeInt(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -380,8 +358,7 @@
 as_value
 socket_writeMultiByte(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -390,8 +367,7 @@
 as_value
 socket_writeObject(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -400,8 +376,7 @@
 as_value
 socket_writeShort(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -410,8 +385,7 @@
 as_value
 socket_writeUnsignedInt(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -420,8 +394,7 @@
 as_value
 socket_writeUTF(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -430,8 +403,7 @@
 as_value
 socket_writeUTFBytes(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -440,8 +412,7 @@
 as_value
 socket_close(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -450,8 +421,7 @@
 as_value
 socket_ioError(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -460,8 +430,7 @@
 as_value
 socket_securityError(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -470,8 +439,7 @@
 as_value
 socket_socketData(const fn_call& fn)
 {
-    boost::intrusive_ptr<Socket_as> ptr =
-        ensureType<Socket_as>(fn.this_ptr);
+    Socket_as* ptr = ensure<ThisIs<Socket_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/net/URLLoader_as.cpp'
--- a/libcore/asobj/flash/net/URLLoader_as.cpp  2009-07-29 05:40:20 +0000
+++ b/libcore/asobj/flash/net/URLLoader_as.cpp  2009-10-22 14:56:18 +0000
@@ -111,8 +111,7 @@
 as_value
 urlloader_close(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLLoader_as> ptr =
-        ensureType<URLLoader_as>(fn.this_ptr);
+    URLLoader_as* ptr = ensure<ThisIs<URLLoader_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -121,8 +120,7 @@
 as_value
 urlloader_load(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLLoader_as> ptr =
-        ensureType<URLLoader_as>(fn.this_ptr);
+    URLLoader_as* ptr = ensure<ThisIs<URLLoader_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -131,8 +129,7 @@
 as_value
 urlloader_complete(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLLoader_as> ptr =
-        ensureType<URLLoader_as>(fn.this_ptr);
+    URLLoader_as* ptr = ensure<ThisIs<URLLoader_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -141,8 +138,7 @@
 as_value
 urlloader_httpStatus(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLLoader_as> ptr =
-        ensureType<URLLoader_as>(fn.this_ptr);
+    URLLoader_as* ptr = ensure<ThisIs<URLLoader_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -151,8 +147,7 @@
 as_value
 urlloader_ioError(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLLoader_as> ptr =
-        ensureType<URLLoader_as>(fn.this_ptr);
+    URLLoader_as* ptr = ensure<ThisIs<URLLoader_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -161,8 +156,7 @@
 as_value
 urlloader_open(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLLoader_as> ptr =
-        ensureType<URLLoader_as>(fn.this_ptr);
+    URLLoader_as* ptr = ensure<ThisIs<URLLoader_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -171,8 +165,7 @@
 as_value
 urlloader_progress(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLLoader_as> ptr =
-        ensureType<URLLoader_as>(fn.this_ptr);
+    URLLoader_as* ptr = ensure<ThisIs<URLLoader_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -181,8 +174,7 @@
 as_value
 urlloader_securityError(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLLoader_as> ptr =
-        ensureType<URLLoader_as>(fn.this_ptr);
+    URLLoader_as* ptr = ensure<ThisIs<URLLoader_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/net/URLStream_as.cpp'
--- a/libcore/asobj/flash/net/URLStream_as.cpp  2009-08-20 08:57:16 +0000
+++ b/libcore/asobj/flash/net/URLStream_as.cpp  2009-10-22 14:56:18 +0000
@@ -129,8 +129,7 @@
 as_value
 urlstream_load(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -139,8 +138,7 @@
 as_value
 urlstream_readBoolean(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -149,8 +147,7 @@
 as_value
 urlstream_readByte(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -159,8 +156,7 @@
 as_value
 urlstream_readBytes(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -169,8 +165,7 @@
 as_value
 urlstream_readDouble(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -179,8 +174,7 @@
 as_value
 urlstream_readFloat(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -189,8 +183,7 @@
 as_value
 urlstream_readInt(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -199,8 +192,7 @@
 as_value
 urlstream_readMultiByte(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -209,8 +201,7 @@
 as_value
 urlstream_readObject(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -219,8 +210,7 @@
 as_value
 urlstream_readShort(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -229,8 +219,7 @@
 as_value
 urlstream_readUnsignedByte(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -239,8 +228,7 @@
 as_value
 urlstream_readUnsignedInt(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -249,8 +237,7 @@
 as_value
 urlstream_readUnsignedShort(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -259,8 +246,7 @@
 as_value
 urlstream_readUTF(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -269,8 +255,7 @@
 as_value
 urlstream_readUTFBytes(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -279,8 +264,7 @@
 as_value
 urlstream_complete(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -289,8 +273,7 @@
 as_value
 urlstream_httpStatus(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -299,8 +282,7 @@
 as_value
 urlstream_ioError(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -309,8 +291,7 @@
 as_value
 urlstream_open(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -319,8 +300,7 @@
 as_value
 urlstream_progress(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -329,8 +309,7 @@
 as_value
 urlstream_securityError(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLStream_as> ptr =
-        ensureType<URLStream_as>(fn.this_ptr);
+    URLStream_as* ptr = ensure<ThisIs<URLStream_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/net/URLVariables_as.cpp'
--- a/libcore/asobj/flash/net/URLVariables_as.cpp       2009-08-20 08:57:16 
+0000
+++ b/libcore/asobj/flash/net/URLVariables_as.cpp       2009-10-22 14:56:18 
+0000
@@ -88,8 +88,7 @@
 as_value
 urlvariables_toString(const fn_call& fn)
 {
-    boost::intrusive_ptr<URLVariables_as> ptr =
-        ensureType<URLVariables_as>(fn.this_ptr);
+    URLVariables_as* ptr = ensure<ThisIs<URLVariables_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/net/XMLSocket_as.cpp'
--- a/libcore/asobj/flash/net/XMLSocket_as.cpp  2009-09-29 14:40:27 +0000
+++ b/libcore/asobj/flash/net/XMLSocket_as.cpp  2009-10-22 14:56:18 +0000
@@ -446,8 +446,7 @@
     log_debug(_("XMLSocket.connect(%s) called"), ss.str());
 #endif
 
-    XMLSocket_as* ptr =
-        ensureNativeType<XMLSocket_as>(fn.this_ptr);
+    XMLSocket_as* ptr = ensure<ThisIsNative<XMLSocket_as> >(fn);
 
     if (ptr->ready()) {
         log_error(_("XMLSocket.connect() called while already "
@@ -487,9 +486,7 @@
 as_value
 xmlsocket_send(const fn_call& fn)
 {
-    XMLSocket_as* ptr =
-        ensureNativeType<XMLSocket_as>(fn.this_ptr);
-
+    XMLSocket_as* ptr = ensure<ThisIsNative<XMLSocket_as> >(fn);
     const std::string& str = fn.arg(0).to_string();
     ptr->send(str);
     return as_value();
@@ -504,8 +501,7 @@
 {
     GNASH_REPORT_FUNCTION;
     
-    XMLSocket_as* ptr =
-        ensureNativeType<XMLSocket_as>(fn.this_ptr);
+    XMLSocket_as* ptr = ensure<ThisIsNative<XMLSocket_as> >(fn);
 
     ptr->close();
     return as_value();

=== modified file 'libcore/asobj/flash/printing/PrintJob_as.cpp'
--- a/libcore/asobj/flash/printing/PrintJob_as.cpp      2009-08-20 08:57:16 
+0000
+++ b/libcore/asobj/flash/printing/PrintJob_as.cpp      2009-10-22 14:56:18 
+0000
@@ -90,8 +90,7 @@
 as_value
 printjob_send(const fn_call& fn)
 {
-    boost::intrusive_ptr<PrintJob_as> ptr =
-        ensureType<PrintJob_as>(fn.this_ptr);
+    PrintJob_as* ptr = ensure<ThisIs<PrintJob_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -100,8 +99,7 @@
 as_value
 printjob_start(const fn_call& fn)
 {
-    boost::intrusive_ptr<PrintJob_as> ptr =
-        ensureType<PrintJob_as>(fn.this_ptr);
+    PrintJob_as* ptr = ensure<ThisIs<PrintJob_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/sampler/StackFrame_as.cpp'
--- a/libcore/asobj/flash/sampler/StackFrame_as.cpp     2009-08-20 08:57:16 
+0000
+++ b/libcore/asobj/flash/sampler/StackFrame_as.cpp     2009-10-22 14:56:18 
+0000
@@ -93,8 +93,7 @@
 as_value
 stackframe_file(const fn_call& fn)
 {
-    boost::intrusive_ptr<StackFrame_as> ptr =
-        ensureType<StackFrame_as>(fn.this_ptr);
+    StackFrame_as* ptr = ensure<ThisIs<StackFrame_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -103,8 +102,7 @@
 as_value
 stackframe_line(const fn_call& fn)
 {
-    boost::intrusive_ptr<StackFrame_as> ptr =
-        ensureType<StackFrame_as>(fn.this_ptr);
+    StackFrame_as* ptr = ensure<ThisIs<StackFrame_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -113,8 +111,7 @@
 as_value
 stackframe_name(const fn_call& fn)
 {
-    boost::intrusive_ptr<StackFrame_as> ptr =
-        ensureType<StackFrame_as>(fn.this_ptr);
+    StackFrame_as* ptr = ensure<ThisIs<StackFrame_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/system/ApplicationDomain_as.cpp'
--- a/libcore/asobj/flash/system/ApplicationDomain_as.cpp       2009-08-20 
08:57:16 +0000
+++ b/libcore/asobj/flash/system/ApplicationDomain_as.cpp       2009-10-22 
14:56:18 +0000
@@ -88,8 +88,7 @@
 as_value
 applicationdomain_hasDefinition(const fn_call& fn)
 {
-    boost::intrusive_ptr<ApplicationDomain_as> ptr =
-        ensureType<ApplicationDomain_as>(fn.this_ptr);
+    ApplicationDomain_as* ptr = ensure<ThisIs<ApplicationDomain_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/system/IME_as.cpp'
--- a/libcore/asobj/flash/system/IME_as.cpp     2009-08-20 08:57:16 +0000
+++ b/libcore/asobj/flash/system/IME_as.cpp     2009-10-22 14:56:18 +0000
@@ -90,8 +90,7 @@
 as_value
 ime_setCompositionString(const fn_call& fn)
 {
-    boost::intrusive_ptr<IME_as> ptr =
-        ensureType<IME_as>(fn.this_ptr);
+    IME_as* ptr = ensure<ThisIs<IME_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -100,8 +99,7 @@
 as_value
 ime_imeComposition(const fn_call& fn)
 {
-    boost::intrusive_ptr<IME_as> ptr =
-        ensureType<IME_as>(fn.this_ptr);
+    IME_as* ptr = ensure<ThisIs<IME_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/system/Security_as.cpp'
--- a/libcore/asobj/flash/system/Security_as.cpp        2009-07-29 05:40:20 
+0000
+++ b/libcore/asobj/flash/system/Security_as.cpp        2009-10-22 14:56:18 
+0000
@@ -47,31 +47,18 @@
 
 }
 
-class Security_as : public as_object
-{
-
-public:
-
-    Security_as()
-        :
-        as_object(getSecurityInterface())
-    {}
-};
-
 // extern (used by Global.cpp)
-void security_class_init(as_object& where, const ObjectURI& uri)
+void
+security_class_init(as_object& where, const ObjectURI& uri)
 {
-    static boost::intrusive_ptr<as_object> cl;
-
-    if (!cl) {
-        Global_as* gl = getGlobal(where);
-        as_object* proto = getSecurityInterface();
-        cl = gl->createClass(&security_ctor, proto);
-        attachSecurityStaticInterface(*cl);
-    }
+    Global_as* gl = getGlobal(where);
+    as_object* proto = gl->createObject();
+    as_object* cl = gl->createClass(&security_ctor, proto);
+    attachSecurityStaticInterface(*cl);
+    attachSecurityInterface(*proto);
 
     // Register _global.Security
-    where.init_member(getName(uri), cl.get(), as_object::DefaultFlags,
+    where.init_member(getName(uri), cl, as_object::DefaultFlags,
             getNamespace(uri));
 }
 
@@ -95,83 +82,51 @@
 {
 }
 
-as_object*
-getSecurityInterface()
-{
-    static boost::intrusive_ptr<as_object> o;
-    if ( ! o ) {
-        o = new as_object();
-        attachSecurityInterface(*o);
-    }
-    return o.get();
-}
-
-as_value
-security_allowInsecureDomain(const fn_call& fn)
-{
-    boost::intrusive_ptr<Security_as> ptr =
-        ensureType<Security_as>(fn.this_ptr);
-    UNUSED(ptr);
-    log_unimpl (__FUNCTION__);
-    return as_value();
-}
-
-as_value
-security_loadPolicyFile(const fn_call& fn)
-{
-    boost::intrusive_ptr<Security_as> ptr =
-        ensureType<Security_as>(fn.this_ptr);
-    UNUSED(ptr);
-    log_unimpl (__FUNCTION__);
-    return as_value();
-}
-
-as_value
-security_showSettings(const fn_call& fn)
-{
-    boost::intrusive_ptr<Security_as> ptr =
-        ensureType<Security_as>(fn.this_ptr);
-    UNUSED(ptr);
-    log_unimpl (__FUNCTION__);
-    return as_value();
-}
-
-as_value
-security_LOCAL_TRUSTED(const fn_call& fn)
-{
-    boost::intrusive_ptr<Security_as> ptr =
-        ensureType<Security_as>(fn.this_ptr);
-    UNUSED(ptr);
-    log_unimpl (__FUNCTION__);
-    return as_value();
-}
-
-as_value
-security_LOCAL_WITH_FILE(const fn_call& fn)
-{
-    boost::intrusive_ptr<Security_as> ptr =
-        ensureType<Security_as>(fn.this_ptr);
-    UNUSED(ptr);
-    log_unimpl (__FUNCTION__);
-    return as_value();
-}
-
-as_value
-security_LOCAL_WITH_NETWORK(const fn_call& fn)
-{
-    boost::intrusive_ptr<Security_as> ptr =
-        ensureType<Security_as>(fn.this_ptr);
-    UNUSED(ptr);
-    log_unimpl (__FUNCTION__);
-    return as_value();
-}
-
-as_value
-security_REMOTE(const fn_call& fn)
-{
-    boost::intrusive_ptr<Security_as> ptr =
-        ensureType<Security_as>(fn.this_ptr);
-    UNUSED(ptr);
+as_value
+security_allowInsecureDomain(const fn_call& /*fn*/)
+{
+    log_unimpl (__FUNCTION__);
+    return as_value();
+}
+
+as_value
+security_loadPolicyFile(const fn_call& /*fn*/)
+{
+    log_unimpl (__FUNCTION__);
+    return as_value();
+}
+
+as_value
+security_showSettings(const fn_call&)
+{
+    log_unimpl (__FUNCTION__);
+    return as_value();
+}
+
+as_value
+security_LOCAL_TRUSTED(const fn_call&)
+{
+    log_unimpl (__FUNCTION__);
+    return as_value();
+}
+
+as_value
+security_LOCAL_WITH_FILE(const fn_call&)
+{
+    log_unimpl (__FUNCTION__);
+    return as_value();
+}
+
+as_value
+security_LOCAL_WITH_NETWORK(const fn_call&)
+{
+    log_unimpl (__FUNCTION__);
+    return as_value();
+}
+
+as_value
+security_REMOTE(const fn_call&)
+{
     log_unimpl (__FUNCTION__);
     return as_value();
 }
@@ -179,9 +134,7 @@
 as_value
 security_ctor(const fn_call& /*fn*/)
 {
-    boost::intrusive_ptr<as_object> obj = new Security_as;
-
-    return as_value(obj.get()); // will keep alive
+    return as_value(); 
 }
 
 } // anonymous namespace 

=== modified file 'libcore/asobj/flash/system/System_as.cpp'
--- a/libcore/asobj/flash/system/System_as.cpp  2009-08-27 06:50:57 +0000
+++ b/libcore/asobj/flash/system/System_as.cpp  2009-10-22 14:56:18 +0000
@@ -429,18 +429,15 @@
 as_value
 system_exactsettings(const fn_call& fn)
 {
-       boost::intrusive_ptr<as_object> obj = 
ensureType<as_object>(fn.this_ptr);
 
     // Getter
-    if (fn.nargs == 0)
-    {
+    if (fn.nargs == 0) {
         // Is always true until we implement it.
         return as_value(true);   
     }
     
     // Setter
-    else 
-    {
+    else {
         LOG_ONCE(log_unimpl ("System.exactSettings") );
         return as_value();
     }
@@ -453,9 +450,6 @@
 as_value
 system_usecodepage(const fn_call& fn)
 {
-       boost::intrusive_ptr<as_object> obj = 
-        ensureType<as_object>(fn.this_ptr);
-
     // Getter
     if (fn.nargs == 0)
     {

=== modified file 'libcore/asobj/flash/text/Font_as.cpp'
--- a/libcore/asobj/flash/text/Font_as.cpp      2009-08-20 08:57:16 +0000
+++ b/libcore/asobj/flash/text/Font_as.cpp      2009-10-22 14:56:18 +0000
@@ -90,8 +90,7 @@
 as_value
 font_hasGlyphs(const fn_call& fn)
 {
-    boost::intrusive_ptr<Font_as> ptr =
-        ensureType<Font_as>(fn.this_ptr);
+    Font_as* ptr = ensure<ThisIs<Font_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -100,8 +99,7 @@
 as_value
 font_registerFont(const fn_call& fn)
 {
-    boost::intrusive_ptr<Font_as> ptr =
-        ensureType<Font_as>(fn.this_ptr);
+    Font_as* ptr = ensure<ThisIs<Font_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/text/StyleSheet_as.cpp'
--- a/libcore/asobj/flash/text/StyleSheet_as.cpp        2009-07-29 05:40:20 
+0000
+++ b/libcore/asobj/flash/text/StyleSheet_as.cpp        2009-10-22 14:56:18 
+0000
@@ -103,8 +103,7 @@
 as_value
 stylesheet_getStyle(const fn_call& fn)
 {
-    boost::intrusive_ptr<StyleSheet_as> ptr =
-        ensureType<StyleSheet_as>(fn.this_ptr);
+    StyleSheet_as* ptr = ensure<ThisIs<StyleSheet_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -113,8 +112,7 @@
 as_value
 stylesheet_parseCSS(const fn_call& fn)
 {
-    boost::intrusive_ptr<StyleSheet_as> ptr =
-        ensureType<StyleSheet_as>(fn.this_ptr);
+    StyleSheet_as* ptr = ensure<ThisIs<StyleSheet_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -123,8 +121,7 @@
 as_value
 stylesheet_setStyle(const fn_call& fn)
 {
-    boost::intrusive_ptr<StyleSheet_as> ptr =
-        ensureType<StyleSheet_as>(fn.this_ptr);
+    StyleSheet_as* ptr = ensure<ThisIs<StyleSheet_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
@@ -133,8 +130,7 @@
 as_value
 stylesheet_transform(const fn_call& fn)
 {
-    boost::intrusive_ptr<StyleSheet_as> ptr =
-        ensureType<StyleSheet_as>(fn.this_ptr);
+    StyleSheet_as* ptr = ensure<ThisIs<StyleSheet_as> >(fn);
     UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();

=== modified file 'libcore/asobj/flash/text/TextSnapshot_as.cpp'
--- a/libcore/asobj/flash/text/TextSnapshot_as.cpp      2009-10-21 13:16:25 
+0000
+++ b/libcore/asobj/flash/text/TextSnapshot_as.cpp      2009-10-22 14:56:18 
+0000
@@ -501,7 +501,7 @@
 as_value
 textsnapshot_getTextRunInfo(const fn_call& fn)
 {
-    TextSnapshot_as* ts = ensureNativeType<TextSnapshot_as>(fn.this_ptr);
+    TextSnapshot_as* ts = ensure<ThisIsNative<TextSnapshot_as> >(fn);
     
     if (!ts->valid()) return as_value();
 
@@ -523,7 +523,7 @@
 as_value
 textsnapshot_findText(const fn_call& fn)
 {
-    TextSnapshot_as* ts = ensureNativeType<TextSnapshot_as>(fn.this_ptr);
+    TextSnapshot_as* ts = ensure<ThisIsNative<TextSnapshot_as> >(fn);
     
     if (!ts->valid()) return as_value();
 
@@ -547,7 +547,7 @@
 as_value
 textsnapshot_getCount(const fn_call& fn)
 {
-    TextSnapshot_as* ts = ensureNativeType<TextSnapshot_as>(fn.this_ptr);
+    TextSnapshot_as* ts = ensure<ThisIsNative<TextSnapshot_as> >(fn);
     
     if (!ts->valid()) return as_value();
 
@@ -565,7 +565,7 @@
 as_value
 textsnapshot_getSelected(const fn_call& fn)
 {
-    TextSnapshot_as* ts = ensureNativeType<TextSnapshot_as>(fn.this_ptr);
+    TextSnapshot_as* ts = ensure<ThisIsNative<TextSnapshot_as> >(fn);
 
     if (!ts->valid()) return as_value();
 
@@ -583,7 +583,7 @@
 as_value
 textsnapshot_getSelectedText(const fn_call& fn)
 {
-    TextSnapshot_as* ts = ensureNativeType<TextSnapshot_as>(fn.this_ptr);
+    TextSnapshot_as* ts = ensure<ThisIsNative<TextSnapshot_as> >(fn);
 
     if (!ts->valid()) return as_value();
 
@@ -600,7 +600,7 @@
 as_value
 textsnapshot_getText(const fn_call& fn)
 {
-    TextSnapshot_as* ts = ensureNativeType<TextSnapshot_as>(fn.this_ptr);
+    TextSnapshot_as* ts = ensure<ThisIsNative<TextSnapshot_as> >(fn);
 
     if (!ts->valid()) return as_value();
     
@@ -626,7 +626,7 @@
 as_value
 textsnapshot_hitTestTextNearPos(const fn_call& fn)
 {
-    TextSnapshot_as* ts = ensureNativeType<TextSnapshot_as>(fn.this_ptr);
+    TextSnapshot_as* ts = ensure<ThisIsNative<TextSnapshot_as> >(fn);
 
     if (!ts->valid()) return as_value();
 
@@ -639,7 +639,7 @@
 textsnapshot_setSelectColor(const fn_call& fn)
 {
 
-    TextSnapshot_as* ts = ensureNativeType<TextSnapshot_as>(fn.this_ptr);
+    TextSnapshot_as* ts = ensure<ThisIsNative<TextSnapshot_as> >(fn);
     UNUSED(ts);
 
     log_unimpl (__FUNCTION__);
@@ -651,7 +651,7 @@
 as_value
 textsnapshot_setSelected(const fn_call& fn)
 {
-    TextSnapshot_as* ts = ensureNativeType<TextSnapshot_as>(fn.this_ptr);
+    TextSnapshot_as* ts = ensure<ThisIsNative<TextSnapshot_as> >(fn);
 
     if (fn.nargs < 2 || fn.nargs > 3) {
         return as_value();
@@ -670,7 +670,7 @@
 as_value
 textsnapshot_ctor(const fn_call& fn)
 {
-    as_object* ptr = ensureType<as_object>(fn.this_ptr);
+    as_object* ptr = ensure<ValidThis>(fn);
 
     MovieClip* mc = (fn.nargs == 1) ? fn.arg(0).to_sprite() : 0;
 

=== modified file 'libcore/asobj/flash/ui/ContextMenuItem_as.cpp'
--- a/libcore/asobj/flash/ui/ContextMenuItem_as.cpp     2009-08-20 08:57:16 
+0000
+++ b/libcore/asobj/flash/ui/ContextMenuItem_as.cpp     2009-10-22 14:56:18 
+0000
@@ -63,7 +63,7 @@
 as_value
 contextmenuitem_copy(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     Global_as* gl = getGlobal(fn);
     string_table& st = getStringTable(fn);

=== modified file 'libcore/asobj/flash/ui/ContextMenu_as.cpp'
--- a/libcore/asobj/flash/ui/ContextMenu_as.cpp 2009-10-14 14:50:52 +0000
+++ b/libcore/asobj/flash/ui/ContextMenu_as.cpp 2009-10-22 14:56:18 +0000
@@ -88,7 +88,7 @@
 as_value
 contextmenu_hideBuiltInItems(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
     string_table& st = getStringTable(fn);
 
     Global_as* gl = getGlobal(fn);
@@ -101,7 +101,7 @@
 as_value
 contextmenu_copy(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
     Global_as* gl = getGlobal(fn);
 

=== modified file 'libcore/asobj/flash/ui/Keyboard_as.cpp'
--- a/libcore/asobj/flash/ui/Keyboard_as.cpp    2009-08-20 10:19:21 +0000
+++ b/libcore/asobj/flash/ui/Keyboard_as.cpp    2009-10-22 14:56:18 +0000
@@ -134,10 +134,8 @@
 as_value
 key_is_accessible(const fn_call& fn)
 {
-
-    boost::intrusive_ptr<Keyboard_as> ko = 
-        ensureType<Keyboard_as>(fn.this_ptr);
-
+    Keyboard_as* ptr = ensure<ThisIs<Keyboard_as> >(fn);
+    UNUSED(ptr);
     log_unimpl("Key.isAccessible");
     return as_value();
 }
@@ -147,8 +145,7 @@
 as_value   
 key_get_ascii(const fn_call& fn)
 {
-    boost::intrusive_ptr<Keyboard_as> ko = 
-        ensureType<Keyboard_as>(fn.this_ptr);
+    Keyboard_as* ko = ensure<ThisIs<Keyboard_as> >(fn);
 
     int code = ko->get_last_key();
 
@@ -159,8 +156,7 @@
 as_value   
 key_get_code(const fn_call& fn)
 {
-    boost::intrusive_ptr<Keyboard_as> ko = 
-        ensureType<Keyboard_as>(fn.this_ptr);
+    Keyboard_as* ko = ensure<ThisIs<Keyboard_as> >(fn);
 
     int code = ko->get_last_key();
 
@@ -171,8 +167,7 @@
 as_value   
 key_is_down(const fn_call& fn)
 {
-    boost::intrusive_ptr<Keyboard_as> ko = 
-        ensureType<Keyboard_as>(fn.this_ptr);
+    Keyboard_as* ko = ensure<ThisIs<Keyboard_as> >(fn);
 
     if (fn.nargs < 1)
     {

=== modified file 'libcore/asobj/flash/xml/XMLDocument_as.cpp'
--- a/libcore/asobj/flash/xml/XMLDocument_as.cpp        2009-10-14 08:47:08 
+0000
+++ b/libcore/asobj/flash/xml/XMLDocument_as.cpp        2009-10-22 14:56:18 
+0000
@@ -693,8 +693,7 @@
 as_value
 xml_loaded(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLDocument_as> ptr =
-        ensureType<XMLDocument_as>(fn.this_ptr);
+    XMLDocument_as* ptr = ensure<ThisIs<XMLDocument_as> >(fn);
 
     if (!fn.nargs) {
         XMLDocument_as::LoadStatus ls = ptr->loaded();
@@ -709,8 +708,7 @@
 as_value
 xml_status(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLDocument_as> ptr =
-        ensureType<XMLDocument_as>(fn.this_ptr);
+    XMLDocument_as* ptr = ensure<ThisIs<XMLDocument_as> >(fn);
     
     if (!fn.nargs) {
         return as_value(ptr->status());
@@ -799,7 +797,7 @@
 xml_parseXML(const fn_call& fn)
 {
 
-    boost::intrusive_ptr<XMLDocument_as> ptr = 
ensureType<XMLDocument_as>(fn.this_ptr);
+    XMLDocument_as* ptr = ensure<ThisIs<XMLDocument_as> >(fn);
 
     if (fn.nargs < 1)
     {
@@ -818,8 +816,7 @@
 as_value
 xml_xmlDecl(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLDocument_as> ptr =
-        ensureType<XMLDocument_as>(fn.this_ptr);
+    XMLDocument_as* ptr = ensure<ThisIs<XMLDocument_as> >(fn);
 
     if (!fn.nargs)
     {
@@ -841,7 +838,7 @@
 as_value
 xml_docTypeDecl(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLDocument_as> ptr = 
ensureType<XMLDocument_as>(fn.this_ptr);
+    XMLDocument_as* ptr = ensure<ThisIs<XMLDocument_as> >(fn);
 
     if (!fn.nargs)
     {

=== modified file 'libcore/asobj/flash/xml/XMLNode_as.cpp'
--- a/libcore/asobj/flash/xml/XMLNode_as.cpp    2009-10-14 14:50:52 +0000
+++ b/libcore/asobj/flash/xml/XMLNode_as.cpp    2009-10-22 14:56:18 +0000
@@ -526,7 +526,7 @@
 {
 //    GNASH_REPORT_FUNCTION;
 
-       boost::intrusive_ptr<XMLNode_as> ptr = 
ensureType<XMLNode_as>(fn.this_ptr);
+       boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
 
        if ( ! fn.nargs )
        {
@@ -556,7 +556,7 @@
 as_value
 xmlnode_cloneNode(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
 
     bool deep = false;
     if (fn.nargs > 0) deep = fn.arg(0).to_bool();
@@ -569,7 +569,7 @@
 as_value
 xmlnode_insertBefore(const fn_call& fn)
 {
-       boost::intrusive_ptr<XMLNode_as> ptr = 
ensureType<XMLNode_as>(fn.this_ptr);
+       boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
 
        if ( fn.nargs < 2 )
        {
@@ -614,7 +614,7 @@
 as_value
 xmlnode_getNamespaceForPrefix(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
     if (!fn.nargs) {
         return as_value();
     }
@@ -630,7 +630,7 @@
 as_value
 xmlnode_getPrefixForNamespace(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
     if (!fn.nargs) {
         return as_value();
     }
@@ -657,7 +657,7 @@
 as_value
 xmlnode_namespaceURI(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
 
     // Read-only property
     
@@ -694,7 +694,7 @@
 as_value
 xmlnode_prefix(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
 
     // Read-only property
     
@@ -716,7 +716,7 @@
 as_value
 xmlnode_localName(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
 
     // Read-only property
     
@@ -741,7 +741,7 @@
 as_value
 xmlnode_removeNode(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
     
     ptr->removeNode();
     return as_value();
@@ -753,7 +753,7 @@
 {
     //GNASH_REPORT_FUNCTION;
     
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
     
     std::stringstream ss;
     ptr->toString(ss);
@@ -765,7 +765,7 @@
 as_value
 xmlnode_hasChildNodes(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
     return as_value(ptr->hasChildNodes());
 }
 
@@ -773,7 +773,7 @@
 as_value
 xmlnode_nodeValue(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
     as_value rv;
     rv.set_null();
     
@@ -793,7 +793,7 @@
 as_value
 xmlnode_nodeName(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
     as_value rv;
     rv.set_null();
 
@@ -812,7 +812,7 @@
 as_value
 xmlnode_nodeType(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
     return as_value(ptr->nodeType());
 }
 
@@ -820,7 +820,7 @@
 as_value
 xmlnode_attributes(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
 
     as_object* attrs = ptr->getAttributes();
     if (attrs) return as_value(attrs);
@@ -839,7 +839,7 @@
 as_value
 xmlnode_firstChild(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
     as_value rv;
     rv.set_null();
 
@@ -861,7 +861,7 @@
 as_value
 xmlnode_lastChild(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
     as_value rv;
     rv.set_null();
 
@@ -878,7 +878,7 @@
     as_value rv;
     rv.set_null();
 
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
     XMLNode_as *node = ptr->nextSibling();
     if (node) {
        rv = node;
@@ -893,7 +893,7 @@
     as_value rv;
     rv.set_null();
 
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
     XMLNode_as *node = ptr->previousSibling();
     if (node) {
        rv = node;
@@ -908,7 +908,7 @@
     as_value rv;
     rv.set_null();
 
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
     XMLNode_as *node = ptr->getParent();
     if (node) {
        rv = node;
@@ -920,7 +920,7 @@
 as_value
 xmlnode_childNodes(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
  
     Global_as* gl = getGlobal(fn);
     as_object* ary = gl->createArray();

=== modified file 'libcore/asobj/gen-asclass.pl'
--- a/libcore/asobj/gen-asclass.pl      2009-02-25 22:33:03 +0000
+++ b/libcore/asobj/gen-asclass.pl      2009-10-22 14:56:18 +0000
@@ -126,7 +126,7 @@
           qq|\nstatic as_value\n$args{lc}_| .$m.
           qq|(const fn_call& fn)
 {
-       boost::intrusive_ptr<$args{lc}_as> ptr = 
ensureType<$args{lc}_as>(fn.this_ptr);
+       boost::intrusive_ptr<$args{lc}_as> ptr = ensure<ThisIs<$args{lc}_as> 
>(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -158,7 +158,7 @@
           qq|\nstatic as_value\n$args{lc}_| .$m.
           qq|(const fn_call& fn)
 {
-       boost::intrusive_ptr<$args{lc}_as> ptr = 
ensureType<$args{lc}_as>(fn.this_ptr);
+       boost::intrusive_ptr<$args{lc}_as> ptr = ensure<ThisIs<$args{lc}_as> 
>(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -189,7 +189,7 @@
           qq|\nstatic as_value\n$args{lc}_| .$p. "_getset" .
           qq|(const fn_call& fn)
 {
-       boost::intrusive_ptr<$args{lc}_as> ptr = 
ensureType<$args{lc}_as>(fn.this_ptr);
+       boost::intrusive_ptr<$args{lc}_as> ptr = ensure<ThisIs<$args{lc}_as> 
>(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();
@@ -220,7 +220,7 @@
           qq|\nstatic as_value\n$args{lc}_| .$p. "_getset" .
           qq|(const fn_call& fn)
 {
-       boost::intrusive_ptr<$args{lc}_as> ptr = 
ensureType<$args{lc}_as>(fn.this_ptr);
+       boost::intrusive_ptr<$args{lc}_as> ptr = ensure<ThisIs<$args{lc}_as> 
>(fn);
        UNUSED(ptr);
        LOG_ONCE( log_unimpl (__FUNCTION__) );
        return as_value();

=== modified file 'libcore/vm/fn_call.h'
--- a/libcore/vm/fn_call.h      2009-08-20 06:55:15 +0000
+++ b/libcore/vm/fn_call.h      2009-10-22 14:56:18 +0000
@@ -263,6 +263,81 @@
 
 };
 
+
+/// Check that the 'this' pointer is a particular type
+//
+/// NB: this function and is deprecated.
+template<typename T>
+struct ThisIs
+{
+    typedef T value_type;
+    value_type* operator()(as_object* o) const {
+        return dynamic_cast<value_type*>(o);
+    }
+};
+
+
+/// Check that the 'this' pointer has a particular native type ('Relay').
+//
+/// This is the most likely of the cases to reflect AS behaviour.
+template<typename T>
+struct ThisIsNative
+{
+    typedef T value_type;
+    value_type* operator()(as_object* o) const {
+        return dynamic_cast<value_type*>(o->relay());
+    }
+};
+
+
+/// Check that the 'this' pointer is not null.
+struct ValidThis
+{
+    typedef as_object value_type;
+    value_type* operator()(as_object* o) const {
+        return o;
+    }
+};
+
+/// Templated function to check the validity of a function call.
+//
+/// It throws an exception if the condition is not fulfilled, it throws
+/// an ActionTypeError, resulting in the function call being aborted and
+/// an undefined as_value returned.
+//
+/// Note that not carrying out a function because the this pointer is
+/// undefined is not ActionScript behaviour in most cases. To avoid
+/// spreading its usage outside AS function implementations, this function
+/// now takes a fn_call as an argument.
+//
+/// @tparam T       A struct defining a value_type and an operator() that
+///                 checks the as_object's validity. A pointer to the
+///                 value_type is returned on success, an exception thrown
+///                 on failure.
+/// @param fn       The function whose 'this' pointer should be checked.
+/// @return         If the cast succeeds, the pointer cast to the
+///                 requested type.
+template<typename T>
+typename T::value_type*
+ensure(const fn_call& fn)
+{
+    as_object* obj = fn.this_ptr;
+    if (!obj) throw ActionTypeError();
+
+    typename T::value_type* ret = T()(obj);
+
+    if (!ret) {
+        std::string target = typeName(ret);
+        std::string source = typeName(obj);
+
+        std::string msg = "Function requiring " + target + " as 'this' "
+            "called from " + source + " instance.";
+
+        throw ActionTypeError(msg);
+    }
+    return ret;
+}
+
 /// Check whether the currently executing code is AS3 (ABC)
 //
 /// This is a non-member, non-friend function for better encapsulation.

=== modified file 'testsuite/actionscript.all/TextField.as'
--- a/testsuite/actionscript.all/TextField.as   2009-10-22 11:45:14 +0000
+++ b/testsuite/actionscript.all/TextField.as   2009-10-22 15:41:38 +0000
@@ -1210,7 +1210,7 @@
 
   // It is no longer an array.
   this[2] = 3;
-  xcheck_equals(this.length, 0);
+  check_equals(this.length, 0);
   check_equals(this[2], 3);
 
   this.__proto__.__constructor__ = Date;
@@ -1220,7 +1220,7 @@
 
   this.__proto__.__constructor__ = TextField;
   super();
-  xcheck_equals(typeof(this.getTime()), "undefined");
+  check_equals(typeof(this.getTime()), "undefined");
 
 };
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]