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


Ignore:
Timestamp:
Jul 5, 2006, 10:46:00 AM (19 years ago)
Author:
ggaren
Message:

Reviewed by Maciej.


Implemented JSFunctionMakeWithBody, which parses a script as a function body
in the global scope, and returns the resulting anonymous function.


I also removed private data from JSCallbackFunction. It never worked,
since JSCallbackFunction doesn't inherit from JSCallbackObject.

  • API/JSCallbackConstructor.cpp: Removed.
  • API/JSCallbackConstructor.h: Removed.
  • API/JSCallbackFunction.cpp: (KJS::JSCallbackFunction::JSCallbackFunction): (KJS::JSCallbackFunction::implementsConstruct): (KJS::JSCallbackFunction::construct): (KJS::JSCallbackFunction::implementsCall): (KJS::JSCallbackFunction::callAsFunction):
  • API/JSCallbackFunction.h:
  • API/JSCallbackObject.cpp: (KJS::JSCallbackObject::staticFunctionGetter):
  • API/JSObjectRef.cpp: (JSFunctionMake): (JSFunctionMakeWithCallbacks):
  • API/JSObjectRef.h:
  • API/JSValueRef.h:
  • API/minidom.c: (main):
  • API/testapi.c: (main):
  • JavaScriptCore.exp: Programmatically added all symbols exported by API object files, and sorted results
  • JavaScriptCore.xcodeproj/project.pbxproj:
File:
1 edited

Legend:

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

    r15163 r15164  
    501501    JSValueRef exception;
    502502
    503     result = JSEvaluate(context, goodSyntaxBuf, NULL, NULL, 0, NULL);
     503    result = JSEvaluate(context, goodSyntaxBuf, NULL, NULL, 1, NULL);
    504504    assert(result);
    505505    assert(JSValueIsEqual(context, result, jsOne));
    506506   
    507     result = JSEvaluate(context, badSyntaxBuf, NULL, NULL, 0, &exception);
     507    result = JSEvaluate(context, badSyntaxBuf, NULL, NULL, 1, &exception);
    508508    assert(!result);
    509509    assert(!JSContextGetException(context));
     
    537537    assert(!JSValueIsInstanceOf(context, JSNullMake(), arrayConstructor));
    538538   
     539    JSCharBufferRef functionBuf;
     540   
     541    functionBuf = JSCharBufferCreateUTF8("rreturn Array;");
     542    assert(!JSFunctionMakeWithBody(context, functionBuf, NULL, 1));
     543    JSCharBufferRelease(functionBuf);
     544
     545    functionBuf = JSCharBufferCreateUTF8("return Array;");
     546    JSObjectRef function = JSFunctionMakeWithBody(context, functionBuf, NULL, 1);
     547    JSCharBufferRelease(functionBuf);
     548
     549    assert(JSObjectIsFunction(function));
     550    v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL);
     551    assert(JSValueIsEqual(context, v, arrayConstructor));
     552                                                 
    539553    JSObjectRef myObject = JSObjectMake(context, MyObject_class(context), NULL);
    540554    assert(didInitialize);
     
    548562
    549563    JSCharBufferRef myConstructorBuf = JSCharBufferCreateUTF8("MyConstructor");
    550     JSObjectSetProperty(context, globalObject, myConstructorBuf, JSConstructorMake(context, myConstructor_callAsConstructor), kJSPropertyAttributeNone); 
     564    JSObjectSetProperty(context, globalObject, myConstructorBuf, JSConstructorMake(context, myConstructor_callAsConstructor), kJSPropertyAttributeNone);
    551565    JSCharBufferRelease(myConstructorBuf);
    552566
    553567    char* script = createStringWithContentsOfFile("testapi.js");
    554568    JSCharBufferRef scriptBuf = JSCharBufferCreateUTF8(script);
    555     result = JSEvaluate(context, scriptBuf, NULL, NULL, 0, &exception);
     569    result = JSEvaluate(context, scriptBuf, NULL, NULL, 1, &exception);
    556570    if (JSValueIsUndefined(result))
    557571        printf("PASS: Test script executed successfully.\n");
Note: See TracChangeset for help on using the changeset viewer.