Ignore:
Timestamp:
Jul 17, 2006, 1:20:28 AM (19 years ago)
Author:
ggaren
Message:

Reviewed by Maciej.


  • Changed JSObjectMakeConstructor to JSObjectMakeConstructorWithCallback, to match JSObjectMakeFunctionWithCallback.


  • Added prototype parameter, so the generated constructor automatically works with hasInstance / instanceof


  • Moved hasInstance implementation from InternalFunctionImp to JSObject so that subclasses can inherit it without inheriting function-related baggage. More refactoring here would be good, but this seems like a good short-term solution.

(KJS::JSCallbackFunction::implementsHasInstance): override and return false,
because callback functions aren't constructors.

File:
1 edited

Legend:

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

    r15481 r15482  
    389389@param name A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function.
    390390@param callAsFunction The JSObjectCallAsFunctionCallback to invoke when the function is called.
    391 @result A JSObject that is an anonymous function. The object's prototype will be the default function prototype.
     391@result A JSObject that is a function. The object's prototype will be the default function prototype.
    392392*/
    393393JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction);
     394
    394395/*!
    395396@function
    396397@abstract Convenience method for creating a JavaScript constructor with a given callback as its implementation.
    397398@param ctx The execution context to use.
     399@param prototype A JSValue to use as the constructor's .prototype property. This should be the same value your constructor will set as the prototype of the objects it constructs.
    398400@param callAsConstructor The JSObjectCallAsConstructorCallback to invoke when the constructor is used in a 'new' expression.
    399401@result A JSObject that is a constructor. The object's prototype will be the default object prototype.
    400402*/
    401 JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSObjectCallAsConstructorCallback callAsConstructor);
     403JSObjectRef JSObjectMakeConstructorWithCallback(JSContextRef ctx, JSValueRef prototype, JSObjectCallAsConstructorCallback callAsConstructor);
    402404
    403405/*!
Note: See TracChangeset for help on using the changeset viewer.