[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/kjs-tweaks/kjs
From: Christopher E. Hyde <C.Hyde () parableuk ! force9 ! co ! uk>
Date: 2007-04-07 2:50:50
Message-ID: 1175914250.860727.32015.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 651235 by chyde:
added new List ctor & a couple of other minor changes
M +1 -5 bool_object.cpp
M +4 -6 function_object.cpp
M +17 -1 list.cpp
M +16 -3 list.h
--- branches/work/kjs-tweaks/kjs/bool_object.cpp #651234:651235
@@ -102,11 +102,7 @@
{
BooleanInstance *obj(new BooleanInstance(exec->lexicalInterpreter()->builtinBooleanPrototype()));
- bool b;
- if (args.size() > 0)
- b = args.begin()->toBoolean(exec);
- else
- b = false;
+ bool b = !args.isEmpty() && args(0)->toBoolean(exec);
obj->setInternalValue(jsBoolean(b));
--- branches/work/kjs-tweaks/kjs/function_object.cpp #651234:651235
@@ -127,13 +127,11 @@
if (!func->implementsCall())
return throwError(exec, TypeError);
- JSObject *callThis;
- if (thisArg->isUndefinedOrNull())
- callThis = exec->dynamicInterpreter()->globalObject();
- else
- callThis = thisArg->toObject(exec);
+ JSObject* callThis = thisArg->isUndefinedOrNull()
+ ? exec->dynamicInterpreter()->globalObject()
+ : thisArg->toObject(exec);
- result = func->call(exec,callThis,args.copyTail());
+ result = func->call(exec, callThis, List(args, List::tail));
}
break;
}
--- branches/work/kjs-tweaks/kjs/list.cpp #651234:651235
@@ -139,6 +139,8 @@
//------------------------------------------------------------------------------------------
+#pragma mark -
+//------------------------------------------------------------------------------------------
ListHeap* ListHeap::gHeap = NULL;
int ListHeap::gFree = 0;
@@ -410,6 +412,20 @@
DUMP_STATS_NEW(imp);
}
+List::List(JSArgs b, Tail)
+ : _imp(ListHeap::allocate())
+{
+ _imp->fSize = 0;
+ JSValues ptr = b;
+ for (int size = b.size(); --size > 0; )
+ append(*++ptr);
+
+#if DUMP_STATISTICS
+ ListImp* imp = static_cast<ListImp*>(_imp);
+ DUMP_STATS_NEW(imp);
+#endif
+}
+
void List::release()
{
ListImp *imp = static_cast<ListImp *>(_imp);
@@ -456,7 +472,7 @@
/* if (newCapacity < 16)
newCapacity = 16;*/
JSValue** newPtr = new JSValue* [newCapacity];
- JSValue** oldPtr = imp->fPtr;
+ JSValues oldPtr = imp->fPtr;
for (int j = 0; j != i; ++j)
newPtr[j] = oldPtr[j];
if (oldPtr != imp->fValues)
--- branches/work/kjs-tweaks/kjs/list.h #651234:651235
@@ -41,6 +41,9 @@
*/
class KJS_EXPORT List {
public:
+ typedef const List& JSArgs;
+ typedef JSValue* const* JSValues;
+
struct ImpBase {
int fSize;
int fRefCount;
@@ -56,7 +59,14 @@
List(JSValue* v0, JSValue* v1, JSValue* v2);
~List() { deref(); }
- List(const List &b) : _imp(b._imp) { ++_imp->fRefCount; }
+ List(JSArgs b) : _imp(b._imp) { ++_imp->fRefCount; }
+ enum Tail { tail };
+
+ /**
+ * Construct a copy of @param b, omitting the first element.
+ */
+ List(JSArgs b, Tail);
+
List& operator=(const List& rhs) { ImpBase* tmp = rhs._imp; ++(tmp->fRefCount);
deref(); _imp = tmp; return *this; }
@@ -116,7 +126,7 @@
/**
* Get the raw list.
*/
- operator JSValue* const* () const { return _imp->fPtr; }
+ operator JSValues () const { return _imp->fPtr; }
/**
* Equivalent to at.
@@ -197,7 +207,10 @@
inline ListIterator List::begin() const { return ListIterator(*this); }
inline ListIterator List::end() const { return ListIterator(*this, size()); }
-
+
+ typedef List::JSArgs JSArgs;
+ typedef List::JSValues JSValues;
+
} // namespace KJS
#endif // KJS_LIST_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic