diff --git a/CMakeLists.txt b/CMakeLists.txt index f8eea6b..aae2d71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,7 +167,7 @@ if(Boost_FOUND) ENDIF(Boost_FOUND) IF(UNIX) INCLUDE(FindPkgConfig REQUIRED) - pkg_check_modules(EXTRA_LIBS REQUIRED x11 fontconfig cairo pangocairo) + pkg_check_modules(EXTRA_LIBS REQUIRED x11 cairo pangocairo) ENDIF(UNIX) IF(WIN32) diff --git a/conf/FindFTGL.cmake b/conf/FindFTGL.cmake deleted file mode 100644 index d63178f..0000000 --- a/conf/FindFTGL.cmake +++ /dev/null @@ -1,27 +0,0 @@ -# - Find FTGL -# Find the native FTGL headers and libraries. -# -# FTGL_INCLUDE_DIRS - where to find pcre.h, etc. -# FTGL_LIBRARIES - List of libraries when using ftgl -# FTGL_FOUND - True if ftgl found. - -# Look for the header file. -FIND_PATH(FTGL_INCLUDE_DIR NAMES FTGL/ftgl.h) -MARK_AS_ADVANCED(FTGL_INCLUDE_DIR) - -# Look for the library. -FIND_LIBRARY(FTGL_LIBRARY NAMES - ftgl - ftgl_d -) -MARK_AS_ADVANCED(FTGL_LIBRARY) - -# handle the QUIETLY and REQUIRED arguments and set FTGL_FOUND to TRUE if -# all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(FTGL DEFAULT_MSG FTGL_LIBRARY FTGL_INCLUDE_DIR) - -IF(FTGL_FOUND) - SET(FTGL_LIBRARIES ${FTGL_LIBRARY}) - SET(FTGL_INCLUDE_DIRS ${FTGL_INCLUDE_DIR}) -ENDIF(FTGL_FOUND) diff --git a/src/asobject.cpp b/src/asobject.cpp index f2f9620..6808c14 100644 --- a/src/asobject.cpp +++ b/src/asobject.cpp @@ -556,6 +556,7 @@ ASFUNCTIONBODY(ASObject,hasOwnProperty) name.name_type=multiname::NAME_STRING; name.name_s=args[0]->toString(); name.ns.push_back(nsNameAndKind("",NAMESPACE)); + name.isAttribute=false; bool ret=obj->hasPropertyByMultiname(name, true); return abstract_b(ret); } diff --git a/src/backends/decoder.cpp b/src/backends/decoder.cpp index 46c25bc..279d1f7 100644 --- a/src/backends/decoder.cpp +++ b/src/backends/decoder.cpp @@ -26,7 +26,7 @@ #include "graphics.h" #include "backends/rendering.h" -#if LIBAVUTIL_VERSION_MAJOR < 52 +#if LIBAVUTIL_VERSION_MAJOR < 51 #define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO #define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO #endif diff --git a/src/backends/netutils.cpp b/src/backends/netutils.cpp index ce08dbc..8e4ff6a 100644 --- a/src/backends/netutils.cpp +++ b/src/backends/netutils.cpp @@ -681,7 +681,6 @@ void Downloader::allocateBuffer(size_t size) //Create buffer if(buffer == NULL) { - buffer = (uint8_t*) calloc(size, sizeof(uint8_t)); stableBuffer = buffer; setg((char*)buffer,(char*)buffer,(char*)buffer); @@ -690,7 +689,7 @@ void Downloader::allocateBuffer(size_t size) else { assert(!cached); - intptr_t curLen = (intptr_t) (egptr()-eback()); + intptr_t curLen = receivedLength; //We have to extend the buffer, so create a new one if(stableBuffer!=buffer) { diff --git a/src/backends/rendering.cpp b/src/backends/rendering.cpp index ea7f5ec..b52b8f2 100644 --- a/src/backends/rendering.cpp +++ b/src/backends/rendering.cpp @@ -223,13 +223,13 @@ void* RenderThread::worker(RenderThread* th) LOG(LOG_ERROR,_("glX not present")); return NULL; } - int attrib[10]={GLX_BUFFER_SIZE,24,GLX_DOUBLEBUFFER,True,None}; + int attrib[10]={GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, GLX_DOUBLEBUFFER, True, None}; GLXFBConfig* fb=glXChooseFBConfig(d, 0, attrib, &a); if(!fb) { - attrib[2]=None; - fb=glXChooseFBConfig(d, 0, attrib, &a); + attrib[6]=None; LOG(LOG_ERROR,_("Falling back to no double buffering")); + fb=glXChooseFBConfig(d, 0, attrib, &a); } if(!fb) { diff --git a/src/backends/urlutils.cpp b/src/backends/urlutils.cpp index 7575e49..176b7db 100644 --- a/src/backends/urlutils.cpp +++ b/src/backends/urlutils.cpp @@ -332,14 +332,14 @@ std::string URLInfo::encode(const std::string& u, ENCODING type) str += '+'; //Additionally ENCODE_URICOMPONENT and ENCODE_URI don't encode: //- _ . ! ~ * ' ( ) - else if((type == ENCODE_URI || ENCODE_URICOMPONENT) && + else if((type == ENCODE_URI || type == ENCODE_URICOMPONENT || type == ENCODE_ESCAPE) && (u[i] == '-' || u[i] == '_' || u[i] == '.' || u[i] == '!' || u[i] == '~' || u[i] == '*' || u[i] == '\'' || u[i] == '(' || u[i] == ')')) str += u[i]; //Additionally ENCODE_URI doesn't encode: //; / ? : @ & = + $ , # - else if(type == ENCODE_URI && + else if((type == ENCODE_URI || type == ENCODE_ESCAPE) && (u[i] == ';' || u[i] == '/' || u[i] == '?' || u[i] == ':' || u[i] == '@' || u[i] == '&' || u[i] == '=' || u[i] == '+' || u[i] == '$' || u[i] == ',' || u[i] == '#')) diff --git a/src/parsing/streams.cpp b/src/parsing/streams.cpp index 8a5d7b0..b7894b0 100644 --- a/src/parsing/streams.cpp +++ b/src/parsing/streams.cpp @@ -27,167 +27,6 @@ using namespace std; -sync_stream::sync_stream():head(0),tail(0),wait_notfull(false),wait_notempty(false),buf_size(1024*1024),failed(false),ended(false),consumed(0) -{ - buffer=new char[buf_size]; - sem_init(&mutex,0,1); - sem_init(¬full,0,0); - sem_init(¬empty,0,0); - setg(buffer,buffer,buffer); -} - -sync_stream::~sync_stream() -{ - delete[] buffer; - sem_destroy(&mutex); - sem_destroy(¬full); - sem_destroy(¬empty); -} - -void sync_stream::stop() -{ - sem_wait(&mutex); - failed=true; - if(wait_notfull) - { - wait_notfull=false; - sem_post(¬full); - sem_wait(&mutex); - } - if(wait_notempty) - { - wait_notempty=false; - sem_post(¬empty); - sem_wait(&mutex); - } - sem_post(&mutex); -} - -void sync_stream::eof() -{ - sem_wait(&mutex); - ended=true; - if(wait_notempty) - { - wait_notempty=false; - sem_post(¬empty); - } - else - sem_post(&mutex); -} - -sync_stream::pos_type sync_stream::seekoff(off_type off, ios_base::seekdir dir,ios_base::openmode mode) -{ - assert(off==0); - //The current offset is the amount of byte completely consumed plus the amount used in the buffer - int ret=consumed+(gptr()-eback()); - return ret; -} - -sync_stream::int_type sync_stream::underflow() -{ - assert(gptr()==egptr()); - - sem_wait(&mutex); - //First of all we add the length of the buffer to the consumed variable - int consumedNow=(gptr()-eback()); - consumed+=consumedNow; - head+=consumedNow; - head%=buf_size; - if(failed) - { - sem_post(&mutex); - //Return EOF - return -1; - } - if(tail==head) - { - if(ended) //There is no way more data will arrive - { - sem_post(&mutex); - //Return EOF - return -1; - } - wait_notempty=true; - sem_post(&mutex); - sem_wait(¬empty); - if(failed || ended) - { - sem_post(&mutex); - //Return EOF - return -1; - } - } - - if(headbuf_size) - { - int i=buf_size-tail; - memcpy(buffer+tail,buf,i); - memcpy(buffer,buf+i,len-i); - } - else - memcpy(buffer+tail,buf,len); - tail+=len; - tail%=buf_size; - assert(head!=tail); - if(wait_notempty) - { - wait_notempty=false; - sem_post(¬empty); - } - else - sem_post(&mutex); - return len; -} - -uint32_t sync_stream::getFree() -{ - sem_wait(&mutex); - uint32_t freeBytes=(head-tail+buf_size-1)%buf_size; - sem_post(&mutex); - return freeBytes; -} zlib_filter::zlib_filter(streambuf* b):backend(b),consumed(0) { diff --git a/src/parsing/streams.h b/src/parsing/streams.h index c631e45..988dcf2 100644 --- a/src/parsing/streams.h +++ b/src/parsing/streams.h @@ -43,31 +43,6 @@ public: ~zlib_filter(); }; -class DLL_PUBLIC sync_stream: public std::streambuf -{ -public: - sync_stream(); - void stop(); - void eof(); - ~sync_stream(); - uint32_t write(char* buf, int len); - uint32_t getFree(); - virtual int_type underflow(); - virtual pos_type seekoff(off_type, std::ios_base::seekdir, std::ios_base::openmode); -private: - char* buffer; - int head; - int tail; - sem_t mutex; - sem_t notfull; - sem_t notempty; - bool wait_notfull; - bool wait_notempty; - const int buf_size; - bool failed; - bool ended; - int consumed; -}; class bytes_buf:public std::streambuf { diff --git a/src/plugin/plugin.cpp b/src/plugin/plugin.cpp index ffb578d..fd60233 100644 --- a/src/plugin/plugin.cpp +++ b/src/plugin/plugin.cpp @@ -569,6 +569,7 @@ int32_t nsPluginInstance::Write(NPStream *stream, int32_t offset, int32_t len, v NPError nsPluginInstance::DestroyStream(NPStream *stream, NPError reason) { + sys=m_sys; NPDownloader* dl=static_cast(stream->pdata); assert(dl); //Check if async destructin of this downloader has been requested @@ -586,6 +587,7 @@ NPError nsPluginInstance::DestroyStream(NPStream *stream, NPError reason) } //Notify our downloader of what happened URLNotify(stream->url, reason, stream->pdata); + sys=NULL; return NPERR_NO_ERROR; } diff --git a/src/scripting/flashdisplay.cpp b/src/scripting/flashdisplay.cpp index bfdf846..5df6f98 100644 --- a/src/scripting/flashdisplay.cpp +++ b/src/scripting/flashdisplay.cpp @@ -323,6 +323,7 @@ void Loader::execute() contentLoaderInfo->incRef(); //Use a local variable to store the new root, as the localRoot member may change _R newRoot=_MR(RootMovieClip::getInstance(contentLoaderInfo.getPtr())); + newRoot->setOrigin(url.getParsedURL(), ""); _addChildAt(newRoot,0); @@ -2972,7 +2973,10 @@ ASFUNCTIONBODY(Graphics,beginGradientFill) assert_and_throw(args[2]->getObjectType()==T_ARRAY); Array* alphas=Class::cast(args[2]); - assert_and_throw(args[3]->getObjectType()==T_ARRAY); + //assert_and_throw(args[3]->getObjectType()==T_ARRAY); + //Work around for bug in YouTube player of July 13 2011 + if(args[3]->getObjectType()==T_UNDEFINED) + return NULL; Array* ratios=Class::cast(args[3]); int NumGradient = colors->size(); diff --git a/src/scripting/flashgeom.cpp b/src/scripting/flashgeom.cpp index db5236e..660bb85 100644 --- a/src/scripting/flashgeom.cpp +++ b/src/scripting/flashgeom.cpp @@ -1127,12 +1127,12 @@ ASFUNCTIONBODY(Matrix,concat) number_t ta, tb, tc, td, tx, ty; - ta = th->a * m->a + th->c * m->b; - tb = th->b * m->a + th->d * m->b; - tc = th->a * m->c + th->c * m->d; - td = th->b * m->c + th->d * m->d; - tx = th->a * m->tx + th->c * m->ty + th->tx; - ty = th->b * m->tx + th->d * m->ty + th->ty; + ta = m->a * th->a + m->c * th->b; + tb = m->b * th->a + m->d * th->b; + tc = m->a * th->c + m->c * th->d; + td = m->b * th->c + m->d * th->d; + tx = m->a * th->tx + m->c * th->ty + m->tx; + ty = m->b * th->tx + m->d * th->ty + m->ty; th->a = ta; th->b = tb; diff --git a/src/scripting/flashutils.cpp b/src/scripting/flashutils.cpp index f44b61e..04cce66 100644 --- a/src/scripting/flashutils.cpp +++ b/src/scripting/flashutils.cpp @@ -784,36 +784,52 @@ ASFUNCTIONBODY(lightspark,describeType) ret+=(isStatic)?"\"true\"":"\"false\""; ret+=">"; //TODO: add support for extendsClass and implementsInterface and factory - auto it=args[0]->Variables.Variables.begin(); - for(;it!=args[0]->Variables.Variables.end();it++) + type=static_cast(args[0]); + do { - if(isStatic && it->second.kind==BORROWED_TRAIT) - continue; - - //TODO: add support for constant, method, parameter - if(it->second.var.getter) - { - //Output an accessor - //TODO: add support in accessor for access,type,declaredBy - ret+="first.raw_buf(); - ret+="\"/>"; - } - else if(it->second.var.var) + auto it=type->Variables.Variables.begin(); + for(;it!=type->Variables.Variables.end();it++) { - //Output a variable - ret+="first.raw_buf(); - ret+="\""; - if(it->second.var.type) + if(isStatic && it->second.kind==BORROWED_TRAIT) + continue; + + //TODO: add support for constant, method, parameter + if(it->second.var.getter) + { + //Output an accessor + //TODO: add support in accessor for access,type,declaredBy + ret+="first.raw_buf(); + ret+="\"/>"; + } + else if(it->second.var.var) { - ret+=" type=\""; - ret+=it->second.var.type->class_name.getQualifiedName().raw_buf(); - ret+="\""; + if(it->second.var.var->getObjectType()==T_FUNCTION) + { + //Output a method + //TODO: add support in method for declaredBy,returnType + ret+="first.raw_buf(); + ret+="\"/>"; + } + else + { + //Output a variable + ret+="first.raw_buf(); + ret+="\""; + if(it->second.var.type) + { + ret+=" type=\""; + ret+=it->second.var.type->class_name.getQualifiedName().raw_buf(); + ret+="\""; + } + ret+="/>"; + } } - ret+="/>"; } } + while((type=type->getPrototype())!=NULL); ret+=""; return Class::getInstanceS(ret);; diff --git a/src/scripting/toplevel.cpp b/src/scripting/toplevel.cpp index c64403c..69709f5 100644 --- a/src/scripting/toplevel.cpp +++ b/src/scripting/toplevel.cpp @@ -271,6 +271,10 @@ ASFUNCTIONBODY(Array,lastIndexOf) int unsigned i = th->data.size()-1; int j; + + if(argslen == 2 && std::isnan(args[1]->toNumber())) + return abstract_i(0); + if(argslen == 2 && args[1]->getObjectType() != T_UNDEFINED && !std::isnan(args[1]->toNumber())) { j = args[1]->toInt(); //Preserve sign @@ -314,24 +318,30 @@ ASFUNCTIONBODY(Array,shift) ASFUNCTIONBODY(Array,splice) { Array* th=static_cast(obj); - + int startIndex=args[0]->toInt(); int deleteCount=args[1]->toUInt(); int totalSize=th->data.size(); - - //A negative startIndex is relative to the end - assert_and_throw(abs(startIndex)::getInstanceS(); + + if(totalSize) + { + //A negative startIndex is relative to the end + assert_and_throw(abs(startIndex)totalSize) deleteCount=totalSize-startIndex; - - Array* ret=Class::getInstanceS(); - ret->data.reserve(deleteCount); - for(int i=0;idata.push_back(th->data[startIndex+i]); - - th->data.erase(th->data.begin()+startIndex,th->data.begin()+startIndex+deleteCount); + if(deleteCount) + { + ret->data.reserve(deleteCount); + + for(int i=0;idata.push_back(th->data[startIndex+i]); + + th->data.erase(th->data.begin()+startIndex,th->data.begin()+startIndex+deleteCount); + } //Insert requested values starting at startIndex for(unsigned int i=2,n=0;i(node); if(element==NULL) return NULL; - xmlpp::Attribute* attr=element->get_attribute(normalizedName.raw_buf()); + xmlpp::Attribute* attr=element->get_attribute(buf); if(attr==NULL) return NULL; @@ -1021,7 +1038,7 @@ ASObject* XML::getVariableByMultiname(const multiname& name, bool skip_impl) assert_and_throw(name.ns.size()>0 && name.ns[0].name==""); //Normalize the name to the string form assert(node); - const xmlpp::Node::NodeList& children=node->get_children(normalizedName.raw_buf()); + const xmlpp::Node::NodeList& children=node->get_children(buf); xmlpp::Node::NodeList::const_iterator it=children.begin(); std::vector<_R> ret; @@ -1055,8 +1072,15 @@ bool XML::hasPropertyByMultiname(const multiname& name, bool considerDynamic) if(considerDynamic==false) return ASObject::hasPropertyByMultiname(name, considerDynamic); + bool isAttr=name.isAttribute; const tiny_string& normalizedName=name.normalizedName(); - if(name.isAttribute) + const char *buf=normalizedName.raw_buf(); + if(normalizedName[0]=='@') + { + isAttr=true; + buf+=1; + } + if(isAttr) { //Lookup attribute //TODO: support namespaces @@ -1067,7 +1091,7 @@ bool XML::hasPropertyByMultiname(const multiname& name, bool considerDynamic) xmlpp::Element* element=dynamic_cast(node); if(element==NULL) return NULL; - xmlpp::Attribute* attr=element->get_attribute(normalizedName.raw_buf()); + xmlpp::Attribute* attr=element->get_attribute(buf); if(attr!=NULL) return true; } @@ -1078,7 +1102,7 @@ bool XML::hasPropertyByMultiname(const multiname& name, bool considerDynamic) assert_and_throw(name.ns.size()>0 && name.ns[0].name==""); //Normalize the name to the string form assert(node); - const xmlpp::Node::NodeList& children=node->get_children(normalizedName.raw_buf()); + const xmlpp::Node::NodeList& children=node->get_children(buf); if(!children.empty()) return true; } diff --git a/src/swf.cpp b/src/swf.cpp index 6378dd6..b50907e 100644 --- a/src/swf.cpp +++ b/src/swf.cpp @@ -468,6 +468,8 @@ void SystemState::setShutdownFlag() shutdown=true; sem_post(&terminated); + if(standalone) + gtk_main_quit(); } void SystemState::wait() @@ -1132,7 +1134,7 @@ void ParseThread::execute() } catch(std::exception& e) { - LOG(LOG_ERROR,_("Stream exception in ParseThread")); + LOG(LOG_ERROR,_("Stream exception in ParseThread ") << e.what()); root->parsingFailed(); } pt=NULL; diff --git a/tests/Dictionary_test.mxml b/tests/Dictionary_test.mxml index d0d6897..226eb94 100644 --- a/tests/Dictionary_test.mxml +++ b/tests/Dictionary_test.mxml @@ -1,57 +1,57 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/tests/Object_test.mxml b/tests/Object_test.mxml index d78adab..d057823 100644 --- a/tests/Object_test.mxml +++ b/tests/Object_test.mxml @@ -13,6 +13,11 @@ var o:Object = {foo: "bar", foo2: "bar2", foo: "bar3"}; Tests.assertEquals(o.foo2,"bar2","Simple assignment in object literal"); Tests.assertEquals(o.foo,"bar","Duplicated assignment in object literal"); + + var s:String = "Lightspark"; + var c:Class = s.constructor; + Tests.assertTrue(c == String, "Constructor property"); + Tests.report(visual, this.name); } ]]> diff --git a/tests/XML_test.mxml b/tests/XML_test.mxml index cb18282..54587d7 100644 --- a/tests/XML_test.mxml +++ b/tests/XML_test.mxml @@ -44,6 +44,9 @@ Tests.assertTrue(Object("123")==simplexml, "equality: string and simple XML"); Tests.assertTrue(Object(123)==simplexml, "equality: integer and simple XML"); + var cdata:XML = new XML(""); + Tests.assertEquals(cdata, "Lightspark", "Only CDATA node in file"); + Tests.report(visual, this.name); } ]]> diff --git a/tests/geom_Matrix_test.mxml b/tests/geom_Matrix_test.mxml index 667904a..89d2a5d 100644 --- a/tests/geom_Matrix_test.mxml +++ b/tests/geom_Matrix_test.mxml @@ -1,64 +1,64 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/tests/geom_Point_test.mxml b/tests/geom_Point_test.mxml index f8d926c..25bbaa3 100644 --- a/tests/geom_Point_test.mxml +++ b/tests/geom_Point_test.mxml @@ -1,52 +1,52 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/tests/geom_Rectangle_test.mxml b/tests/geom_Rectangle_test.mxml index b8450c4..43734db 100644 --- a/tests/geom_Rectangle_test.mxml +++ b/tests/geom_Rectangle_test.mxml @@ -1,72 +1,72 @@ - - - - - - - - - - - + + + + + + + + + + +