Skip to content

Commit

Permalink
Stubbed XMLDocument
Browse files Browse the repository at this point in the history
  • Loading branch information
alexp-sssup committed May 5, 2010
1 parent 63fc32c commit 8f318b3
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -71,7 +71,7 @@ IF(NOT CMAKE_BUILD_TYPE)
ENDIF()


SET(LIBSPARK_SOURCES swf.cpp swftypes.cpp tags.cpp geometry.cpp actions.cpp frame.cpp input.cpp streams.cpp tags_stub.cpp logger.cpp vm.cpp asobjects.cpp abc.cpp abc_codesynt.cpp abc_opcodes.cpp flashdisplay.cpp flashevents.cpp textfile.cpp thread_pool.cpp flashgeom.cpp flashnet.cpp flashsystem.cpp flashutils.cpp compat.cpp abc_interpreter.cpp flashexternal.cpp flashtext.cpp flashmedia.cpp flv.cpp netutils.cpp timer.cpp decoder.cpp threading.cpp)
SET(LIBSPARK_SOURCES swf.cpp swftypes.cpp tags.cpp geometry.cpp actions.cpp frame.cpp input.cpp streams.cpp tags_stub.cpp logger.cpp vm.cpp asobjects.cpp abc.cpp abc_codesynt.cpp abc_opcodes.cpp flashdisplay.cpp flashevents.cpp textfile.cpp thread_pool.cpp flashgeom.cpp flashnet.cpp flashsystem.cpp flashutils.cpp compat.cpp abc_interpreter.cpp flashexternal.cpp flashtext.cpp flashmedia.cpp flv.cpp netutils.cpp timer.cpp decoder.cpp threading.cpp flashxml.cpp)
IF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "i[3-6]86")
SET(LIBSPARK_SOURCES ${LIBSPARK_SOURCES} fastpaths_32.asm)
ELSEIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
Expand Down
3 changes: 2 additions & 1 deletion abc.cpp
Expand Up @@ -39,6 +39,7 @@
#include "flashgeom.h"
#include "flashexternal.h"
#include "flashmedia.h"
#include "flashxml.h"
#include "class.h"
#include "exceptions.h"

Expand Down Expand Up @@ -180,7 +181,7 @@ void ABCVm::registerClasses()
Global.setVariableByQName("TextFieldType","flash.text",Class<ASObject>::getClass("TextFieldType"));
Global.setVariableByQName("Font","flash.text",Class<Font>::getClass());

Global.setVariableByQName("XMLDocument","flash.xml",new ASObject);
Global.setVariableByQName("XMLDocument","flash.xml",Class<XMLDocument>::getClass());

Global.setVariableByQName("ExternalInterface","flash.external",Class<ExternalInterface>::getClass());

Expand Down
8 changes: 8 additions & 0 deletions asobjects.cpp
Expand Up @@ -765,6 +765,14 @@ double ASString::toNumber()
return atof(data.c_str());
}

int32_t ASString::toInt()
{
assert(implEnable);
if(data.empty() || !isdigit(data[0]))
return 0;
return atoi(data.c_str());
}

ASFUNCTIONBODY(Undefined,call)
{
LOG(LOG_CALLS,"Undefined function");
Expand Down
1 change: 1 addition & 0 deletions asobjects.h
Expand Up @@ -362,6 +362,7 @@ class ASString: public ASObject
bool isLess(ASObject* r);
tiny_string toString(bool debugMsg=false);
double toNumber();
int32_t toInt();
};

class Null: public ASObject
Expand Down
49 changes: 49 additions & 0 deletions flashxml.cpp
@@ -0,0 +1,49 @@
/**************************************************************************
Lightspark, a free flash player implementation
Copyright (C) 2009,2010 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 "flashxml.h"
#include "swf.h"
#include "compat.h"
#include "class.h"

using namespace std;
using namespace lightspark;

extern TLSDATA SystemState* sys;
extern TLSDATA RenderThread* rt;

REGISTER_CLASS_NAME(XMLDocument);

void XMLDocument::sinit(Class_base* c)
{
c->setConstructor(new Function(_constructor));
c->super=Class<ASObject>::getClass();
c->max_level=c->super->max_level+1;
}

void XMLDocument::buildTraits(ASObject* o)
{
}

ASFUNCTIONBODY(XMLDocument,_constructor)
{
XMLDocument* th=static_cast<XMLDocument*>(obj);
return NULL;
}

37 changes: 37 additions & 0 deletions flashxml.h
@@ -0,0 +1,37 @@
/**************************************************************************
Lightspark, a free flash player implementation
Copyright (C) 2009,2010 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/>.
**************************************************************************/

#ifndef _FLASH_XML_H
#define _FLASH_XML_H

#include "swftypes.h"

namespace lightspark
{

class XMLDocument: public ASObject
{
public:
static void sinit(Class_base*);
static void buildTraits(ASObject* o);
ASFUNCTION(_constructor);
};

};
#endif
2 changes: 1 addition & 1 deletion plugin-dir/CMakeLists.txt
Expand Up @@ -31,7 +31,7 @@ IF(UNIX)
ENDIF(UNIX)


