Changeset 15310 in webkit for trunk/JavaScriptCore/API/testapi.c


Ignore:
Timestamp:
Jul 10, 2006, 2:17:26 PM (19 years ago)
Author:
ggaren
Message:

Reviewed by Darin.

Improved type safety by implementing opaque JSValue/JSObject typing through
abuse of 'const', not void*. Also fixed an alarming number of bugs
exposed by this new type safety.


I made one design change in JavaScriptCore, which is that the JSObject
constructor should take a JSValue* as its prototype argument, not a JSObject*,
since we allow the prototype to be any JSValue*, including jsNull(), for
example.


  • API/APICast.h: (toJS):
  • API/JSBase.h:
  • API/JSCallbackConstructor.cpp: (KJS::JSCallbackConstructor::construct):
  • API/JSCallbackFunction.cpp: (KJS::JSCallbackFunction::callAsFunction):
  • API/JSCallbackObject.cpp: (KJS::JSCallbackObject::JSCallbackObject): (KJS::JSCallbackObject::getOwnPropertySlot): (KJS::JSCallbackObject::put): (KJS::JSCallbackObject::construct): (KJS::JSCallbackObject::callAsFunction): (KJS::JSCallbackObject::staticFunctionGetter):
  • API/JSCallbackObject.h:
  • API/JSContextRef.cpp: (JSEvaluate):
  • API/JSNode.c: (JSNodePrototype_appendChild): (JSNodePrototype_removeChild): (JSNodePrototype_replaceChild):
  • API/JSObjectRef.cpp: (JSObjectMake): (JSFunctionMakeWithBody): (JSObjectGetProperty): (JSObjectCallAsFunction): (JSObjectCallAsConstructor):
  • API/JSObjectRef.h:
  • API/testapi.c: (main):
  • ChangeLog:
  • kjs/object.h: (KJS::JSObject::JSObject):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/testapi.c

    r15307 r15310  
    553553    assert(!JSFunctionMakeWithBody(context, functionBuf, NULL, 1, &exception));
    554554    assert(JSValueIsObject(exception));
    555     v = JSObjectGetProperty(context, exception, lineBuf);
     555    v = JSObjectGetProperty(context, JSValueToObject(context, exception), lineBuf);
    556556    assert(v);
    557557    assertEqualsAsNumber(v, 2); // FIXME: Lexer::setCode bumps startingLineNumber by 1 -- we need to change internal callers so that it doesn't have to (saying '0' to mean '1' in the API would be really confusing -- it's really confusing internally, in fact)
     
    574574
    575575    JSInternalStringRef printBuf = JSInternalStringCreateUTF8("print");
    576     JSValueRef printFunction = JSFunctionMake(context, print_callAsFunction);
     576    JSObjectRef printFunction = JSFunctionMake(context, print_callAsFunction);
    577577    JSObjectSetProperty(context, globalObject, printBuf, printFunction, kJSPropertyAttributeNone);
    578578    JSInternalStringRelease(printBuf);
     
    582582
    583583    JSInternalStringRef myConstructorBuf = JSInternalStringCreateUTF8("MyConstructor");
    584     JSValueRef myConstructor = JSConstructorMake(context, myConstructor_callAsConstructor);
     584    JSObjectRef myConstructor = JSConstructorMake(context, myConstructor_callAsConstructor);
    585585    JSObjectSetProperty(context, globalObject, myConstructorBuf, myConstructor, kJSPropertyAttributeNone);
    586586    JSInternalStringRelease(myConstructorBuf);
     
    590590   
    591591    o = JSObjectMake(context, NULL, NULL);
    592     JSObjectSetProperty(context, o, jsOneString, JSNumberMake(1), kJSPropertyAttributeNone);
    593     JSObjectSetProperty(context, o, jsCFString,  JSNumberMake(1), kJSPropertyAttributeDontEnum);
     592    JSObjectSetProperty(context, o, jsOneStringBuf, JSNumberMake(1), kJSPropertyAttributeNone);
     593    JSObjectSetProperty(context, o, jsCFStringBuf,  JSNumberMake(1), kJSPropertyAttributeDontEnum);
    594594    JSPropertyEnumeratorRef enumerator = JSObjectCreatePropertyEnumerator(context, o);
    595595    int count = 0;
Note: See TracChangeset for help on using the changeset viewer.