Skip to content

Commit

Permalink
Stubbed Bitmap and Font
Browse files Browse the repository at this point in the history
  • Loading branch information
alexp-sssup committed Feb 13, 2010
1 parent 922fbc9 commit 041d187
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 28 deletions.
3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -12,7 +12,8 @@ datadir = $(datarootdir)

LIBOBJS = swf.o swftypes.o tags.o geometry.o actions.o frame.o input.o streams.o tags_stub.o logger.o vm.o \
asobjects.o abc.o abc_codesynt.o abc_opcodes.o flashdisplay.o flashevents.o textfile.o thread_pool.o \
flashgeom.o flashnet.o flashsystem.o flashutils.o compat.o abc_interpreter.o flashexternal.o
flashgeom.o flashnet.o flashsystem.o flashutils.o compat.o abc_interpreter.o flashexternal.o \
flashtext.o

# TODO: library?
all: lightspark tightspark
Expand Down
2 changes: 2 additions & 0 deletions abc.cpp
Expand Up @@ -160,12 +160,14 @@ void ABCVm::registerClasses()
Global.setVariableByQName("StageAlign","flash.display",Class<StageAlign>::getClass());
Global.setVariableByQName("IBitmapDrawable","flash.display",Class<IInterface>::getClass("IBitmapDrawable"));
Global.setVariableByQName("BitmapData","flash.display",Class<IInterface>::getClass("BitmapData"));
Global.setVariableByQName("Bitmap","flash.display",Class<Bitmap>::getClass());

Global.setVariableByQName("DropShadowFilter","flash.filters",Class<IInterface>::getClass("DropShadowFilter"));

Global.setVariableByQName("TextField","flash.text",Class<IInterface>::getClass("TextField"));
Global.setVariableByQName("TextFormat","flash.text",Class<IInterface>::getClass("TextFormat"));
Global.setVariableByQName("TextFieldType","flash.text",Class<IInterface>::getClass("TextFieldType"));
Global.setVariableByQName("Font","flash.text",Class<Font>::getClass());

Global.setVariableByQName("XMLDocument","flash.xml",new ASObject);

