Changeset 15480 in webkit for trunk/JavaScriptCore/API


Ignore:
Timestamp:
Jul 16, 2006, 9:41:01 PM (19 years ago)
Author:
ggaren
Message:

Approved by Maciej, RS by Beth.


JSObjectMakeFunction -> JSObjectMakeFunctionWithCallback
JSObjectMakeFunctionWithBody -> JSObjectMakeFunction


because the latter is more common, and more fundamental, than the former.

  • API/APICast.h: (toJS):
  • API/JSBase.h:
  • API/JSCallbackObject.cpp: (KJS::JSCallbackObject::getOwnPropertySlot): (KJS::JSCallbackObject::put): (KJS::JSCallbackObject::deleteProperty): (KJS::JSCallbackObject::getPropertyNames): (KJS::JSCallbackObject::staticValueGetter): (KJS::JSCallbackObject::staticFunctionGetter):
  • API/JSClassRef.cpp: (OpaqueJSClass::OpaqueJSClass): (OpaqueJSClass::~OpaqueJSClass):
  • API/JSClassRef.h:
  • API/JSObjectRef.cpp: (JSClassCreate): (JSObjectMakeFunctionWithCallback): (JSObjectMakeFunction): (OpaqueJSPropertyNameArray::OpaqueJSPropertyNameArray): (JSObjectCopyPropertyNames):
  • API/JSObjectRef.h:
  • API/minidom.c: (main):
  • API/testapi.c: (main):
  • ChangeLog:
  • JavaScriptCore.exp:
