Changeset 15698 in webkit for trunk/JavaScriptCore
- Timestamp:
- Jul 29, 2006, 5:04:22 PM (19 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r15697 r15698 1 2006-07-29 Darin Adler <[email protected]> 2 3 - Removed tabs from these source files that still had them. 4 We don't use them; that way source files look fine in editors 5 that have tabs set to 8 spaces or to 4 spaces. 6 - Removed allow-tabs Subversion property from the files too. 7 8 * bindings/NP_jsobject.cpp: 9 * bindings/c/c_utility.cpp: 10 * bindings/jni/jni_runtime.cpp: 11 * bindings/jni/jni_utility.cpp: 12 * bindings/objc/objc_utility.mm: 13 * bindings/runtime.cpp: 14 * bindings/runtime_method.cpp: 15 * bindings/testbindings.cpp: 16 * bindings/testbindings.mm: 17 * kjs/date_object.cpp: 18 * kjs/function.cpp: 19 * kjs/list.cpp: 20 * kjs/nodes.cpp: 21 * kjs/nodes.h: 22 * kjs/string_object.cpp: 23 * kjs/ustring.cpp: 24 1 25 2006-07-29 Darin Adler <[email protected]> 2 26 -
trunk/JavaScriptCore/bindings/NP_jsobject.cpp
- Property allow-tabs deleted
r14834 r15698 73 73 { 74 74 if (obj->originExecutionContext) { 75 76 77 75 Interpreter* originInterpreter = obj->originExecutionContext->interpreter(); 76 if (originInterpreter) 77 return originInterpreter->isSafeScript(obj->executionContext->interpreter()); 78 78 } 79 79 return true; … … 113 113 if (o->_class == NPScriptObjectClass) { 114 114 JavaScriptObject* obj = (JavaScriptObject*)o; 115 116 115 if (!_isSafeScript(obj)) 116 return false; 117 117 118 118 PrivateIdentifier* i = (PrivateIdentifier*)methodName; … … 120 120 return false; 121 121 122 123 124 125 126 127 128 129 122 // Special case the "eval" method. 123 if (methodName == _NPN_GetStringIdentifier("eval")) { 124 if (argCount != 1) 125 return false; 126 if (args[0].type != NPVariantType_String) 127 return false; 128 return _NPN_Evaluate(npp, o, (NPString *)&args[0].value.stringValue, result); 129 } 130 130 131 131 // Lookup the function object. … … 164 164 JavaScriptObject* obj = (JavaScriptObject*)o; 165 165 166 167 166 if (!_isSafeScript(obj)) 167 return false; 168 168 169 169 ExecState* exec = obj->executionContext->interpreter()->globalExec(); … … 199 199 if (o->_class == NPScriptObjectClass) { 200 200 JavaScriptObject* obj = (JavaScriptObject*)o; 201 202 201 if (!_isSafeScript(obj)) 202 return false; 203 203 204 204 ExecState* exec = obj->executionContext->interpreter()->globalExec(); … … 238 238 if (o->_class == NPScriptObjectClass) { 239 239 JavaScriptObject* obj = (JavaScriptObject*)o; 240 241 240 if (!_isSafeScript(obj)) 241 return false; 242 242 243 243 ExecState* exec = obj->executionContext->interpreter()->globalExec(); … … 261 261 if (o->_class == NPScriptObjectClass) { 262 262 JavaScriptObject* obj = (JavaScriptObject*)o; 263 264 263 if (!_isSafeScript(obj)) 264 return false; 265 265 266 266 ExecState* exec = obj->executionContext->interpreter()->globalExec(); … … 289 289 if (o->_class == NPScriptObjectClass) { 290 290 JavaScriptObject* obj = (JavaScriptObject*)o; 291 292 291 if (!_isSafeScript(obj)) 292 return false; 293 293 294 294 ExecState* exec = obj->executionContext->interpreter()->globalExec(); … … 310 310 if (o->_class == NPScriptObjectClass) { 311 311 JavaScriptObject* obj = (JavaScriptObject*)o; 312 313 312 if (!_isSafeScript(obj)) 313 return false; 314 314 315 315 PrivateIdentifier* i = (PrivateIdentifier*)methodName; -
trunk/JavaScriptCore/bindings/c/c_utility.cpp
- Property allow-tabs deleted
r13603 r15698 117 117 NPObject* obj = instance->getObject(); 118 118 _NPN_RetainObject(obj); 119 119 OBJECT_TO_NPVARIANT(obj, *result); 120 120 } else { 121 121 Interpreter *originInterpreter = exec->dynamicInterpreter(); 122 122 const Bindings::RootObject *originExecutionContext = rootForInterpreter(originInterpreter); 123 123 124 125 126 127 124 Interpreter *interpreter = 0; 125 if (originInterpreter->isGlobalObject(value)) { 126 interpreter = originInterpreter->interpreterForGlobalObject(value); 127 } 128 128 129 130 131 129 if (!interpreter) 130 interpreter = originInterpreter; 131 132 132 const Bindings::RootObject *executionContext = rootForInterpreter(interpreter); 133 133 if (!executionContext) { … … 137 137 } 138 138 139 140 141 139 NPObject* obj = (NPObject *)exec->dynamicInterpreter()->createLanguageInstanceForValue(exec, Instance::CLanguage, value->toObject(exec), originExecutionContext, executionContext); 140 OBJECT_TO_NPVARIANT(obj, *result); 141 } 142 142 } 143 143 else -
trunk/JavaScriptCore/bindings/jni/jni_runtime.cpp
- Property allow-tabs deleted
r15696 r15698 87 87 jclass cls = env->GetObjectClass(fieldJInstance); 88 88 if ( cls != NULL ) { 89 90 91 92 93 94 95 96 97 98 99 100 101 102 89 jmethodID mid = env->GetMethodID(cls, name, sig); 90 if ( mid != NULL ) 91 { 92 const RootObject *execContext = instance->executionContext(); 93 if (execContext && execContext->nativeHandle()) { 94 JSValue *exceptionDescription = NULL; 95 jvalue args[1]; 96 97 args[0].l = jinstance; 98 dispatchJNICall (execContext->nativeHandle(), fieldJInstance, false, returnType, mid, args, result, 0, exceptionDescription); 99 if (exceptionDescription) 100 throwError(exec, GeneralError, exceptionDescription->toString(exec)); 101 } 102 } 103 103 } 104 104 return result; … … 113 113 switch (_JNIType) { 114 114 case object_type: { 115 116 115 jvalue result = dispatchValueFromInstance (exec, instance, "get", "(Ljava/lang/Object;)Ljava/lang/Object;", object_type); 116 jobject anObject = result.l; 117 117 118 118 const char *arrayType = type(); … … 121 121 } 122 122 else if (anObject != 0){ 123 123 jsresult = Instance::createRuntimeObject(Instance::JavaLanguage, anObject, instance->executionContext()); 124 124 } 125 125 } … … 136 136 case int_type: { 137 137 jint value; 138 139 138 jvalue result = dispatchValueFromInstance (exec, instance, "getInt", "(Ljava/lang/Object;)I", int_type); 139 value = result.i; 140 140 jsresult = jsNumber((int)value); 141 142 141 } 142 break; 143 143 144 144 case long_type: … … 146 146 case double_type: { 147 147 jdouble value; 148 149 148 jvalue result = dispatchValueFromInstance (exec, instance, "getDouble", "(Ljava/lang/Object;)D", double_type); 149 value = result.i; 150 150 jsresult = jsNumber((double)value); 151 151 } … … 168 168 jclass cls = env->GetObjectClass(fieldJInstance); 169 169 if ( cls != NULL ) { 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 170 jmethodID mid = env->GetMethodID(cls, name, sig); 171 if ( mid != NULL ) 172 { 173 const RootObject *execContext = instance->executionContext(); 174 if (execContext && execContext->nativeHandle()) { 175 JSValue *exceptionDescription = NULL; 176 jvalue args[2]; 177 jvalue result; 178 179 args[0].l = jinstance; 180 args[1] = javaValue; 181 dispatchJNICall (execContext->nativeHandle(), fieldJInstance, false, void_type, mid, args, result, 0, exceptionDescription); 182 if (exceptionDescription) 183 throwError(exec, GeneralError, exceptionDescription->toString(exec)); 184 } 185 } 186 186 } 187 187 } … … 196 196 switch (_JNIType) { 197 197 case object_type: { 198 198 dispatchSetValueToInstance (exec, instance, javaValue, "set", "(Ljava/lang/Object;Ljava/lang/Object;)V"); 199 199 } 200 200 break; 201 201 202 202 case boolean_type: { 203 203 dispatchSetValueToInstance (exec, instance, javaValue, "setBoolean", "(Ljava/lang/Object;Z)V"); 204 204 } 205 205 break; 206 206 207 207 case byte_type: { 208 208 dispatchSetValueToInstance (exec, instance, javaValue, "setByte", "(Ljava/lang/Object;B)V"); 209 209 } 210 210 break; 211 211 212 212 case char_type: { 213 213 dispatchSetValueToInstance (exec, instance, javaValue, "setChar", "(Ljava/lang/Object;C)V"); 214 214 } 215 215 break; 216 216 217 217 case short_type: { 218 218 dispatchSetValueToInstance (exec, instance, javaValue, "setShort", "(Ljava/lang/Object;S)V"); 219 219 } 220 220 break; 221 221 222 222 case int_type: { 223 223 dispatchSetValueToInstance (exec, instance, javaValue, "setInt", "(Ljava/lang/Object;I)V"); 224 224 } 225 225 break; 226 226 227 227 case long_type: { 228 228 dispatchSetValueToInstance (exec, instance, javaValue, "setLong", "(Ljava/lang/Object;J)V"); 229 229 } 230 230 break; 231 231 232 232 case float_type: { 233 233 dispatchSetValueToInstance (exec, instance, javaValue, "setFloat", "(Ljava/lang/Object;F)V"); 234 234 } 235 235 break; 236 236 237 237 case double_type: { 238 238 dispatchSetValueToInstance (exec, instance, javaValue, "setDouble", "(Ljava/lang/Object;D)V"); 239 239 } 240 240 break; -
trunk/JavaScriptCore/bindings/jni/jni_utility.cpp
- Property allow-tabs deleted
r15241 r15698 296 296 JNIEnv *env = getJNIEnv(); 297 297 jmethodID mid = 0; 298 298 299 299 if ( env != NULL) { 300 300 jclass cls = env->GetObjectClass(obj); 301 301 if ( cls != NULL ) { 302 302 mid = env->GetMethodID(cls, name, sig); 303 303 if (!mid) { 304 304 env->ExceptionClear(); 305 306 307 308 309 305 mid = env->GetStaticMethodID(cls, name, sig); 306 if (!mid) { 307 env->ExceptionClear(); 308 } 309 } 310 310 } 311 311 env->DeleteLocalRef(cls); … … 531 531 env->ExceptionDescribe(); 532 532 env->ExceptionClear(); 533 533 fprintf (stderr, "\n"); 534 534 } 535 535 return s; … … 548 548 env->ExceptionDescribe(); 549 549 env->ExceptionClear(); 550 550 fprintf (stderr, "\n"); 551 551 } 552 552 return s; … … 739 739 if (value->isObject()){ 740 740 JSObject *objectImp = static_cast<JSObject*>(value); 741 742 743 744 745 746 747 748 749 750 741 if (objectImp->classInfo() == &RuntimeObjectImp::info) { 742 RuntimeObjectImp *imp = static_cast<RuntimeObjectImp *>(value); 743 JavaInstance *instance = static_cast<JavaInstance*>(imp->getInternalInstance()); 744 result.l = instance->javaInstance(); 745 } 746 else if (objectImp->classInfo() == &RuntimeArray::info) { 747 RuntimeArray *imp = static_cast<RuntimeArray *>(value); 748 JavaArray *array = static_cast<JavaArray*>(imp->getConcreteArray()); 749 result.l = array->javaArray(); 750 } 751 751 } 752 752 … … 755 755 if (result.l == 0 && strcmp(javaClassName, "java.lang.String") == 0) { 756 756 #ifdef CONVERT_NULL_TO_EMPTY_STRING 757 758 759 760 761 762 763 757 if (value->isNull()) { 758 JNIEnv *env = getJNIEnv(); 759 jchar buf[2]; 760 jobject javaString = env->functions->NewString (env, buf, 0); 761 result.l = javaString; 762 } 763 else 764 764 #else 765 765 if (!value->isNull()) 766 766 #endif 767 768 769 770 771 772 767 { 768 UString stringValue = value->toString(exec); 769 JNIEnv *env = getJNIEnv(); 770 jobject javaString = env->functions->NewString (env, (const jchar *)stringValue.data(), stringValue.size()); 771 result.l = javaString; 772 } 773 773 } 774 774 } -
trunk/JavaScriptCore/bindings/objc/objc_utility.mm
- Property allow-tabs deleted
r15618 r15698 68 68 } else if (*sp == '_') 69 69 *dp = ':'; 70 70 else 71 71 *dp = *sp; 72 72 … … 104 104 105 105 if (value->isNumber() || value->isString() || value->isBoolean()) 106 107 106 d = value->toNumber(exec); 107 108 108 switch (type){ 109 109 case ObjcObjectType: { 110 110 Interpreter *originInterpreter = exec->dynamicInterpreter(); 111 111 const RootObject *originExecutionContext = rootForInterpreter(originInterpreter); 112 112 113 114 115 116 117 118 119 120 113 Interpreter *interpreter = 0; 114 if (originInterpreter->isGlobalObject(value)) { 115 interpreter = originInterpreter->interpreterForGlobalObject (value); 116 } 117 118 if (!interpreter) 119 interpreter = originInterpreter; 120 121 121 const RootObject *executionContext = rootForInterpreter(interpreter); 122 122 if (!executionContext) { … … 309 309 { 310 310 if (!value->isObject()) 311 311 return 0; 312 312 if (!webScriptObjectClass) 313 313 webScriptObjectClass = NSClassFromString(@"WebScriptObject"); -
trunk/JavaScriptCore/bindings/runtime.cpp
- Property allow-tabs deleted
r13015 r15698 1 1 /* 2 * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 38 38 void deleteMethodList(CFAllocatorRef, const void* value) 39 39 { 40 const MethodList* methodList = static_cast<const MethodList*>(value); 41 int end = methodList->length(); 42 for (int i = 0; i < end; i++) { 43 delete methodList->methodAt(i); 44 } 45 46 delete methodList; 40 const MethodList* methodList = static_cast<const MethodList*>(value); 41 int end = methodList->length(); 42 for (int i = 0; i < end; i++) 43 delete methodList->methodAt(i); 44 delete methodList; 47 45 } 48 46 … … 134 132 135 133 switch (language) { 136 137 138 139 140 141 142 143 144 145 146 147 148 149 134 case Instance::JavaLanguage: { 135 newInstance = new Bindings::JavaInstance((jobject)nativeInstance, executionContext); 136 break; 137 } 138 case Instance::ObjectiveCLanguage: { 139 newInstance = new Bindings::ObjcInstance((ObjectStructPtr)nativeInstance); 140 break; 141 } 142 case Instance::CLanguage: { 143 newInstance = new Bindings::CInstance((NPObject *)nativeInstance); 144 break; 145 } 146 default: 147 break; 150 148 } 151 149 152 150 if (newInstance) 153 154 151 newInstance->setExecutionContext(executionContext); 152 155 153 return newInstance; 156 154 } … … 169 167 170 168 if (!value->isObject()) 171 169 return 0; 172 170 173 171 JSObject *imp = static_cast<JSObject*>(value); 174 172 175 173 switch (language) { 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 174 case Instance::ObjectiveCLanguage: { 175 result = createObjcInstanceForValue(value, origin, current); 176 break; 177 } 178 case Instance::CLanguage: { 179 result = _NPN_CreateScriptObject(0, imp, origin, current); 180 break; 181 } 182 case Instance::JavaLanguage: { 183 // FIXME: factor creation of jni_jsobjects, also remove unnecessary thread 184 // invocation code. 185 break; 186 } 187 default: 188 break; 191 189 } 192 190 -
trunk/JavaScriptCore/bindings/runtime_method.cpp
- Property allow-tabs deleted
r13821 r15698 70 70 { 71 71 if (_methodList.length() > 0) { 72 73 74 75 76 77 78 79 80 81 82 72 RuntimeObjectImp *imp; 73 74 // If thisObj is the DOM object for a plugin, get the corresponding 75 // runtime object from the DOM object. 76 if (thisObj->classInfo() != &KJS::RuntimeObjectImp::info) { 77 JSValue *runtimeObject = thisObj->get(exec, "__apple_runtime_object"); 78 imp = static_cast<RuntimeObjectImp*>(runtimeObject); 79 } 80 else { 81 imp = static_cast<RuntimeObjectImp*>(thisObj); 82 } 83 83 if (imp) { 84 84 Instance *instance = imp->getInternalInstance(); … … 107 107 return Completion(Normal, jsUndefined()); 108 108 } 109 -
trunk/JavaScriptCore/bindings/testbindings.cpp
- Property allow-tabs deleted
r12069 r15698 45 45 typedef struct 46 46 { 47 48 49 50 51 47 NPObject object; 48 double doubleValue; 49 int intValue; 50 NPVariant stringValue; 51 bool boolValue; 52 52 } MyObject; 53 53 … … 55 55 static bool identifiersInitialized = false; 56 56 57 #define ID_DOUBLE_VALUE 58 #define ID_INT_VALUE 59 #define ID_STRING_VALUE 60 #define ID_BOOLEAN_VALUE 61 #define ID_NULL_VALUE 62 #define ID_UNDEFINED_VALUE 63 #define NUM_PROPERTY_IDENTIFIERS657 #define ID_DOUBLE_VALUE 0 58 #define ID_INT_VALUE 1 59 #define ID_STRING_VALUE 2 60 #define ID_BOOLEAN_VALUE 3 61 #define ID_NULL_VALUE 4 62 #define ID_UNDEFINED_VALUE 5 63 #define NUM_PROPERTY_IDENTIFIERS 6 64 64 65 65 static NPIdentifier myPropertyIdentifiers[NUM_PROPERTY_IDENTIFIERS]; 66 66 static const NPUTF8 *myPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = { 67 68 69 70 71 72 67 "doubleValue", 68 "intValue", 69 "stringValue", 70 "booleanValue", 71 "nullValue", 72 "undefinedValue" 73 73 }; 74 74 75 #define ID_LOG_MESSAGE 76 #define ID_SET_DOUBLE_VALUE 77 #define ID_SET_INT_VALUE 78 #define ID_SET_STRING_VALUE 79 #define ID_SET_BOOLEAN_VALUE 80 #define ID_GET_DOUBLE_VALUE 81 #define ID_GET_INT_VALUE 82 #define ID_GET_STRING_VALUE 83 #define ID_GET_BOOLEAN_VALUE 84 #define NUM_METHOD_IDENTIFIERS 75 #define ID_LOG_MESSAGE 0 76 #define ID_SET_DOUBLE_VALUE 1 77 #define ID_SET_INT_VALUE 2 78 #define ID_SET_STRING_VALUE 3 79 #define ID_SET_BOOLEAN_VALUE 4 80 #define ID_GET_DOUBLE_VALUE 5 81 #define ID_GET_INT_VALUE 6 82 #define ID_GET_STRING_VALUE 7 83 #define ID_GET_BOOLEAN_VALUE 8 84 #define NUM_METHOD_IDENTIFIERS 9 85 85 86 86 static NPIdentifier myMethodIdentifiers[NUM_METHOD_IDENTIFIERS]; 87 87 static const NPUTF8 *myMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = { 88 89 90 91 92 93 94 95 96 88 "logMessage", 89 "setDoubleValue", 90 "setIntValue", 91 "setStringValue", 92 "setBooleanValue", 93 "getDoubleValue", 94 "getIntValue", 95 "getStringValue", 96 "getBooleanValue" 97 97 }; 98 98 99 99 static void initializeIdentifiers() 100 100 { 101 102 101 NPN_GetStringIdentifiers (myPropertyIdentifierNames, NUM_PROPERTY_IDENTIFIERS, myPropertyIdentifiers); 102 NPN_GetStringIdentifiers (myMethodIdentifierNames, NUM_METHOD_IDENTIFIERS, myMethodIdentifiers); 103 103 }; 104 104 105 105 bool myHasProperty (NPClass *theClass, NPIdentifier name) 106 { 107 108 109 110 111 112 113 106 { 107 int i; 108 for (i = 0; i < NUM_PROPERTY_IDENTIFIERS; i++) { 109 if (name == myPropertyIdentifiers[i]){ 110 return true; 111 } 112 } 113 return false; 114 114 } 115 115 116 116 bool myHasMethod (NPClass *theClass, NPIdentifier name) 117 117 { 118 119 120 121 122 123 124 118 int i; 119 for (i = 0; i < NUM_METHOD_IDENTIFIERS; i++) { 120 if (name == myMethodIdentifiers[i]){ 121 return true; 122 } 123 } 124 return false; 125 125 } 126 126 … … 129 129 { 130 130 if (message->type == NPVariantStringType) { 131 132 133 131 char msgBuf[1024]; 132 strncpy (msgBuf, message->value.stringValue.UTF8Characters, message->value.stringValue.UTF8Length); 133 msgBuf[message->value.stringValue.UTF8Length] = 0; 134 134 printf ("%s\n", msgBuf); 135 135 } … … 144 144 void setDoubleValue (MyObject *obj, const NPVariant *variant) 145 145 { 146 147 148 149 150 151 152 146 if (!NPN_VariantToDouble (variant, &obj->doubleValue)) { 147 NPUTF8 *msg = "Attempt to set double value with invalid type."; 148 NPString aString; 149 aString.UTF8Characters = msg; 150 aString.UTF8Length = strlen (msg); 151 NPN_SetException ((NPObject *)obj, &aString); 152 } 153 153 } 154 154 155 155 void setIntValue (MyObject *obj, const NPVariant *variant) 156 156 { 157 158 159 160 161 162 163 157 if (!NPN_VariantToInt32 (variant, &obj->intValue)) { 158 NPUTF8 *msg = "Attempt to set int value with invalid type."; 159 NPString aString; 160 aString.UTF8Characters = msg; 161 aString.UTF8Length = strlen (msg); 162 NPN_SetException ((NPObject *)obj, &aString); 163 } 164 164 } 165 165 166 166 void setStringValue (MyObject *obj, const NPVariant *variant) 167 167 { 168 169 168 NPN_ReleaseVariantValue (&obj->stringValue); 169 NPN_InitializeVariantWithVariant (&obj->stringValue, variant); 170 170 } 171 171 172 172 void setBooleanValue (MyObject *obj, const NPVariant *variant) 173 173 { 174 175 176 177 178 179 180 174 if (!NPN_VariantToBool (variant, (NPBool *)&obj->boolValue)) { 175 NPUTF8 *msg = "Attempt to set bool value with invalid type."; 176 NPString aString; 177 aString.UTF8Characters = msg; 178 aString.UTF8Length = strlen (msg); 179 NPN_SetException ((NPObject *)obj, &aString); 180 } 181 181 } 182 182 183 183 void getDoubleValue (MyObject *obj, NPVariant *variant) 184 184 { 185 185 NPN_InitializeVariantWithDouble (variant, obj->doubleValue); 186 186 } 187 187 188 188 void getIntValue (MyObject *obj, NPVariant *variant) 189 189 { 190 190 NPN_InitializeVariantWithInt32 (variant, obj->intValue); 191 191 } 192 192 193 193 void getStringValue (MyObject *obj, NPVariant *variant) 194 194 { 195 195 NPN_InitializeVariantWithVariant (variant, &obj->stringValue); 196 196 } 197 197 198 198 void getBooleanValue (MyObject *obj, NPVariant *variant) 199 199 { 200 200 NPN_InitializeVariantWithBool (variant, obj->boolValue); 201 201 } 202 202 203 203 void myGetProperty (MyObject *obj, NPIdentifier name, NPVariant *variant) 204 204 { 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 205 if (name == myPropertyIdentifiers[ID_DOUBLE_VALUE]){ 206 getDoubleValue (obj, variant); 207 } 208 else if (name == myPropertyIdentifiers[ID_INT_VALUE]){ 209 getIntValue (obj, variant); 210 } 211 else if (name == myPropertyIdentifiers[ID_STRING_VALUE]){ 212 getStringValue (obj, variant); 213 } 214 else if (name == myPropertyIdentifiers[ID_BOOLEAN_VALUE]){ 215 getBooleanValue (obj, variant); 216 } 217 else if (name == myPropertyIdentifiers[ID_NULL_VALUE]){ 218 return NPN_InitializeVariantAsNull (variant); 219 } 220 else if (name == myPropertyIdentifiers[ID_UNDEFINED_VALUE]){ 221 return NPN_InitializeVariantAsUndefined (variant); 222 } 223 else 224 NPN_InitializeVariantAsUndefined(variant); 225 225 } 226 226 227 227 void mySetProperty (MyObject *obj, NPIdentifier name, const NPVariant *variant) 228 228 { 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 229 if (name == myPropertyIdentifiers[ID_DOUBLE_VALUE]) { 230 setDoubleValue (obj, variant); 231 } 232 else if (name == myPropertyIdentifiers[ID_INT_VALUE]) { 233 setIntValue (obj, variant); 234 } 235 else if (name == myPropertyIdentifiers[ID_STRING_VALUE]) { 236 setStringValue (obj, variant); 237 } 238 else if (name == myPropertyIdentifiers[ID_BOOLEAN_VALUE]) { 239 setBooleanValue (obj, variant); 240 } 241 else if (name == myPropertyIdentifiers[ID_NULL_VALUE]) { 242 // Do nothing! 243 } 244 else if (name == myPropertyIdentifiers[ID_UNDEFINED_VALUE]) { 245 // Do nothing! 246 } 247 247 } 248 248 249 249 void myInvoke (MyObject *obj, NPIdentifier name, NPVariant *args, unsigned argCount, NPVariant *result) 250 250 { 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 251 if (name == myMethodIdentifiers[ID_LOG_MESSAGE]) { 252 if (argCount == 1 && NPN_VariantIsString(&args[0])) 253 logMessage (&args[0]); 254 NPN_InitializeVariantAsVoid (result); 255 } 256 else if (name == myMethodIdentifiers[ID_SET_DOUBLE_VALUE]) { 257 if (argCount == 1 && NPN_VariantIsDouble (&args[0])) 258 setDoubleValue (obj, &args[0]); 259 NPN_InitializeVariantAsVoid (result); 260 } 261 else if (name == myMethodIdentifiers[ID_SET_INT_VALUE]) { 262 if (argCount == 1 && (NPN_VariantIsDouble (&args[0]) || NPN_VariantIsInt32 (&args[0]))) 263 setIntValue (obj, &args[0]); 264 NPN_InitializeVariantAsVoid (result); 265 } 266 else if (name == myMethodIdentifiers[ID_SET_STRING_VALUE]) { 267 if (argCount == 1 && NPN_VariantIsString (&args[0])) 268 setStringValue (obj, &args[0]); 269 NPN_InitializeVariantAsVoid (result); 270 } 271 else if (name == myMethodIdentifiers[ID_SET_BOOLEAN_VALUE]) { 272 if (argCount == 1 && NPN_VariantIsBool (&args[0])) 273 setBooleanValue (obj, &args[0]); 274 NPN_InitializeVariantAsVoid (result); 275 } 276 else if (name == myMethodIdentifiers[ID_GET_DOUBLE_VALUE]) { 277 getDoubleValue (obj, result); 278 } 279 else if (name == myMethodIdentifiers[ID_GET_INT_VALUE]) { 280 getIntValue (obj, result); 281 } 282 else if (name == myMethodIdentifiers[ID_GET_STRING_VALUE]) { 283 getStringValue (obj, result); 284 } 285 else if (name == myMethodIdentifiers[ID_GET_BOOLEAN_VALUE]) { 286 getBooleanValue (obj, result); 287 } 288 else 289 NPN_InitializeVariantAsUndefined (result); 290 290 } 291 291 292 292 NPObject *myAllocate () 293 293 { 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 294 MyObject *newInstance = (MyObject *)malloc (sizeof(MyObject)); 295 296 if (!identifiersInitialized) { 297 identifiersInitialized = true; 298 initializeIdentifiers(); 299 } 300 301 302 newInstance->doubleValue = 666.666; 303 newInstance->intValue = 1234; 304 newInstance->boolValue = true; 305 newInstance->stringValue.value.stringValue.UTF8Length = strlen ("Hello world"); 306 newInstance->stringValue.value.stringValue.UTF8Characters = strdup ("Hello world"); 307 308 return (NPObject *)newInstance; 309 309 } 310 310 311 311 void myInvalidate () 312 312 { 313 // Make sure we've released any remainging references to JavaScript 314 // objects. 313 // Make sure we've released any remaining references to JavaScript objects. 315 314 } 316 315 317 316 void myDeallocate (MyObject *obj) 318 317 { 319 318 free ((void *)obj); 320 319 } 321 320 322 321 static NPClass _myFunctionPtrs = { 323 324 325 326 327 328 329 330 331 322 kNPClassStructVersionCurrent, 323 (NPAllocateFunctionPtr) myAllocate, 324 (NPDeallocateFunctionPtr) myDeallocate, 325 (NPInvalidateFunctionPtr) myInvalidate, 326 (NPHasMethodFunctionPtr) myHasMethod, 327 (NPInvokeFunctionPtr) myInvoke, 328 (NPHasPropertyFunctionPtr) myHasProperty, 329 (NPGetPropertyFunctionPtr) myGetProperty, 330 (NPSetPropertyFunctionPtr) mySetProperty, 332 331 }; 333 332 static NPClass *myFunctionPtrs = &_myFunctionPtrs; -
trunk/JavaScriptCore/bindings/testbindings.mm
- Property allow-tabs deleted
r13089 r15698 67 67 @interface MyFirstInterface : NSObject 68 68 { 69 70 71 72 69 int myInt; 70 MySecondInterface *mySecondInterface; 71 id jsobject; 72 NSString *string; 73 73 } 74 74 … … 106 106 - (id)invokeUndefinedMethodFromWebScript:(NSString *)name withArguments:(NSArray *)args; 107 107 { 108 109 110 111 112 113 114 108 NSLog (@"Call to undefined method %@", name); 109 NSLog (@"%d args\n", [args count]); 110 int i; 111 for (i = 0; i < [args count]; i++) { 112 NSLog (@"%d: %@\n", i, [args objectAtIndex:i]); 113 } 114 return @"success"; 115 115 } 116 116 */ … … 119 119 - (id)valueForUndefinedKey:(NSString *)key 120 120 { 121 122 121 NSLog (@"%s: key = %@", __PRETTY_FUNCTION__, key); 122 return @"aValue"; 123 123 } 124 124 */ … … 126 126 - (void)setValue:(id)value forUndefinedKey:(NSString *)key 127 127 { 128 128 NSLog (@"%s: key = %@", __PRETTY_FUNCTION__, key); 129 129 } 130 130 … … 157 157 - (NSString *)getString 158 158 { 159 159 return string; 160 160 } 161 161 -
trunk/JavaScriptCore/kjs/date_object.cpp
- Property allow-tabs deleted
r15595 r15698 117 117 { 118 118 if (string == "short") 119 119 return kCFDateFormatterShortStyle; 120 120 if (string == "medium") 121 121 return kCFDateFormatterMediumStyle; 122 122 if (string == "long") 123 123 return kCFDateFormatterLongStyle; 124 124 if (string == "full") 125 125 return kCFDateFormatterFullStyle; 126 126 return defaultStyle; 127 127 } … … 137 137 UString arg0String = args[0]->toString(exec); 138 138 if (arg0String == "custom" && !args[1]->isUndefined()) { 139 140 139 useCustomFormat = true; 140 customFormatString = args[1]->toString(exec); 141 141 } else if (includeDate && includeTime && !args[1]->isUndefined()) { 142 143 142 dateStyle = styleFromArgString(arg0String, dateStyle); 143 timeStyle = styleFromArgString(args[1]->toString(exec), timeStyle); 144 144 } else if (includeDate && !args[0]->isUndefined()) { 145 145 dateStyle = styleFromArgString(arg0String, dateStyle); 146 146 } else if (includeTime && !args[0]->isUndefined()) { 147 147 timeStyle = styleFromArgString(arg0String, timeStyle); 148 148 } 149 149 … … 153 153 154 154 if (useCustomFormat) { 155 156 157 155 CFStringRef customFormatCFString = CFStringCreateWithCharacters(0, (UniChar *)customFormatString.data(), customFormatString.size()); 156 CFDateFormatterSetFormat(formatter, customFormatCFString); 157 CFRelease(customFormatCFString); 158 158 } 159 159 … … 453 453 We use a negative ID to denote the "UTC" variant. 454 454 @begin dateTable 61 455 toString DateProtoFunc::ToString DontEnum|Function0456 toUTCString -DateProtoFunc::ToUTCString DontEnum|Function0457 toDateString DateProtoFunc::ToDateString DontEnum|Function0458 toTimeString DateProtoFunc::ToTimeString DontEnum|Function0459 toLocaleString DateProtoFunc::ToLocaleString DontEnum|Function0460 toLocaleDateString DateProtoFunc::ToLocaleDateString DontEnum|Function0461 toLocaleTimeString DateProtoFunc::ToLocaleTimeString DontEnum|Function0462 valueOf DateProtoFunc::ValueOf DontEnum|Function0463 getTime DateProtoFunc::GetTime DontEnum|Function0464 getFullYear DateProtoFunc::GetFullYear DontEnum|Function0465 getUTCFullYear -DateProtoFunc::GetFullYear DontEnum|Function0466 toGMTString -DateProtoFunc::ToGMTString DontEnum|Function0467 getMonth DateProtoFunc::GetMonth DontEnum|Function0468 getUTCMonth -DateProtoFunc::GetMonth DontEnum|Function0469 getDate DateProtoFunc::GetDate DontEnum|Function0470 getUTCDate -DateProtoFunc::GetDate DontEnum|Function0471 getDay DateProtoFunc::GetDay DontEnum|Function0472 getUTCDay -DateProtoFunc::GetDay DontEnum|Function0473 getHours DateProtoFunc::GetHours DontEnum|Function0474 getUTCHours -DateProtoFunc::GetHours DontEnum|Function0475 getMinutes DateProtoFunc::GetMinutes DontEnum|Function0476 getUTCMinutes -DateProtoFunc::GetMinutes DontEnum|Function0477 getSeconds DateProtoFunc::GetSeconds DontEnum|Function0478 getUTCSeconds -DateProtoFunc::GetSeconds DontEnum|Function0479 getMilliseconds DateProtoFunc::GetMilliSeconds DontEnum|Function0480 getUTCMilliseconds -DateProtoFunc::GetMilliSeconds DontEnum|Function0481 getTimezoneOffset DateProtoFunc::GetTimezoneOffset DontEnum|Function0482 setTime DateProtoFunc::SetTime DontEnum|Function1483 setMilliseconds DateProtoFunc::SetMilliSeconds DontEnum|Function1484 setUTCMilliseconds -DateProtoFunc::SetMilliSeconds DontEnum|Function1485 setSeconds DateProtoFunc::SetSeconds DontEnum|Function2486 setUTCSeconds -DateProtoFunc::SetSeconds DontEnum|Function2487 setMinutes DateProtoFunc::SetMinutes DontEnum|Function3488 setUTCMinutes -DateProtoFunc::SetMinutes DontEnum|Function3489 setHours DateProtoFunc::SetHours DontEnum|Function4490 setUTCHours -DateProtoFunc::SetHours DontEnum|Function4491 setDate DateProtoFunc::SetDate DontEnum|Function1492 setUTCDate -DateProtoFunc::SetDate DontEnum|Function1493 setMonth DateProtoFunc::SetMonth DontEnum|Function2494 setUTCMonth -DateProtoFunc::SetMonth DontEnum|Function2495 setFullYear DateProtoFunc::SetFullYear DontEnum|Function3496 setUTCFullYear -DateProtoFunc::SetFullYear DontEnum|Function3497 setYear DateProtoFunc::SetYear DontEnum|Function1498 getYear DateProtoFunc::GetYear DontEnum|Function0455 toString DateProtoFunc::ToString DontEnum|Function 0 456 toUTCString -DateProtoFunc::ToUTCString DontEnum|Function 0 457 toDateString DateProtoFunc::ToDateString DontEnum|Function 0 458 toTimeString DateProtoFunc::ToTimeString DontEnum|Function 0 459 toLocaleString DateProtoFunc::ToLocaleString DontEnum|Function 0 460 toLocaleDateString DateProtoFunc::ToLocaleDateString DontEnum|Function 0 461 toLocaleTimeString DateProtoFunc::ToLocaleTimeString DontEnum|Function 0 462 valueOf DateProtoFunc::ValueOf DontEnum|Function 0 463 getTime DateProtoFunc::GetTime DontEnum|Function 0 464 getFullYear DateProtoFunc::GetFullYear DontEnum|Function 0 465 getUTCFullYear -DateProtoFunc::GetFullYear DontEnum|Function 0 466 toGMTString -DateProtoFunc::ToGMTString DontEnum|Function 0 467 getMonth DateProtoFunc::GetMonth DontEnum|Function 0 468 getUTCMonth -DateProtoFunc::GetMonth DontEnum|Function 0 469 getDate DateProtoFunc::GetDate DontEnum|Function 0 470 getUTCDate -DateProtoFunc::GetDate DontEnum|Function 0 471 getDay DateProtoFunc::GetDay DontEnum|Function 0 472 getUTCDay -DateProtoFunc::GetDay DontEnum|Function 0 473 getHours DateProtoFunc::GetHours DontEnum|Function 0 474 getUTCHours -DateProtoFunc::GetHours DontEnum|Function 0 475 getMinutes DateProtoFunc::GetMinutes DontEnum|Function 0 476 getUTCMinutes -DateProtoFunc::GetMinutes DontEnum|Function 0 477 getSeconds DateProtoFunc::GetSeconds DontEnum|Function 0 478 getUTCSeconds -DateProtoFunc::GetSeconds DontEnum|Function 0 479 getMilliseconds DateProtoFunc::GetMilliSeconds DontEnum|Function 0 480 getUTCMilliseconds -DateProtoFunc::GetMilliSeconds DontEnum|Function 0 481 getTimezoneOffset DateProtoFunc::GetTimezoneOffset DontEnum|Function 0 482 setTime DateProtoFunc::SetTime DontEnum|Function 1 483 setMilliseconds DateProtoFunc::SetMilliSeconds DontEnum|Function 1 484 setUTCMilliseconds -DateProtoFunc::SetMilliSeconds DontEnum|Function 1 485 setSeconds DateProtoFunc::SetSeconds DontEnum|Function 2 486 setUTCSeconds -DateProtoFunc::SetSeconds DontEnum|Function 2 487 setMinutes DateProtoFunc::SetMinutes DontEnum|Function 3 488 setUTCMinutes -DateProtoFunc::SetMinutes DontEnum|Function 3 489 setHours DateProtoFunc::SetHours DontEnum|Function 4 490 setUTCHours -DateProtoFunc::SetHours DontEnum|Function 4 491 setDate DateProtoFunc::SetDate DontEnum|Function 1 492 setUTCDate -DateProtoFunc::SetDate DontEnum|Function 1 493 setMonth DateProtoFunc::SetMonth DontEnum|Function 2 494 setUTCMonth -DateProtoFunc::SetMonth DontEnum|Function 2 495 setFullYear DateProtoFunc::SetFullYear DontEnum|Function 3 496 setUTCFullYear -DateProtoFunc::SetFullYear DontEnum|Function 3 497 setYear DateProtoFunc::SetYear DontEnum|Function 1 498 getYear DateProtoFunc::GetYear DontEnum|Function 0 499 499 @end 500 500 */ … … 1018 1018 dateString = newPosStr; 1019 1019 } else if (*dateString == '/' && month == -1) { 1020 1020 dateString++; 1021 1021 // This looks like a MM/DD/YYYY date, not an RFC date. 1022 1022 month = day - 1; // 0-based -
trunk/JavaScriptCore/kjs/function.cpp
- Property allow-tabs deleted
r15546 r15698 174 174 #ifdef KJS_VERBOSE 175 175 fprintf(stderr, "---------------------------------------------------\n" 176 177 176 "processing parameters for %s call\n", 177 name().isEmpty() ? "(internal)" : name().ascii()); 178 178 #endif 179 179 … … 185 185 if (it != args.end()) { 186 186 #ifdef KJS_VERBOSE 187 188 187 fprintf(stderr, "setting parameter %s ", p->name.ascii()); 188 printInfo(exec,"to", *it); 189 189 #endif 190 191 190 variable->put(exec, p->name, v); 191 v = ++it; 192 192 } else 193 193 variable->put(exec, p->name, jsUndefined()); 194 194 p = p->next.get(); 195 195 } … … 301 301 302 302 DeclaredFunctionImp::DeclaredFunctionImp(ExecState *exec, const Identifier &n, 303 303 FunctionBodyNode *b, const ScopeChain &sc) 304 304 : FunctionImp(exec, n, b) 305 305 { … … 639 639 && isxdigit(p[2].uc) && isxdigit(p[3].uc) 640 640 && isxdigit(p[4].uc) && isxdigit(p[5].uc)) { 641 642 641 charLen = 6; 642 u = Lexer::convertUnicode(p[2].uc, p[3].uc, p[4].uc, p[5].uc); 643 643 } 644 644 } … … 892 892 if (Lexer::isHexDigit((c+2)->uc) && Lexer::isHexDigit((c+3)->uc) && 893 893 Lexer::isHexDigit((c+4)->uc) && Lexer::isHexDigit((c+5)->uc)) { 894 895 896 897 894 u = Lexer::convertUnicode((c+2)->uc, (c+3)->uc, 895 (c+4)->uc, (c+5)->uc); 896 c = &u; 897 k += 5; 898 898 } 899 899 } else if (*c == UChar('%') && k <= len - 3 && … … 961 961 } 962 962 963 964 963 } // namespace -
trunk/JavaScriptCore/kjs/list.cpp
- Property allow-tabs deleted
r13541 r15698 105 105 int inlineSize = min(size, inlineValuesSize); 106 106 for (int i = 0; i != inlineSize; ++i) { 107 108 109 107 if (!values[i]->marked()) { 108 values[i]->mark(); 109 } 110 110 } 111 111 112 112 int overflowSize = size - inlineSize; 113 113 for (int i = 0; i != overflowSize; ++i) { 114 115 116 114 if (!overflow[i]->marked()) { 115 overflow[i]->mark(); 116 } 117 117 } 118 118 } … … 144 144 // Find a free one in the pool. 145 145 if (poolUsed < poolSize) { 146 147 148 149 150 146 ListImp *imp = poolFreeList ? poolFreeList : &pool[0]; 147 poolFreeList = imp->nextInFreeList ? imp->nextInFreeList : imp + 1; 148 imp->state = usedInPool; 149 poolUsed++; 150 return imp; 151 151 } 152 152 … … 218 218 if (imp->state == usedInPool) { 219 219 imp->state = unusedInPool; 220 221 222 220 imp->nextInFreeList = poolFreeList; 221 poolFreeList = imp; 222 poolUsed--; 223 223 } else { 224 224 assert(imp->state == usedOnHeap); -
trunk/JavaScriptCore/kjs/nodes.cpp
- Property allow-tabs deleted
r15593 r15698 1233 1233 1234 1234 JSObject *o2(static_cast<JSObject*>(v2)); 1235 if (!o2->implementsHasInstance()) {1235 if (!o2->implementsHasInstance()) 1236 1236 // According to the spec, only some types of objects "implement" the [[HasInstance]] property. 1237 1237 // But we are supposed to throw an exception where the object does not "have" the [[HasInstance]] … … 1239 1239 // case we return false (consistent with mozilla) 1240 1240 return jsBoolean(false); 1241 // return throwError(exec, TypeError,1242 // "Object does not implement the [[HasInstance]] method." );1243 }1244 1241 return jsBoolean(o2->hasInstance(exec, v1)); 1245 1242 } … … 1814 1811 KJS_CHECKEXCEPTION 1815 1812 if (!v->toBoolean(exec)) 1816 1813 return Completion(Normal, cval); 1817 1814 } 1818 1815 // bail out on error … … 2156 2153 KJS_CHECKEXCEPTION 2157 2154 if (strictEqual(exec, input, v)) { 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2155 res = clause->evalStatements(exec); 2156 if (res.complType() != Normal) 2157 return res; 2158 while (a) { 2159 res = a->getClause()->evalStatements(exec); 2160 if (res.complType() != Normal) 2161 return res; 2162 a = a->getNext(); 2163 } 2164 break; 2168 2165 } 2169 2166 } … … 2177 2174 res = clause->evalStatements(exec); 2178 2175 if (res.complType() != Normal) 2179 2176 return res; 2180 2177 goto step18; 2181 2178 } -
trunk/JavaScriptCore/kjs/nodes.h
- Property allow-tabs deleted
r15593 r15698 40 40 41 41 enum Operator { OpEqual, 42 43 44 45 46 47 48 49 42 OpEqEq, 43 OpNotEq, 44 OpStrEq, 45 OpStrNEq, 46 OpPlusEq, 47 OpMinusEq, 48 OpMultEq, 49 OpDivEq, 50 50 OpPlusPlus, 51 52 53 54 55 56 57 58 59 51 OpMinusMinus, 52 OpLess, 53 OpLessEq, 54 OpGreater, 55 OpGreaterEq, 56 OpAndEq, 57 OpXOrEq, 58 OpOrEq, 59 OpModEq, 60 60 OpAnd, 61 61 OpOr, 62 63 64 65 66 67 68 69 62 OpBitAnd, 63 OpBitXOr, 64 OpBitOr, 65 OpLShift, 66 OpRShift, 67 OpURShift, 68 OpIn, 69 OpInstanceOf 70 70 }; 71 71 -
trunk/JavaScriptCore/kjs/string_object.cpp
- Property allow-tabs deleted
r15468 r15698 107 107 /* Source for string_object.lut.h 108 108 @begin stringTable 26 109 toString StringProtoFunc::ToString DontEnum|Function0110 valueOf StringProtoFunc::ValueOf DontEnum|Function0111 charAt StringProtoFunc::CharAt DontEnum|Function1112 charCodeAt StringProtoFunc::CharCodeAt DontEnum|Function1113 concat StringProtoFunc::Concat DontEnum|Function1114 indexOf StringProtoFunc::IndexOf DontEnum|Function1115 lastIndexOf StringProtoFunc::LastIndexOf DontEnum|Function1116 match StringProtoFunc::Match DontEnum|Function1117 replace StringProtoFunc::Replace DontEnum|Function2118 search StringProtoFunc::Search DontEnum|Function1119 slice StringProtoFunc::Slice DontEnum|Function2120 split StringProtoFunc::Split DontEnum|Function2121 substr StringProtoFunc::Substr DontEnum|Function2122 substring StringProtoFunc::Substring DontEnum|Function2123 toLowerCase StringProtoFunc::ToLowerCase DontEnum|Function0124 toUpperCase StringProtoFunc::ToUpperCase DontEnum|Function0125 toLocaleLowerCase StringProtoFunc::ToLocaleLowerCase DontEnum|Function0126 toLocaleUpperCase StringProtoFunc::ToLocaleUpperCase DontEnum|Function 109 toString StringProtoFunc::ToString DontEnum|Function 0 110 valueOf StringProtoFunc::ValueOf DontEnum|Function 0 111 charAt StringProtoFunc::CharAt DontEnum|Function 1 112 charCodeAt StringProtoFunc::CharCodeAt DontEnum|Function 1 113 concat StringProtoFunc::Concat DontEnum|Function 1 114 indexOf StringProtoFunc::IndexOf DontEnum|Function 1 115 lastIndexOf StringProtoFunc::LastIndexOf DontEnum|Function 1 116 match StringProtoFunc::Match DontEnum|Function 1 117 replace StringProtoFunc::Replace DontEnum|Function 2 118 search StringProtoFunc::Search DontEnum|Function 1 119 slice StringProtoFunc::Slice DontEnum|Function 2 120 split StringProtoFunc::Split DontEnum|Function 2 121 substr StringProtoFunc::Substr DontEnum|Function 2 122 substring StringProtoFunc::Substring DontEnum|Function 2 123 toLowerCase StringProtoFunc::ToLowerCase DontEnum|Function 0 124 toUpperCase StringProtoFunc::ToUpperCase DontEnum|Function 0 125 toLocaleLowerCase StringProtoFunc::ToLocaleLowerCase DontEnum|Function 0 126 toLocaleUpperCase StringProtoFunc::ToLocaleUpperCase DontEnum|Function 0 127 127 # 128 128 # Under here: html extension, should only exist if KJS_PURE_ECMA is not defined 129 129 # I guess we need to generate two hashtables in the .lut.h file, and use #ifdef 130 130 # to select the right one... TODO. ##### 131 big StringProtoFunc::Big DontEnum|Function0132 small StringProtoFunc::Small DontEnum|Function0133 blink StringProtoFunc::Blink DontEnum|Function0134 bold StringProtoFunc::Bold DontEnum|Function0135 fixed StringProtoFunc::Fixed DontEnum|Function0136 italics StringProtoFunc::Italics DontEnum|Function0137 strike StringProtoFunc::Strike DontEnum|Function0138 sub StringProtoFunc::Sub DontEnum|Function0139 sup StringProtoFunc::Sup DontEnum|Function0140 fontcolor StringProtoFunc::Fontcolor DontEnum|Function1141 fontsize StringProtoFunc::Fontsize DontEnum|Function1142 anchor StringProtoFunc::Anchor DontEnum|Function1143 link StringProtoFunc::Link DontEnum|Function1131 big StringProtoFunc::Big DontEnum|Function 0 132 small StringProtoFunc::Small DontEnum|Function 0 133 blink StringProtoFunc::Blink DontEnum|Function 0 134 bold StringProtoFunc::Bold DontEnum|Function 0 135 fixed StringProtoFunc::Fixed DontEnum|Function 0 136 italics StringProtoFunc::Italics DontEnum|Function 0 137 strike StringProtoFunc::Strike DontEnum|Function 0 138 sub StringProtoFunc::Sub DontEnum|Function 0 139 sup StringProtoFunc::Sup DontEnum|Function 0 140 fontcolor StringProtoFunc::Fontcolor DontEnum|Function 1 141 fontsize StringProtoFunc::Fontsize DontEnum|Function 1 142 anchor StringProtoFunc::Anchor DontEnum|Function 1 143 link StringProtoFunc::Link DontEnum|Function 1 144 144 @end 145 145 */ … … 488 488 // Exec 489 489 if ((reg->flags() & RegExp::Global) == 0) { 490 491 492 493 494 495 490 // case without 'g' flag is handled like RegExp.prototype.exec 491 if (mstr.isNull()) { 492 result = jsNull(); 493 } else { 494 result = regExpObj->arrayOfMatches(exec,mstr); 495 } 496 496 } else { 497 498 499 500 497 // return array of matches 498 List list; 499 int lastIndex = 0; 500 while (pos >= 0) { 501 501 if (mstr.isNull()) 502 502 list.append(jsUndefined()); 503 503 else 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 504 list.append(jsString(mstr)); 505 lastIndex = pos; 506 pos += mstr.isEmpty() ? 1 : mstr.size(); 507 mstr = regExpObj->performMatch(reg, u, pos, &pos); 508 } 509 if (imp) 510 imp->put(exec, "lastIndex", jsNumber(lastIndex), DontDelete|DontEnum); 511 if (list.isEmpty()) { 512 // if there are no matches at all, it's important to return 513 // Null instead of an empty array, because this matches 514 // other browsers and because Null is a false value. 515 result = jsNull(); 516 } else { 517 result = exec->lexicalInterpreter()->builtinArray()->construct(exec, list); 518 } 519 519 } 520 520 } … … 553 553 RegExp *reg = static_cast<RegExpImp *>(a0)->regExp(); 554 554 if (u.isEmpty() && !reg->match(u, 0).isNull()) { 555 556 557 555 // empty string matched by regexp -> empty array 556 res->put(exec,lengthPropertyName, jsNumber(0)); 557 break; 558 558 } 559 559 pos = 0; 560 560 while (static_cast<uint32_t>(i) != limit && pos < u.size()) { 561 561 // TODO: back references 562 562 int mpos; 563 563 int *ovector = 0L; 564 564 UString mstr = reg->match(u, pos, &mpos, &ovector); 565 565 delete [] ovector; ovector = 0L; 566 567 568 569 570 571 572 573 566 if (mpos < 0) 567 break; 568 pos = mpos + (mstr.isEmpty() ? 1 : mstr.size()); 569 if (mpos != p0 || !mstr.isEmpty()) { 570 res->put(exec,i, jsString(u.substr(p0, mpos-p0))); 571 p0 = mpos + mstr.size(); 572 i++; 573 } 574 574 } 575 575 } else { 576 576 u2 = a0->toString(exec); 577 577 if (u2.isEmpty()) { 578 579 580 581 582 583 584 585 578 if (u.isEmpty()) { 579 // empty separator matches empty string -> empty array 580 put(exec,lengthPropertyName, jsNumber(0)); 581 break; 582 } else { 583 while (static_cast<uint32_t>(i) != limit && i < u.size()-1) 584 res->put(exec, i++, jsString(u.substr(p0++, 1))); 585 } 586 586 } else { 587 588 589 590 591 587 while (static_cast<uint32_t>(i) != limit && (pos = u.find(u2, p0)) >= 0) { 588 res->put(exec, i, jsString(u.substr(p0, pos-p0))); 589 p0 = pos + u2.size(); 590 i++; 591 } 592 592 } 593 593 } -
trunk/JavaScriptCore/kjs/ustring.cpp
- Property allow-tabs deleted
r15696 r15698 435 435 m_rep = a.m_rep; 436 436 } else if (aOffset + aSize == a.usedCapacity() && 4 * aSize >= bSize && 437 437 (-bOffset != b.usedPreCapacity() || aSize >= bSize)) { 438 438 // - a reaches the end of its buffer so it qualifies for shared append 439 439 // - also, it's at least a quarter the length of b - appending to a much shorter … … 577 577 i += length; 578 578 for (int j = 0; j < decimalPoint - length; j++) { 579 579 buf[i++] = '0'; 580 580 } 581 581 buf[i] = '\0'; … … 878 878 while (*(++c)) { 879 879 if (*c >= '0' && *c <= '9') 880 880 d = d * 16.0 + *c - '0'; 881 881 else if ((*c >= 'A' && *c <= 'F') || (*c >= 'a' && *c <= 'f')) 882 882 d = d * 16.0 + (*c & 0xdf) - 'A' + 10.0; 883 883 else 884 884 break; 885 885 } 886 886 } else { … … 894 894 d = 1.0; 895 895 if (*c == '+') 896 896 c++; 897 897 else if (*c == '-') { 898 899 898 d = -1.0; 899 c++; 900 900 } 901 901 if (strncmp(c, "Infinity", 8) != 0) 902 902 return NaN; 903 903 d = d * Inf; 904 904 c += 8; … … 1113 1113 1114 1114 return (memcmp(s1.m_rep->data(), s2.m_rep->data(), 1115 1115 s1.m_rep->len * sizeof(UChar)) == 0); 1116 1116 } 1117 1117
Note:
See TracChangeset
for help on using the changeset viewer.