Expand Down
33 changes: 14 additions & 19 deletions abc_interpreter.cpp
Expand Up @@ -731,14 +731,6 @@ ASObject* ABCVm::executeFunction(SyntheticFunction* function, call_context* cont
static_stack_push(static_stack,stack_entry(value,STACK_OBJECT));
break;
}
case 0x20:
{
//pushnull
LOG(LOG_TRACE, "synt pushnull" );
value=Builder.CreateCall(ex->FindFunctionNamed("pushNull"));
static_stack_push(static_stack,stack_entry(value,STACK_OBJECT));
break;
}
case 0x21:
{
//pushundefined
Expand Down Expand Up @@ -1129,17 +1121,6 @@ ASObject* ABCVm::executeFunction(SyntheticFunction* function, call_context* cont
static_stack_push(static_stack,stack_entry(value,STACK_OBJECT));
break;
}
case 0x58:
{
//newclass
LOG(LOG_TRACE, "synt newclass" );
syncStacks(ex,Builder,static_stack,dynamic_stack,dynamic_stack_index);
u30 t;
code2 >> t;
constant = llvm::ConstantInt::get(int_type, t);
Builder.CreateCall2(ex->FindFunctionNamed("newClass"), context, constant);
break;
}
case 0x59:
{
//getdescendants
Expand Down Expand Up @@ -2180,12 +2161,26 @@ ASObject* ABCVm::executeFunction(SyntheticFunction* function, call_context* cont
code2 >> t;
break;
}*/
case 0x20:
{
//pushnull
context->runtime_stack_push(new Null);
break;
}
case 0x30:
{
//pushscope
pushScope(context);
break;
}
case 0x58:
{
//newclass
u30 t;
code >> t;
newClass(context,t);
break;
}
case 0x65:
{
//getscopeobject
Expand Down
8 changes: 7 additions & 1 deletion asobjects.cpp
Expand Up @@ -1216,6 +1216,7 @@ void RegExp::buildTraits(ASObject* o)
{
o->setVariableByQName("exec",AS3,new Function(exec));
o->setVariableByQName("test",AS3,new Function(test));
o->setGetterByQName("global","",new Function(_getGlobal));
}

ASFUNCTIONBODY(RegExp,_constructor)
Expand Down Expand Up @@ -1245,10 +1246,15 @@ ASFUNCTIONBODY(RegExp,_constructor)
return NULL;
}

ASFUNCTIONBODY(RegExp,_getGlobal)
{
RegExp* th=static_cast<RegExp*>(obj->implementation);
return abstract_b(th->global);
}

ASFUNCTIONBODY(RegExp,exec)
{
RegExp* th=static_cast<RegExp*>(obj->implementation);
// assert(th->global);
pcrecpp::RE_Options opt;
opt.set_caseless(th->ignoreCase);

Expand Down
1 change: 1 addition & 0 deletions asobjects.h
Expand Up @@ -734,6 +734,7 @@ friend class ASString;
ASFUNCTION(_constructor);
ASFUNCTION(exec);
ASFUNCTION(test);
ASFUNCTION(_getGlobal);
};

};
Expand Down
12 changes: 9 additions & 3 deletions flashdisplay.cpp
Expand Up @@ -51,6 +51,7 @@ REGISTER_CLASS_NAME(Graphics);
REGISTER_CLASS_NAME(LineScaleMode);
REGISTER_CLASS_NAME(StageScaleMode);
REGISTER_CLASS_NAME(StageAlign);
REGISTER_CLASS_NAME(Bitmap);

void LoaderInfo::sinit(Class_base* c)
{
Expand Down Expand Up @@ -811,9 +812,6 @@ void DisplayObjectContainer::_addChildAt(DisplayObject* child, int index)
//The HACK for this supports only Sprites now
assert(child->obj->prototype->isSubClass(Class<Sprite>::getClass()));

// if(child->obj->prototype->class_name=="BorderSkin")
// abort();

//If the child has no parent, set this container to parent
//If there is a previous parent, purge the child from his list
if(child->parent)
Expand Down Expand Up @@ -1105,3 +1103,11 @@ void StageAlign::sinit(Class_base* c)
{
c->setVariableByQName("TOP_LEFT","",Class<ASString>::getInstanceS(true,"TL")->obj);
}

void Bitmap::sinit(Class_base* c)
{
assert(c->constructor==NULL);
// c->constructor=new Function(_constructor);
c->super=Class<DisplayObject>::getClass();
c->max_level=c->super->max_level+1;
}
6 changes: 6 additions & 0 deletions flashdisplay.h
Expand Up @@ -309,6 +309,12 @@ class LineScaleMode: public IInterface
static void sinit(Class_base* c);
};

class Bitmap: public DisplayObject
{
public:
static void sinit(Class_base* c);
};

};

#endif
32 changes: 32 additions & 0 deletions flashtext.cpp
@@ -0,0 +1,32 @@
/**************************************************************************
Lightspark, a free flash player implementation
Copyright (C) 2009 Alessandro Pignotti (a.pignotti@sssup.it)
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, see <http://www.gnu.org/licenses/>.
**************************************************************************/

#include "flashtext.h"
#include "class.h"

using namespace std;
using namespace lightspark;

REGISTER_CLASS_NAME2(lightspark::Font,"Font");

void lightspark::Font::sinit(Class_base* c)
{
assert(c->constructor==NULL);
// c->constructor=new Function(_constructor);
}
7 changes: 5 additions & 2 deletions flashtext.h
Expand Up @@ -24,11 +24,14 @@

namespace lightspark
{
class ASFont: public ASObject

class Font: public IInterface
{
public:
ASFont(){}
static void sinit(Class_base* c);
// static void buildTraits(ASObject* o);
};

};

#endif
4 changes: 2 additions & 2 deletions tags.h
Expand Up @@ -413,7 +413,7 @@ class DefineBinaryDataTag: public DictionaryTag, public ByteArray
virtual int getId(){return Tag;}
};

class FontTag: public DictionaryTag, public ASFont
class FontTag: public DictionaryTag
{
protected:
UI16 FontID;
Expand Down Expand Up @@ -555,7 +555,7 @@ class DefineBitsJPEG2Tag: public Tag
DefineBitsJPEG2Tag(RECORDHEADER h, std::istream& in);
};

class DefineBitsLossless2Tag: public DictionaryTag, public ASObject
class DefineBitsLossless2Tag: public DictionaryTag, public Bitmap
{
private:
UI16 CharacterId;
Expand Down

0 comments on commit 041d187

Please sign in to comment.