Location:
trunk/JavaScriptCore/API
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/APICast.h

    r15468 r15480  
    4242inline KJS::ExecState* toJS(JSContextRef c)
    4343{
    44     return reinterpret_cast<KJS::ExecState*>(const_cast<__JSContext*>(c));
     44    return reinterpret_cast<KJS::ExecState*>(const_cast<OpaqueJSContext*>(c));
    4545}
    4646
     
    5252inline KJS::JSValue* toJS(JSValueRef v)
    5353{
    54     return reinterpret_cast<KJS::JSValue*>(const_cast<__JSValue*>(v));
     54    return reinterpret_cast<KJS::JSValue*>(const_cast<OpaqueJSValue*>(v));
    5555}
    5656
  • trunk/JavaScriptCore/API/JSBase.h

    r15468 r15480  
    3333
    3434/*! @typedef JSContextRef A JavaScript execution context. Holds the global object and other execution state. */
    35 typedef const struct __JSContext* JSContextRef;
     35typedef const struct OpaqueJSContext* JSContextRef;
    3636
    3737/*! @typedef JSGlobalContextRef A global JavaScript execution context. A JSGlobalContext is a JSContext. */
    38 typedef struct __JSContext* JSGlobalContextRef;
     38typedef struct OpaqueJSContext* JSGlobalContextRef;
    3939
    4040/*! @typedef JSString A UTF16 character buffer. The fundamental string representation in JavaScript. */
    41 typedef struct __JSString* JSStringRef;
     41typedef struct OpaqueJSString* JSStringRef;
    4242
    4343/*! @typedef JSClassRef A JavaScript class. Used with JSObjectMake to construct objects with custom behavior. */
    44 typedef struct __JSClass* JSClassRef;
     44typedef struct OpaqueJSClass* JSClassRef;
    4545
    4646/*! @typedef JSPropertyNameArrayRef An array of JavaScript property names. */
    47 typedef struct __JSPropertyNameArray* JSPropertyNameArrayRef;
     47typedef struct OpaqueJSPropertyNameArray* JSPropertyNameArrayRef;
    4848
    4949/*! @typedef JSPropertyNameAccumulatorRef A data type used to collect a JavaScript object's property names. */
    50 typedef struct __JSPropertyNameAccumulator* JSPropertyNameAccumulatorRef;
     50typedef struct OpaqueJSPropertyNameAccumulator* JSPropertyNameAccumulatorRef;
    5151
    5252
     
    5454
    5555/*! @typedef JSValueRef A JavaScript value. The base type for all JavaScript values, and polymorphic functions on them. */
    56 typedef const struct __JSValue* JSValueRef;
     56typedef const struct OpaqueJSValue* JSValueRef;
    5757
    5858/*! @typedef JSObjectRef A JavaScript object. A JSObject is a JSValue. */
    59 typedef struct __JSValue* JSObjectRef;
     59typedef struct OpaqueJSValue* JSObjectRef;
    6060
    6161#ifdef __cplusplus
  • trunk/JavaScriptCore/API/JSCallbackObject.cpp

    r15473 r15480  
    107107        }
    108108
    109         if (__JSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
     109        if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
    110110            if (staticValues->contains(propertyName.ustring().rep())) {
    111111                slot.setCustom(this, staticValueGetter);
     
    114114        }
    115115       
    116         if (__JSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
     116        if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
    117117            if (staticFunctions->contains(propertyName.ustring().rep())) {
    118118                slot.setCustom(this, staticFunctionGetter);
     
    143143        }
    144144   
    145         if (__JSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
     145        if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
    146146            if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) {
    147147                if (entry->attributes & kJSPropertyAttributeReadOnly)
     
    154154        }
    155155       
    156         if (__JSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
     156        if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
    157157            if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
    158158                if (entry->attributes & kJSPropertyAttributeReadOnly)
     
    184184        }
    185185
    186         if (__JSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
     186        if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
    187187            if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) {
    188188                if (entry->attributes & kJSPropertyAttributeDontDelete)
     
    192192        }
    193193       
    194         if (__JSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
     194        if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
    195195            if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
    196196                if (entry->attributes & kJSPropertyAttributeDontDelete)
     
    298298            getPropertyNames(execRef, thisRef, toRef(&propertyNames));
    299299
    300         if (__JSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
    301             typedef __JSClass::StaticValuesTable::const_iterator iterator;
     300        if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
     301            typedef OpaqueJSClass::StaticValuesTable::const_iterator iterator;
    302302            iterator end = staticValues->end();
    303303            for (iterator it = staticValues->begin(); it != end; ++it) {
     
    309309        }
    310310
    311         if (__JSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
    312             typedef __JSClass::StaticFunctionsTable::const_iterator iterator;
     311        if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
     312            typedef OpaqueJSClass::StaticFunctionsTable::const_iterator iterator;
    313313            iterator end = staticFunctions->end();
    314314            for (iterator it = staticFunctions->begin(); it != end; ++it) {
     
    385385
    386386    for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass)
    387         if (__JSClass::StaticValuesTable* staticValues = jsClass->staticValues)
     387        if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues)
    388388            if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep()))
    389389                if (JSObjectGetPropertyCallback getProperty = entry->getProperty)
     
    403403
    404404    for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass) {
    405         if (__JSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
     405        if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
    406406            if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
    407407                if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) {
  • trunk/JavaScriptCore/API/JSClassRef.cpp

    r15468 r15480  
    3333const JSClassDefinition kJSClassDefinitionNull = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    3434
    35 __JSClass::__JSClass(JSClassDefinition* definition)
     35OpaqueJSClass::OpaqueJSClass(JSClassDefinition* definition)
    3636    : refCount(0)
    3737    , className(definition->className)
     
    7070}
    7171
    72 __JSClass::~__JSClass()
     72OpaqueJSClass::~OpaqueJSClass()
    7373{
    7474    if (staticValues) {
  • trunk/JavaScriptCore/API/JSClassRef.h

    r15468 r15480  
    5353};
    5454
    55 struct __JSClass {
    56     __JSClass(JSClassDefinition*);
    57     ~__JSClass();
     55struct OpaqueJSClass {
     56    OpaqueJSClass(JSClassDefinition*);
     57    ~OpaqueJSClass();
    5858   
    5959    typedef HashMap<RefPtr<KJS::UString::Rep>, StaticValueEntry*> StaticValuesTable;
     
    6363
    6464    KJS::UString className;
    65     __JSClass* parentClass;
     65    OpaqueJSClass* parentClass;
    6666       
    6767    StaticValuesTable* staticValues;
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r15474 r15480  
    4444JSClassRef JSClassCreate(JSClassDefinition* definition)
    4545{
    46     JSClassRef jsClass = new __JSClass(definition);
     46    JSClassRef jsClass = new OpaqueJSClass(definition);
    4747    return JSClassRetain(jsClass);
    4848}
     
    7676}
    7777
    78 JSObjectRef JSObjectMakeFunction(JSContextRef context, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction)
     78JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef context, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction)
    7979{
    8080    JSLock lock;
     
    9292}
    9393
    94 JSObjectRef JSObjectMakeFunctionWithBody(JSContextRef context, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
     94JSObjectRef JSObjectMakeFunction(JSContextRef context, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
    9595{
    9696    JSLock lock;
     
    298298}
    299299
    300 struct __JSPropertyNameArray
    301 {
    302     __JSPropertyNameArray() : refCount(0)
     300struct OpaqueJSPropertyNameArray
     301{
     302    OpaqueJSPropertyNameArray() : refCount(0)
    303303    {
    304304    }
     
    314314    ExecState* exec = toJS(context);
    315315   
    316     JSPropertyNameArrayRef propertyNames = new __JSPropertyNameArray();
     316    JSPropertyNameArrayRef propertyNames = new OpaqueJSPropertyNameArray();
    317317    jsObject->getPropertyNames(exec, propertyNames->array);
    318318   
  • trunk/JavaScriptCore/API/JSObjectRef.h

    r15474 r15480  
    391391@result A JSObject that is an anonymous function. The object's prototype will be the default function prototype.
    392392*/
    393 JSObjectRef JSObjectMakeFunction(JSContextRef context, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction);
     393JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef context, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction);
    394394/*!
    395395@function
     
    415415@discussion Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution.
    416416*/
    417 JSObjectRef JSObjectMakeFunctionWithBody(JSContextRef context, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
     417JSObjectRef JSObjectMakeFunction(JSContextRef context, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
    418418
    419419/*!
  • trunk/JavaScriptCore/API/minidom.c

    r15469 r15480  
    4141   
    4242    JSStringRef printIString = JSStringCreateWithUTF8CString("print");
    43     JSObjectSetProperty(context, globalObject, printIString, JSObjectMakeFunction(context, printIString, print), kJSPropertyAttributeNone, NULL);
     43    JSObjectSetProperty(context, globalObject, printIString, JSObjectMakeFunctionWithCallback(context, printIString, print), kJSPropertyAttributeNone, NULL);
    4444    JSStringRelease(printIString);
    4545   
  • trunk/JavaScriptCore/API/testapi.c

    r15474 r15480  
    561561    functionBody = JSStringCreateWithUTF8CString("rreturn Array;");
    562562    JSStringRef line = JSStringCreateWithUTF8CString("line");
    563     assert(!JSObjectMakeFunctionWithBody(context, NULL, 0, NULL, functionBody, NULL, 1, &exception));
     563    assert(!JSObjectMakeFunction(context, NULL, 0, NULL, functionBody, NULL, 1, &exception));
    564564    assert(JSValueIsObject(exception));
    565565    v = JSObjectGetProperty(context, JSValueToObject(context, exception, NULL), line, NULL);
     
    570570    exception = NULL;
    571571    functionBody = JSStringCreateWithUTF8CString("return Array;");
    572     function = JSObjectMakeFunctionWithBody(context, NULL, 0, NULL, functionBody, NULL, 1, &exception);
     572    function = JSObjectMakeFunction(context, NULL, 0, NULL, functionBody, NULL, 1, &exception);
    573573    JSStringRelease(functionBody);
    574574    assert(!exception);
     
    579579   
    580580    exception = NULL;
    581     function = JSObjectMakeFunctionWithBody(context, NULL, 0, NULL, jsEmptyIString, NULL, 0, &exception);
     581    function = JSObjectMakeFunction(context, NULL, 0, NULL, jsEmptyIString, NULL, 0, &exception);
    582582    assert(!exception);
    583583    v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, &exception);
     
    590590    JSStringRef argumentNames[] = { foo };
    591591    functionBody = JSStringCreateWithUTF8CString("return foo;");
    592     function = JSObjectMakeFunctionWithBody(context, foo, 1, argumentNames, functionBody, NULL, 1, &exception);
     592    function = JSObjectMakeFunction(context, foo, 1, argumentNames, functionBody, NULL, 1, &exception);
    593593    assert(function && !exception);
    594594    JSValueRef arguments[] = { JSValueMakeNumber(2) };
     
    602602
    603603    JSStringRef print = JSStringCreateWithUTF8CString("print");
    604     JSObjectRef printFunction = JSObjectMakeFunction(context, print, print_callAsFunction);
     604    JSObjectRef printFunction = JSObjectMakeFunctionWithCallback(context, print, print_callAsFunction);
    605605    JSObjectSetProperty(context, globalObject, print, printFunction, kJSPropertyAttributeNone, NULL);
    606606    JSStringRelease(print);
     
    633633   
    634634    functionBody = JSStringCreateWithUTF8CString("return this;");
    635     function = JSObjectMakeFunctionWithBody(context, NULL, 0, NULL, functionBody, NULL, 1, NULL);
     635    function = JSObjectMakeFunction(context, NULL, 0, NULL, functionBody, NULL, 1, NULL);
    636636    JSStringRelease(functionBody);
    637637    v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL);
Note: See TracChangeset for help on using the changeset viewer.