Changes of Revision 70
lightspark.spec
Changed
x
1
2
%endif
3
4
Name: lightspark
5
-Version: 0.7.2.99+git20150603.1702
6
+Version: 0.7.2.99+git20150607.1836
7
Release: 0
8
Summary: Modern, free, open-source flash player implementation
9
License: LGPL-3.0+
10
lightspark.tar.xz/src/asobject.cpp
Changed
84
1
2
return ret;
3
}
4
5
- throw Class<TypeError>::getInstanceS();
6
+ throwError<TypeError>(kConvertToPrimitiveError,this->getClassName());
7
return _MR((ASObject*)NULL);
8
}
9
10
11
// fixed properties cannot be deleted
12
if (hasPropertyByMultiname(name,true,true))
13
return false;
14
+
15
//unknown variables must return true
16
return true;
17
}
18
19
//looking for a settable even if a super class sets
20
//has_getter to true.
21
obj=cls->findBorrowedSettable(name,&has_getter);
22
- if(obj && cls->isFinal && !obj->setter)
23
+ if(obj && (cls->isFinal || cls->isSealed) && !obj->setter)
24
{
25
throwError<ReferenceError>(kCannotAssignToMethodError, name.normalizedName(), cls ? cls->getQualifiedClassName() : "");
26
}
27
28
29
const variable* variables_map::findObjVar(const multiname& mname, uint32_t traitKinds, NS_KIND &nskind) const
30
{
31
+ if (mname.isEmpty())
32
+ return NULL;
33
uint32_t name=mname.normalizedNameId();
34
assert(!mname.ns.empty());
35
36
37
mainObj->as<Class_base>()->class_name.getQualifiedName() == typemname->qualifiedString())
38
{
39
// avoid recursive construction
40
- obj = getSys()->getNullRef();
41
+ //obj = getSys()->getNullRef();
42
+ obj = getSys()->getUndefinedRef();
43
}
44
else if (type != Class_object::getClass() &&
45
dynamic_cast<const Class_base*>(type))
46
{
47
- if (!((Class_base*)type)->super)
48
+ //if (!((Class_base*)type)->super)
49
{
50
// super type could not be found, so the class is stored as an uninitialized variable
51
LOG(LOG_CALLS,"add uninitialized class var:"<<mname);
52
53
obj = getSys()->getNullRef();
54
obj = type->coerce(obj);
55
}
56
- else
57
- obj = ((Class_base*)type)->getInstance(false,NULL,0);
58
+ //else
59
+ // obj = ((Class_base*)type)->getInstance(false,NULL,0);
60
}
61
else
62
{
63
64
ASFUNCTIONBODY(ASObject,_toString)
65
{
66
tiny_string ret;
67
- if(obj->getClass())
68
+ if (obj->is<Class_base>())
69
{
70
ret="[object ";
71
- ret+=obj->getClass()->class_name.name;
72
+ ret+=static_cast<Class_base*>(obj)->class_name.name;
73
ret+="]";
74
}
75
- else if (obj->is<Class_base>())
76
+ else if(obj->getClass())
77
{
78
ret="[object ";
79
- ret+=static_cast<Class_base*>(obj)->class_name.name;
80
+ ret+=obj->getClass()->class_name.name;
81
ret+="]";
82
}
83
else
84
lightspark.tar.xz/src/scripting/abc.cpp
Changed
67
1
2
builtin->registerBuiltin("print","",_MR(Class<IFunction>::getFunction(print)));
3
builtin->registerBuiltin("trace","",_MR(Class<IFunction>::getFunction(trace)));
4
builtin->registerBuiltin("parseInt","",_MR(Class<IFunction>::getFunction(parseInt,2)));
5
- builtin->registerBuiltin("parseFloat","",_MR(Class<IFunction>::getFunction(parseFloat)));
6
+ builtin->registerBuiltin("parseFloat","",_MR(Class<IFunction>::getFunction(parseFloat,1)));
7
builtin->registerBuiltin("encodeURI","",_MR(Class<IFunction>::getFunction(encodeURI)));
8
builtin->registerBuiltin("decodeURI","",_MR(Class<IFunction>::getFunction(decodeURI)));
9
builtin->registerBuiltin("encodeURIComponent","",_MR(Class<IFunction>::getFunction(encodeURIComponent)));
10
builtin->registerBuiltin("decodeURIComponent","",_MR(Class<IFunction>::getFunction(decodeURIComponent)));
11
- builtin->registerBuiltin("escape","",_MR(Class<IFunction>::getFunction(escape)));
12
- builtin->registerBuiltin("unescape","",_MR(Class<IFunction>::getFunction(unescape)));
13
+ builtin->registerBuiltin("escape","",_MR(Class<IFunction>::getFunction(escape,1)));
14
+ builtin->registerBuiltin("unescape","",_MR(Class<IFunction>::getFunction(unescape,1)));
15
builtin->registerBuiltin("toString","",_MR(Class<IFunction>::getFunction(ASObject::_toString)));
16
17
builtin->registerBuiltin("AccessibilityProperties","flash.accessibility",Class<AccessibilityProperties>::getRef());
18
19
builtin->registerBuiltin("PrintJobOptions","flash.printing",Class<PrintJobOptions>::getRef());
20
builtin->registerBuiltin("PrintJobOrientation","flash.printing",Class<PrintJobOrientation>::getRef());
21
22
- builtin->registerBuiltin("isNaN","",_MR(Class<IFunction>::getFunction(isNaN)));
23
- builtin->registerBuiltin("isFinite","",_MR(Class<IFunction>::getFunction(isFinite)));
24
+ builtin->registerBuiltin("isNaN","",_MR(Class<IFunction>::getFunction(isNaN,1)));
25
+ builtin->registerBuiltin("isFinite","",_MR(Class<IFunction>::getFunction(isFinite,1)));
26
builtin->registerBuiltin("isXMLName","",_MR(Class<IFunction>::getFunction(_isXMLName)));
27
28
29
30
case 0x0D: //QNameA
31
{
32
ret->ns.push_back(nsNameAndKind(this, m->ns));
33
-
34
- ret->name_s_id=getSys()->getUniqueStringId(getString(m->name));
35
- ret->name_type=multiname::NAME_STRING;
36
+ if (m->name)
37
+ {
38
+ ret->name_s_id=getSys()->getUniqueStringId(getString(m->name));
39
+ ret->name_type=multiname::NAME_STRING;
40
+ }
41
break;
42
}
43
case 0x09: //Multiname
44
45
}
46
sort(ret->ns.begin(),ret->ns.end());
47
48
- ret->name_s_id=getSys()->getUniqueStringId(getString(m->name));
49
- ret->name_type=multiname::NAME_STRING;
50
+ if (m->name)
51
+ {
52
+ ret->name_s_id=getSys()->getUniqueStringId(getString(m->name));
53
+ ret->name_type=multiname::NAME_STRING;
54
+ }
55
break;
56
}
57
case 0x1b: //MultinameL
58
59
60
method_info* m=get_method(scripts[i].init);
61
SyntheticFunction* entry=Class<IFunction>::getSyntheticFunction(m);
62
-
63
+
64
g->incRef();
65
entry->addToScope(scope_entry(_MR(g),false));
66
67
lightspark.tar.xz/src/scripting/abc_opcodes.cpp
Changed
133
1
2
for(int i=0;i<m;i++)
3
args[i]->decRef();
4
//LOG(LOG_NOT_IMPLEMENTED,"callProperty: " << name->qualifiedString() << " not found on " << obj->toDebugString());
5
+ if (obj->hasPropertyByMultiname(*name,true,true))
6
+ throwError<ReferenceError>(kWriteOnlyError, name->normalizedName(), obj->getClass()->getQualifiedClassName());
7
+ if (obj->getClass() && obj->getClass()->isSealed)
8
+ throwError<ReferenceError>(kReadSealedError, name->normalizedName(), obj->getClass()->getQualifiedClassName());
9
throwError<TypeError>(kCallNotFoundError, name->qualifiedString(), obj->getClassName());
10
11
if(keepReturn)
12
13
{
14
if (obj->getClass() && obj->getClass()->isSealed)
15
throwError<ReferenceError>(kReadSealedError, name->normalizedName(), obj->getClass()->getQualifiedClassName());
16
+ if (name->isEmpty())
17
+ throwError<ReferenceError>(kReadSealedErrorNs, name->normalizedName(), obj->getClassName());
18
+ if (obj->is<Undefined>())
19
+ throwError<TypeError>(kConvertUndefinedToObjectError);
20
if (Log::getLevel() >= LOG_NOT_IMPLEMENTED && obj->getClassName() != "Object")
21
LOG(LOG_NOT_IMPLEMENTED,"getProperty: " << name->normalizedName() << " not found on " << obj->toDebugString());
22
ret = getSys()->getUndefinedRef();
23
24
ret=o_class->getInstance(true,args,m);
25
break;
26
}
27
-
28
+/*
29
case T_OBJECT:
30
{
31
Class_base* o_class=static_cast<Class_base*>(obj->getClass());
32
33
ret=o_class->getInstance(true,args,m);
34
break;
35
}
36
-
37
+*/
38
case T_FUNCTION:
39
{
40
ret = constructFunction(th, obj->as<IFunction>(), args, m);
41
42
43
ASObject* obj=th->runtime_stack_pop();
44
45
- assert_and_throw(th->inClass);
46
- assert_and_throw(th->inClass->super);
47
- assert_and_throw(obj->getClass());
48
- assert_and_throw(obj->getClass()->isSubClass(th->inClass));
49
-
50
- _NR<ASObject> ret = obj->getVariableByMultiname(*name,ASObject::NONE,th->inClass->super.getPtr());
51
- name->resetNameIfObject();
52
- if(ret.isNull())
53
+ if(obj->is<Null>())
54
{
55
- LOG(LOG_NOT_IMPLEMENTED,"getSuper: " << name->normalizedName() << " not found on " << obj->toDebugString());
56
- ret = _MNR(getSys()->getUndefinedRef());
57
+ LOG(LOG_ERROR,"calling getSuper on null:" << *name << ' ' << obj->toDebugString());
58
+ throwError<TypeError>(kConvertNullToObjectError);
59
+ }
60
+ if (obj->is<Undefined>())
61
+ {
62
+ LOG(LOG_ERROR,"calling getSuper on undefined:" << *name << ' ' << obj->toDebugString());
63
+ throwError<TypeError>(kConvertUndefinedToObjectError);
64
}
65
66
+ Class_base* cls = NULL;
67
+ if (th->inClass && !th->inClass->super.isNull())
68
+ cls = th->inClass->super.getPtr();
69
+ else if (obj->getClass() && !obj->getClass()->super.isNull())
70
+ cls = obj->getClass()->super.getPtr();
71
+ assert_and_throw(cls);
72
+
73
+ _NR<ASObject> ret = obj->getVariableByMultiname(*name,ASObject::NONE,cls);
74
+ if (ret.isNull())
75
+ throwError<ReferenceError>(kCallOfNonFunctionError,name->normalizedName());
76
+
77
+ name->resetNameIfObject();
78
+
79
obj->decRef();
80
ret->incRef();
81
th->runtime_stack_push(ret.getPtr());
82
83
multiname* name=th->context->getMultiname(n,th);
84
ASObject* obj=th->runtime_stack_pop();
85
LOG(LOG_CALLS,"getDescendants " << *name << " " <<name->isAttribute<< " "<<obj->getClassName());
86
- //The name must be a QName
87
- assert_and_throw(name->name_type==multiname::NAME_STRING);
88
XML::XMLVector ret;
89
- //TODO: support multiname and namespaces
90
XMLList* targetobject = NULL;
91
if(obj->getClass()==Class<XML>::getClass())
92
{
93
94
if (ns_uri.empty() && name->ns.size() == 1)
95
ns_uri="*";
96
}
97
- xmlObj->getDescendantsByQName(getSys()->getStringFromUniqueId(name->name_s_id), ns_uri,name->isAttribute, ret);
98
+ xmlObj->getDescendantsByQName(name->normalizedName(), ns_uri,name->isAttribute, ret);
99
}
100
else if(obj->getClass()==Class<XMLList>::getClass())
101
{
102
103
ns_uri="*";
104
}
105
targetobject = xmlObj;
106
- xmlObj->getDescendantsByQName(getSys()->getStringFromUniqueId(name->name_s_id), ns_uri,name->isAttribute, ret);
107
+ xmlObj->getDescendantsByQName(name->normalizedName(), ns_uri,name->isAttribute, ret);
108
}
109
else if(obj->getClass()->isSubClass(Class<Proxy>::getClass()))
110
{
111
112
ASObject* namearg = Class<ASString>::getInstanceS(name->normalizedName());
113
namearg->setProxyProperty(*name);
114
proxyArgs[1]=namearg;
115
- LOG(LOG_ERROR,"Proxy::getDescend:"<<namearg->toDebugString()<<*name);
116
117
//We now suppress special handling
118
LOG(LOG_CALLS,_("Proxy::callProperty"));
119
120
121
bool ABCVm::deleteProperty(ASObject* obj, multiname* name)
122
{
123
- LOG(LOG_CALLS,_("deleteProperty ") << *name);
124
+ LOG(LOG_CALLS,_("deleteProperty ") << *name<<" "<<obj->toDebugString());
125
+ if (name->name_type == multiname::NAME_OBJECT && name->name_o)
126
+ {
127
+ if (name->name_o->is<XMLList>())
128
+ throwError<TypeError>(kDeleteTypeError,name->name_o->getClassName());
129
+ }
130
bool ret = obj->deleteVariableByMultiname(*name);
131
132
obj->decRef();
133
lightspark.tar.xz/src/scripting/toplevel/Array.cpp
Changed
56
1
2
return NULL;
3
ASObject* params[3];
4
5
- std::map<uint32_t, data_slot>::iterator it=th->data.begin();
6
- for(;it != th->data.end();++it)
7
+ uint32_t s = th->size();
8
+ for (uint32_t i=0; i < s; i++ )
9
{
10
- if (it->second.type==DATA_OBJECT)
11
+ if (th->data.count(i))
12
{
13
- params[0] = it->second.data;
14
- it->second.data->incRef();
15
+ const data_slot& slot=th->data[i];
16
+ if(slot.type==DATA_INT)
17
+ params[0]=abstract_i(slot.data_i);
18
+ else if(slot.type==DATA_OBJECT && slot.data)
19
+ {
20
+ params[0]=slot.data;
21
+ params[0]->incRef();
22
+ }
23
+ else
24
+ params[0]=getSys()->getUndefinedRef();
25
}
26
else
27
- params[0] =abstract_d(it->second.data_i);
28
- params[1] = abstract_i(it->first);
29
+ continue;
30
+ params[1] = abstract_i(i);
31
params[2] = th;
32
th->incRef();
33
34
35
36
bool Array::isValidMultiname(const multiname& name, uint32_t& index)
37
{
38
+ if(name.isEmpty())
39
+ return false;
40
//First of all the multiname has to contain the null namespace
41
//As the namespace vector is sorted, we check only the first one
42
assert_and_throw(name.ns.size()!=0);
43
44
assert_and_throw(implEnable);
45
uint32_t index=0;
46
if(!isValidMultiname(name,index))
47
- return ASObject::setVariableByMultiname(name,o,allowConst);
48
+ {
49
+ ASObject::setVariableByMultiname(name,o,allowConst);
50
+// setIsEnumerable(name,false);
51
+ return;
52
+ }
53
// Derived classes may be sealed!
54
if (getClass() && getClass()->isSealed)
55
throwError<ReferenceError>(kWriteSealedError,
56
lightspark.tar.xz/src/scripting/toplevel/Vector.cpp
Changed
46
1
2
Vector* th=static_cast<Vector*>(obj);
3
if (th->fixed)
4
throwError<RangeError>(kVectorFixedError);
5
- th->vec.resize(th->size()+argslen, NULL);
6
- for(uint32_t i=th->size();i> 0;i--)
7
+ if (argslen > 0)
8
{
9
- if (th->vec[i-1])
10
+ th->vec.resize(th->size()+argslen, NULL);
11
+ for(uint32_t i=th->size();i> 0;i--)
12
{
13
- th->vec[(i-1)+argslen]=th->vec[i-1];
14
- th->vec[i-1] = NULL;
15
+ if (th->vec[i-1])
16
+ {
17
+ th->vec[(i-1)+argslen]=th->vec[i-1];
18
+ th->vec[i-1] = NULL;
19
+ }
20
+
21
}
22
23
- }
24
-
25
- for(uint32_t i=0;i<argslen;i++)
26
- {
27
- args[i]->incRef();
28
- th->vec[i] = th->vec_type->coerce(args[i]);
29
+ for(uint32_t i=0;i<argslen;i++)
30
+ {
31
+ args[i]->incRef();
32
+ th->vec[i] = th->vec_type->coerce(args[i]);
33
+ }
34
}
35
return abstract_i(th->size());
36
}
37
38
}
39
}
40
41
-tiny_string Vector::toString(bool debugMsg)
42
+tiny_string Vector::toString()
43
{
44
//TODO: test
45
tiny_string t;
46
lightspark.tar.xz/src/scripting/toplevel/Vector.h
Changed
10
1
2
bool sameType(const QName& classname) const;
3
4
//Overloads
5
- tiny_string toString(bool debugMsg=false);
6
+ tiny_string toString();
7
void setVariableByMultiname(const multiname& name, ASObject* o, CONST_ALLOWED_FLAG allowConst);
8
bool hasPropertyByMultiname(const multiname& name, bool considerDynamic, bool considerPrototype);
9
_NR<ASObject> getVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt);
10
lightspark.tar.xz/src/scripting/toplevel/XML.cpp
Changed
188
1
2
3
void XML::sinit(Class_base* c)
4
{
5
- CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED | CLASS_FINAL);
6
+ CLASS_SETUP(c, ASObject, _constructor, CLASS_FINAL);
7
setDefaultXMLSettings();
8
9
c->setDeclaredMethodByQName("ignoreComments","",Class<IFunction>::getFunction(_getIgnoreComments),GETTER_METHOD,false);
10
11
defns += getVm()->getDefaultXMLNamespace();
12
defns += "|";
13
tiny_string normalizedName= "";
14
- if (!name.isEmpty()) normalizedName= name.normalizedName();
15
+ normalizedName= name.normalizedName();
16
if (normalizedName.startsWith("@"))
17
normalizedName = normalizedName.substr(1,normalizedName.end());
18
tiny_string namespace_uri="|";
19
20
}
21
else
22
{
23
- const XMLVector& ret=getValuesByMultiname(childrenlist,name);
24
- if(ret.empty() && (opt & XML_STRICT)!=0)
25
- return NullRef;
26
-
27
- _R<XMLList> ch =_MNR(Class<XMLList>::getInstanceS(ret,this->getChildrenlist(),name));
28
- return ch;
29
+ if (normalizedName == "*")
30
+ {
31
+ XMLVector ret;
32
+ childrenImpl(ret, "*");
33
+ multiname mname(NULL);
34
+ mname.name_s_id=getSys()->getUniqueStringId("*");
35
+ mname.name_type=multiname::NAME_STRING;
36
+ mname.ns.push_back(nsNameAndKind("",NAMESPACE));
37
+ XMLList* retObj=Class<XMLList>::getInstanceS(ret,this->getChildrenlist(),mname);
38
+ return _MNR(retObj);
39
+ }
40
+ else
41
+ {
42
+ const XMLVector& ret=getValuesByMultiname(childrenlist,name);
43
+ if(ret.empty() && (opt & XML_STRICT)!=0)
44
+ return NullRef;
45
+
46
+ _R<XMLList> ch =_MNR(Class<XMLList>::getInstanceS(ret,this->getChildrenlist(),name));
47
+ return ch;
48
+ }
49
}
50
}
51
52
53
54
if(isAttr)
55
{
56
- bool found = false;
57
- for (XMLList::XMLListVector::iterator it = attributelist->nodes.begin(); it != attributelist->nodes.end(); it++)
58
+ tiny_string nodeval;
59
+ if(o->is<XMLList>())
60
+ {
61
+ _NR<XMLList> x = _NR<XMLList>(o->as<XMLList>());
62
+ for (auto it2 = x->nodes.begin(); it2 != x->nodes.end(); it2++)
63
+ {
64
+ if (nodeval != "")
65
+ nodeval += " ";
66
+ nodeval += (*it2)->toString();
67
+ }
68
+ }
69
+ else
70
+ {
71
+ nodeval = o->toString();
72
+ }
73
+ _NR<XML> a;
74
+ XMLList::XMLListVector::iterator it = attributelist->nodes.begin();
75
+ while (it != attributelist->nodes.end())
76
{
77
_R<XML> attr = *it;
78
- if (attr->nodenamespace_uri == ns_uri && (attr->nodename == buf || (*buf==0)))
79
+ XMLList::XMLListVector::iterator ittmp = it;
80
+ it++;
81
+ if (attr->nodenamespace_uri == ns_uri && (attr->nodename == buf || (*buf=='*')|| (*buf==0)))
82
{
83
- if(o->is<XMLList>())
84
- {
85
- _NR<XMLList> x = _NR<XMLList>(o->as<XMLList>());
86
- for (auto it = x->nodes.begin(); it != x->nodes.end(); it++)
87
- {
88
- if (!found)
89
- attr->nodevalue = (*it)->toString();
90
- else
91
- {
92
- attr->nodevalue += " ";
93
- attr->nodevalue += (*it)->toString();
94
- }
95
- found = true;
96
- }
97
- }
98
- else
99
- {
100
- if (!found)
101
- attr->nodevalue = o->toString();
102
- else
103
- {
104
- attr->nodevalue += " ";
105
- attr->nodevalue += o->toString();
106
- }
107
- found = true;
108
- }
109
-
110
+ if (!a.isNull())
111
+ it=attributelist->nodes.erase(ittmp);
112
+ a = *ittmp;
113
+ a->nodevalue = nodeval;
114
}
115
}
116
- if (!found && !normalizedName.empty())
117
+ if (a.isNull() && !((*buf=='*')|| (*buf==0)))
118
{
119
_NR<XML> tmp = _MR<XML>(Class<XML>::getInstanceS());
120
this->incRef();
121
122
tmp->nodename = buf;
123
tmp->nodenamespace_uri = ns_uri;
124
tmp->nodenamespace_prefix = ns_prefix;
125
- tmp->nodevalue = o->toString();
126
+ tmp->nodevalue = nodeval;
127
tmp->constructed = true;
128
attributelist->nodes.push_back(tmp);
129
}
130
131
}
132
else if(o->is<XML>())
133
{
134
- _NR<XML> tmp = _MR<XML>(o->as<XML>());
135
- tmp->parentNode = _MR<XML>(this);
136
- tmp->incRef();
137
+ if (o->as<XML>()->getNodeKind() == XML_TEXT_NODE)
138
+ {
139
+ _R<XML> tmp = _MR<XML>(Class<XML>::getInstanceS());
140
+ tmp->parentNode = tmpnode;
141
+ tmp->incRef();
142
+ tmp->nodetype = XML_TEXT_NODE;
143
+ tmp->nodename = "text";
144
+ tmp->nodenamespace_uri = "";
145
+ tmp->nodenamespace_prefix = "";
146
+ tmp->nodevalue = o->toString();
147
+ tmp->constructed = true;
148
+ tmpnode->childrenlist->clear();
149
+ tmpnode->childrenlist->append(tmp);
150
+ if (!found)
151
+ tmpnodes.push_back(tmpnode);
152
+ }
153
+ else
154
+ {
155
+ _NR<XML> tmp = _MR<XML>(o->as<XML>());
156
+ tmp->parentNode = _MR<XML>(this);
157
+ tmp->incRef();
158
+ if (!found)
159
+ tmpnodes.push_back(tmp);
160
+ }
161
162
- if (!found)
163
- tmpnodes.push_back(tmp);
164
}
165
else
166
{
167
168
}
169
170
bool isAttr=name.isAttribute;
171
+ unsigned int index=0;
172
const tiny_string normalizedName=name.normalizedName();
173
const char *buf=normalizedName.raw_buf();
174
if(!normalizedName.empty() && normalizedName.charAt(0)=='@')
175
176
return true;
177
}
178
}
179
+ else if(XML::isValidMultiname(name,index))
180
+ {
181
+ // If the multiname is a valid array property, the XML
182
+ // object is treated as a single-item XMLList.
183
+ return(index==0);
184
+ }
185
else
186
{
187
//Lookup children
188
lightspark.tar.xz/src/scripting/toplevel/XMLList.cpp
Changed
100
1
2
3
void XMLList::sinit(Class_base* c)
4
{
5
- CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED | CLASS_FINAL);
6
+ CLASS_SETUP(c, ASObject, _constructor, CLASS_FINAL);
7
c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(_getLength),NORMAL_METHOD,true);
8
c->setDeclaredMethodByQName("attribute",AS3,Class<IFunction>::getFunction(attribute),NORMAL_METHOD,true);
9
c->setDeclaredMethodByQName("attributes",AS3,Class<IFunction>::getFunction(attributes),NORMAL_METHOD,true);
10
11
for (uint32_t i = 0; i < nodes.size(); i++)
12
{
13
_R<XML> child= nodes[i];
14
- bool nameMatches = (normalizedName=="" || normalizedName==child->nodename);
15
+ bool nameMatches = (normalizedName=="" || normalizedName==child->nodename || normalizedName=="*");
16
bool nsMatches = (namespace_uri=="" ||
17
(child->nodenamespace_uri == namespace_uri));
18
-
19
+
20
if(nameMatches && nsMatches)
21
{
22
retnodes.push_back(child);
23
24
tmpprop = tmplist->targetproperty;
25
tmplist = tmplist->targetobject;
26
}
27
- if (tmplist && !tmpprop.isEmpty())
28
+ if (tmplist)
29
{
30
tmplist->getTargetVariables(tmpprop,retnodes);
31
}
32
33
{
34
if (tmplist)
35
{
36
+ if (tmplist->nodes.size() > 1)
37
+ throwError<TypeError>(kXMLAssigmentOneItemLists);
38
if (!tmpprop.isEmpty())
39
{
40
XML* tmp = Class<XML>::getInstanceS();
41
42
}
43
else
44
{
45
- // do nothing, see ECMA-357, Section 9.2.1.2
46
+ throwError<TypeError>(kXMLAssigmentOneItemLists);
47
}
48
}
49
50
51
if (idx >= nodes.size())
52
return;
53
54
- if (nodes[idx]->getNodeKind() == XML_ATTRIBUTE_NODE || nodes[idx]->getNodeKind() == XML_TEXT_NODE)
55
+ if (nodes[idx]->getNodeKind() == XML_ATTRIBUTE_NODE)
56
{
57
if (targetobject)
58
targetobject->setVariableByMultiname(targetproperty,o,allowConst);
59
nodes[idx]->setTextContent(o->toString());
60
}
61
- else if (o->is<XMLList>())
62
+ if (o->is<XMLList>())
63
{
64
+ if (o->as<XMLList>()->nodes.size() == 1)
65
+ {
66
+ replace(idx,o->as<XMLList>()->nodes[0].getPtr(),retnodes,allowConst);
67
+ return;
68
+ }
69
if (targetobject)
70
{
71
for (uint32_t i = 0; i < targetobject->nodes.size(); i++)
72
73
m.ns.push_back(nsNameAndKind("",NAMESPACE));
74
targetobject->setVariableByMultiname(m,o,allowConst);
75
}
76
- o->incRef();
77
- nodes[idx] = _MR(o->as<XML>());
78
+ if (o->as<XML>()->getNodeKind() == XML_TEXT_NODE)
79
+ {
80
+ nodes[idx]->childrenlist->clear();
81
+ _R<XML> tmp = _MR<XML>(Class<XML>::getInstanceS());
82
+ nodes[idx]->incRef();
83
+ tmp->parentNode = nodes[idx];
84
+ tmp->nodetype = XML_TEXT_NODE;
85
+ tmp->nodename = "text";
86
+ tmp->nodenamespace_uri = "";
87
+ tmp->nodenamespace_prefix = "";
88
+ tmp->nodevalue = o->toString();
89
+ tmp->constructed = true;
90
+ nodes[idx]->childrenlist->append(tmp);
91
+ }
92
+ else
93
+ {
94
+ o->incRef();
95
+ nodes[idx] = _MR(o->as<XML>());
96
+ }
97
}
98
else
99
{
100
lightspark.tar.xz/src/scripting/toplevel/toplevel.cpp
Changed
137
1
2
return s + local_name;
3
}
4
5
+uint32_t ASQName::nextNameIndex(uint32_t cur_index)
6
+{
7
+ assert_and_throw(implEnable);
8
+ if(cur_index<2)
9
+ return cur_index+1;
10
+ else
11
+ {
12
+ //Fall back on object properties
13
+ uint32_t ret=ASObject::nextNameIndex(cur_index-2);
14
+ if(ret==0)
15
+ return 0;
16
+ else
17
+ return ret+2;
18
+
19
+ }
20
+}
21
+
22
+_R<ASObject> ASQName::nextName(uint32_t index)
23
+{
24
+ assert_and_throw(implEnable);
25
+ switch(index)
26
+ {
27
+ case 1:
28
+ return _MR(Class<ASString>::getInstanceS("uri"));
29
+ case 2:
30
+ return _MR(Class<ASString>::getInstanceS("localName"));
31
+ default:
32
+ return ASObject::nextName(index-2);
33
+ }
34
+}
35
+
36
+_R<ASObject> ASQName::nextValue(uint32_t index)
37
+{
38
+ assert_and_throw(implEnable);
39
+ switch(index)
40
+ {
41
+ case 1:
42
+ if (uri_is_null)
43
+ return _MR(getSys()->getNullRef());
44
+ else
45
+ return _MR(Class<ASString>::getInstanceS(this->uri));
46
+ case 2:
47
+ return _MR(Class<ASString>::getInstanceS(this->local_name));
48
+ default:
49
+ return ASObject::nextName(index-2);
50
+ }
51
+}
52
+
53
Namespace::Namespace(Class_base* c):ASObject(c),nskind(NAMESPACE)
54
{
55
type=T_NAMESPACE;
56
57
return ASObject::isEqual(o);
58
}
59
60
+uint32_t Namespace::nextNameIndex(uint32_t cur_index)
61
+{
62
+ assert_and_throw(implEnable);
63
+ if(cur_index<2)
64
+ return cur_index+1;
65
+ else
66
+ {
67
+ //Fall back on object properties
68
+ uint32_t ret=ASObject::nextNameIndex(cur_index-2);
69
+ if(ret==0)
70
+ return 0;
71
+ else
72
+ return ret+2;
73
+
74
+ }
75
+}
76
+
77
+_R<ASObject> Namespace::nextName(uint32_t index)
78
+{
79
+ assert_and_throw(implEnable);
80
+ switch(index)
81
+ {
82
+ case 1:
83
+ return _MR(Class<ASString>::getInstanceS("uri"));
84
+ case 2:
85
+ return _MR(Class<ASString>::getInstanceS("prefix"));
86
+ default:
87
+ return ASObject::nextName(index-2);
88
+ }
89
+}
90
+
91
+_R<ASObject> Namespace::nextValue(uint32_t index)
92
+{
93
+ assert_and_throw(implEnable);
94
+ switch(index)
95
+ {
96
+ case 1:
97
+ return _MR(Class<ASString>::getInstanceS(this->uri));
98
+ case 2:
99
+ if(prefix_is_undefined)
100
+ return _MR(getSys()->getUndefinedRef());
101
+ else
102
+ return _MR(Class<ASString>::getInstanceS(this->prefix));
103
+ default:
104
+ return ASObject::nextName(index-2);
105
+ }
106
+}
107
108
ASObject* ASNop(ASObject* obj, ASObject* const* args, const unsigned int argslen)
109
{
110
111
{
112
tiny_string str;
113
ARG_UNPACK (str, "undefined");
114
+ if (argslen > 0 && args[0]->is<Undefined>())
115
+ return Class<ASString>::getInstanceS("null");
116
return Class<ASString>::getInstanceS(URLInfo::encode(str, URLInfo::ENCODE_ESCAPE));
117
}
118
119
120
{
121
tiny_string str;
122
ARG_UNPACK (str, "undefined");
123
+ if (argslen > 0 && args[0]->is<Undefined>())
124
+ return Class<ASString>::getInstanceS("null");
125
return Class<ASString>::getInstanceS(URLInfo::decode(str, URLInfo::ENCODE_ESCAPE));
126
}
127
128
129
130
Function_object::Function_object(Class_base* c, _R<ASObject> p) : ASObject(c), functionPrototype(p)
131
{
132
+ traitsInitialized = true;
133
+ constructIndicator = true;
134
}
135
136
void Function_object::finalize()
137
lightspark.tar.xz/src/scripting/toplevel/toplevel.h
Changed
34
1
2
SyntheticFunction* sf=dynamic_cast<SyntheticFunction*>(r);
3
if(sf==NULL)
4
return false;
5
+ if (closure_this.isNull())
6
+ return this == r;
7
return (mi==sf->mi) && (closure_this==sf->closure_this);
8
}
9
void acquireScope(const std::vector<scope_entry>& scope)
10
11
tiny_string getURI() const { return uri; }
12
tiny_string getLocalName() const { return local_name; }
13
bool isEqual(ASObject* o);
14
+
15
tiny_string toString();
16
+
17
+ uint32_t nextNameIndex(uint32_t cur_index);
18
+ _R<ASObject> nextName(uint32_t index);
19
+ _R<ASObject> nextValue(uint32_t index);
20
};
21
22
class Namespace: public ASObject
23
24
bool isEqual(ASObject* o);
25
tiny_string getURI() { return uri; }
26
tiny_string getPrefix(bool& is_undefined) { is_undefined=prefix_is_undefined; return prefix; }
27
+
28
+ uint32_t nextNameIndex(uint32_t cur_index);
29
+ _R<ASObject> nextName(uint32_t index);
30
+ _R<ASObject> nextValue(uint32_t index);
31
};
32
33
34
lightspark.tar.xz/src/swftypes.cpp
Changed
10
1
2
case multiname::NAME_STRING:
3
return getSys()->getStringFromUniqueId(name_s_id);
4
case multiname::NAME_OBJECT:
5
- return name_o->toString();
6
+ return name_o ? name_o->toString() : "*";
7
default:
8
assert("Unexpected name kind" && false);
9
//Should never reach this
10