Projects
Essentials
lightspark
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 62
View file
lightspark.spec
Changed
@@ -1,7 +1,7 @@ # # spec file for package lightspark # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ %endif Name: lightspark -Version: 0.7.2.99+git20141022.1737 +Version: 0.7.2.99+git20150305.1754 Release: 0 Summary: Modern, free, open-source flash player implementation License: LGPL-3.0+
View file
lightspark.tar.xz/CMakeLists.txt
Changed
@@ -78,7 +78,7 @@ # GCC 4.6+ is required, GCC_VERSION macro taken from GCC manual INCLUDE(CheckCSourceCompiles) -IF(CMAKE_COMPILER_IS_GNUCC) +IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") CHECK_C_SOURCE_COMPILES(" #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #if GCC_VERSION < 40600 @@ -88,7 +88,7 @@ IF(NOT GCC_IS_4_6) MESSAGE(FATAL_ERROR "GCC 4.6+ is required.") ENDIF(NOT GCC_IS_4_6) -ENDIF(CMAKE_COMPILER_IS_GNUCC) +ENDIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # Find put the path of the gnash executable, if available FIND_PROGRAM(GNASH_EXE_PATH NAMES gnash) @@ -114,31 +114,31 @@ INCLUDE(Pack) # If we're gcc, then use nasm to get fastpath. If MSVC, just use inline asm to get around # CMake issues -IF(CMAKE_COMPILER_IS_GNUCC) +IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") INCLUDE(CMakeASM-NASMCompiler) -ENDIF(CMAKE_COMPILER_IS_GNUCC) +ENDIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") IF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^i[3-6]86$|^x86$") SET(i386 1) SET(LIB_SUFFIX "" CACHE STRING "Choose the suffix of the lib folder (if any) : None 32") # nasm for assembly optimizations - IF(CMAKE_COMPILER_IS_GNUCC) + IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") ENABLE_LANGUAGE(ASM-NASM) - ENDIF(CMAKE_COMPILER_IS_GNUCC) + ENDIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") ELSEIF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "unknown" AND ${CMAKE_SYSTEM} MATCHES "GNU-0.3") # GNU Hurd is i386 SET(i386 1) SET(LIB_SUFFIX "" CACHE STRING "Choose the suffix of the lib folder (if any) : None 32") # nasm for assembly optimizations - IF(CMAKE_COMPILER_IS_GNUCC) + IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") ENABLE_LANGUAGE(ASM-NASM) ENDIF () ELSEIF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^x86_64$|^amd64$") SET(x86_64 1) SET(LIB_SUFFIX "" CACHE STRING "Choose the suffix of the lib folder (if any) : None 64") # nasm for assembly optimizations - IF(CMAKE_COMPILER_IS_GNUCC) + IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") ENABLE_LANGUAGE(ASM-NASM) - ENDIF(CMAKE_COMPILER_IS_GNUCC) + ENDIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") ELSEIF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc") SET(ppc 1) SET(LIB_SUFFIX "" CACHE STRING "Choose the suffix of the lib folder (if any) : None ppc") @@ -390,7 +390,7 @@ SET(OPTIONAL_LIBRARIES ${OPTIONAL_LIBRARIES} ${FFMPEG_LIBRARIES}) ENDIF(ENABLE_LIBAVCODEC) -IF(CMAKE_COMPILER_IS_GNUCC) +IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") IF(MINGW) SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed,--no-undefined -mthreads ${CMAKE_EXE_LINKER_FLAGS}") SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed,--no-undefined,--enable-stdcall-fixup -mthreads ${CMAKE_SHARED_LINKER_FLAGS}") @@ -400,7 +400,13 @@ ENDIF() SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s") SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "-s") -ENDIF(CMAKE_COMPILER_IS_GNUCC) +ENDIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") +IF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--no-undefined ${CMAKE_EXE_LINKER_FLAGS}") + SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed,-z,noexecstack,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}") + SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s") + SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "-s") +ENDIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") LINK_DIRECTORIES(${LLVM_LIB_DIR}) @@ -431,13 +437,13 @@ ENDIF(ENABLE_MEMORY_USAGE_PROFILING) # Compiler defaults flags for different profiles -IF(CMAKE_COMPILER_IS_GNUCC) +IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") IF(MINGW) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mms-bitfields -mthreads -fexceptions -Wall -Wnon-virtual-dtor -Woverloaded-virtual -pipe -std=c++0x -Wdisabled-optimization -Wextra -Wno-unused-parameter -Wno-invalid-offsetof") ELSE() SET(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -Wall -Wnon-virtual-dtor -Woverloaded-virtual -pipe -fvisibility=hidden -fvisibility-inlines-hidden -std=c++0x -Wdisabled-optimization -Wextra -Wno-unused-parameter -Wno-invalid-offsetof") + "${CMAKE_CXX_FLAGS} -Wall -Wnon-virtual-dtor -Woverloaded-virtual -pipe -fvisibility=hidden -fvisibility-inlines-hidden -std=c++11 -Wdisabled-optimization -Wextra -Wno-unused-parameter -Wno-invalid-offsetof") ENDIF() SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -DEXPENSIVE_DEBUG") SET(CMAKE_CXX_FLAGS_PROFILE "-g -pg -O2") @@ -445,7 +451,18 @@ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O2 -DNDEBUG") SET(CMAKE_CXX_FLAGS_LEANDEBUG "-g -O2") ADD_DEFINITIONS(-DLS_DATADIR="${LSDATADIR}" -DGNASH_PATH="${GNASH_EXE_PATH}" -DPRIVATELIBDIR="${PRIVATELIBDIR}") -ENDIF(CMAKE_COMPILER_IS_GNUCC) +ENDIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") +IF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + SET(CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -Wall -Wnon-virtual-dtor -Woverloaded-virtual -pipe -fvisibility=hidden -fvisibility-inlines-hidden -std=c++11 -Wdisabled-optimization -Wextra -Wno-unused-parameter -Wno-invalid-offsetof") + SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -DEXPENSIVE_DEBUG") + SET(CMAKE_CXX_FLAGS_PROFILE "-g -pg -O2") + SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O2 -DNDEBUG") + SET(CMAKE_CXX_FLAGS_LEANDEBUG "-g -O2") + ADD_DEFINITIONS(-DLS_DATADIR="${LSDATADIR}" -DGNASH_PATH="${GNASH_EXE_PATH}" -DPRIVATELIBDIR="${PRIVATELIBDIR}") + ADD_DEFINITIONS(-DUSE_CLANG) +ENDIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") IF(MSVC) ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -DVPCOMPAT -DPTW32_STATIC_LIB -DPCRE_STATIC) @@ -463,11 +480,16 @@ ENDIF(HAVE_ATOMIC) # Setting the output directories, so we can build all profiles without mixmatching -IF(CMAKE_COMPILER_IS_GNUCC) +IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE}/bin") + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE}/lib${LIB_SUFFIX}") + #SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/objs/${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE}/lib${LIB_SUFFIX}" CACHE PATH "Static libraries output directory") +ENDIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") +IF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE}/bin") SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE}/lib${LIB_SUFFIX}") #SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/objs/${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE}/lib${LIB_SUFFIX}" CACHE PATH "Static libraries output directory") -ENDIF(CMAKE_COMPILER_IS_GNUCC) +ENDIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") #Install icons and desktop file if(UNIX)
View file
lightspark.tar.xz/src/CMakeLists.txt
Changed
@@ -66,6 +66,8 @@ scripting/abc_opcodes.cpp scripting/abctypes.cpp scripting/flash/accessibility/flashaccessibility.cpp + scripting/flash/concurrent/Mutex.cpp + scripting/flash/concurrent/Condition.cpp scripting/flash/desktop/flashdesktop.cpp scripting/flash/display/BitmapContainer.cpp scripting/flash/display/BitmapData.cpp @@ -91,6 +93,8 @@ scripting/flash/net/URLRequestHeader.cpp scripting/flash/net/URLStream.cpp scripting/flash/net/XMLSocket.cpp + scripting/flash/net/NetStreamPlayOptions.cpp + scripting/flash/net/NetStreamPlayTransitions.cpp scripting/flash/errors/flasherrors.cpp scripting/flash/sensors/flashsensors.cpp scripting/flash/system/flashsystem.cpp @@ -105,6 +109,9 @@ scripting/flash/utils/IntervalRunner.cpp scripting/flash/ui/Keyboard.cpp scripting/flash/ui/Mouse.cpp + scripting/flash/ui/ContextMenu.cpp + scripting/flash/ui/ContextMenuItem.cpp + scripting/flash/ui/ContextMenuBuiltInItems.cpp scripting/flash/xml/flashxml.cpp scripting/toplevel/Array.cpp scripting/toplevel/ASString.cpp
View file
lightspark.tar.xz/src/allclasses.cpp
Changed
@@ -26,6 +26,8 @@ #include "scripting/toplevel/XML.h" #include "scripting/toplevel/XMLList.h" #include "scripting/flash/accessibility/flashaccessibility.h" +#include "scripting/flash/concurrent/Mutex.h" +#include "scripting/flash/concurrent/Condition.h" #include "scripting/flash/desktop/flashdesktop.h" #include "scripting/flash/display/flashdisplay.h" #include "scripting/flash/display/BitmapData.h" @@ -48,6 +50,8 @@ #include "scripting/flash/net/URLRequestHeader.h" #include "scripting/flash/net/URLStream.h" #include "scripting/flash/net/XMLSocket.h" +#include "scripting/flash/net/NetStreamPlayOptions.h" +#include "scripting/flash/net/NetStreamPlayTransitions.h" #include "scripting/flash/system/flashsystem.h" #include "scripting/flash/sensors/flashsensors.h" #include "scripting/flash/utils/flashutils.h" @@ -66,6 +70,9 @@ #include "scripting/flash/text/flashtextengine.h" #include "scripting/flash/ui/Keyboard.h" #include "scripting/flash/ui/Mouse.h" +#include "scripting/flash/ui/ContextMenu.h" +#include "scripting/flash/ui/ContextMenuItem.h" +#include "scripting/flash/ui/ContextMenuBuiltInItems.h" using namespace lightspark;
View file
lightspark.tar.xz/src/allclasses.h
Changed
@@ -56,6 +56,10 @@ REGISTER_CLASS_NAME(AccessibilityProperties,"flash.accessibility") REGISTER_CLASS_NAME(AccessibilityImplementation,"flash.accessibility") +//Concurrent +REGISTER_CLASS_NAME(ASMutex,"flash.concurrent") +REGISTER_CLASS_NAME(ASCondition,"flash.concurrent") + //Desktop (AIR) REGISTER_CLASS_NAME(NativeApplication,"flash.desktop") @@ -129,6 +133,7 @@ REGISTER_CLASS_NAME(StatusEvent,"flash.events") REGISTER_CLASS_NAME(TextEvent,"flash.events") REGISTER_CLASS_NAME(TimerEvent,"flash.events") +REGISTER_CLASS_NAME(ContextMenuEvent,"flash.events") //External interface (browser interaction) REGISTER_CLASS_NAME(ExternalInterface,"flash.external") @@ -160,6 +165,8 @@ //Net REGISTER_CLASS_NAME(NetConnection,"flash.net") REGISTER_CLASS_NAME(NetStream,"flash.net") +REGISTER_CLASS_NAME(NetStreamPlayTransitions,"flash.net") +REGISTER_CLASS_NAME(NetStreamPlayOptions,"flash.net") REGISTER_CLASS_NAME(ObjectEncoding,"flash.net") REGISTER_CLASS_NAME(Responder,"flash.net") REGISTER_CLASS_NAME(SharedObject,"flash.net") @@ -234,6 +241,9 @@ REGISTER_CLASS_NAME(KeyboardType,"flash.ui") REGISTER_CLASS_NAME(KeyLocation,"flash.ui") REGISTER_CLASS_NAME(Mouse,"flash.ui") +REGISTER_CLASS_NAME(ContextMenu,"flash.ui") +REGISTER_CLASS_NAME(ContextMenuItem,"flash.ui") +REGISTER_CLASS_NAME(ContextMenuBuiltInItems,"flash.ui") //XML REGISTER_CLASS_NAME(XMLDocument,"flash.xml")
View file
lightspark.tar.xz/src/asobject.cpp
Changed
@@ -37,7 +37,13 @@ { check(); string ret; - if(getClass()) + if(this->is<Class_base>()) + { + ret = "[class "; + ret+=this->as<Class_base>()->class_name.getQualifiedName().raw_buf(); + ret+="]"; + } + else if(getClass()) { ret="[object "; ret+=getClass()->class_name.name.raw_buf(); @@ -47,12 +53,6 @@ ret = "Undefined"; else if(this->is<Null>()) ret = "Null"; - else if(this->is<Class_base>()) - { - ret = "[class "; - ret+=this->as<Class_base>()->class_name.getQualifiedName().raw_buf(); - ret+="]"; - } else if(this->is<Template_base>()) { ret = "[templated class]"; @@ -64,6 +64,33 @@ return ret; } +void ASObject::setProxyProperty(const multiname &name) +{ + if (this->proxyMultiName) + this->proxyMultiName->ns.clear(); + else + this->proxyMultiName = new (getVm()->vmDataMemory) multiname(getVm()->vmDataMemory); + this->proxyMultiName->isAttribute = name.isAttribute; + this->proxyMultiName->ns.reserve(name.ns.size()); + for(unsigned int i=0;i<name.ns.size();i++) + { + this->proxyMultiName->ns.push_back(name.ns[i]); + } + +} + +void ASObject::applyProxyProperty(multiname &name) +{ + if (!this->proxyMultiName) + return; + name.isAttribute = this->proxyMultiName->isAttribute; + name.ns.clear(); + name.ns.reserve(this->proxyMultiName->ns.size()); + for(unsigned int i=0;i<this->proxyMultiName->ns.size();i++) + { + name.ns.push_back(this->proxyMultiName->ns[i]); + } +} tiny_string ASObject::toString() { check(); @@ -388,7 +415,10 @@ type==T_STRING || type==T_BOOLEAN || type==T_INTEGER || type==T_UINTEGER; } - +bool ASObject::isConstructed() const +{ + return traitsInitialized && constructorCalled; +} variables_map::variables_map(MemoryAccount* m): Variables(std::less<mapType::key_type>(), reporter_allocator<mapType::value_type>(m)),slots_vars(m) { @@ -673,7 +703,7 @@ return; } - Variables.initializeVar(name, o, typemname, context, traitKind); + Variables.initializeVar(name, o, typemname, context, traitKind,this); } variable::variable(TRAIT_KIND _k, ASObject* _v, multiname* _t, const Type* _type) @@ -829,28 +859,57 @@ return NULL; } -void variables_map::initializeVar(const multiname& mname, ASObject* obj, multiname* typemname, ABCContext* context, TRAIT_KIND traitKind) +void variables_map::initializeVar(const multiname& mname, ASObject* obj, multiname* typemname, ABCContext* context, TRAIT_KIND traitKind, ASObject* mainObj) { const Type* type = NULL; /* If typename is a builtin type, we coerce obj. * It it's not it must be a user defined class, - * so we only allow Null and Undefined (which are both coerced to Null) */ + * so we try to find the class it is derived from and create an apropriate uninitialized instance */ type = Type::getBuiltinType(typemname); + if (type == NULL) + type = Type::getTypeFromMultiname(typemname,context); if(type==NULL) { - assert_and_throw(obj->is<Null>() || obj->is<Undefined>()); - if(obj->is<Undefined>()) + if (obj == NULL) // create dynamic object { - //Casting undefined to an object (of unknown class) - //results in Null - obj->decRef(); - obj = getSys()->getNullRef(); + obj = getSys()->getUndefinedRef(); + } + else + { + assert_and_throw(obj->is<Null>() || obj->is<Undefined>()); + if(obj->is<Undefined>()) + { + //Casting undefined to an object (of unknown class) + //results in Null + obj->decRef(); + obj = getSys()->getNullRef(); + } } } else + { + if (obj == NULL) // create dynamic object + { + if(mainObj->is<Class_base>() && + mainObj->as<Class_base>()->class_name.getQualifiedName() == typemname->qualifiedString()) + { + // avoid recursive construction + obj = getSys()->getNullRef(); + } + else if (type != Class_object::getClass() && + dynamic_cast<const Class_base*>(type) + && ((Class_base*)type)->super) + { + obj = ((Class_base*)type)->getInstance(false,NULL,0); + } + else + { + obj = getSys()->getUndefinedRef(); + } + } obj = type->coerce(obj); - + } assert(traitKind==DECLARED_TRAIT || traitKind==CONSTANT_TRAIT); uint32_t name=mname.normalizedNameId(); @@ -978,6 +1037,10 @@ { Variables.initSlot(n,name.name_s_id,name.ns[0]); } +void ASObject::appendSlot(const multiname& name) +{ + Variables.appendSlot(name.name_s_id,name.ns[0]); +} int32_t ASObject::getVariableByMultiname_i(const multiname& name) { @@ -1194,8 +1257,8 @@ Variables.clear(); } -ASObject::ASObject(MemoryAccount* m):Variables(m),classdef(NULL), - type(T_OBJECT),traitsInitialized(false),implEnable(true) +ASObject::ASObject(MemoryAccount* m):Variables(m),classdef(NULL),proxyMultiName(NULL), + type(T_OBJECT),traitsInitialized(false),constructorCalled(false),implEnable(true) { #ifndef NDEBUG //Stuff only used in debugging @@ -1203,8 +1266,8 @@ #endif } -ASObject::ASObject(Class_base* c):Variables((c)?c->memoryAccount:NULL),classdef(NULL), - type(T_OBJECT),traitsInitialized(false),implEnable(true) +ASObject::ASObject(Class_base* c):Variables((c)?c->memoryAccount:NULL),classdef(NULL),proxyMultiName(NULL), + type(T_OBJECT),traitsInitialized(false),constructorCalled(false),implEnable(true) { setClass(c); #ifndef NDEBUG @@ -1213,8 +1276,8 @@ #endif } -ASObject::ASObject(const ASObject& o):Variables((o.classdef)?o.classdef->memoryAccount:NULL),classdef(NULL), - type(o.type),traitsInitialized(false),implEnable(true) +ASObject::ASObject(const ASObject& o):Variables((o.classdef)?o.classdef->memoryAccount:NULL),classdef(NULL),proxyMultiName(NULL), + type(o.type),traitsInitialized(false),constructorCalled(false),implEnable(true) { if(o.classdef) setClass(o.classdef); @@ -1251,6 +1314,9 @@ classdef->decRef(); classdef=NULL; } + if (proxyMultiName) + delete proxyMultiName; + proxyMultiName = NULL; } ASObject::~ASObject()
View file
lightspark.tar.xz/src/asobject.h
Changed
@@ -222,7 +222,7 @@ */ const variable* findObjVar(const multiname& mname, uint32_t traitKinds) const; //Initialize a new variable specifying the type (TODO: add support for const) - void initializeVar(const multiname& mname, ASObject* obj, multiname* typemname, ABCContext* context, TRAIT_KIND traitKind); + void initializeVar(const multiname& mname, ASObject* obj, multiname* typemname, ABCContext* context, TRAIT_KIND traitKind,ASObject* mainObj); void killObjVar(const multiname& mname); ASObject* getSlot(unsigned int n) { @@ -240,6 +240,10 @@ */ void setSlotNoCoerce(unsigned int n,ASObject* o); void initSlot(unsigned int n, uint32_t nameId, const nsNameAndKind& ns); + void appendSlot(uint32_t nameId, const nsNameAndKind& ns) + { + initSlot(slots_vars.size()+1, nameId, ns); + } int size() const { return Variables.size(); @@ -272,12 +276,14 @@ Class_base* classdef; const variable* findGettable(const multiname& name) const DLL_LOCAL; variable* findSettable(const multiname& name, bool* has_getter=NULL) DLL_LOCAL; + multiname* proxyMultiName; protected: ASObject(MemoryAccount* m); ASObject(const ASObject& o); virtual ~ASObject(); SWFOBJECT_TYPE type; bool traitsInitialized:1; + bool constructorCalled:1; void serializeDynamicProperties(ByteArray* out, std::map<tiny_string, uint32_t>& stringMap, std::map<const ASObject*, uint32_t>& objMap, std::map<const Class_base*, uint32_t> traitsMap) const; @@ -398,6 +404,7 @@ Variables.setSlotNoCoerce(n,o); } void initSlot(unsigned int n, const multiname& name); + void appendSlot(const multiname& name); unsigned int numVariables() const; tiny_string getNameAt(int i) const { @@ -420,6 +427,9 @@ _R<ASObject> toPrimitive(TP_HINT hint = NO_HINT); bool isPrimitive() const; + bool isInitialized() const {return traitsInitialized;} + bool isConstructed() const; + /* helper functions for calling the "valueOf" and * "toString" AS-functions which may be members of this * object */ @@ -478,6 +488,11 @@ /* Returns a debug string identifying this object */ virtual std::string toDebugString(); + + /* stores proxy namespace settings for internal usage */ + void setProxyProperty(const multiname& name); + /* applies proxy namespace settings to name for internal usage */ + void applyProxyProperty(multiname &name); }; class Number;
View file
lightspark.tar.xz/src/parsing/amf3_generator.cpp
Changed
@@ -274,6 +274,7 @@ return _MR(xmlObj); } + _R<ASObject> Amf3Deserializer::parseValue(std::vector<tiny_string>& stringMap, std::vector<ASObject*>& objMap, std::vector<TraitsRef>& traitsMap) const @@ -282,33 +283,144 @@ uint8_t marker; if(!input->readByte(marker)) throw ParseException("Not enough data to parse AMF3 object"); + if (input->getCurrentObjectEncoding() == ObjectEncoding::AMF3) + { + switch(marker) + { + case null_marker: + return _MR(getSys()->getNullRef()); + case undefined_marker: + return _MR(getSys()->getUndefinedRef()); + case false_marker: + return _MR(abstract_b(false)); + case true_marker: + return _MR(abstract_b(true)); + case integer_marker: + return parseInteger(); + case double_marker: + return parseDouble(); + case string_marker: + return _MR(Class<ASString>::getInstanceS(parseStringVR(stringMap))); + case xml_doc_marker: + return parseXML(objMap, true); + case array_marker: + return parseArray(stringMap, objMap, traitsMap); + case object_marker: + return parseObject(stringMap, objMap, traitsMap); + case xml_marker: + return parseXML(objMap, false); + default: + LOG(LOG_ERROR,"Unsupported marker " << (uint32_t)marker); + throw UnsupportedException("Unsupported marker"); + } + + } + else + { + switch(marker) + { + case amf0_number_marker: + return parseDouble(); + case amf0_boolean_marker: + return _MR(abstract_b(input->readByte(marker))); + case amf0_string_marker: + return _MR(Class<ASString>::getInstanceS(parseStringAMF0())); + case amf0_object_marker: + return parseObjectAMF0(stringMap,objMap,traitsMap); + case amf0_null_marker: + return _MR(getSys()->getNullRef()); + case amf0_undefined_marker: + return _MR(getSys()->getUndefinedRef()); + case amf0_reference_marker: + LOG(LOG_ERROR,"unimplemented marker " << (uint32_t)marker); + throw UnsupportedException("unimplemented marker"); + case amf0_ecma_array_marker: + return parseECMAArrayAMF0(stringMap,objMap,traitsMap); + case amf0_strict_array_marker: + LOG(LOG_ERROR,"unimplemented marker " << (uint32_t)marker); + throw UnsupportedException("unimplemented marker"); + case amf0_date_marker: + LOG(LOG_ERROR,"unimplemented marker " << (uint32_t)marker); + throw UnsupportedException("unimplemented marker"); + case amf0_long_string_marker: + LOG(LOG_ERROR,"unimplemented marker " << (uint32_t)marker); + throw UnsupportedException("unimplemented marker"); + case amf0_xml_document_marker: + return parseXML(objMap, false); + case amf0_typed_object_marker: + LOG(LOG_ERROR,"unimplemented marker " << (uint32_t)marker); + throw UnsupportedException("unimplemented marker"); + case amf0_avmplus_object_marker: + input->setCurrentObjectEncoding(ObjectEncoding::AMF3); + return parseValue(stringMap, objMap, traitsMap); + default: + LOG(LOG_ERROR,"Unsupported marker " << (uint32_t)marker); + throw UnsupportedException("Unsupported marker"); + } + } +} +tiny_string Amf3Deserializer::parseStringAMF0() const +{ + uint16_t strLen; + if(!input->readShort(strLen)) + throw ParseException("Not enough data to parse integer"); + + string retStr; + for(uint32_t i=0;i<strLen;i++) + { + uint8_t c; + if(!input->readByte(c)) + throw ParseException("Not enough data to parse string"); + retStr.push_back(c); + } + return retStr; +} +_R<ASObject> Amf3Deserializer::parseECMAArrayAMF0(std::vector<tiny_string>& stringMap, + std::vector<ASObject*>& objMap, + std::vector<TraitsRef>& traitsMap) const +{ + uint32_t count; + if(!input->readUnsignedInt(count)) + throw ParseException("Not enough data to parse AMF3 array"); + + _R<ASObject> ret=_MR(Class<ASObject>::getInstanceS()); - switch(marker) + //Read name, value pairs + while(count) { - case null_marker: - return _MR(getSys()->getNullRef()); - case undefined_marker: - return _MR(getSys()->getUndefinedRef()); - case false_marker: - return _MR(abstract_b(false)); - case true_marker: - return _MR(abstract_b(true)); - case integer_marker: - return parseInteger(); - case double_marker: - return parseDouble(); - case string_marker: - return _MR(Class<ASString>::getInstanceS(parseStringVR(stringMap))); - case xml_doc_marker: - return parseXML(objMap, true); - case array_marker: - return parseArray(stringMap, objMap, traitsMap); - case object_marker: - return parseObject(stringMap, objMap, traitsMap); - case xml_marker: - return parseXML(objMap, false); - default: - LOG(LOG_ERROR,"Unsupported marker " << (uint32_t)marker); - throw UnsupportedException("Unsupported marker"); + tiny_string varName = parseStringAMF0(); + if (varName == "") + throw ParseException("empty key in AMF0 ECMA array"); + _R<ASObject> value=parseValue(stringMap, objMap, traitsMap); + value->incRef(); + + ret->setVariableByQName(varName,"",value.getPtr(),DYNAMIC_TRAIT); + count--; } + return ret; } +_R<ASObject> Amf3Deserializer::parseObjectAMF0(std::vector<tiny_string>& stringMap, + std::vector<ASObject*>& objMap, + std::vector<TraitsRef>& traitsMap) const +{ + _R<ASObject> ret=_MR(Class<ASObject>::getInstanceS()); + + while (true) + { + tiny_string varName = parseStringAMF0(); + if (varName == "") + { + uint8_t marker = 0; + input->readByte(marker); + if (marker == amf0_object_end_marker ) + return ret; + throw ParseException("empty key in AMF0 object"); + } + _R<ASObject> value=parseValue(stringMap, objMap, traitsMap); + value->incRef(); + + ret->setVariableByQName(varName,"",value.getPtr(),DYNAMIC_TRAIT); + } + return _R<ASObject>(getSys()->getUndefinedRef()); +} +
View file
lightspark.tar.xz/src/parsing/amf3_generator.h
Changed
@@ -50,6 +50,28 @@ xml_marker = 0xb }; +enum amf0_markers_type +{ + amf0_number_marker = 0x00, + amf0_boolean_marker = 0x01, + amf0_string_marker = 0x02, + amf0_object_marker = 0x03, + amf0_movieclip_marker = 0x04, + amf0_null_marker = 0x05, + amf0_undefined_marker = 0x06, + amf0_reference_marker = 0x07, + amf0_ecma_array_marker = 0x08, + amf0_object_end_marker = 0x09, + amf0_strict_array_marker = 0x0A, + amf0_date_marker = 0x0B, + amf0_long_string_marker = 0x0C, + amf0_unsupported_marker = 0x0D, + amf0_recordset_marker = 0x0E, + amf0_xml_document_marker = 0x0F, + amf0_typed_object_marker = 0x10, + amf0_avmplus_object_marker = 0x11 +}; + class TraitsRef { public: @@ -64,6 +86,7 @@ private: ByteArray* input; tiny_string parseStringVR(std::vector<tiny_string>& stringMap) const; + _R<ASObject> parseObject(std::vector<tiny_string>& stringMap, std::vector<ASObject*>& objMap, std::vector<TraitsRef>& traitsMap) const; @@ -76,6 +99,15 @@ _R<ASObject> parseInteger() const; _R<ASObject> parseDouble() const; _R<ASObject> parseXML(std::vector<ASObject*>& objMap, bool legacyXML) const; + + + tiny_string parseStringAMF0() const; + _R<ASObject> parseECMAArrayAMF0(std::vector<tiny_string>& stringMap, + std::vector<ASObject*>& objMap, + std::vector<TraitsRef>& traitsMap) const; + _R<ASObject> parseObjectAMF0(std::vector<tiny_string>& stringMap, + std::vector<ASObject*>& objMap, + std::vector<TraitsRef>& traitsMap) const; public: Amf3Deserializer(ByteArray* i):input(i) {} _R<ASObject> readObject() const;
View file
lightspark.tar.xz/src/parsing/tags.cpp
Changed
@@ -1189,8 +1189,7 @@ //TODO: support clipping if(ClipDepth!=0) { - LOG(LOG_ERROR,"ClipDepth is not supported"); - return; + LOG(LOG_ERROR,"ClipDepth is not supported, but object is created anyway"); } if(!PlaceFlagHasCharacter && !PlaceFlagMove)
View file
lightspark.tar.xz/src/plugin/npscriptobject.cpp
Changed
@@ -814,8 +814,11 @@ //SUCCESS if(!NPVARIANT_IS_OBJECT(resultVariant)) { - //Something very wrong happended, our forged function is not a function! - LOG(LOG_ERROR,"Could not evaluate wrapper function in external interface"); + std::map<const NPObject*, std::unique_ptr<ExtObject>> npObjectsMap; + NPVariantObject tmp(npObjectsMap, instance, resultVariant); + std::map<const ExtObject*, ASObject*> asObjectsMap; + *(result) = tmp.getASObject(asObjectsMap); + NPN_ReleaseVariantValue(&resultVariant); } else {
View file
lightspark.tar.xz/src/plugin/plugin.cpp
Changed
@@ -328,29 +328,6 @@ m_sys=new lightspark::SystemState(0, lightspark::SystemState::FLASH); //Files running in the plugin have REMOTE sandbox m_sys->securityManager->setSandboxType(lightspark::SecurityManager::REMOTE); - //Parse OBJECT/EMBED tag attributes - string baseURL; - for(int i=0;i<argc;i++) - { - if(argn[i]==NULL || argv[i]==NULL) - continue; - if(strcasecmp(argn[i],"flashvars")==0) - { - m_sys->parseParametersFromFlashvars(argv[i]); - } - else if(strcasecmp(argn[i],"base")==0) - { - baseURL = argv[i]; - //This is a directory, not a file - baseURL += "/"; - } - //The SWF file url should be getted from NewStream - } - //basedir is a qualified URL or a path relative to the HTML page - URLInfo page(getPageURL()); - m_sys->mainClip->setBaseURL(page.goToURL(baseURL).getURL()); - - m_sys->downloadManager=new NPDownloadManager(mInstance); int p_major, p_minor, n_major, n_minor; NPN_Version(&p_major, &p_minor, &n_major, &n_minor); @@ -359,6 +336,33 @@ (NPScriptObjectGW *) NPN_CreateObject(mInstance, &NPScriptObjectGW::npClass); m_sys->extScriptObject = scriptObject->getScriptObject(); scriptObject->m_sys = m_sys; + //Parse OBJECT/EMBED tag attributes + string baseURL; + for(int i=0;i<argc;i++) + { + if(argn[i]==NULL || argv[i]==NULL) + continue; + if(strcasecmp(argn[i],"flashvars")==0) + { + m_sys->parseParametersFromFlashvars(argv[i]); + } + else if(strcasecmp(argn[i],"base")==0) + { + baseURL = argv[i]; + //This is a directory, not a file + baseURL += "/"; + } + else if(strcasecmp(argn[i],"name")==0) + { + m_sys->extScriptObject->setProperty(argn[i],argv[i]); + } + //The SWF file url should be getted from NewStream + } + //basedir is a qualified URL or a path relative to the HTML page + URLInfo page(getPageURL()); + m_sys->mainClip->setBaseURL(page.goToURL(baseURL).getURL()); + + m_sys->downloadManager=new NPDownloadManager(mInstance); } else LOG(LOG_ERROR, "PLUGIN: Browser doesn't support NPRuntime");
View file
lightspark.tar.xz/src/scripting/abc.cpp
Changed
@@ -67,6 +67,8 @@ #include "scripting/toplevel/XML.h" #include "scripting/toplevel/XMLList.h" #include "scripting/flash/accessibility/flashaccessibility.h" +#include "scripting/flash/concurrent/Mutex.h" +#include "scripting/flash/concurrent/Condition.h" #include "scripting/flash/desktop/flashdesktop.h" #include "scripting/flash/display/flashdisplay.h" #include "scripting/flash/display/BitmapData.h" @@ -89,6 +91,8 @@ #include "scripting/flash/net/URLRequestHeader.h" #include "scripting/flash/net/URLStream.h" #include "scripting/flash/net/XMLSocket.h" +#include "scripting/flash/net/NetStreamPlayOptions.h" +#include "scripting/flash/net/NetStreamPlayTransitions.h" #include "scripting/flash/system/flashsystem.h" #include "scripting/flash/sensors/flashsensors.h" #include "scripting/flash/utils/flashutils.h" @@ -104,6 +108,9 @@ #include "scripting/flash/text/flashtextengine.h" #include "scripting/flash/ui/Keyboard.h" #include "scripting/flash/ui/Mouse.h" +#include "scripting/flash/ui/ContextMenu.h" +#include "scripting/flash/ui/ContextMenuItem.h" +#include "scripting/flash/ui/ContextMenuBuiltInItems.h" #include "scripting/class.h" #include "exceptions.h" #include "scripting/abc.h" @@ -265,6 +272,9 @@ builtin->registerBuiltin("AccessibilityProperties","flash.accessibility",Class<AccessibilityProperties>::getRef()); builtin->registerBuiltin("AccessibilityImplementation","flash.accessibility",Class<AccessibilityImplementation>::getRef()); + builtin->registerBuiltin("Mutex","flash.concurrent",Class<ASMutex>::getRef()); + builtin->registerBuiltin("Condition","flash.concurrent",Class<ASCondition>::getRef()); + builtin->registerBuiltin("MovieClip","flash.display",Class<MovieClip>::getRef()); builtin->registerBuiltin("DisplayObject","flash.display",Class<DisplayObject>::getRef()); builtin->registerBuiltin("Loader","flash.display",Class<Loader>::getRef()); @@ -411,13 +421,19 @@ builtin->registerBuiltin("DRMStatusEvent","flash.events",Class<DRMStatusEvent>::getRef()); builtin->registerBuiltin("StageVideoEvent","flash.events",Class<StageVideoEvent>::getRef()); builtin->registerBuiltin("StageVideoAvailabilityEvent","flash.events",Class<StageVideoAvailabilityEvent>::getRef()); + builtin->registerBuiltin("TouchEvent","flash.events",Class<ASObject>::getStubClass(QName("TouchEvent","flash.events"))); + builtin->registerBuiltin("GestureEvent","flash.events",Class<ASObject>::getStubClass(QName("GestureEvent","flash.events"))); + builtin->registerBuiltin("PressAndTapGestureEvent","flash.events",Class<ASObject>::getStubClass(QName("PressAndTapGestureEvent","flash.events"))); + builtin->registerBuiltin("TransformGestureEvent","flash.events",Class<ASObject>::getStubClass(QName("TransformGestureEvent","flash.events"))); + builtin->registerBuiltin("ContextMenuEvent","flash.events",Class<ContextMenuEvent>::getRef()); builtin->registerBuiltin("navigateToURL","flash.net",_MR(Class<IFunction>::getFunction(navigateToURL))); builtin->registerBuiltin("sendToURL","flash.net",_MR(Class<IFunction>::getFunction(sendToURL))); builtin->registerBuiltin("LocalConnection","flash.net",Class<ASObject>::getStubClass(QName("LocalConnection","flash.net"))); builtin->registerBuiltin("NetConnection","flash.net",Class<NetConnection>::getRef()); builtin->registerBuiltin("NetStream","flash.net",Class<NetStream>::getRef()); - builtin->registerBuiltin("NetStreamPlayOptions","flash.net",Class<ASObject>::getStubClass(QName("NetStreamPlayOptions","flash.net"))); + builtin->registerBuiltin("NetStreamPlayOptions","flash.net",Class<NetStreamPlayOptions>::getRef()); + builtin->registerBuiltin("NetStreamPlayTransitions","flash.net",Class<NetStreamPlayTransitions>::getRef()); builtin->registerBuiltin("URLLoader","flash.net",Class<URLLoader>::getRef()); builtin->registerBuiltin("URLStream","flash.net",Class<URLStream>::getRef()); builtin->registerBuiltin("URLLoaderDataFormat","flash.net",Class<URLLoaderDataFormat>::getRef()); @@ -453,8 +469,9 @@ builtin->registerBuiltin("Keyboard","flash.ui",Class<Keyboard>::getRef()); builtin->registerBuiltin("KeyboardType","flash.ui",Class<KeyboardType>::getRef()); builtin->registerBuiltin("KeyLocation","flash.ui",Class<KeyLocation>::getRef()); - builtin->registerBuiltin("ContextMenu","flash.ui",Class<ASObject>::getStubClass(QName("ContextMenu","flash.ui"))); - builtin->registerBuiltin("ContextMenuItem","flash.ui",Class<ASObject>::getStubClass(QName("ContextMenuItem","flash.ui"))); + builtin->registerBuiltin("ContextMenu","flash.ui",Class<ContextMenu>::getRef()); + builtin->registerBuiltin("ContextMenuItem","flash.ui",Class<ContextMenuItem>::getRef()); + builtin->registerBuiltin("ContextMenuBuiltInItems","flash.ui",Class<ContextMenuBuiltInItems>::getRef()); builtin->registerBuiltin("Mouse","flash.ui",Class<Mouse>::getRef()); builtin->registerBuiltin("Accelerometer", "flash.sensors",Class<Accelerometer>::getRef()); @@ -476,6 +493,9 @@ builtin->registerBuiltin("isFinite","",_MR(Class<IFunction>::getFunction(isFinite))); builtin->registerBuiltin("isXMLName","",_MR(Class<IFunction>::getFunction(_isXMLName))); + // TODO stub classes, not yet implemented, but needed in tests + builtin->registerBuiltin("Worker","flash.system",Class<ASObject>::getStubClass(QName("Worker","flash.system"))); + //If needed add AIR definitions if(getSys()->flashMode==SystemState::AIR) { @@ -666,6 +686,8 @@ */ multiname* ABCContext::getMultinameImpl(ASObject* n, ASObject* n2, unsigned int midx) { + if (constant_pool.multiname_count == 0) + return NULL; multiname* ret; multiname_info* m=&constant_pool.multinames[midx]; @@ -791,6 +813,8 @@ ret->ns.clear(); ret->ns.push_back(nsNameAndKind(qname->getURI(),NAMESPACE)); } + else + n->applyProxyProperty(*ret); ret->setName(n); n->decRef(); break; @@ -2008,7 +2032,7 @@ case traits_info::Setter: case traits_info::Method: { - //methods can also be defined at toplevel (not only traits_info::Function!) + //methods can also be defined at toplevel (not only traits_info::Function!) if(kind == traits_info::Getter) LOG(LOG_CALLS,"Getter trait: " << *mname << _(" #") << t->method); else if(kind == traits_info::Setter) @@ -2075,6 +2099,8 @@ if(t->slot_id) obj->initSlot(t->slot_id, *mname); + else // slot_id 0 seems to mean appending new slot + obj->appendSlot(*mname); break; } case traits_info::Slot: @@ -2094,15 +2120,16 @@ else { LOG(LOG_CALLS,_("Slot ")<< t->slot_id<< _(" vindex 0 ") << *mname <<_(" type ")<<*tname); - //The Undefined is coerced to the right type by the initializeVar.. - ret = getSys()->getUndefinedRef(); + ret = NULL; } obj->initializeVariableByMultiname(*mname, ret, tname, this, DECLARED_TRAIT); if(t->slot_id) obj->initSlot(t->slot_id, *mname); - + else // slot_id 0 seems to mean appending new slot + obj->appendSlot(*mname); + break; } default:
View file
lightspark.tar.xz/src/scripting/abc.h
Changed
@@ -246,6 +246,28 @@ _R<ApplicationDomain> appDomain = getCurrentApplicationDomain(th); appDomain->writeToDomainMemory<T>(addr, val); } + + static void loadNumber(call_context* th) + { + ASObject* arg1=th->runtime_stack_pop(); + number_t addr=arg1->toNumber(); + arg1->decRef(); + _R<ApplicationDomain> appDomain = getCurrentApplicationDomain(th); + number_t ret=appDomain->readFromDomainMemory<number_t>(addr); + th->runtime_stack_push(abstract_d(ret)); + } + static void storeNumber(call_context* th) + { + ASObject* arg1=th->runtime_stack_pop(); + ASObject* arg2=th->runtime_stack_pop(); + number_t addr=arg1->toNumber(); + arg1->decRef(); + number_t val=arg2->toNumber(); + arg2->decRef(); + _R<ApplicationDomain> appDomain = getCurrentApplicationDomain(th); + appDomain->writeToDomainMemory<number_t>(addr, val); + } + static void callSuper(call_context* th, int n, int m, method_info** called_mi, bool keepReturn); static void callProperty(call_context* th, int n, int m, method_info** called_mi, bool keepReturn); static void callImpl(call_context* th, ASObject* f, ASObject* obj, ASObject** args, int m, method_info** called_mi, bool keepReturn); @@ -299,6 +321,7 @@ static void decLocal_i(call_context* th, int n); static void decLocal(call_context* th, int n); static void coerce(call_context* th, int n); + static void checkDeclaredTraits(ASObject* obj); static ASObject* getProperty(ASObject* obj, multiname* name); static int32_t getProperty_i(ASObject* obj, multiname* name); static void setProperty(ASObject* value,ASObject* obj, multiname* name);
View file
lightspark.tar.xz/src/scripting/abc_fast_interpreter.cpp
Changed
@@ -75,6 +75,12 @@ switch(opcode) { + case 0x01: + { + //bkpt + LOG(LOG_CALLS, _("bkpt") ); + break; + } case 0x02: { //nop @@ -565,6 +571,20 @@ loadIntN<uint32_t>(context); break; } + case 0x38: + { + //lf32 + LOG(LOG_CALLS, "lf32"); + loadNumber(context); + break; + } + case 0x39: + { + //lf32 + LOG(LOG_CALLS, "lf64"); + loadNumber(context); + break; + } case 0x3a: { //si8 @@ -802,7 +822,12 @@ //getlocal uint32_t i=data->uints[0]; instructionPointer+=4; - assert_and_throw(context->locals[i]); + if (!context->locals[i]) + { + LOG(LOG_CALLS, _("getLocal ") << i << " not set, pushing Undefined"); + context->runtime_stack_push(getSys()->getUndefinedRef()); + break; + } context->locals[i]->incRef(); LOG(LOG_CALLS, _("getLocal ") << i << _(": ") << context->locals[i]->toDebugString() ); context->runtime_stack_push(context->locals[i]); @@ -896,6 +921,27 @@ setSlot(v1, v2, t); break; } + case 0x6e: + { + //getglobalSlot + uint32_t t=data->uints[0]; + instructionPointer+=4; + + Global* globalscope = getGlobalScope(context); + context->runtime_stack_push(globalscope->getSlot(t)); + break; + } + case 0x6f: + { + //setglobalSlot + uint32_t t=data->uints[0]; + instructionPointer+=4; + + Global* globalscope = getGlobalScope(context); + ASObject* obj=context->runtime_stack_pop(); + globalscope->setSlot(t,obj); + break; + } case 0x70: { //convert_s @@ -942,6 +988,18 @@ context->runtime_stack_push(abstract_b(convert_b(val))); break; } + case 0x77: + { + //convert_o + ASObject* val=context->runtime_stack_pop(); + if (val->is<Null>()) + throwError<TypeError>(kConvertNullToObjectError); + if (val->is<Undefined>()) + throwError<TypeError>(kConvertUndefinedToObjectError); + + context->runtime_stack_push(val); + break; + } case 0x78: { //checkfilter @@ -1358,7 +1416,12 @@ { //getlocal_n int i=opcode&3; - assert_and_throw(context->locals[i]); + if (!context->locals[i]) + { + LOG(LOG_CALLS, _("getLocal ") << i << " not set, pushing Undefined"); + context->runtime_stack_push(getSys()->getUndefinedRef()); + break; + } LOG(LOG_CALLS, "getLocal " << i << ": " << context->locals[i]->toDebugString() ); context->locals[i]->incRef(); context->runtime_stack_push(context->locals[i]); @@ -1378,6 +1441,20 @@ context->locals[i]=obj; break; } + case 0xf2: + { + //bkptline + LOG(LOG_CALLS, _("bkptline") ); + instructionPointer+=4; + break; + } + case 0xf3: + { + //timestamp + LOG(LOG_CALLS, _("timestamp") ); + instructionPointer+=4; + break; + } //lightspark custom opcodes case 0xfb: {
View file
lightspark.tar.xz/src/scripting/abc_interpreter.cpp
Changed
@@ -73,6 +73,12 @@ context->exec_pos = code.tellg(); switch(opcode) { + case 0x01: + { + //bkpt + LOG(LOG_CALLS, _("bkpt") ); + break; + } case 0x02: { //nop @@ -663,6 +669,20 @@ loadIntN<uint32_t>(context); break; } + case 0x38: + { + //lf32 + LOG(LOG_CALLS, "lf32"); + loadNumber(context); + break; + } + case 0x39: + { + //lf32 + LOG(LOG_CALLS, "lf64"); + loadNumber(context); + break; + } case 0x3a: { //si8 @@ -684,6 +704,20 @@ storeIntN<uint32_t>(context); break; } + case 0x3d: + { + //sf32 + LOG(LOG_CALLS, "sf32"); + storeNumber(context); + break; + } + case 0x3e: + { + //sf32 + LOG(LOG_CALLS, "sf64"); + storeNumber(context); + break; + } case 0x40: { //newfunction @@ -909,7 +943,12 @@ //getlocal u30 i; code >> i; - assert_and_throw(context->locals[i]); + if (!context->locals[i]) + { + LOG(LOG_CALLS, _("getLocal ") << i << " not set, pushing Undefined"); + context->runtime_stack_push(getSys()->getUndefinedRef()); + break; + } context->locals[i]->incRef(); LOG(LOG_CALLS, _("getLocal ") << i << _(": ") << context->locals[i]->toDebugString() ); context->runtime_stack_push(context->locals[i]); @@ -1003,6 +1042,27 @@ setSlot(v1, v2, t); break; } + case 0x6e: + { + //getglobalSlot + u30 t; + code >> t; + + Global* globalscope = getGlobalScope(context); + context->runtime_stack_push(globalscope->getSlot(t)); + break; + } + case 0x6f: + { + //setglobalSlot + u30 t; + code >> t; + + Global* globalscope = getGlobalScope(context); + ASObject* obj=context->runtime_stack_pop(); + globalscope->setSlot(t,obj); + break; + } case 0x70: { //convert_s @@ -1049,6 +1109,18 @@ context->runtime_stack_push(abstract_b(convert_b(val))); break; } + case 0x77: + { + //convert_o + ASObject* val=context->runtime_stack_pop(); + if (val->is<Null>()) + throwError<TypeError>(kConvertNullToObjectError); + if (val->is<Undefined>()) + throwError<TypeError>(kConvertUndefinedToObjectError); + + context->runtime_stack_push(val); + break; + } case 0x78: { //checkfilter @@ -1453,7 +1525,12 @@ { //getlocal_n int i=opcode&3; - assert_and_throw(context->locals[i]); + if (!context->locals[i]) + { + LOG(LOG_CALLS, _("getLocal ") << i << " not set, pushing Undefined"); + context->runtime_stack_push(getSys()->getUndefinedRef()); + break; + } LOG(LOG_CALLS, _("getLocal ") << i << _(": ") << context->locals[i]->toDebugString() ); context->locals[i]->incRef(); context->runtime_stack_push(context->locals[i]); @@ -1503,6 +1580,20 @@ code >> t; break; } + case 0xf2: + { + //bkptline + LOG(LOG_CALLS, _("bkptline") ); + u30 t; + code >> t; + break; + } + case 0xf3: + { + //timestamp + LOG(LOG_CALLS, _("timestamp") ); + break; + } default: LOG(LOG_ERROR,_("Not interpreted instruction @") << code.tellg()); LOG(LOG_ERROR,_("dump ") << hex << (unsigned int)opcode << dec);
View file
lightspark.tar.xz/src/scripting/abc_opcodes.cpp
Changed
@@ -53,7 +53,7 @@ void ABCVm::setProperty(ASObject* value,ASObject* obj,multiname* name) { - LOG(LOG_CALLS,_("setProperty ") << *name << ' ' << obj); + LOG(LOG_CALLS,_("setProperty ") << *name << ' ' << obj->toDebugString()<<" " << value->toString()); //Do not allow to set contant traits obj->setVariableByMultiname(*name,value,ASObject::CONST_NOT_ALLOWED); @@ -287,14 +287,29 @@ LOG(LOG_CALLS, (keepReturn ? "callProperty " : "callPropVoid") << *name << ' ' << m); ASObject* obj=th->runtime_stack_pop(); - if(obj->classdef) - LOG(LOG_CALLS,obj->classdef->class_name); + checkDeclaredTraits(obj); + + if(obj->is<Null>()) + throwError<TypeError>(kConvertNullToObjectError); + if (obj->is<Undefined>()) + throwError<TypeError>(kConvertUndefinedToObjectError); //We should skip the special implementation of get _NR<ASObject> o=obj->getVariableByMultiname(*name, ASObject::SKIP_IMPL); name->resetNameIfObject(); - - if(!o.isNull()) + if(o.isNull() && obj->is<Class_base>()) + { + // check super classes + _NR<Class_base> tmpcls = obj->as<Class_base>()->super; + while (tmpcls && !tmpcls.isNull()) + { + o=tmpcls->getVariableByMultiname(*name, ASObject::SKIP_IMPL); + if(!o.isNull()) + break; + tmpcls = tmpcls->super; + } + } + if(!o.isNull() && !(obj->classdef && obj->classdef->isSubClass(Class<Proxy>::getClass()))) { o->incRef(); callImpl(th, o.getPtr(), obj, args, m, called_mi, keepReturn); @@ -309,35 +324,43 @@ callPropertyName.name_type=multiname::NAME_STRING; callPropertyName.name_s_id=getSys()->getUniqueStringId("callProperty"); callPropertyName.ns.push_back(nsNameAndKind(flash_proxy,NAMESPACE)); - _NR<ASObject> o=obj->getVariableByMultiname(callPropertyName,ASObject::SKIP_IMPL); + _NR<ASObject> oproxy=obj->getVariableByMultiname(callPropertyName,ASObject::SKIP_IMPL); - if(!o.isNull()) + if(!oproxy.isNull()) { - assert_and_throw(o->getObjectType()==T_FUNCTION); - - IFunction* f=static_cast<IFunction*>(o.getPtr()); - //Create a new array - ASObject** proxyArgs=g_newa(ASObject*, m+1); - //Well, I don't how to pass multiname to an as function. I'll just pass the name as a string - proxyArgs[0]=Class<ASString>::getInstanceS(getSys()->getStringFromUniqueId(name->name_s_id)); - for(int i=0;i<m;i++) - proxyArgs[i+1]=args[i]; - - //We now suppress special handling - LOG(LOG_CALLS,_("Proxy::callProperty")); - f->incRef(); - obj->incRef(); - ASObject* ret=f->call(obj,proxyArgs,m+1); - //call getMethodInfo only after the call, so it's updated - if(called_mi) - *called_mi=f->getMethodInfo(); - f->decRef(); - if(keepReturn) - th->runtime_stack_push(ret); + assert_and_throw(oproxy->getObjectType()==T_FUNCTION); + if(!o.isNull()) + { + o->incRef(); + callImpl(th, o.getPtr(), obj, args, m, called_mi, keepReturn); + } else - ret->decRef(); - - obj->decRef(); + { + IFunction* f=static_cast<IFunction*>(oproxy.getPtr()); + //Create a new array + ASObject** proxyArgs=g_newa(ASObject*, m+1); + ASObject* namearg = Class<ASString>::getInstanceS(name->normalizedName()); + namearg->setProxyProperty(*name); + proxyArgs[0]=namearg; + for(int i=0;i<m;i++) + proxyArgs[i+1]=args[i]; + + //We now suppress special handling + LOG(LOG_CALLS,_("Proxy::callProperty")); + f->incRef(); + obj->incRef(); + ASObject* ret=f->call(obj,proxyArgs,m+1); + //call getMethodInfo only after the call, so it's updated + if(called_mi) + *called_mi=f->getMethodInfo(); + f->decRef(); + if(keepReturn) + th->runtime_stack_push(ret); + else + ret->decRef(); + + obj->decRef(); + } LOG(LOG_CALLS,_("End of calling ") << *name); return; } @@ -353,10 +376,21 @@ } LOG(LOG_CALLS,_("End of calling ") << *name); } +void ABCVm::checkDeclaredTraits(ASObject* obj) +{ + if(!obj->isInitialized() && + !obj->is<Null>() && + !obj->is<Undefined>() && + !obj->is<IFunction>() && + obj->getClass() && + obj->getClass() != Class_object::getClass()) + obj->getClass()->setupDeclaredTraits(obj); +} int32_t ABCVm::getProperty_i(ASObject* obj, multiname* name) { LOG(LOG_CALLS, _("getProperty_i ") << *name ); + checkDeclaredTraits(obj); //TODO: implement exception handling to find out if no integer can be returned int32_t ret=obj->getVariableByMultiname_i(*name); @@ -367,7 +401,8 @@ ASObject* ABCVm::getProperty(ASObject* obj, multiname* name) { - LOG(LOG_CALLS, _("getProperty ") << *name << ' ' << obj); + LOG(LOG_CALLS, _("getProperty ") << *name << ' ' << obj << ' '<<obj->isInitialized()); + checkDeclaredTraits(obj); _NR<ASObject> prop=obj->getVariableByMultiname(*name); ASObject *ret; @@ -1317,7 +1352,8 @@ o=getCurrentApplicationDomain(th)->getVariableAndTargetByMultiname(*name, target); if(o==NULL) { - LOG(LOG_NOT_IMPLEMENTED,"getLex: " << *name<< " not found, pushing Undefined"); + LOG(LOG_NOT_IMPLEMENTED,"getLex: " << *name<< " not found"); + throwError<ReferenceError>(kUndefinedVarError); th->runtime_stack_push(getSys()->getUndefinedRef()); name->resetNameIfObject(); return; @@ -1410,7 +1446,8 @@ ret=target; else { - LOG(LOG_NOT_IMPLEMENTED,"findPropStrict: " << *name << " not found, pushing Undefined"); + LOG(LOG_NOT_IMPLEMENTED,"findPropStrict: " << *name << " not found"); + throwError<ReferenceError>(kUndefinedVarError); return getSys()->getUndefinedRef(); } } @@ -1455,8 +1492,8 @@ void ABCVm::initProperty(ASObject* obj, ASObject* value, multiname* name) { - LOG(LOG_CALLS, _("initProperty ") << *name << ' ' << obj); - + checkDeclaredTraits(obj); + //Allow to set contant traits obj->setVariableByMultiname(*name,value,ASObject::CONST_ALLOWED); @@ -1801,8 +1838,8 @@ void ABCVm::getDescendants(call_context* th, int n) { multiname* name=th->context->getMultiname(n,th); - LOG(LOG_CALLS,"getDescendants " << *name); ASObject* obj=th->runtime_stack_pop(); + LOG(LOG_CALLS,"getDescendants " << *name << " " <<name->isAttribute<< " "<<obj->getClassName()); //The name must be a QName assert_and_throw(name->name_type==multiname::NAME_STRING); XML::XMLVector ret; @@ -1836,44 +1873,42 @@ } else if(obj->getClass()->isSubClass(Class<Proxy>::getClass())) { - _NR<ASObject> o=obj->getVariableByMultiname(*name, ASObject::SKIP_IMPL); + multiname callPropertyName(NULL); + callPropertyName.name_type=multiname::NAME_STRING; + callPropertyName.name_s_id=getSys()->getUniqueStringId("callProperty"); + callPropertyName.ns.push_back(nsNameAndKind(flash_proxy,NAMESPACE)); + _NR<ASObject> o=obj->getVariableByMultiname(callPropertyName,ASObject::SKIP_IMPL); + if(!o.isNull()) { - o->incRef(); - multiname callPropertyName(NULL); - callPropertyName.name_type=multiname::NAME_STRING; - callPropertyName.name_s_id=getSys()->getUniqueStringId("callProperty"); - callPropertyName.ns.push_back(nsNameAndKind(flash_proxy,NAMESPACE)); - _NR<ASObject> o=obj->getVariableByMultiname(callPropertyName,ASObject::SKIP_IMPL); - - if(!o.isNull()) - { - assert_and_throw(o->getObjectType()==T_FUNCTION); - - IFunction* f=static_cast<IFunction*>(o.getPtr()); - //Create a new array - ASObject** proxyArgs=g_newa(ASObject*, 1); - //Well, I don't how to pass multiname to an as function. I'll just pass the name as a string - proxyArgs[0]=Class<ASString>::getInstanceS(getSys()->getStringFromUniqueId(name->name_s_id)); - - //We now suppress special handling - LOG(LOG_CALLS,_("Proxy::callProperty")); - f->incRef(); - obj->incRef(); - ASObject* ret=f->call(obj,proxyArgs,1); - f->decRef(); - th->runtime_stack_push(ret); - - obj->decRef(); - LOG(LOG_CALLS,_("End of calling ") << *name); - return; - } - else - { - tiny_string objName = obj->getClassName(); - obj->decRef(); - throwError<TypeError>(kDescendentsError, objName); - } + assert_and_throw(o->getObjectType()==T_FUNCTION); + + IFunction* f=static_cast<IFunction*>(o.getPtr()); + //Create a new array + ASObject** proxyArgs=g_newa(ASObject*, 2); + proxyArgs[0]=Class<ASString>::getInstanceS("descendants"); + ASObject* namearg = Class<ASString>::getInstanceS(name->normalizedName()); + namearg->setProxyProperty(*name); + proxyArgs[1]=namearg; + LOG(LOG_ERROR,"Proxy::getDescend:"<<namearg->toDebugString()<<*name); + + //We now suppress special handling + LOG(LOG_CALLS,_("Proxy::callProperty")); + f->incRef(); + obj->incRef(); + ASObject* ret=f->call(obj,proxyArgs,2); + f->decRef(); + th->runtime_stack_push(ret); + + obj->decRef(); + LOG(LOG_CALLS,_("End of calling ") << *name); + return; + } + else + { + tiny_string objName = obj->getClassName(); + obj->decRef(); + throwError<TypeError>(kDescendentsError, objName); } } else
View file
lightspark.tar.xz/src/scripting/class.cpp
Changed
@@ -172,3 +172,48 @@ handleConstruction(ret,args,argslen,true); return ret; } +_R<Class<ASObject>> Class<ASObject>::getStubClass(const QName& name, _R<Class_base> superClass) +{ + MemoryAccount* memoryAccount = getSys()->allocateMemoryAccount(name.name); + Class<ASObject>* ret = new (getSys()->unaccountedMemory) Class<ASObject>(name, memoryAccount); + + ret->setSuper(superClass); + ret->prototype = _MNR(new_objectPrototype()); + ret->prototype->prevPrototype=ret->super->prototype; + ret->incRef(); + ret->prototype->setVariableByQName("constructor","",ret,DYNAMIC_TRAIT); + ret->addPrototypeGetter(); + ret->addLengthGetter(); + + ret->setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(Class_base::_toString),NORMAL_METHOD,false); + getSys()->customClasses.insert(ret); + ret->incRef(); + return _MR(ret); +} +Class<ASObject>* Class<ASObject>::getClass() +{ + uint32_t classId=ClassName<ASObject>::id; + Class<ASObject>* ret=NULL; + Class_base** retAddr=&getSys()->builtinClasses[classId]; + if(*retAddr==NULL) + { + //Create the class + QName name(ClassName<ASObject>::name,ClassName<ASObject>::ns); + MemoryAccount* memoryAccount = getSys()->allocateMemoryAccount(name.name); + ret=new (getSys()->unaccountedMemory) Class<ASObject>(name, memoryAccount); + ret->incRef(); + *retAddr=ret; + ret->prototype = _MNR(new_objectPrototype()); + ASObject::sinit(ret); + + ret->setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(Class_base::_toString),NORMAL_METHOD,false); + ret->incRef(); + ret->prototype->setVariableByQName("constructor","",ret,DYNAMIC_TRAIT); + ret->addPrototypeGetter(); + ret->addLengthGetter(); + } + else + ret=static_cast<Class<ASObject>*>(*retAddr); + + return ret; +}
View file
lightspark.tar.xz/src/scripting/class.h
Changed
@@ -244,51 +244,8 @@ /* This creates a stub class, i.e. a class with given name but without * any implementation. */ - static _R<Class<ASObject>> getStubClass(const QName& name, _R<Class_base> superClass=Class<ASObject>::getRef()) - { - MemoryAccount* memoryAccount = getSys()->allocateMemoryAccount(name.name); - Class<ASObject>* ret = new (getSys()->unaccountedMemory) Class<ASObject>(name, memoryAccount); - - ret->setSuper(superClass); - ret->prototype = _MNR(new_objectPrototype()); - ret->prototype->prevPrototype=ret->super->prototype; - ret->incRef(); - ret->prototype->setVariableByQName("constructor","",ret,DYNAMIC_TRAIT); - ret->addPrototypeGetter(); - ret->addLengthGetter(); - - ret->setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(Class_base::_toString),NORMAL_METHOD,false); - getSys()->customClasses.insert(ret); - ret->incRef(); - return _MR(ret); - } - static Class<ASObject>* getClass() - { - uint32_t classId=ClassName<ASObject>::id; - Class<ASObject>* ret=NULL; - Class_base** retAddr=&getSys()->builtinClasses[classId]; - if(*retAddr==NULL) - { - //Create the class - QName name(ClassName<ASObject>::name,ClassName<ASObject>::ns); - MemoryAccount* memoryAccount = getSys()->allocateMemoryAccount(name.name); - ret=new (getSys()->unaccountedMemory) Class<ASObject>(name, memoryAccount); - ret->incRef(); - *retAddr=ret; - ret->prototype = _MNR(new_objectPrototype()); - ASObject::sinit(ret); - - ret->setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(Class_base::_toString),NORMAL_METHOD,false); - ret->incRef(); - ret->prototype->setVariableByQName("constructor","",ret,DYNAMIC_TRAIT); - ret->addPrototypeGetter(); - ret->addLengthGetter(); - } - else - ret=static_cast<Class<ASObject>*>(*retAddr); - - return ret; - } + static _R<Class<ASObject>> getStubClass(const QName& name, _R<Class_base> superClass=Class<ASObject>::getRef()); + static Class<ASObject>* getClass(); static _R<Class<ASObject>> getRef() { Class<ASObject>* ret = getClass(); @@ -331,7 +288,7 @@ template<class T> class InterfaceClass: public Class_base { - virtual ~InterfaceClass() {} + virtual ~InterfaceClass() { } void buildInstanceTraits(ASObject*) const {} ASObject* getInstance(bool, ASObject* const*, unsigned int, Class_base* realClass) { @@ -343,7 +300,7 @@ assert(argslen == 1); return args[0]; } - InterfaceClass(const QName& name, MemoryAccount* m):Class_base(name, m) {} + InterfaceClass(const QName& name, MemoryAccount* m):Class_base(name, m) { } public: static InterfaceClass<T>* getClass() {
View file
lightspark.tar.xz/src/scripting/flash/concurrent
Added
+(directory)
View file
lightspark.tar.xz/src/scripting/flash/concurrent/Condition.cpp
Added
@@ -0,0 +1,81 @@ +/************************************************************************** + Lightspark, a free flash player implementation + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +**************************************************************************/ + +#include "scripting/flash/concurrent/Condition.h" +#include "scripting/flash/errors/flasherrors.h" +#include "scripting/class.h" +#include "scripting/argconv.h" + +using namespace std; +using namespace lightspark; + +ASCondition::ASCondition(Class_base* c):ASObject(c) +{ + +} +void ASCondition::sinit(Class_base* c) +{ + CLASS_SETUP(c, ASObject, _constructor, CLASS_FINAL); + c->setVariableByQName("isSupported","",abstract_b(false),CONSTANT_TRAIT); + c->setDeclaredMethodByQName("notify","",Class<IFunction>::getFunction(_notify),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("notifyAll","",Class<IFunction>::getFunction(_notifyAll),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("wait","",Class<IFunction>::getFunction(_wait),NORMAL_METHOD,true); + REGISTER_GETTER(c,mutex); +} + +ASFUNCTIONBODY_GETTER(ASCondition,mutex); + +ASFUNCTIONBODY(ASCondition,_constructor) +{ + ASCondition* th=obj->as<ASCondition>(); + _NR<ASObject> arg; + ARG_UNPACK(arg); + if (arg->is<Null>()) + throwError<ArgumentError>(kNullPointerError); + + if (!arg->is<ASMutex>()) + throwError<ArgumentError>(kInvalidArgumentError) ; + arg->incRef(); + th->mutex = _NR<ASMutex>(arg->as<ASMutex>()); + + return NULL; +} +ASFUNCTIONBODY(ASCondition,_notify) +{ + LOG(LOG_NOT_IMPLEMENTED,"condition notify not implemented"); + ASCondition* th=obj->as<ASCondition>(); + if (!th->mutex->getLockCount()) + throwError<ASError>(kConditionCannotNotify) ; + return NULL; +} +ASFUNCTIONBODY(ASCondition,_notifyAll) +{ + LOG(LOG_NOT_IMPLEMENTED,"condition notifyAll not implemented"); + ASCondition* th=obj->as<ASCondition>(); + if (!th->mutex->getLockCount()) + throwError<ASError>(kConditionCannotNotifyAll) ; + return NULL; +} +ASFUNCTIONBODY(ASCondition,_wait) +{ + LOG(LOG_NOT_IMPLEMENTED,"condition wait not implemented"); + ASCondition* th=obj->as<ASCondition>(); + if (!th->mutex->getLockCount()) + throwError<ASError>(kConditionCannotWait) ; + return abstract_b(true); +} +
View file
lightspark.tar.xz/src/scripting/flash/concurrent/Condition.h
Added
@@ -0,0 +1,41 @@ +/************************************************************************** + Lightspark, a free flash player implementation + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +**************************************************************************/ + +#ifndef FLASH_CONCURRENT_CONDITION_H +#define FLASH_CONCURRENT_CONDITION_H + +#include "asobject.h" +#include "scripting/flash/events/flashevents.h" +#include "scripting/flash/concurrent/Mutex.h" + +namespace lightspark +{ + +class ASCondition: public ASObject +{ + ASPROPERTY_GETTER(_NR<ASMutex>,mutex); +public: + ASCondition(Class_base* c); + static void sinit(Class_base*); + ASFUNCTION(_constructor); + ASFUNCTION(_notify); + ASFUNCTION(_notifyAll); + ASFUNCTION(_wait); +}; + +} +#endif // FLASH_CONCURRENT_CONDITION_H
View file
lightspark.tar.xz/src/scripting/flash/concurrent/Mutex.cpp
Added
@@ -0,0 +1,60 @@ +/************************************************************************** + Lightspark, a free flash player implementation + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +**************************************************************************/ + +#include "scripting/flash/concurrent/Mutex.h" +#include "scripting/class.h" +#include "scripting/argconv.h" + +using namespace std; +using namespace lightspark; + +ASMutex::ASMutex(Class_base* c):ASObject(c),lockcount(0) +{ + +} +void ASMutex::sinit(Class_base* c) +{ + CLASS_SETUP(c, ASObject, _constructor, CLASS_FINAL); + c->setDeclaredMethodByQName("lock","",Class<IFunction>::getFunction(_lock),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("unlock","",Class<IFunction>::getFunction(_unlock),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("tryLock","",Class<IFunction>::getFunction(_trylock),NORMAL_METHOD,true); +} + +ASFUNCTIONBODY(ASMutex,_constructor) +{ + return NULL; +} +ASFUNCTIONBODY(ASMutex,_lock) +{ + ASMutex* th=obj->as<ASMutex>(); + th->mutex.lock(); + th->lockcount++; + return NULL; +} +ASFUNCTIONBODY(ASMutex,_unlock) +{ + ASMutex* th=obj->as<ASMutex>(); + th->mutex.unlock(); + th->lockcount--; + return NULL; +} +ASFUNCTIONBODY(ASMutex,_trylock) +{ + ASMutex* th=obj->as<ASMutex>(); + return abstract_b(th->mutex.trylock()); +} +
View file
lightspark.tar.xz/src/scripting/flash/concurrent/Mutex.h
Added
@@ -0,0 +1,44 @@ +/************************************************************************** + Lightspark, a free flash player implementation + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +**************************************************************************/ + +#ifndef FLASH_CONCURRENT_MUTEX_H +#define FLASH_CONCURRENT_MUTEX_H + +#include "asobject.h" +#include "scripting/flash/events/flashevents.h" + +namespace lightspark +{ + +class ASMutex: public ASObject +{ +private: + RecMutex mutex; + int lockcount; + +public: + ASMutex(Class_base* c); + static void sinit(Class_base*); + ASFUNCTION(_constructor); + ASFUNCTION(_lock); + ASFUNCTION(_unlock); + ASFUNCTION(_trylock); + int getLockCount() { return lockcount; } +}; + +} +#endif // FLASH_CONCURRENT_MUTEX_H
View file
lightspark.tar.xz/src/scripting/flash/display/BitmapData.cpp
Changed
@@ -80,6 +80,8 @@ c->setDeclaredMethodByQName("getVector","",Class<IFunction>::getFunction(getVector),NORMAL_METHOD,true); c->setDeclaredMethodByQName("setPixels","",Class<IFunction>::getFunction(setPixels),NORMAL_METHOD,true); c->setDeclaredMethodByQName("setVector","",Class<IFunction>::getFunction(setVector),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("colorTransform","",Class<IFunction>::getFunction(colorTransform),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("compare","",Class<IFunction>::getFunction(compare),NORMAL_METHOD,true); // properties c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(_getHeight),GETTER_METHOD,true); @@ -728,3 +730,105 @@ return NULL; } + +ASFUNCTIONBODY(BitmapData,colorTransform) +{ + BitmapData* th = obj->as<BitmapData>(); + + _NR<Rectangle> inputRect; + _NR<ColorTransform> inputColorTransform; + ARG_UNPACK (inputRect) (inputColorTransform); + + if (inputRect.isNull()) + throwError<TypeError>(kNullPointerError, "rect"); + if (inputColorTransform.isNull()) + throwError<TypeError>(kNullPointerError, "inputVector"); + + RECT rect; + th->pixels->clipRect(inputRect->getRect(), rect); + + vector<uint32_t> pixelvec = th->pixels->getPixelVector(rect); + + unsigned int i = 0; + for (int32_t y=rect.Ymin; y<rect.Ymax; y++) + { + for (int32_t x=rect.Xmin; x<rect.Xmax; x++) + { + + uint32_t pixel = pixelvec[i]; + + int a, r, g, b; + a = ((pixel >> 24 )&0xff) * inputColorTransform->alphaMultiplier + inputColorTransform->alphaOffset; + if (a > 255) a = 255; + if (a < 0) a = 0; + r = ((pixel >> 16 )&0xff) * inputColorTransform->redMultiplier + inputColorTransform->redOffset; + if (r > 255) r = 255; + if (r < 0) r = 0; + g = ((pixel >> 8 )&0xff) * inputColorTransform->greenMultiplier + inputColorTransform->greenOffset; + if (g > 255) g = 255; + if (g < 0) g = 0; + b = ((pixel )&0xff) * inputColorTransform->blueMultiplier + inputColorTransform->blueOffset; + if (b > 255) b = 255; + if (b < 0) b = 0; + + pixel = (a<<24) | (r<<16) | (g<<8) | b; + + th->pixels->setPixel(x, y, pixel, th->transparent); + i++; + } + } + + return NULL; +} +ASFUNCTIONBODY(BitmapData,compare) +{ + BitmapData* th = obj->as<BitmapData>(); + + _NR<BitmapData> otherBitmapData; + ARG_UNPACK (otherBitmapData); + + if (otherBitmapData.isNull()) + throwError<TypeError>(kNullPointerError, "otherBitmapData"); + + if (th->getWidth() != otherBitmapData->getWidth()) + return abstract_d(-3); + if (th->getHeight() != otherBitmapData->getHeight()) + return abstract_d(-4); + RECT rect; + rect.Xmin = 0; + rect.Xmax = th->getWidth(); + rect.Ymin = 0; + rect.Ymax = th->getHeight(); + + vector<uint32_t> pixelvec = th->pixels->getPixelVector(rect); + vector<uint32_t> otherpixelvec = otherBitmapData->pixels->getPixelVector(rect); + + BitmapData* res = Class<BitmapData>::getInstanceS(rect.Xmax,rect.Ymax); + unsigned int i = 0; + bool different = false; + for (int32_t y=rect.Ymin; y<rect.Ymax; y++) + { + for (int32_t x=rect.Xmin; x<rect.Xmax; x++) + { + + uint32_t pixel = pixelvec[i]; + uint32_t otherpixel = otherpixelvec[i]; + if (pixel == otherpixel) + res->pixels->setPixel(x, y, 0, true); + else if ((pixel & 0x00FFFFFF) == (otherpixel & 0x00FFFFFF)) + { + different = true; + res->pixels->setPixel(x, y, ((pixel & 0xFF000000) - (otherpixel & 0xFF000000)) | 0x00FFFFFF , true); + } + else + { + different = true; + res->pixels->setPixel(x, y, ((pixel & 0x00FFFFFF) - (otherpixel & 0x00FFFFFF)), true); + } + i++; + } + } + if (!different) + return abstract_d(0); + return res; +}
View file
lightspark.tar.xz/src/scripting/flash/display/BitmapData.h
Changed
@@ -81,6 +81,8 @@ ASFUNCTION(getVector); ASFUNCTION(setPixels); ASFUNCTION(setVector); + ASFUNCTION(colorTransform); + ASFUNCTION(compare); }; };
View file
lightspark.tar.xz/src/scripting/flash/display/Graphics.h
Changed
@@ -47,7 +47,7 @@ public: Graphics(Class_base* c):ASObject(c),owner(NULL) { - throw RunTimeException("Cannot instantiate a Graphics object"); +// throw RunTimeException("Cannot instantiate a Graphics object"); } Graphics(Class_base* c, TokenContainer* _o) : ASObject(c),owner(_o) {}
View file
lightspark.tar.xz/src/scripting/flash/display/flashdisplay.cpp
Changed
@@ -1035,6 +1035,7 @@ c->setDeclaredMethodByQName("play","",Class<IFunction>::getFunction(play),NORMAL_METHOD,true); c->setDeclaredMethodByQName("gotoAndStop","",Class<IFunction>::getFunction(gotoAndStop),NORMAL_METHOD,true); c->setDeclaredMethodByQName("gotoAndPlay","",Class<IFunction>::getFunction(gotoAndPlay),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("prevFrame","",Class<IFunction>::getFunction(prevFrame),NORMAL_METHOD,true); c->setDeclaredMethodByQName("nextFrame","",Class<IFunction>::getFunction(nextFrame),NORMAL_METHOD,true); c->setDeclaredMethodByQName("addFrameScript","",Class<IFunction>::getFunction(addFrameScript),NORMAL_METHOD,true); REGISTER_GETTER_SETTER(c, enabled); @@ -1233,6 +1234,15 @@ return NULL; } +ASFUNCTIONBODY(MovieClip,prevFrame) +{ + MovieClip* th=static_cast<MovieClip*>(obj); + assert_and_throw(th->state.FP<th->getFramesLoaded()); + th->state.next_FP = th->state.FP-1; + th->state.explicit_FP=true; + return NULL; +} + ASFUNCTIONBODY(MovieClip,_getFramesLoaded) { MovieClip* th=static_cast<MovieClip*>(obj); @@ -1542,11 +1552,13 @@ REGISTER_GETTER_SETTER(c, contextMenu); REGISTER_GETTER_SETTER(c, tabEnabled); REGISTER_GETTER_SETTER(c, tabIndex); + REGISTER_GETTER_SETTER(c, focusRect); } ASFUNCTIONBODY_GETTER_SETTER(InteractiveObject, contextMenu); ASFUNCTIONBODY_GETTER_SETTER(InteractiveObject, tabEnabled); ASFUNCTIONBODY_GETTER_SETTER(InteractiveObject, tabIndex); +ASFUNCTIONBODY_GETTER_SETTER(InteractiveObject, focusRect); // stub void DisplayObjectContainer::dumpDisplayList(unsigned int level) { @@ -2049,6 +2061,7 @@ // override the setter from DisplayObjectContainer c->setDeclaredMethodByQName("tabChildren","",Class<IFunction>::getFunction(_setTabChildren),SETTER_METHOD,true); c->setDeclaredMethodByQName("wmodeGPU","",Class<IFunction>::getFunction(_getWmodeGPU),GETTER_METHOD,true); + c->setDeclaredMethodByQName("invalidate","",Class<IFunction>::getFunction(_invalidate),NORMAL_METHOD,true); REGISTER_GETTER_SETTER(c,align); REGISTER_GETTER_SETTER(c,colorCorrection); REGISTER_GETTER_SETTER(c,displayState); @@ -2304,6 +2317,16 @@ { return abstract_b(false); } +ASFUNCTIONBODY(Stage,_invalidate) +{ + LOG(LOG_NOT_IMPLEMENTED,"invalidate not implemented yet"); + // TODO this crashes lightspark + //Stage* th=obj->as<Stage>(); + //_R<FlushInvalidationQueueEvent> event=_MR(new (getSys()->unaccountedMemory) FlushInvalidationQueueEvent()); + //getVm()->addEvent(_MR(th),event); + return NULL; +} + void StageScaleMode::sinit(Class_base* c) {
View file
lightspark.tar.xz/src/scripting/flash/display/flashdisplay.h
Changed
@@ -31,6 +31,7 @@ #include "backends/netutils.h" #include "scripting/flash/display/DisplayObject.h" #include "scripting/flash/display/TokenContainer.h" +#include "scripting/flash/ui/ContextMenu.h" namespace lightspark { @@ -65,9 +66,10 @@ ~InteractiveObject(); public: InteractiveObject(Class_base* c); - ASPROPERTY_GETTER_SETTER(_NR<ASObject>,contextMenu); // TOOD: should be NativeMenu + ASPROPERTY_GETTER_SETTER(_NR<ContextMenu>,contextMenu); // TOOD: should be NativeMenu ASPROPERTY_GETTER_SETTER(bool,tabEnabled); ASPROPERTY_GETTER_SETTER(int32_t,tabIndex); + ASPROPERTY_GETTER_SETTER(_NR<ASObject>,focusRect); ASFUNCTION(_constructor); ASFUNCTION(_setMouseEnabled); ASFUNCTION(_getMouseEnabled); @@ -251,7 +253,6 @@ static void sinit(Class_base* c); static void buildTraits(ASObject* o); ASFUNCTION(_constructor); - ASFUNCTION(addEventListener); ASFUNCTION(_getLoaderURL); ASFUNCTION(_getURL); ASFUNCTION(_getBytesLoaded); @@ -485,6 +486,7 @@ ASFUNCTION(play); ASFUNCTION(gotoAndStop); ASFUNCTION(gotoAndPlay); + ASFUNCTION(prevFrame); ASFUNCTION(nextFrame); ASFUNCTION(_getCurrentFrame); ASFUNCTION(_getCurrentFrameLabel); @@ -539,6 +541,7 @@ ASFUNCTION(_getFrameRate); ASFUNCTION(_setFrameRate); ASFUNCTION(_getWmodeGPU); + ASFUNCTION(_invalidate); ASPROPERTY_GETTER_SETTER(tiny_string,align); ASPROPERTY_GETTER_SETTER(tiny_string,colorCorrection); ASPROPERTY_GETTER_SETTER(tiny_string,displayState);
View file
lightspark.tar.xz/src/scripting/flash/events/flashevents.cpp
Changed
@@ -1265,3 +1265,10 @@ } ASFUNCTIONBODY_GETTER(StageVideoAvailabilityEvent,availability); + +void ContextMenuEvent::sinit(Class_base* c) +{ + CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); + c->setVariableByQName("MENU_ITEM_SELECT","",Class<ASString>::getInstanceS("menuItemSelect"),DECLARED_TRAIT); + c->setVariableByQName("MENU_SELECT","",Class<ASString>::getInstanceS("menuSelect"),DECLARED_TRAIT); +}
View file
lightspark.tar.xz/src/scripting/flash/events/flashevents.h
Changed
@@ -516,5 +516,13 @@ ASPROPERTY_GETTER(tiny_string,availability); }; +class ContextMenuEvent: public Event +{ +public: + ContextMenuEvent(Class_base* c) : Event(c, "ContextMenuEvent") {} + static void sinit(Class_base*); + static void buildTraits(ASObject* o) {} }; + +} #endif /* SCRIPTING_FLASH_EVENTS_FLASHEVENTS_H */
View file
lightspark.tar.xz/src/scripting/flash/geom/flashgeom.h
Changed
@@ -107,7 +107,8 @@ class ColorTransform: public ASObject { -private: +friend class BitmapData; +protected: number_t redMultiplier,greenMultiplier,blueMultiplier,alphaMultiplier; number_t redOffset,greenOffset,blueOffset,alphaOffset; public:
View file
lightspark.tar.xz/src/scripting/flash/media/flashmedia.cpp
Changed
@@ -63,6 +63,7 @@ c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(Video::_getHeight),GETTER_METHOD,true); c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(Video::_setHeight),SETTER_METHOD,true); c->setDeclaredMethodByQName("attachNetStream","",Class<IFunction>::getFunction(attachNetStream),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("clear","",Class<IFunction>::getFunction(clear),NORMAL_METHOD,true); REGISTER_GETTER_SETTER(c, deblocking); REGISTER_GETTER_SETTER(c, smoothing); } @@ -209,6 +210,11 @@ th->netStream=_MR(Class<NetStream>::cast(args[0])); return NULL; } +ASFUNCTIONBODY(Video,clear) +{ + LOG(LOG_NOT_IMPLEMENTED,"clear is not implemented"); + return NULL; +} _NR<DisplayObject> Video::hitTestImpl(_NR<DisplayObject> last, number_t x, number_t y, DisplayObject::HIT_TYPE type) {
View file
lightspark.tar.xz/src/scripting/flash/media/flashmedia.h
Changed
@@ -138,6 +138,7 @@ ASFUNCTION(_getHeight); ASFUNCTION(_setHeight); ASFUNCTION(attachNetStream); + ASFUNCTION(clear); void renderImpl(RenderContext& ctxt) const; bool boundsRect(number_t& xmin, number_t& xmax, number_t& ymin, number_t& ymax) const; _NR<DisplayObject> hitTestImpl(_NR<DisplayObject> last, number_t x, number_t y, DisplayObject::HIT_TYPE type);
View file
lightspark.tar.xz/src/scripting/flash/net/NetStreamPlayOptions.cpp
Added
@@ -0,0 +1,51 @@ +/************************************************************************** + Lightspark, a free flash player implementation + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +**************************************************************************/ + +#include "scripting/flash/net/NetStreamPlayOptions.h" +#include "scripting/class.h" +#include "scripting/argconv.h" + +using namespace std; +using namespace lightspark; + +NetStreamPlayOptions::NetStreamPlayOptions(Class_base* c):EventDispatcher(c),len(-1),offset(-1),start(-2) +{ + +} +void NetStreamPlayOptions::sinit(Class_base* c) +{ + CLASS_SETUP(c, EventDispatcher, _constructor, CLASS_DYNAMIC_NOT_FINAL); + REGISTER_GETTER_SETTER(c,len); + REGISTER_GETTER_SETTER(c,offset); + REGISTER_GETTER_SETTER(c,oldStreamName); + REGISTER_GETTER_SETTER(c,start); + REGISTER_GETTER_SETTER(c,streamName); + REGISTER_GETTER_SETTER(c,transition); +} + +ASFUNCTIONBODY_GETTER_SETTER(NetStreamPlayOptions,len); +ASFUNCTIONBODY_GETTER_SETTER(NetStreamPlayOptions,offset); +ASFUNCTIONBODY_GETTER_SETTER(NetStreamPlayOptions,oldStreamName); +ASFUNCTIONBODY_GETTER_SETTER(NetStreamPlayOptions,start); +ASFUNCTIONBODY_GETTER_SETTER(NetStreamPlayOptions,streamName); +ASFUNCTIONBODY_GETTER_SETTER(NetStreamPlayOptions,transition); + +ASFUNCTIONBODY(NetStreamPlayOptions,_constructor) +{ + return NULL; +} +
View file
lightspark.tar.xz/src/scripting/flash/net/NetStreamPlayOptions.h
Added
@@ -0,0 +1,43 @@ +/************************************************************************** + Lightspark, a free flash player implementation + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +**************************************************************************/ + +#ifndef NETSTREAMPLAYOPTIONS_H +#define NETSTREAMPLAYOPTIONS_H + +#include "asobject.h" +#include "scripting/flash/events/flashevents.h" + +namespace lightspark +{ + +class NetStreamPlayOptions: public EventDispatcher +{ +private: + ASPROPERTY_GETTER_SETTER(number_t,len); + ASPROPERTY_GETTER_SETTER(number_t,offset); + ASPROPERTY_GETTER_SETTER(tiny_string,oldStreamName); + ASPROPERTY_GETTER_SETTER(number_t,start); + ASPROPERTY_GETTER_SETTER(tiny_string,streamName); + ASPROPERTY_GETTER_SETTER(tiny_string,transition); +public: + NetStreamPlayOptions(Class_base* c); + static void sinit(Class_base*); + ASFUNCTION(_constructor); +}; + +} +#endif // NETSTREAMPLAYOPTIONS_H
View file
lightspark.tar.xz/src/scripting/flash/net/NetStreamPlayTransitions.cpp
Added
@@ -0,0 +1,40 @@ +/************************************************************************** + Lightspark, a free flash player implementation + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +**************************************************************************/ +#include "scripting/flash/net/NetStreamPlayTransitions.h" +#include "scripting/class.h" +#include "scripting/argconv.h" + +using namespace std; +using namespace lightspark; + +NetStreamPlayTransitions::NetStreamPlayTransitions(Class_base* c):ASObject(c) +{ + +} + +void NetStreamPlayTransitions::sinit(Class_base* c) +{ + CLASS_SETUP(c, ASObject, NULL, CLASS_FINAL); + c->setVariableByQName("APPEND","",Class<ASString>::getInstanceS("append"),CONSTANT_TRAIT); + c->setVariableByQName("APPEND_AND_WAIT","",Class<ASString>::getInstanceS("appendAndWait"),CONSTANT_TRAIT); + c->setVariableByQName("RESET","",Class<ASString>::getInstanceS("reset"),CONSTANT_TRAIT); + c->setVariableByQName("RESUME","",Class<ASString>::getInstanceS("resume"),CONSTANT_TRAIT); + c->setVariableByQName("STOP","",Class<ASString>::getInstanceS("stop"),CONSTANT_TRAIT); + c->setVariableByQName("SWAP","",Class<ASString>::getInstanceS("swap"),CONSTANT_TRAIT); + c->setVariableByQName("SWITCH","",Class<ASString>::getInstanceS("switch"),CONSTANT_TRAIT); +} +
View file
lightspark.tar.xz/src/scripting/flash/net/NetStreamPlayTransitions.h
Added
@@ -0,0 +1,33 @@ +/************************************************************************** + Lightspark, a free flash player implementation + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +**************************************************************************/ +#ifndef NETSTREAMPLAYTRANSITIONS_H +#define NETSTREAMPLAYTRANSITIONS_H + +#include "asobject.h" + +namespace lightspark +{ + +class NetStreamPlayTransitions: public ASObject +{ +public: + NetStreamPlayTransitions(Class_base* c); + static void sinit(Class_base*); +}; + +} +#endif // NETSTREAMPLAYTRANSITIONS_H
View file
lightspark.tar.xz/src/scripting/flash/net/flashnet.cpp
Changed
@@ -1018,6 +1018,7 @@ c->setDeclaredMethodByQName("client","",Class<IFunction>::getFunction(_setClient),SETTER_METHOD,true); c->setDeclaredMethodByQName("checkPolicyFile","",Class<IFunction>::getFunction(_getCheckPolicyFile),GETTER_METHOD,true); c->setDeclaredMethodByQName("checkPolicyFile","",Class<IFunction>::getFunction(_setCheckPolicyFile),SETTER_METHOD,true); + c->setDeclaredMethodByQName("attach","",Class<IFunction>::getFunction(attach),NORMAL_METHOD,true); REGISTER_GETTER(c, backBufferLength); REGISTER_GETTER_SETTER(c, backBufferTime); REGISTER_GETTER(c, bufferLength); @@ -1081,40 +1082,30 @@ ASFUNCTIONBODY(NetStream,_constructor) { - obj->incRef(); - _R<NetStream> th=_MR(Class<NetStream>::cast(obj)); + NetStream* th=obj->as<NetStream>(); LOG(LOG_CALLS,_("NetStream constructor")); - assert_and_throw(argslen>=1 && argslen <=2); - assert_and_throw(args[0]->getClass()==Class<NetConnection>::getClass()); + tiny_string value; + _NR<NetConnection> netConnection; - args[0]->incRef(); - _R<NetConnection> netConnection = _MR(Class<NetConnection>::cast(args[0])); - if(argslen == 2) - { - if(args[1]->getObjectType() == T_STRING) - { - tiny_string value = Class<ASString>::cast(args[1])->toString(); - if(value == "directConnections") - th->peerID = DIRECT_CONNECTIONS; - else - th->peerID = CONNECT_TO_FMS; - } - else if(args[1]->getObjectType() == T_NULL) - th->peerID = CONNECT_TO_FMS; - else - throw Class<ArgumentError>::getInstanceS("NetStream constructor: peerID"); - } + ARG_UNPACK(netConnection)(value, "connectToFMS"); - th->client = th; + if(value == "directConnections") + th->peerID = DIRECT_CONNECTIONS; + else + th->peerID = CONNECT_TO_FMS; + + th->incRef(); + netConnection->incRef(); th->connection=netConnection; + th->client = _NR<ASObject>(th); return NULL; } ASFUNCTIONBODY(NetStream,play) { - NetStream* th=Class<NetStream>::cast(obj); + NetStream* th=obj->as<NetStream>(); //Make sure the stream is restarted properly if(th->closed) @@ -1125,8 +1116,10 @@ //Reset the paused states th->paused = false; // th->audioPaused = false; - assert(!th->connection.isNull()); + if (th->connection.isNull()) + throwError<ASError>(0,"not connected"); + if(th->connection->uri.getProtocol()=="http") { //Remoting connection used, this should not happen @@ -1264,6 +1257,17 @@ return NULL; } +ASFUNCTIONBODY(NetStream,attach) +{ + NetStream* th=obj->as<NetStream>(); + _NR<NetConnection> netConnection; + ARG_UNPACK(netConnection); + + netConnection->incRef(); + th->connection=netConnection; + return NULL; +} + //Tick is called from the timer thread, this happens only if a decoder is available void NetStream::tick() { @@ -1846,10 +1850,6 @@ //TODO: should we disallow accessing local files in a directory above //the current one like we do with NetStream.play? - vector<uint8_t> postData; - urlRequest->getPostData(postData); - assert_and_throw(postData.empty()); - Downloader* downloader=getSys()->downloadManager->download(url, _MR(new MemoryStreamCache), NULL); //TODO: make the download asynchronous instead of waiting for an unused response downloader->waitForTermination();
View file
lightspark.tar.xz/src/scripting/flash/net/flashnet.h
Changed
@@ -272,6 +272,7 @@ ASFUNCTION(_setClient); ASFUNCTION(_getCheckPolicyFile); ASFUNCTION(_setCheckPolicyFile); + ASFUNCTION(attach); ASPROPERTY_GETTER(number_t, backBufferLength); ASPROPERTY_GETTER_SETTER(number_t, backBufferTime); ASPROPERTY_GETTER(number_t, bufferLength);
View file
lightspark.tar.xz/src/scripting/flash/system/flashsystem.cpp
Changed
@@ -56,6 +56,8 @@ c->setDeclaredMethodByQName("serverString","",Class<IFunction>::getFunction(_getServerString),GETTER_METHOD,false); c->setDeclaredMethodByQName("screenResolutionX","",Class<IFunction>::getFunction(_getScreenResolutionX),GETTER_METHOD,false); c->setDeclaredMethodByQName("screenResolutionY","",Class<IFunction>::getFunction(_getScreenResolutionY),GETTER_METHOD,false); + c->setDeclaredMethodByQName("hasAccessibility","",Class<IFunction>::getFunction(_getHasAccessibility),GETTER_METHOD,false); + } ASFUNCTIONBODY(Capabilities,_getPlayerType) @@ -121,9 +123,16 @@ gint height = gdk_screen_get_height (screen); return abstract_d(height); } +ASFUNCTIONBODY(Capabilities,_getHasAccessibility) +{ + LOG(LOG_NOT_IMPLEMENTED,"hasAccessibility always returns false"); + return abstract_b(false); +} -ApplicationDomain::ApplicationDomain(Class_base* c, _NR<ApplicationDomain> p):ASObject(c),parentDomain(p) +#define MIN_DOMAIN_MEMORY_LIMIT 1024 +ApplicationDomain::ApplicationDomain(Class_base* c, _NR<ApplicationDomain> p):ASObject(c),domainMemory(Class<ByteArray>::getInstanceS()),parentDomain(p) { + domainMemory->setLength(MIN_DOMAIN_MEMORY_LIMIT); } void ApplicationDomain::sinit(Class_base* c) @@ -172,7 +181,7 @@ ASFUNCTIONBODY(ApplicationDomain,_getMinDomainMemoryLength) { - return abstract_ui(1024); + return abstract_ui(MIN_DOMAIN_MEMORY_LIMIT); } ASFUNCTIONBODY(ApplicationDomain,_getCurrentDomain) @@ -421,6 +430,7 @@ c->setDeclaredMethodByQName("allowInsecureDomain","",Class<IFunction>::getFunction(allowInsecureDomain),NORMAL_METHOD,false); c->setDeclaredMethodByQName("loadPolicyFile","",Class<IFunction>::getFunction(loadPolicyFile),NORMAL_METHOD,false); c->setDeclaredMethodByQName("showSettings","",Class<IFunction>::getFunction(showSettings),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("pageDomain","",Class<IFunction>::getFunction(pageDomain),GETTER_METHOD,false); getSys()->securityManager->setExactSettings(true, false); } @@ -481,6 +491,12 @@ return NULL; } +ASFUNCTIONBODY(Security, pageDomain) +{ + tiny_string s = getSys()->mainClip->getBaseURL().getProtocol()+"://"+getSys()->mainClip->getBaseURL().getHostname(); + return Class<ASString>::getInstanceS(s); +} + ASFUNCTIONBODY(lightspark, fscommand) { assert_and_throw(argslen >= 1 && argslen <= 2);
View file
lightspark.tar.xz/src/scripting/flash/system/flashsystem.h
Changed
@@ -49,6 +49,7 @@ ASFUNCTION(_getServerString); ASFUNCTION(_getScreenResolutionX); ASFUNCTION(_getScreenResolutionY); + ASFUNCTION(_getHasAccessibility); }; class ApplicationDomain: public ASObject @@ -138,6 +139,7 @@ ASFUNCTION(allowInsecureDomain); ASFUNCTION(loadPolicyFile); ASFUNCTION(showSettings); + ASFUNCTION(pageDomain); }; ASObject* fscommand(ASObject* obj,ASObject* const* args, const unsigned int argslen);
View file
lightspark.tar.xz/src/scripting/flash/ui/ContextMenu.cpp
Added
@@ -0,0 +1,53 @@ +/************************************************************************** + Lightspark, a free flash player implementation + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +**************************************************************************/ + +#include "ContextMenu.h" +#include "scripting/class.h" +#include "scripting/argconv.h" + +using namespace std; +using namespace lightspark; + +ContextMenu::ContextMenu(Class_base* c):EventDispatcher(c),customItems(Class<Array>::getInstanceS()),builtInItems(Class<ContextMenuBuiltInItems>::getInstanceS()) +{ +} + +void ContextMenu::sinit(Class_base* c) +{ + CLASS_SETUP(c, EventDispatcher, _constructor, CLASS_FINAL); + c->setVariableByQName("isSupported","",abstract_b(false),CONSTANT_TRAIT); + c->setDeclaredMethodByQName("hideBuiltInItems","",Class<IFunction>::getFunction(hideBuiltInItems),NORMAL_METHOD,true); + REGISTER_GETTER_SETTER(c,customItems); + REGISTER_GETTER_SETTER(c,builtInItems); +} + +ASFUNCTIONBODY_GETTER_SETTER(ContextMenu,customItems); +ASFUNCTIONBODY_GETTER_SETTER(ContextMenu,builtInItems); + +ASFUNCTIONBODY(ContextMenu,_constructor) +{ + LOG(LOG_NOT_IMPLEMENTED,"ContextMenu constructor is a stub"); + return NULL; +} + +ASFUNCTIONBODY(ContextMenu,hideBuiltInItems) +{ + LOG(LOG_NOT_IMPLEMENTED,"ContextMenu hideBuiltInItems is a stub"); + return NULL; +} + +
View file
lightspark.tar.xz/src/scripting/flash/ui/ContextMenu.h
Added
@@ -0,0 +1,42 @@ +/************************************************************************** + Lightspark, a free flash player implementation + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +**************************************************************************/ + +#ifndef SCRIPTING_FLASH_UI_CONTEXTMENU_H +#define SCRIPTING_FLASH_UI_CONTEXTMENU_H + +#include "asobject.h" +#include "scripting/flash/events/flashevents.h" +#include "scripting/flash/ui/ContextMenuBuiltInItems.h" +#include "scripting/toplevel/Array.h" + +namespace lightspark +{ +class Array; + +class ContextMenu : public EventDispatcher +{ +public: + ContextMenu(Class_base* c); + static void sinit(Class_base* c); + ASFUNCTION(_constructor); + ASFUNCTION(hideBuiltInItems); + ASPROPERTY_GETTER_SETTER(_NR<Array>,customItems); + ASPROPERTY_GETTER_SETTER(_NR<ContextMenuBuiltInItems>,builtInItems); +}; + +} +#endif // SCRIPTING_FLASH_UI_CONTEXTMENU_H
View file
lightspark.tar.xz/src/scripting/flash/ui/ContextMenuBuiltInItems.cpp
Added
@@ -0,0 +1,57 @@ +/************************************************************************** + Lightspark, a free flash player implementation + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +**************************************************************************/ + +#include "ContextMenuItem.h" +#include "scripting/class.h" +#include "scripting/argconv.h" + +using namespace std; +using namespace lightspark; + +ContextMenuBuiltInItems::ContextMenuBuiltInItems(Class_base* c):ASObject(c), + forwardAndBack(false),loop(false),play(false),print(false),quality(false),rewind(false),save(false),zoom(false) +{ +} + +void ContextMenuBuiltInItems::sinit(Class_base* c) +{ + CLASS_SETUP(c, ASObject, _constructor, CLASS_FINAL); + REGISTER_GETTER_SETTER(c,forwardAndBack); + REGISTER_GETTER_SETTER(c,loop); + REGISTER_GETTER_SETTER(c,play); + REGISTER_GETTER_SETTER(c,print); + REGISTER_GETTER_SETTER(c,quality); + REGISTER_GETTER_SETTER(c,rewind); + REGISTER_GETTER_SETTER(c,save); + REGISTER_GETTER_SETTER(c,zoom); +} + +ASFUNCTIONBODY_GETTER_SETTER(ContextMenuBuiltInItems,forwardAndBack); +ASFUNCTIONBODY_GETTER_SETTER(ContextMenuBuiltInItems,loop); +ASFUNCTIONBODY_GETTER_SETTER(ContextMenuBuiltInItems,play); +ASFUNCTIONBODY_GETTER_SETTER(ContextMenuBuiltInItems,print); +ASFUNCTIONBODY_GETTER_SETTER(ContextMenuBuiltInItems,quality); +ASFUNCTIONBODY_GETTER_SETTER(ContextMenuBuiltInItems,rewind); +ASFUNCTIONBODY_GETTER_SETTER(ContextMenuBuiltInItems,save); +ASFUNCTIONBODY_GETTER_SETTER(ContextMenuBuiltInItems,zoom); + +ASFUNCTIONBODY(ContextMenuBuiltInItems,_constructor) +{ + return NULL; +} + +
View file
lightspark.tar.xz/src/scripting/flash/ui/ContextMenuBuiltInItems.h
Added
@@ -0,0 +1,46 @@ +/************************************************************************** + Lightspark, a free flash player implementation + + Copyright (C) 2013 Antti Ajanki (antti.ajanki@iki.fi) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +**************************************************************************/ + +#ifndef SCRIPTING_FLASH_UI_CONTEXTMENUBUILTINITEMS_H +#define SCRIPTING_FLASH_UI_CONTEXTMENUBUILTINITEMS_H + +#include "asobject.h" + +namespace lightspark +{ + +class ContextMenuBuiltInItems : public ASObject +{ +private: + ASPROPERTY_GETTER_SETTER(bool,forwardAndBack); + ASPROPERTY_GETTER_SETTER(bool,loop); + ASPROPERTY_GETTER_SETTER(bool,play); + ASPROPERTY_GETTER_SETTER(bool,print); + ASPROPERTY_GETTER_SETTER(bool,quality); + ASPROPERTY_GETTER_SETTER(bool,rewind); + ASPROPERTY_GETTER_SETTER(bool,save); + ASPROPERTY_GETTER_SETTER(bool,zoom); +public: + ContextMenuBuiltInItems(Class_base* c); + static void sinit(Class_base* c); + ASFUNCTION(_constructor); +}; + +} +#endif // SCRIPTING_FLASH_UI_CONTEXTMENUBUILTINITEMS_H
View file
lightspark.tar.xz/src/scripting/flash/ui/ContextMenuItem.cpp
Added
@@ -0,0 +1,36 @@ +/************************************************************************** + Lightspark, a free flash player implementation + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +**************************************************************************/ + +#include "ContextMenuItem.h" +#include "scripting/class.h" +#include "scripting/argconv.h" + +using namespace std; +using namespace lightspark; + +void ContextMenuItem::sinit(Class_base* c) +{ + CLASS_SETUP(c, EventDispatcher, _constructor, CLASS_FINAL); +} + +ASFUNCTIONBODY(ContextMenuItem,_constructor) +{ + LOG(LOG_NOT_IMPLEMENTED,"ContextMenuItem constructor is a stub"); + return NULL; +} + +
View file
lightspark.tar.xz/src/scripting/flash/ui/ContextMenuItem.h
Added
@@ -0,0 +1,38 @@ +/************************************************************************** + Lightspark, a free flash player implementation + + Copyright (C) 2013 Antti Ajanki (antti.ajanki@iki.fi) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +**************************************************************************/ + +#ifndef SCRIPTING_FLASH_UI_CONTEXTMENUITEM_H +#define SCRIPTING_FLASH_UI_CONTEXTMENUITEM_H + +#include "asobject.h" +#include "scripting/flash/events/flashevents.h" + +namespace lightspark +{ + +class ContextMenuItem : public EventDispatcher +{ +public: + ContextMenuItem(Class_base* c):EventDispatcher(c){} + static void sinit(Class_base* c); + ASFUNCTION(_constructor); +}; + +} +#endif // SCRIPTING_FLASH_UI_CONTEXTMENUITEM_H
View file
lightspark.tar.xz/src/scripting/flash/utils/ByteArray.cpp
Changed
@@ -35,7 +35,7 @@ #define BA_CHUNK_SIZE 4096 -ByteArray::ByteArray(Class_base* c, uint8_t* b, uint32_t l):ASObject(c),littleEndian(false),objectEncoding(ObjectEncoding::AMF3), +ByteArray::ByteArray(Class_base* c, uint8_t* b, uint32_t l):ASObject(c),littleEndian(false),objectEncoding(ObjectEncoding::AMF3),currentObjectEncoding(ObjectEncoding::AMF3), position(0),bytes(b),real_len(l),len(l),shareable(false) { #ifdef MEMORY_USAGE_PROFILING @@ -288,6 +288,7 @@ throwError<ArgumentError>(kInvalidEnumError, "objectEncoding"); th->objectEncoding=value; + th->currentObjectEncoding=value; return NULL; } @@ -704,6 +705,14 @@ return NULL; } +bool ByteArray::peekByte(uint8_t& b) +{ + if (len <= position+1) + return false; + + b=bytes[position+1]; + return true; +} bool ByteArray::readByte(uint8_t& b) { if (len <= position) @@ -940,7 +949,7 @@ return getSys()->getUndefinedRef(); //throwError<EOFError>(kEOFError); } - assert_and_throw(th->objectEncoding==ObjectEncoding::AMF3); + //assert_and_throw(th->objectEncoding==ObjectEncoding::AMF3); Amf3Deserializer d(th); _NR<ASObject> ret(NullRef); try
View file
lightspark.tar.xz/src/scripting/flash/utils/ByteArray.h
Changed
@@ -31,9 +31,11 @@ { friend class LoaderThread; friend class URLLoader; +friend class ApplicationDomain; protected: bool littleEndian; uint8_t objectEncoding; + uint8_t currentObjectEncoding; uint32_t position; uint8_t* bytes; uint32_t real_len; @@ -48,6 +50,7 @@ ByteArray(Class_base* c, uint8_t* b = NULL, uint32_t l = 0); ~ByteArray(); //Helper interface for serialization + bool peekByte(uint8_t& b); bool readByte(uint8_t& b); bool readShort(uint16_t& ret); bool readUnsignedInt(uint32_t& ret); @@ -63,7 +66,10 @@ void writeU29(uint32_t val); uint32_t getPosition() const; void setPosition(uint32_t p); - + + uint8_t getCurrentObjectEncoding() const { return currentObjectEncoding; } + void setCurrentObjectEncoding(uint8_t encoding) { currentObjectEncoding = encoding; } + ASFUNCTION(_getBytesAvailable); ASFUNCTION(_getLength); ASFUNCTION(_setLength);
View file
lightspark.tar.xz/src/scripting/flash/utils/Proxy.cpp
Changed
@@ -37,7 +37,7 @@ void Proxy::sinit(Class_base* c) { - CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED); + CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject,CLASS_DYNAMIC_NOT_FINAL); } void Proxy::buildTraits(ASObject* o) @@ -70,9 +70,10 @@ IFunction* f=static_cast<IFunction*>(proxySetter.getPtr()); - //Well, I don't how to pass multiname to an as function. I'll just pass the name as a string + ASObject* namearg = Class<ASString>::getInstanceS(name.normalizedName()); + namearg->setProxyProperty(name); ASObject* args[2]; - args[0]=Class<ASString>::getInstanceS(name.normalizedName()); + args[0]=namearg; args[1]=o; //We now suppress special handling implEnable=false; @@ -87,15 +88,18 @@ { //It seems that various kind of implementation works only with the empty namespace assert_and_throw(name.ns.size()>0); + _NR<ASObject> o; if(!name.ns[0].hasEmptyName() || ASObject::hasPropertyByMultiname(name, true, true) || !implEnable || (opt & ASObject::SKIP_IMPL)!=0) - return ASObject::getVariableByMultiname(name,opt); + o = ASObject::getVariableByMultiname(name,opt); + if (!o.isNull() || !implEnable || (opt & ASObject::SKIP_IMPL)!=0) + return o; //Check if there is a custom getter defined, skipping implementation to avoid recursive calls multiname getPropertyName(NULL); getPropertyName.name_type=multiname::NAME_STRING; getPropertyName.name_s_id=getSys()->getUniqueStringId("getProperty"); getPropertyName.ns.push_back(nsNameAndKind(flash_proxy,NAMESPACE)); - _NR<ASObject> o=getVariableByMultiname(getPropertyName,ASObject::SKIP_IMPL); + o=getVariableByMultiname(getPropertyName,ASObject::SKIP_IMPL); if(o.isNull()) return ASObject::getVariableByMultiname(name,opt); @@ -104,11 +108,12 @@ IFunction* f=static_cast<IFunction*>(o.getPtr()); - //Well, I don't how to pass multiname to an as function. I'll just pass the name as a string - ASObject* arg=Class<ASString>::getInstanceS(name.normalizedName()); + ASObject* namearg = Class<ASString>::getInstanceS(name.normalizedName()); + namearg->setProxyProperty(name); + ASObject* arg = namearg; //We now suppress special handling implEnable=false; - LOG(LOG_CALLS,"Proxy::getProperty"); + LOG(LOG_CALLS,"Proxy::getProperty "<< name.normalizedName() << " " << this->toDebugString()); incRef(); _NR<ASObject> ret=_MNR(f->call(this,&arg,1)); implEnable=true; @@ -117,6 +122,8 @@ bool Proxy::hasPropertyByMultiname(const multiname& name, bool considerDynamic, bool considerPrototype) { + if (name.normalizedName() == "isAttribute") + return true; //If a variable named like this already exist, use that bool asobject_has_property=ASObject::hasPropertyByMultiname(name, considerDynamic, considerPrototype); if(asobject_has_property || !implEnable) @@ -138,8 +145,9 @@ IFunction* f=static_cast<IFunction*>(proxyHasProperty.getPtr()); - //Well, I don't how to pass multiname to an as function. I'll just pass the name as a string - ASObject* arg=Class<ASString>::getInstanceS(name.normalizedName()); + ASObject* namearg = Class<ASString>::getInstanceS(name.normalizedName()); + namearg->setProxyProperty(name); + ASObject* arg = namearg; //We now suppress special handling implEnable=false; LOG(LOG_CALLS,_("Proxy::hasProperty")); @@ -173,8 +181,9 @@ IFunction* f=static_cast<IFunction*>(proxyDeleter.getPtr()); - //Well, I don't how to pass multiname to an as function. I'll just pass the name as a string - ASObject* arg=Class<ASString>::getInstanceS(name.normalizedName()); + ASObject* namearg = Class<ASString>::getInstanceS(name.normalizedName()); + namearg->setProxyProperty(name); + ASObject* arg = namearg; //We now suppress special handling implEnable=false; LOG(LOG_CALLS,_("Proxy::deleteProperty"));
View file
lightspark.tar.xz/src/scripting/toplevel/Boolean.cpp
Changed
@@ -53,6 +53,15 @@ return o->as<UInteger>()->val != 0; case T_STRING: return !o->as<ASString>()->data.empty(); + case T_CLASS: + case T_FUNCTION: + return true; + case T_ARRAY: + case T_OBJECT: + // not constructed objects return false + if (!o->isConstructed()) + return false; + return true; default: //everything else is an Object regarding to the spec return true;
View file
lightspark.tar.xz/src/scripting/toplevel/Vector.cpp
Changed
@@ -799,10 +799,17 @@ ASFUNCTIONBODY(Vector,_map) { Vector* th=static_cast<Vector*>(obj); - assert_and_throw(argslen==1 && args[0]->getObjectType()==T_FUNCTION); - IFunction* func=static_cast<IFunction*>(args[0]); + _NR<IFunction> func; + _NR<ASObject> thisObject; + + if (argslen >= 1 && !args[0]->is<IFunction>()) + throwError<TypeError>(kCheckTypeFailedError, args[0]->getClassName(), "Function"); + + ARG_UNPACK(func)(thisObject,NullRef); + Vector* ret= (Vector*)obj->getClass()->getInstance(true,NULL,0); + ASObject* thisObj; for(uint32_t i=0;i<th->size();i++) { ASObject* funcArgs[3]; @@ -821,7 +828,14 @@ funcArgs[1]=abstract_i(i); funcArgs[2]=th; funcArgs[2]->incRef(); - ASObject* funcRet=func->call(getSys()->getNullRef(), funcArgs, 3); + if (thisObject.isNull()) + thisObj = getSys()->getNullRef(); + else + { + thisObj = thisObject.getPtr(); + thisObj->incRef(); + } + ASObject* funcRet=func->call(thisObj, funcArgs, 3); assert_and_throw(funcRet); ret->vec.push_back(funcRet); }
View file
lightspark.tar.xz/src/scripting/toplevel/XML.cpp
Changed
@@ -282,10 +282,12 @@ ASFUNCTIONBODY(XML,descendants) { XML* th=Class<XML>::cast(obj); - tiny_string name; - ARG_UNPACK(name,"*"); + _NR<ASObject> name; + ARG_UNPACK(name,_NR<ASObject>(Class<ASString>::getInstanceS("*"))); XMLVector ret; - th->getDescendantsByQName(name,"",false,ret); + multiname mname(NULL); + name->applyProxyProperty(mname); + th->getDescendantsByQName(name->toString(),"",mname.isAttribute,ret); return Class<XMLList>::getInstanceS(ret,th->getChildrenlist(),multiname(NULL)); } @@ -1579,7 +1581,6 @@ bool XML::deleteVariableByMultiname(const multiname& name) { unsigned int index=0; - bool bdeleted = false; if(name.isAttribute) { //Only the first namespace is used, is this right? @@ -1609,7 +1610,6 @@ (attr->nodenamespace_uri == ns_uri && attr->nodename == name.normalizedName())) { attributelist->nodes.erase(it); - bdeleted= true; } } } @@ -1641,12 +1641,11 @@ (node->nodenamespace_uri == ns_uri && node->nodename == name.normalizedName())) { childrenlist->nodes.erase(it); - bdeleted= true; } } } } - return bdeleted; + return true; } bool XML::isValidMultiname(const multiname& name, uint32_t& index) {
View file
lightspark.tar.xz/src/scripting/toplevel/XMLList.cpp
Changed
@@ -342,11 +342,12 @@ ASFUNCTIONBODY(XMLList,descendants) { XMLList* th=Class<XMLList>::cast(obj); - tiny_string name; - assert_and_throw(argslen==0 || args[0]->getObjectType()!=T_QNAME); - ARG_UNPACK(name,"*"); + _NR<ASObject> name; + ARG_UNPACK(name,_NR<ASObject>(Class<ASString>::getInstanceS("*"))); XML::XMLVector ret; - th->getDescendantsByQName(name,"",false,ret); + multiname mname(NULL); + name->applyProxyProperty(mname); + th->getDescendantsByQName(name->toString(),"",mname.isAttribute,ret); return Class<XMLList>::getInstanceS(ret,th->targetobject,multiname(NULL)); }
View file
lightspark.tar.xz/src/scripting/toplevel/toplevel.cpp
Changed
@@ -910,13 +910,16 @@ { target->incRef(); ASObject* ret=constructor->call(target,args,argslen); + target->constructorCalled = true; assert_and_throw(ret->is<Undefined>()); ret->decRef(); } else { + target->constructorCalled = true; for(uint32_t i=0;i<argslen;i++) args[i]->decRef(); + //throwError<TypeError>(kConstructOfNonFunctionError); } } @@ -1080,6 +1083,11 @@ if(cls==this || cls==Class<ASObject>::getClass()) return true; + // it seems that classes with the same name from different applicationDomains + // are treated as equal, so we test for same names + if (this->getQualifiedClassName() == cls->getQualifiedClassName()) + return true; + //Now check the interfaces if (considerInterfaces) {
View file
lightspark.tar.xz/src/scripting/toplevel/toplevel.h
Changed
@@ -45,7 +45,7 @@ class method_info; struct call_context; struct traits_info; -class namespace_info; +struct namespace_info; class Any; class Void; class Class_object; @@ -248,7 +248,7 @@ } void buildInstanceTraits(ASObject* o) const { - throw RunTimeException("Class_object::buildInstanceTraits"); +// throw RunTimeException("Class_object::buildInstanceTraits"); } void finalize(); public: @@ -529,7 +529,7 @@ class ASQName: public ASObject { -friend class multiname; +friend struct multiname; friend class Namespace; private: bool uri_is_null;
View file
lightspark.tar.xz/src/swf.cpp
Changed
@@ -145,6 +145,7 @@ { Class_base* movieClipClass = Class<MovieClip>::getClass(); RootMovieClip* ret=new (movieClipClass->memoryAccount) RootMovieClip(li, appDomain, secDomain, movieClipClass); + ret->constructorCalled = true; return ret; }
View file
lightspark.tar.xz/src/swftypes.h
Changed
@@ -83,7 +83,7 @@ class ASObject; class ABCContext; -class namespace_info; +struct namespace_info; struct multiname; class QName
View file
lightspark.tar.xz/tools/pygil
Changed
@@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2 #This greps the source for SET_NAMESPACE, REGISTER_CLASS_NAME2, #sinit definition and the following ->set{Getter,Setter,Method}ByQName calls @@ -27,7 +27,8 @@ rset2 = re.compile('.*REGISTER_SETTER\([^,]*, *(.*)\)') rgetset2 = re.compile('.*REGISTER_GETTER_SETTER\([^,]*, *(.*)\)') #Constant names do not contain lower-case letters -rconst = re.compile('[^/]*->setVariableByQName\("([A-Z_]*)",.*_TRAIT'); +rconst = re.compile('[^/]*->setVariableByQName\("([A-Z_0-9]*)",.*_TRAIT'); +rcomment = re.compile('[ \t]*/') def getFullname(cls,name): if cls != "": @@ -81,7 +82,14 @@ p2 = Popen(["xargs","cat"], stdin=p1.stdout, stdout=PIPE); p1.stdout.close() -for line in p2.communicate()[0].split(";"): +ptmp ="" +for line in p2.communicate()[0].split("\n"): + m = rcomment.match(line) + if m: + continue + ptmp = ptmp + line + +for line in ptmp.split(";"): line = line.replace("\n","").rstrip().rstrip(); m = sinit.match(line) if m:
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.