Exemplo n.º 1
0
v8::Local<v8::Signature> configureTemplate(v8::Persistent<v8::FunctionTemplate> desc,
                                           const char *interfaceName,
                                           v8::Persistent<v8::FunctionTemplate> parentClass,
                                           int fieldCount,
                                           const BatchedAttribute* attributes, 
                                           size_t attributeCount,
                                           const BatchedCallback* callbacks,
                                           size_t callbackCount)
{
    desc->SetClassName(v8::String::New(interfaceName));
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    instance->SetInternalFieldCount(fieldCount);
    if (!parentClass.IsEmpty())
        desc->Inherit(parentClass);
    if (attributeCount)
        batchConfigureAttributes(instance, desc->PrototypeTemplate(),
                                 attributes, attributeCount);
    v8::Local<v8::Signature> defaultSignature = v8::Signature::New(desc);
    if (callbackCount)
        batchConfigureCallbacks(desc->PrototypeTemplate(),
                                defaultSignature,
                                static_cast<v8::PropertyAttribute>(v8::DontDelete),
                                callbacks, callbackCount);
    return defaultSignature;
}
v8::Local<v8::Object> createV8ObjectForNPObject(NPObject* object, NPObject* root)
{
    static v8::Persistent<v8::FunctionTemplate> npObjectDesc;

    ASSERT(v8::Context::InContext());

    // If this is a v8 object, just return it.
    if (object->_class == npScriptObjectClass) {
        V8NPObject* v8NPObject = reinterpret_cast<V8NPObject*>(object);
        return v8::Local<v8::Object>::New(v8NPObject->v8Object);
    }

    // If we've already wrapped this object, just return it.
    if (staticNPObjectMap.contains(object))
        return v8::Local<v8::Object>::New(staticNPObjectMap.get(object));

    // FIXME: we should create a Wrapper type as a subclass of JSObject. It has two internal fields, field 0 is the wrapped
    // pointer, and field 1 is the type. There should be an api function that returns unused type id. The same Wrapper type
    // can be used by DOM bindings.
    if (npObjectDesc.IsEmpty()) {
        npObjectDesc = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New());
        npObjectDesc->InstanceTemplate()->SetInternalFieldCount(V8Custom::kNPObjectInternalFieldCount);
        npObjectDesc->InstanceTemplate()->SetNamedPropertyHandler(npObjectNamedPropertyGetter, npObjectNamedPropertySetter);
        npObjectDesc->InstanceTemplate()->SetIndexedPropertyHandler(npObjectIndexedPropertyGetter, npObjectIndexedPropertySetter);
        npObjectDesc->InstanceTemplate()->SetCallAsFunctionHandler(npObjectInvokeDefaultHandler);
    }

    v8::Handle<v8::Function> v8Function = npObjectDesc->GetFunction();
    v8::Local<v8::Object> value = SafeAllocation::newInstance(v8Function);

    // If we were unable to allocate the instance, we avoid wrapping and registering the NP object.
    if (value.IsEmpty())
        return value;

    wrapNPObject(value, object);

    // KJS retains the object as part of its wrapper (see Bindings::CInstance).
    _NPN_RetainObject(object);

    _NPN_RegisterObject(object, root);

    // Maintain a weak pointer for v8 so we can cleanup the object.
    v8::Persistent<v8::Object> weakRef = v8::Persistent<v8::Object>::New(value);
    staticNPObjectMap.set(object, weakRef);

    return value;
}
Exemplo n.º 3
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8HTMLCollectionTemplate(v8::Persistent<v8::FunctionTemplate> desc)
{
    desc->ReadOnlyPrototype();

    v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "HTMLCollection", v8::Persistent<v8::FunctionTemplate>(), V8HTMLCollection::internalFieldCount,
        HTMLCollectionAttrs, WTF_ARRAY_LENGTH(HTMLCollectionAttrs),
        HTMLCollectionCallbacks, WTF_ARRAY_LENGTH(HTMLCollectionCallbacks));
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
    
    setCollectionIndexedGetter<HTMLCollection, Node>(desc);
    desc->InstanceTemplate()->SetNamedPropertyHandler(V8HTMLCollection::namedPropertyGetter, 0, 0, 0, 0);
    desc->InstanceTemplate()->SetCallAsFunctionHandler(V8HTMLCollection::callAsFunctionCallback);

    // Custom toString template
    desc->Set(getToStringName(), getToStringTemplate());
    return desc;
}
static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestCustomNamedGetterTemplate(v8::Persistent<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWorldType)
{
    desc->ReadOnlyPrototype();

    v8::Local<v8::Signature> defaultSignature;
    defaultSignature = V8DOMConfiguration::configureTemplate(desc, "TestCustomNamedGetter", v8::Persistent<v8::FunctionTemplate>(), V8TestCustomNamedGetter::internalFieldCount,
        0, 0,
        V8TestCustomNamedGetterMethods, WTF_ARRAY_LENGTH(V8TestCustomNamedGetterMethods), isolate, currentWorldType);
    UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
    UNUSED_PARAM(instance); // In some cases, it will not be used.
    UNUSED_PARAM(proto); // In some cases, it will not be used.
    desc->InstanceTemplate()->SetNamedPropertyHandler(V8TestCustomNamedGetter::namedPropertyGetter, 0, 0, 0, 0);

    // Custom toString template
    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    return desc;
}
Exemplo n.º 5
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestCustomNamedGetterTemplate(v8::Persistent<v8::FunctionTemplate> desc)
{
    desc->ReadOnlyPrototype();

    v8::Local<v8::Signature> defaultSignature;
    defaultSignature = configureTemplate(desc, "TestCustomNamedGetter", v8::Persistent<v8::FunctionTemplate>(), V8TestCustomNamedGetter::internalFieldCount,
        0, 0,
        TestCustomNamedGetterCallbacks, WTF_ARRAY_LENGTH(TestCustomNamedGetterCallbacks));
    UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
    UNUSED_PARAM(instance); // In some cases, it will not be used.
    UNUSED_PARAM(proto); // In some cases, it will not be used.
    
    desc->InstanceTemplate()->SetNamedPropertyHandler(V8TestCustomNamedGetter::namedPropertyGetter, 0, 0, 0, 0);

    // Custom toString template
    desc->Set(getToStringName(), getToStringTemplate());
    return desc;
}
Exemplo n.º 6
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8DOMStringMapTemplate(v8::Persistent<v8::FunctionTemplate> desc)
{
    v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "DOMStringMap", v8::Persistent<v8::FunctionTemplate>(), V8DOMStringMap::internalFieldCount,
        0, 0,
        0, 0);
    
    desc->InstanceTemplate()->SetNamedPropertyHandler(V8DOMStringMap::namedPropertyGetter, V8DOMStringMap::namedPropertySetter, V8DOMStringMap::namedPropertyQuery, V8DOMStringMap::namedPropertyDeleter, V8DOMStringMap::namedPropertyEnumerator);

    // Custom toString template
    desc->Set(getToStringName(), getToStringTemplate());
    return desc;
}
static v8::Persistent<v8::FunctionTemplate> ConfigureV8HTMLFormControlsCollectionTemplate(v8::Persistent<v8::FunctionTemplate> desc)
{
    desc->ReadOnlyPrototype();

    v8::Local<v8::Signature> defaultSignature;
    defaultSignature = V8DOMConfiguration::configureTemplate(desc, "HTMLFormControlsCollection", V8HTMLCollection::GetTemplate(), V8HTMLFormControlsCollection::internalFieldCount,
        0, 0,
        V8HTMLFormControlsCollectionCallbacks, WTF_ARRAY_LENGTH(V8HTMLFormControlsCollectionCallbacks));
    UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
    UNUSED_PARAM(instance); // In some cases, it will not be used.
    UNUSED_PARAM(proto); // In some cases, it will not be used.
    
    setCollectionIndexedGetter<HTMLFormControlsCollection, Node>(desc);
    desc->InstanceTemplate()->SetNamedPropertyHandler(V8HTMLFormControlsCollection::namedPropertyGetter, 0, 0, 0, 0);

    // Custom toString template
    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    return desc;
}
Exemplo n.º 8
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8InspectorFrontendHostTemplate(v8::Persistent<v8::FunctionTemplate> desc) {
  v8::Local<v8::Signature> default_signature = configureTemplate(desc, "InspectorFrontendHost",
      v8::Persistent<v8::FunctionTemplate>(), V8InspectorFrontendHost::internalFieldCount,
      NULL, 0,
      InspectorFrontendHost_callbacks, sizeof(InspectorFrontendHost_callbacks)/sizeof(*InspectorFrontendHost_callbacks));
  v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
  v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
  

  // Custom toString template
  desc->Set(getToStringName(), getToStringTemplate());
  return desc;
}
Exemplo n.º 9
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8StyleMediaTemplate(v8::Persistent<v8::FunctionTemplate> desc)
{
    v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "StyleMedia", v8::Persistent<v8::FunctionTemplate>(), V8StyleMedia::internalFieldCount,
        StyleMediaAttrs, sizeof(StyleMediaAttrs) / sizeof(*StyleMediaAttrs),
        StyleMediaCallbacks, sizeof(StyleMediaCallbacks) / sizeof(*StyleMediaCallbacks));
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
    

    // Custom toString template
    desc->Set(getToStringName(), getToStringTemplate());
    return desc;
}
Exemplo n.º 10
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8TreeWalkerTemplate(v8::Persistent<v8::FunctionTemplate> desc) {
  v8::Local<v8::Signature> default_signature = configureTemplate(desc, "TreeWalker",
      v8::Persistent<v8::FunctionTemplate>(), V8TreeWalker::internalFieldCount,
      TreeWalker_attrs, sizeof(TreeWalker_attrs)/sizeof(*TreeWalker_attrs),
      TreeWalker_callbacks, sizeof(TreeWalker_callbacks)/sizeof(*TreeWalker_callbacks));
  v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
  v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
  

  // Custom toString template
  desc->Set(getToStringName(), getToStringTemplate());
  return desc;
}
static v8::Persistent<v8::FunctionTemplate> ConfigureV8HTMLMarqueeElementTemplate(v8::Persistent<v8::FunctionTemplate> desc)
{
    v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "HTMLMarqueeElement", V8HTMLElement::GetTemplate(), V8HTMLMarqueeElement::internalFieldCount,
        0, 0,
        HTMLMarqueeElementCallbacks, sizeof(HTMLMarqueeElementCallbacks) / sizeof(*HTMLMarqueeElementCallbacks));
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
    

    // Custom toString template
    desc->Set(getToStringName(), getToStringTemplate());
    return desc;
}
Exemplo n.º 12
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8PopStateEventTemplate(v8::Persistent<v8::FunctionTemplate> desc) {
    v8::Local<v8::Signature> default_signature = configureTemplate(desc, "PopStateEvent",
            V8Event::GetTemplate(), V8PopStateEvent::internalFieldCount,
            PopStateEvent_attrs, sizeof(PopStateEvent_attrs)/sizeof(*PopStateEvent_attrs),
            PopStateEvent_callbacks, sizeof(PopStateEvent_callbacks)/sizeof(*PopStateEvent_callbacks));
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();


    // Custom toString template
    desc->Set(getToStringName(), getToStringTemplate());
    return desc;
}
Exemplo n.º 13
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8GeolocationTemplate(v8::Persistent<v8::FunctionTemplate> desc)
{
    v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "Geolocation", v8::Persistent<v8::FunctionTemplate>(), V8Geolocation::internalFieldCount,
        0, 0,
        GeolocationCallbacks, sizeof(GeolocationCallbacks) / sizeof(*GeolocationCallbacks));
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
    

    // Custom toString template
    desc->Set(getToStringName(), getToStringTemplate());
    return desc;
}
void XpcConnection::Init(v8::Handle<v8::Object> target) {
  v8::HandleScope scope;

  v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(XpcConnection::New);

  s_ct = v8::Persistent<v8::FunctionTemplate>::New(t);
  s_ct->InstanceTemplate()->SetInternalFieldCount(1);
  s_ct->SetClassName(v8::String::NewSymbol("XpcConnection"));

  NODE_SET_PROTOTYPE_METHOD(s_ct, "setup", XpcConnection::Setup);
  NODE_SET_PROTOTYPE_METHOD(s_ct, "sendMessage", XpcConnection::SendMessage);

  target->Set(v8::String::NewSymbol("XpcConnection"), s_ct->GetFunction());
}
Exemplo n.º 15
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8SQLErrorTemplate(v8::Persistent<v8::FunctionTemplate> desc)
{
    v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "SQLError", v8::Persistent<v8::FunctionTemplate>(), V8SQLError::internalFieldCount,
        SQLErrorAttrs, sizeof(SQLErrorAttrs) / sizeof(*SQLErrorAttrs),
        0, 0);
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
    
    batchConfigureConstants(desc, proto, SQLErrorConsts, sizeof(SQLErrorConsts) / sizeof(*SQLErrorConsts));

    // Custom toString template
    desc->Set(getToStringName(), getToStringTemplate());
    return desc;
}
Exemplo n.º 16
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8ConnectionTemplate(v8::Persistent<v8::FunctionTemplate> desc) {
    v8::Local<v8::Signature> default_signature = configureTemplate(desc, "Connection",
            v8::Persistent<v8::FunctionTemplate>(), V8Connection::internalFieldCount,
            Connection_attrs, sizeof(Connection_attrs)/sizeof(*Connection_attrs),
            NULL, 0);
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();

    batchConfigureConstants(desc, proto, Connection_consts, sizeof(Connection_consts)/sizeof(*Connection_consts));

    // Custom toString template
    desc->Set(getToStringName(), getToStringTemplate());
    return desc;
}
Exemplo n.º 17
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8WebGLUnsignedIntArrayTemplate(v8::Persistent<v8::FunctionTemplate> desc) {
  v8::Local<v8::Signature> default_signature = configureTemplate(desc, "WebGLUnsignedIntArray",
      V8WebGLArray::GetTemplate(), V8WebGLUnsignedIntArray::internalFieldCount,
      NULL, 0,
      WebGLUnsignedIntArray_callbacks, sizeof(WebGLUnsignedIntArray_callbacks)/sizeof(*WebGLUnsignedIntArray_callbacks));
      desc->SetCallHandler(V8WebGLUnsignedIntArray::constructorCallback);
  v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
  v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
  

  // Custom toString template
  desc->Set(getToStringName(), getToStringTemplate());
  return desc;
}
Exemplo n.º 18
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8MediaListTemplate(v8::Persistent<v8::FunctionTemplate> desc)
{
    v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "MediaList", v8::Persistent<v8::FunctionTemplate>(), V8MediaList::internalFieldCount,
        MediaListAttrs, sizeof(MediaListAttrs) / sizeof(*MediaListAttrs),
        MediaListCallbacks, sizeof(MediaListCallbacks) / sizeof(*MediaListCallbacks));
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
    
    setCollectionStringOrNullIndexedGetter<MediaList>(desc);

    // Custom toString template
    desc->Set(getToStringName(), getToStringTemplate());
    return desc;
}
static v8::Persistent<v8::FunctionTemplate> ConfigureV8SVGFECompositeElementTemplate(v8::Persistent<v8::FunctionTemplate> desc)
{
    v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "SVGFECompositeElement", V8SVGElement::GetTemplate(), V8SVGFECompositeElement::internalFieldCount,
        SVGFECompositeElementAttrs, sizeof(SVGFECompositeElementAttrs) / sizeof(*SVGFECompositeElementAttrs),
        SVGFECompositeElementCallbacks, sizeof(SVGFECompositeElementCallbacks) / sizeof(*SVGFECompositeElementCallbacks));
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
    
    batchConfigureConstants(desc, proto, SVGFECompositeElementConsts, sizeof(SVGFECompositeElementConsts) / sizeof(*SVGFECompositeElementConsts));

    // Custom toString template
    desc->Set(getToStringName(), getToStringTemplate());
    return desc;
}
static v8::Persistent<v8::FunctionTemplate> ConfigureV8CSSVariablesDeclarationTemplate(v8::Persistent<v8::FunctionTemplate> desc)
{
    v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "CSSVariablesDeclaration", v8::Persistent<v8::FunctionTemplate>(), V8CSSVariablesDeclaration::internalFieldCount,
            CSSVariablesDeclarationAttrs, sizeof(CSSVariablesDeclarationAttrs) / sizeof(*CSSVariablesDeclarationAttrs),
            CSSVariablesDeclarationCallbacks, sizeof(CSSVariablesDeclarationCallbacks) / sizeof(*CSSVariablesDeclarationCallbacks));
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();

    setCollectionStringIndexedGetter<CSSVariablesDeclaration>(desc);

    // Custom toString template
    desc->Set(getToStringName(), getToStringTemplate());
    return desc;
}
Exemplo n.º 21
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8DOMParserTemplate(v8::Persistent<v8::FunctionTemplate> desc) {
  v8::Local<v8::Signature> default_signature = configureTemplate(desc, "DOMParser",
      v8::Persistent<v8::FunctionTemplate>(), V8DOMParser::internalFieldCount,
      NULL, 0,
      DOMParser_callbacks, sizeof(DOMParser_callbacks)/sizeof(*DOMParser_callbacks));
      desc->SetCallHandler(V8DOMParser::constructorCallback);
  v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
  v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
  

  // Custom toString template
  desc->Set(getToStringName(), getToStringTemplate());
  return desc;
}
Exemplo n.º 22
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8HTMLAnchorElementTemplate(v8::Persistent<v8::FunctionTemplate> desc) {
  v8::Local<v8::Signature> default_signature = configureTemplate(desc, "HTMLAnchorElement",
      V8HTMLElement::GetTemplate(), V8HTMLAnchorElement::internalFieldCount,
      HTMLAnchorElement_attrs, sizeof(HTMLAnchorElement_attrs)/sizeof(*HTMLAnchorElement_attrs),
      NULL, 0);
  v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
  v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
  
  proto->Set(v8::String::New("toString"), v8::FunctionTemplate::New(HTMLAnchorElementInternal::toStringCallback, v8::Handle<v8::Value>(), default_signature), static_cast<v8::PropertyAttribute>(v8::DontDelete|v8::DontEnum));

  // Custom toString template
  desc->Set(getToStringName(), getToStringTemplate());
  return desc;
}
Exemplo n.º 23
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8XPathResultTemplate(v8::Persistent<v8::FunctionTemplate> desc)
{
    v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "XPathResult", v8::Persistent<v8::FunctionTemplate>(), V8XPathResult::internalFieldCount,
        XPathResultAttrs, sizeof(XPathResultAttrs) / sizeof(*XPathResultAttrs),
        XPathResultCallbacks, sizeof(XPathResultCallbacks) / sizeof(*XPathResultCallbacks));
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
    
    batchConfigureConstants(desc, proto, XPathResultConsts, sizeof(XPathResultConsts) / sizeof(*XPathResultConsts));

    // Custom toString template
    desc->Set(getToStringName(), getToStringTemplate());
    return desc;
}
Exemplo n.º 24
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8CSSRuleListTemplate(v8::Persistent<v8::FunctionTemplate> desc) {
  v8::Local<v8::Signature> default_signature = configureTemplate(desc, "CSSRuleList",
      v8::Persistent<v8::FunctionTemplate>(), V8CSSRuleList::internalFieldCount,
      CSSRuleList_attrs, sizeof(CSSRuleList_attrs)/sizeof(*CSSRuleList_attrs),
      CSSRuleList_callbacks, sizeof(CSSRuleList_callbacks)/sizeof(*CSSRuleList_callbacks));
  v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
  v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
  
  setCollectionIndexedGetter<CSSRuleList, CSSRule>(desc, V8ClassIndex::CSSRULE);

  // Custom toString template
  desc->Set(getToStringName(), getToStringTemplate());
  return desc;
}
Exemplo n.º 25
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8HTMLOutputElementTemplate(v8::Persistent<v8::FunctionTemplate> desc)
{
    desc->ReadOnlyPrototype();

    v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "HTMLOutputElement", V8HTMLElement::GetTemplate(), V8HTMLOutputElement::internalFieldCount,
        HTMLOutputElementAttrs, WTF_ARRAY_LENGTH(HTMLOutputElementAttrs),
        HTMLOutputElementCallbacks, WTF_ARRAY_LENGTH(HTMLOutputElementCallbacks));
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
    

    // Custom toString template
    desc->Set(getToStringName(), getToStringTemplate());
    return desc;
}
Exemplo n.º 26
0
v8::Local<v8::Signature> V8DOMConfiguration::configureTemplate(v8::Persistent<v8::FunctionTemplate> functionDescriptor, const char* interfaceName, v8::Persistent<v8::FunctionTemplate> parentClass,
    size_t fieldCount, const BatchedAttribute* attributes, size_t attributeCount, const BatchedCallback* callbacks, size_t callbackCount, v8::Isolate* isolate)
{
    functionDescriptor->SetClassName(v8::String::NewSymbol(interfaceName));
    v8::Local<v8::ObjectTemplate> instance = functionDescriptor->InstanceTemplate();
    instance->SetInternalFieldCount(fieldCount);
    if (!parentClass.IsEmpty())
        functionDescriptor->Inherit(parentClass);
    if (attributeCount)
        batchConfigureAttributes(instance, functionDescriptor->PrototypeTemplate(), attributes, attributeCount, isolate);
    v8::Local<v8::Signature> defaultSignature = v8::Signature::New(functionDescriptor);
    if (callbackCount)
        batchConfigureCallbacks(functionDescriptor->PrototypeTemplate(), defaultSignature, static_cast<v8::PropertyAttribute>(v8::DontDelete), callbacks, callbackCount, isolate);
    return defaultSignature;
}
Exemplo n.º 27
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8Float32ArrayTemplate(v8::Persistent<v8::FunctionTemplate> desc)
{
    v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "Float32Array", V8ArrayBufferView::GetTemplate(), V8Float32Array::internalFieldCount,
        Float32ArrayAttrs, WTF_ARRAY_LENGTH(Float32ArrayAttrs),
        Float32ArrayCallbacks, WTF_ARRAY_LENGTH(Float32ArrayCallbacks));
        desc->SetCallHandler(V8Float32Array::constructorCallback);
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
    
    batchConfigureConstants(desc, proto, Float32ArrayConsts, WTF_ARRAY_LENGTH(Float32ArrayConsts));

    // Custom toString template
    desc->Set(getToStringName(), getToStringTemplate());
    return desc;
}
Exemplo n.º 28
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8EventExceptionTemplate(v8::Persistent<v8::FunctionTemplate> desc) {
  v8::Local<v8::Signature> default_signature = configureTemplate(desc, "EventException",
      v8::Persistent<v8::FunctionTemplate>(), V8EventException::internalFieldCount,
      EventException_attrs, sizeof(EventException_attrs)/sizeof(*EventException_attrs),
      NULL, 0);
  v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
  v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
  
  proto->Set(v8::String::New("toString"), v8::FunctionTemplate::New(EventExceptionInternal::toStringCallback, v8::Handle<v8::Value>(), default_signature), static_cast<v8::PropertyAttribute>(v8::DontDelete|v8::DontEnum));
  batchConfigureConstants(desc, proto, EventException_consts, sizeof(EventException_consts)/sizeof(*EventException_consts));

  // Custom toString template
  desc->Set(getToStringName(), getToStringTemplate());
  return desc;
}
Exemplo n.º 29
0
static v8::Persistent<v8::FunctionTemplate> ConfigureV8XPathNSResolverTemplate(v8::Persistent<v8::FunctionTemplate> desc)
{
    desc->ReadOnlyPrototype();

    v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "XPathNSResolver", v8::Persistent<v8::FunctionTemplate>(), V8XPathNSResolver::internalFieldCount,
        0, 0,
        XPathNSResolverCallbacks, WTF_ARRAY_LENGTH(XPathNSResolverCallbacks));
    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
    

    // Custom toString template
    desc->Set(getToStringName(), getToStringTemplate());
    return desc;
}
static v8::Persistent<v8::FunctionTemplate> ConfigureV8DOMStringMapTemplate(v8::Persistent<v8::FunctionTemplate> desc)
{
    desc->ReadOnlyPrototype();

    v8::Local<v8::Signature> defaultSignature;
    defaultSignature = V8DOMConfiguration::configureTemplate(desc, "DOMStringMap", v8::Persistent<v8::FunctionTemplate>(), V8DOMStringMap::internalFieldCount,
        0, 0,
        0, 0);
    UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
    
    desc->InstanceTemplate()->SetNamedPropertyHandler(V8DOMStringMap::namedPropertyGetter, V8DOMStringMap::namedPropertySetter, V8DOMStringMap::namedPropertyQuery, V8DOMStringMap::namedPropertyDeleter, V8DOMStringMap::namedPropertyEnumerator);

    // Custom toString template
    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    return desc;
}