see attached testcase, not commited yet.
--zou
On 10/12/07, zou lunkai <[EMAIL PROTECTED]> wrote:
> > I belive swf_function should *always* use the caller's environment.
>
> what's definition of as_environment in Gnash? Apparently it's more
> than a VM stack.
>
> Let's talk about the 'target' first.
>
> (1) if the target in which the swf_function is defined is not
> destroyed, then it is the target of this swf_function.
> (2) if the target is destroyed, then the caller's target is used as
> this swf_function.
>
> That's what I intended to do with the commit, fixed a few focused
> local tests, but triggered some other failures in our
> testsuite(MovieClip.as).
>
> --zou
>
>
>
>
> On 10/12/07, strk <[EMAIL PROTECTED]> wrote:
> > On Fri, Oct 12, 2007 at 07:51:30AM +0000, Zou Lunkai wrote:
> > > CVSROOT: /sources/gnash
> > > Module name: gnash
> > > Changes by: Zou Lunkai <zoulunkai> 07/10/12 07:51:30
> > >
> > > Modified files:
> > > . : ChangeLog
> > > server : swf_function.cpp
> > >
> > > Log message:
> > > * server/swf_function.cpp: use the caller's environment when the
> > > original
> > > target is destroyed.
> >
> > I belive swf_function should *always* use the caller's environment.
> > ActionExec, in it's turn, should initialize the scope stack to contain
> > the target of as_environment for global action code. If this wouldn't
> > currently work is due to the fact we keep togheter 'with' stack and 'scope'
> > stack
> > resulting in 'scope' stack taking precedence over locals.
> >
> > --strk;
> >
>
/*
* Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/*
* Zou Lunkai, [EMAIL PROTECTED]
*/
#include <stdlib.h>
#include <stdio.h>
#include <ming.h>
#include "ming_utils.h"
#define OUTPUT_VERSION 6
#define OUTPUT_FILENAME "_target_in_function1.swf"
int
main(int argc, char** argv)
{
SWFMovie mo;
SWFMovieClip mc1, mc2, mc3, dejagnuclip;
SWFDisplayItem it1, it2, it3;
const char *srcdir=".";
if ( argc>1 )
srcdir=argv[1];
else
{
fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
return 1;
}
Ming_init();
mo = newSWFMovieWithVersion(OUTPUT_VERSION);
SWFMovie_setDimension(mo, 800, 600);
SWFMovie_setRate (mo, 1);
dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0,
800, 600);
SWFMovie_add(mo, (SWFBlock)dejagnuclip);
SWFMovie_nextFrame(mo); // 1st frame
mc1 = newSWFMovieClip();
add_clip_actions(mc1,
" testvar = 'mc1_var'; "
" _root.check_equals(_root.mc1.testvar, 'mc1_var'); "
" func = function () {"
"_root.check_equals(this, _root.mc2);"
"asm{"
"push 'checkpoint' "
"push '' "
"push 11 " //_target
"getproperty "
"setvariable "
"}; "
" _root.check_equals(checkpoint, '/mc1'); " //check current target
" _root.check_equals(testvar, 'mc1_var');"
"};");
SWFMovieClip_nextFrame(mc1);
mc2 = newSWFMovieClip();
add_clip_actions(mc2,
" func2 = _root.mc1.func;"
" func2();"
" stop(); ");
SWFMovieClip_nextFrame(mc2);
it1 = SWFMovie_add(mo, (SWFBlock)mc1);
SWFDisplayItem_setDepth(it1, 10);
SWFDisplayItem_setName(it1, "mc1");
it2 = SWFMovie_add(mo, (SWFBlock)mc2);
SWFDisplayItem_setDepth(it2, 20);
SWFDisplayItem_setName(it2, "mc2");
SWFMovie_nextFrame(mo); //2nd frame
add_actions(mo, "totals(); stop();");
SWFMovie_nextFrame(mo); //3rd frame
//Output movie
puts("Saving " OUTPUT_FILENAME );
SWFMovie_save(mo, OUTPUT_FILENAME);
return 0;
}
/*
* Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/*
* Zou Lunkai, [EMAIL PROTECTED]
*/
#include <stdlib.h>
#include <stdio.h>
#include <ming.h>
#include "ming_utils.h"
#define OUTPUT_VERSION 6
#define OUTPUT_FILENAME "_target_in_function2.swf"
int
main(int argc, char** argv)
{
SWFMovie mo;
SWFMovieClip mc1, mc2, mc3, dejagnuclip;
SWFDisplayItem it1, it2, it3;
const char *srcdir=".";
if ( argc>1 )
srcdir=argv[1];
else
{
fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
return 1;
}
Ming_init();
mo = newSWFMovieWithVersion(OUTPUT_VERSION);
SWFMovie_setDimension(mo, 800, 600);
SWFMovie_setRate (mo, 1);
dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0,
800, 600);
SWFMovie_add(mo, (SWFBlock)dejagnuclip);
SWFMovie_nextFrame(mo); // 1st frame
mc1 = newSWFMovieClip();
add_clip_actions(mc1,
" testvar = 'mc1_var'; "
" _root.check_equals(_root.mc1.testvar, 'mc1_var'); "
" func = function () {"
"_root.check_equals(this, _root.mc2);"
"asm{"
"push 'checkpoint' "
"push '' "
"push 11 " //_target
"getproperty "
"setvariable "
"}; "
"_root.check_equals(checkpoint, '/mc2'); "
"_root.check_equals(testvar, 'mc2_var'); "
"};");
SWFMovieClip_nextFrame(mc1);
mc2 = newSWFMovieClip();
add_clip_actions(mc2,
" func2 = _root.mc1.func; "
" testvar = 'mc2_var'; "
" _root.check_equals(_root.mc2.testvar, 'mc2_var'); ");
SWFMovieClip_nextFrame(mc2); // 1st frame of mc2
SWFMovieClip_nextFrame(mc2); // 2nd frame of mc2
add_clip_actions(mc2, " func2(); stop(); ");
SWFMovieClip_nextFrame(mc2); // 3rd frame of mc2
it1 = SWFMovie_add(mo, (SWFBlock)mc1);
SWFDisplayItem_setDepth(it1, 10);
SWFDisplayItem_setName(it1, "mc1");
it2 = SWFMovie_add(mo, (SWFBlock)mc2);
SWFDisplayItem_setDepth(it2, 20);
SWFDisplayItem_setName(it2, "mc2");
SWFMovie_nextFrame(mo); //2nd frame
SWFDisplayItem_remove(it1);
SWFMovie_nextFrame(mo); //3rd frame
check_equals(mo, "mc1", "undefined");
check_equals(mo, "typeof(mc2)", "'movieclip'");
SWFMovie_nextFrame(mo); //3rd frame
add_actions(mo, "totals(); stop();");
SWFMovie_nextFrame(mo);
//Output movie
puts("Saving " OUTPUT_FILENAME );
SWFMovie_save(mo, OUTPUT_FILENAME);
return 0;
}
_______________________________________________
Gnash-commit mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnash-commit