SET(LIBSPARK_SOURCES ../swf.cpp ../swftypes.cpp ../tags.cpp ../geometry.cpp ../actions.cpp ../frame.cpp ../input.cpp ../streams.cpp ../tags_stub.cpp ../logger.cpp ../vm.cpp ../asobjects.cpp ../abc.cpp ../abc_codesynt.cpp ../abc_opcodes.cpp ../flashdisplay.cpp ../flashevents.cpp ../textfile.cpp ../thread_pool.cpp ../flashgeom.cpp ../flashnet.cpp ../flashsystem.cpp ../flashutils.cpp ../compat.cpp ../abc_interpreter.cpp ../flashexternal.cpp ../flashtext.cpp ../flashmedia.cpp ../flv.cpp ../netutils.cpp ../timer.cpp ../decoder.cpp ../threading.cpp)
SET(LIBSPARK_SOURCES ../swf.cpp ../swftypes.cpp ../tags.cpp ../geometry.cpp ../actions.cpp ../frame.cpp ../input.cpp ../streams.cpp ../tags_stub.cpp ../logger.cpp ../vm.cpp ../asobjects.cpp ../abc.cpp ../abc_codesynt.cpp ../abc_opcodes.cpp ../flashdisplay.cpp ../flashevents.cpp ../textfile.cpp ../thread_pool.cpp ../flashgeom.cpp ../flashnet.cpp ../flashsystem.cpp ../flashutils.cpp ../compat.cpp ../abc_interpreter.cpp ../flashexternal.cpp ../flashtext.cpp ../flashmedia.cpp ../flv.cpp ../netutils.cpp ../timer.cpp ../decoder.cpp ../threading.cpp ../flashxml.cpp)
IF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "i[3-6]86")
SET(LIBSPARK_SOURCES ${LIBSPARK_SOURCES} ../fastpaths_32.asm)
ELSEIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
Expand Down
3 changes: 2 additions & 1 deletion plugin-dir/plugin.cpp
Expand Up @@ -23,7 +23,8 @@
//#define MIME_TYPES_HANDLED "application/x-lightspark"
#define PLUGIN_NAME "Shockwave Flash"
#define MIME_TYPES_DESCRIPTION MIME_TYPES_HANDLED":swf:"PLUGIN_NAME
#define PLUGIN_DESCRIPTION "Shockwave Flash 10.0 - Lightspark implementation"
//#define PLUGIN_DESCRIPTION "Shockwave Flash 10.0 r00 - Lightspark implementation"
#define PLUGIN_DESCRIPTION "Shockwave Flash 10.0 r00"
#include "class.h"

using namespace std;
Expand Down
6 changes: 3 additions & 3 deletions swf.cpp
Expand Up @@ -81,7 +81,7 @@ SWF_HEADER::SWF_HEADER(istream& in)
pt->root->fileLenght=FileLength;
}

RootMovieClip::RootMovieClip(LoaderInfo* li):initialized(false),frameRate(0),toBind(false)
RootMovieClip::RootMovieClip(LoaderInfo* li, bool isSys):initialized(false),frameRate(0),toBind(false)
{
root=this;
sem_init(&mutex,0,1);
Expand All @@ -94,7 +94,7 @@ RootMovieClip::RootMovieClip(LoaderInfo* li):initialized(false),frameRate(0),toB
framesLoaded=0;

//We set the protoype to a generic MovieClip
if(sys)
if(!isSys)
{
prototype=Class<MovieClip>::getClass();
prototype->incRef();
Expand All @@ -117,7 +117,7 @@ void RootMovieClip::bindToName(const tiny_string& n)
bindName=n;
}

SystemState::SystemState():RootMovieClip(NULL),renderRate(0),showProfilingData(false),showInteractiveMap(false),shutdown(false),
SystemState::SystemState():RootMovieClip(NULL,true),renderRate(0),showProfilingData(false),showInteractiveMap(false),shutdown(false),
error(false),currentVm(NULL),inputThread(NULL),renderThread(NULL),useInterpreter(true),useJit(false),downloadManager(NULL)
{
//Do needed global initialization
Expand Down
2 changes: 1 addition & 1 deletion swf.h
Expand Up @@ -96,7 +96,7 @@ friend class ParseThread;
tiny_string bindName;
void tick();
public:
RootMovieClip(LoaderInfo* li);
RootMovieClip(LoaderInfo* li, bool isSys=false);
~RootMovieClip();
unsigned int version;
unsigned int fileLenght;
Expand Down
4 changes: 3 additions & 1 deletion timer.cpp
Expand Up @@ -127,10 +127,12 @@ void* TimerThread::timer_worker(TimerThread* th)
//Wait until a time expires
sem_wait(&th->mutex);
//Check if there is any event
if(th->pendingEvents.empty())
while(th->pendingEvents.empty())
{
sem_post(&th->mutex);
sem_wait(&th->newEvent);
if(th->stopped)
pthread_exit(0);
sem_wait(&th->mutex);
}

Expand Down

0 comments on commit 8f318b3

Please sign in to comment.