bool PropertyCondition::isStillLive() const
{
    if (hasPrototype() && prototype() && !Heap::isMarked(prototype()))
        return false;
    
    if (hasRequiredValue()
        && requiredValue()
        && requiredValue().isCell()
        && !Heap::isMarked(requiredValue().asCell()))
        return false;
    
    return true;
}
Beispiel #2
0
int serverinit(const char *addr, const char *port, const char *proto)
{
    struct sockaddr_in socketaddr;
    int mastersock;
    int trueval = 1;
    struct hostent *hostinfo;
    unsigned long ip;

    socketaddr_init(&socketaddr);

    if (NULL == addr) {
        socketaddr.sin_addr.s_addr = INADDR_ANY;
    } else {
        if (scanaddr(addr, &ip, NULL) != 4) {
            LFATAL("Invalid address : %s provided", addr);
            return -1;
        }
        hostinfo = gethostbyaddr((char *) &ip, 4, AF_INET);
        if (NULL == hostinfo) {
            LFATAL("gethostbyaddr : %s failed", addr);
            return -1;
        }
        socketaddr.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list;
    }
    socketaddr_service(&socketaddr, port, proto);

    mastersock = socket(PF_INET, prototype(proto), resolveproto(proto));
    if (mastersock < 0) {
        LFATAL("couldn't create socket");
        return -1;
    }

    if (bind
        (mastersock, (struct sockaddr *) &socketaddr,
         sizeof(socketaddr)) < 0) {
        return -1;
    }

    setsockopt(mastersock, SOL_SOCKET, SO_REUSEADDR, &trueval,
               sizeof(trueval));

    if (prototype(proto) == SOCK_STREAM) {
        if (listen(mastersock, 5) < 0) {
            LFATAL("listen on port %d failed", socketaddr.sin_port);
            return -1;
        }
    }
    return mastersock;
}
bool DeckLinkController::startExportWithMode(BMDDisplayMode videoMode) {
    int bufferSize = getDisplayModeBufferSize(videoMode);
    
    if(bufferSize != 0) {
        vector<unsigned char> prototype(bufferSize);
        buffer.setup(prototype);
    } else{
        ofLogError("DeckLinkController") << "DeckLinkController needs to be updated to support that mode.";
        return false;
    }
    
    BMDVideoInputFlags videoOutputFlags;
    
    // Enable input video mode detection if the device supports it
    videoOutputFlags = bmdVideoOutputFlagDefault;
    
//    // Set capture callback
//    deckLinkInput->SetCallback(this);
    
    // Enable the video output mode
    if (deckLinkOutput->EnableVideoOutput(videoMode, videoOutputFlags) != S_OK) {
        ofLogError("DeckLinkController") << "This application was unable to select the chosen video mode. Perhaps, the selected device is currently in-use.";
        return false;
    }
    
//    // Start the output
//    if (deckLinkOutput->Ena() != S_OK) {
//        ofLogError("DeckLinkController") << "This application was unable to start the capture. Perhaps, the selected device is currently in-use.";
//        return false;
//    }
//    
//    currentlyCapturing = true;
    
    return true;
}
void JSGlobalObject::init(JSObject* thisValue)
{
    ASSERT(JSLock::currentThreadIsHoldingLock());

    structure()->disableSpecificFunctionTracking();

    d()->globalData = Heap::heap(this)->globalData();
    d()->globalScopeChain = ScopeChain(this, d()->globalData.get(), this, thisValue);

    JSGlobalObject::globalExec()->init(0, 0, d()->globalScopeChain.node(), CallFrame::noCaller(), 0, 0);

    if (JSGlobalObject*& headObject = head()) {
        d()->prev = headObject;
        d()->next = headObject->d()->next;
        headObject->d()->next->d()->prev = this;
        headObject->d()->next = this;
    } else
        headObject = d()->next = d()->prev = this;

    d()->debugger = 0;

    d()->profileGroup = 0;

    reset(prototype());
}
Beispiel #5
0
bool JSNamedNodeMap::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
    ASSERT_GC_OBJECT_INHERITS(this, &s_info);
    JSValue proto = prototype();
    if (proto.isObject() && static_cast<JSObject*>(asObject(proto))->hasProperty(exec, propertyName))
        return false;

    const HashEntry* entry = JSNamedNodeMapTable.entry(exec, propertyName);
    if (entry) {
        PropertySlot slot;
        slot.setCustom(this, entry->propertyGetter());
        descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
        return true;
    }
    bool ok;
    unsigned index = propertyName.toUInt32(ok);
    if (ok && index < static_cast<NamedNodeMap*>(impl())->length()) {
        PropertySlot slot;
        slot.setCustomIndex(this, index, indexGetter);
        descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
        return true;
    }
    if (canGetItemsForName(exec, static_cast<NamedNodeMap*>(impl()), propertyName)) {
        PropertySlot slot;
        slot.setCustom(this, nameGetter);
        descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
        return true;
    }
    return getStaticValueDescriptor<JSNamedNodeMap, Base>(exec, &JSNamedNodeMapTable, this, propertyName, descriptor);
}
JSObject*
RegisterPerfMeasurement(JSContext *cx, JSRawObject global)
{
    js::RootedObject prototype(cx);
    prototype = JS_InitClass(cx, global, NULL /* parent */,
                             &pm_class, pm_construct, 1,
                             pm_props, pm_fns, 0, 0);
    if (!prototype)
        return 0;

    js::RootedObject ctor(cx);
    ctor = JS_GetConstructor(cx, prototype);
    if (!ctor)
        return 0;

    for (const pm_const *c = pm_consts; c->name; c++) {
        if (!JS_DefineProperty(cx, ctor, c->name, INT_TO_JSVAL(c->value),
                               JS_PropertyStub, JS_StrictPropertyStub, PM_CATTRS))
            return 0;
    }

    if (!JS_FreezeObject(cx, prototype) ||
        !JS_FreezeObject(cx, ctor)) {
        return 0;
    }

    return prototype;
}
 void test_matches(const std::string& proto_key, const LLSD& possibles,
                   const char** begin, const char** end)
 {
     std::set<std::string> succeed(begin, end);
     LLSD prototype(possibles[proto_key]);
     for (LLSD::map_const_iterator pi(possibles.beginMap()), pend(possibles.endMap());
          pi != pend; ++pi)
     {
         std::string match(llsd_matches(prototype, pi->second));
         std::set<std::string>::const_iterator found = succeed.find(pi->first);
         if (found != succeed.end())
         {
             // This test is supposed to succeed. Comparing to the
             // empty string ensures that if the test fails, it will
             // display the string received so we can tell what failed.
             ensure_equals("match", match, "");
         }
         else
         {
             // This test is supposed to fail. If we get a false match,
             // the string 'match' will be empty, which doesn't tell us
             // much about which case went awry. So construct a more
             // detailed description string.
             ensure(proto_key + " shouldn't match " + pi->first, ! match.empty());
         }
     }
 }
Beispiel #8
0
JSObject*
RegisterPerfMeasurement(JSContext *cx, HandleObject globalArg)
{
    RootedObject global(cx, globalArg);
    RootedObject prototype(cx);
    prototype = JS_InitClass(cx, global, js::NullPtr() /* parent */,
                             &pm_class, pm_construct, 1,
                             pm_props, pm_fns, 0, 0);
    if (!prototype)
        return 0;

    RootedObject ctor(cx);
    ctor = JS_GetConstructor(cx, prototype);
    if (!ctor)
        return 0;

    for (const pm_const *c = pm_consts; c->name; c++) {
        if (!JS_DefineProperty(cx, ctor, c->name, c->value, PM_CATTRS,
                               JS_PropertyStub, JS_StrictPropertyStub))
            return 0;
    }

    if (!JS_FreezeObject(cx, prototype) ||
        !JS_FreezeObject(cx, ctor)) {
        return 0;
    }

    return prototype;
}
Beispiel #9
0
JSObject*
RegisterPerfMeasurement(JSContext* cx, HandleObject globalArg)
{
    static const uint8_t PM_CATTRS = JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT;

    RootedObject global(cx, globalArg);
    RootedObject prototype(cx);
    prototype = JS_InitClass(cx, global, nullptr /* parent */,
                             &pm_class, pm_construct, 1,
                             pm_props, pm_fns, 0, 0);
    if (!prototype)
        return 0;

    RootedObject ctor(cx);
    ctor = JS_GetConstructor(cx, prototype);
    if (!ctor)
        return 0;

    for (const pm_const* c = pm_consts; c->name; c++) {
        if (!JS_DefineProperty(cx, ctor, c->name, c->value, PM_CATTRS,
                               JS_STUBGETTER, JS_STUBSETTER))
            return 0;
    }

    if (!JS_FreezeObject(cx, prototype) ||
        !JS_FreezeObject(cx, ctor)) {
        return 0;
    }

    return prototype;
}
Beispiel #10
0
inline markOop markOopDesc::prototype_for_object(oop obj) {
#ifdef ASSERT
  markOop prototype_header = obj->klass()->prototype_header();
  assert(prototype_header == prototype() || prototype_header->has_bias_pattern(), "corrupt prototype header");
#endif
  return obj->klass()->prototype_header();
}
Beispiel #11
0
 void BodyManager::_ApiRegister(Luasel::CallHelper& helper)
 {
     Uint32 pluginId = this->_engine.GetCurrentPluginRegistering();
     if (!pluginId)
         throw std::runtime_error("Server.Body.Register: Could not determine currently running plugin, aborting registration.");
     std::string pluginName = this->_engine.GetWorld().GetPluginManager().GetPluginIdentifier(pluginId);
     Luasel::Ref prototype(this->_engine.GetInterpreter().GetState());
     std::string bodyName;
     try
     {
         prototype = helper.PopArg();
         if (!prototype.IsTable())
             throw std::runtime_error("Server.Body.Register[Positional]: Argument \"prototype\" must be of type table (instead of " + prototype.GetTypeName() + ")");
         if (!prototype["bodyName"].IsString())
             throw std::runtime_error("Server.Body.Register[Positional]: Field \"bodyName\" in prototype must exist and be of type string");
         if (!Common::FieldUtils::IsRegistrableType(bodyName = prototype["bodyName"].ToString()))
             throw std::runtime_error("Server.Body.Register[Positional]: Invalid Body name \"" + bodyName + "\"");
     }
     catch (std::exception& e)
     {
         Tools::error << "BodyManager::_ApiRegister: Failed to register new Body type from \"" << pluginName << "\": " << e.what() << " (plugin " << pluginId << ").\n";
         return;
     }
     if (this->_bodyTypes[pluginId].count(bodyName)) // remplacement
     {
         Tools::Delete(this->_bodyTypes[pluginId][bodyName]);
         Tools::log << "BodyManager::_ApiRegister: Replacing Body type \"" << bodyName << "\" with a newer type from \"" << pluginName << "\" (plugin " << pluginId << ").\n";
     }
     this->_bodyTypesVec.push_back(new BodyType(bodyName, pluginId, (Uint32)this->_bodyTypesVec.size() + 1, prototype));
     this->_bodyTypes[pluginId][bodyName] = this->_bodyTypesVec.back();
     Tools::debug << "BodyManager::_ApiRegister: New Body type \"" << bodyName << "\" registered from \"" << pluginName << "\" (plugin " << pluginId << ").\n";
 }
Beispiel #12
0
bool ObjectFatty::createBodyAtPosition( cocos2d::CCPoint position )
{
	// Player physical body
	b2dJson json;

	m_body = json.j2b2Body( physicsWorld(), prototype() );
	if( ! m_body || ! m_body->GetFixtureList() ) {
		std::cout << "Simple inventory item prototype messed up" << std::endl;
		return false;
	}
	m_body->SetUserData( this );
	m_body->SetTransform( b2Vec2(position.x/PTM_RATIO, position.y/PTM_RATIO), m_body->GetAngle() );
	setPosition(position);
	
	b2BodyDef bodyDef;
    bodyDef.type = b2_dynamicBody;
    bodyDef.fixedRotation = true;
	m_contactSensor = physicsWorld()->CreateBody(&bodyDef);
	m_contactSensor->SetTransform( b2Vec2(position.x/PTM_RATIO, position.y/PTM_RATIO), m_body->GetAngle() );
	
	m_bodies.push_back( m_contactSensor );
	m_bodies.push_back( m_body );

	
	b2RevoluteJointDef md;
	md.Initialize(m_body, m_contactSensor, m_body->GetPosition());
	md.maxMotorTorque = 200;
	md.enableMotor = true;
	m_motorJoint = (b2RevoluteJoint *)GameWorld::sharedGameWorld()->physicsWorld->CreateJoint(&md);
	
	saveOriginalProperties();
	return true;
}
void JSDOMWindowShell::setWindow(PassRefPtr<DOMWindow> domWindow)
{
    // Replacing JSDOMWindow via telling JSDOMWindowShell to use the same DOMWindow it already uses makes no sense,
    // so we'd better never try to.
    ASSERT(!window() || domWindow.get() != &window()->impl());
    // Explicitly protect the global object's prototype so it isn't collected
    // when we allocate the global object. (Once the global object is fully
    // constructed, it can mark its own prototype.)

    //VMOLAB
    //printf("JSDOMWindowShell::setWindow Called\n");
    
    VM& vm = JSDOMWindow::commonVM();
    Structure* prototypeStructure = JSDOMWindowPrototype::createStructure(vm, 0, jsNull());
    Strong<JSDOMWindowPrototype> prototype(vm, JSDOMWindowPrototype::create(vm, 0, prototypeStructure));

    Structure* structure = JSDOMWindow::createStructure(vm, 0, prototype.get());
    JSDOMWindow* jsDOMWindow = JSDOMWindow::create(vm, structure, domWindow, this);
    prototype->structure()->setGlobalObject(vm, jsDOMWindow);
    setWindow(vm, jsDOMWindow);
    ASSERT(jsDOMWindow->globalObject() == jsDOMWindow);
    ASSERT(prototype->globalObject() == jsDOMWindow);
#if ENABLE(VMOLAB)
    vm.setInParallelParseLoad(true);
#endif
}
Beispiel #14
0
Ref<Object>
Function::
make_prototype()
{
  Ref<Object> prototype(new Function_Prototype);
  return prototype;
}
bool DeckLinkController::startCaptureWithMode(BMDDisplayMode videoMode) {
	if(videoMode == bmdModeHD1080p30) {
		vector<unsigned char> prototype(1920 * 1080 * 2);
		buffer.setup(prototype);
	} else {
		ofLogError("DeckLinkController") << "DeckLinkController needs to be updated to support that mode.";
		return false;
	}
	
	BMDVideoInputFlags videoInputFlags;
	
	// Enable input video mode detection if the device supports it
	videoInputFlags = supportFormatDetection ? bmdVideoInputEnableFormatDetection : bmdVideoInputFlagDefault;
	
	// Set capture callback
	deckLinkInput->SetCallback(this);
	
	// Set the video input mode
	if (deckLinkInput->EnableVideoInput(videoMode, bmdFormat8BitYUV, videoInputFlags) != S_OK) {
		ofLogError("DeckLinkController") << "This application was unable to select the chosen video mode. Perhaps, the selected device is currently in-use.";
		return false;
	}
	
	// Start the capture
	if (deckLinkInput->StartStreams() != S_OK) {
		ofLogError("DeckLinkController") << "This application was unable to start the capture. Perhaps, the selected device is currently in-use.";
		return false;
	}
	
	currentlyCapturing = true;
	
	return true;
}
void JSDOMWindowShell::setWindow(RefPtr<DOMWindow>&& domWindow)
{
    // Replacing JSDOMWindow via telling JSDOMWindowShell to use the same DOMWindow it already uses makes no sense,
    // so we'd better never try to.
    ASSERT(!window() || domWindow.get() != &window()->wrapped());
    // Explicitly protect the global object's prototype so it isn't collected
    // when we allocate the global object. (Once the global object is fully
    // constructed, it can mark its own prototype.)
    
    VM& vm = JSDOMWindow::commonVM();
    Structure* prototypeStructure = JSDOMWindowPrototype::createStructure(vm, 0, jsNull());
    Strong<JSDOMWindowPrototype> prototype(vm, JSDOMWindowPrototype::create(vm, 0, prototypeStructure));

    Structure* structure = JSDOMWindow::createStructure(vm, 0, prototype.get());
    JSDOMWindow* jsDOMWindow = JSDOMWindow::create(vm, structure, *domWindow, this);
    prototype->structure()->setGlobalObject(vm, jsDOMWindow);

    Structure* windowPropertiesStructure = JSDOMWindowProperties::createStructure(vm, jsDOMWindow, JSEventTarget::prototype(vm, jsDOMWindow));
    JSDOMWindowProperties* windowProperties = JSDOMWindowProperties::create(windowPropertiesStructure, *jsDOMWindow);

    prototype->structure()->setPrototypeWithoutTransition(vm, windowProperties);
    setWindow(vm, jsDOMWindow);
    ASSERT(jsDOMWindow->globalObject() == jsDOMWindow);
    ASSERT(prototype->globalObject() == jsDOMWindow);
}
void PropertyCondition::validateReferences(const TrackedReferences& tracked) const
{
    if (hasPrototype())
        tracked.check(prototype());
    
    if (hasRequiredValue())
        tracked.check(requiredValue());
}
void AstNodeFTask::dump(ostream& str) {
    this->AstNode::dump(str);
    if (taskPublic()) str<<" [PUBLIC]";
    if (prototype()) str<<" [PROTOTYPE]";
    if (dpiImport()) str<<" [DPII]";
    if (dpiExport()) str<<" [DPIX]";
    if ((dpiImport() || dpiExport()) && cname()!=name()) str<<" [c="<<cname()<<"]";
}
Beispiel #19
0
// Should this header (including its age bits) be preserved in the
// case of a scavenge in which CMS is the old generation?
inline bool markOopDesc::must_be_preserved_with_bias_for_cms_scavenge(klassOop klass_of_obj_containing_mark) const {
  assert(UseBiasedLocking, "unexpected");
  // CMS scavenges preserve mark words in similar fashion to promotion failures; see above
  if (has_bias_pattern() ||
      klass_of_obj_containing_mark->klass_part()->prototype_header()->has_bias_pattern()) {
    return true;
  }
  return (this != prototype());
}
Beispiel #20
0
Value DOMCSSStyleDeclaration::tryGet(ExecState *exec, const Identifier &propertyName) const
{
#ifdef KJS_VERBOSE
    kdDebug(6070) << "DOMCSSStyleDeclaration::tryGet " << propertyName.qstring() << endl;
#endif
    const HashEntry *entry = Lookup::findEntry(&DOMCSSStyleDeclarationTable, propertyName);
    if(entry)
        switch(entry->value)
        {
            case CssText:
                return String(styleDecl.cssText());
            case Length:
                return Number(styleDecl.length());
            case ParentRule:
                return getDOMCSSRule(exec, styleDecl.parentRule());
            default:
                break;
        }

    // Look in the prototype (for functions) before assuming it's a name
    Object proto = Object::dynamicCast(prototype());
    if(proto.isValid() && proto.hasProperty(exec, propertyName))
        return proto.get(exec, propertyName);

    bool ok;
    long unsigned int u = propertyName.toULong(&ok);
    if(ok)
        return String(DOM::CSSStyleDeclaration(styleDecl).item(u));

    // pixelTop returns "CSS Top" as number value in unit pixels
    // posTop returns "CSS top" as number value in unit pixels _if_ its a
    // positioned element. if it is not a positioned element, return 0
    // from MSIE documentation ### IMPLEMENT THAT (Dirk)
    bool asNumber;
    QString p = cssPropertyName(propertyName, asNumber);

#ifdef KJS_VERBOSE
    kdDebug(6070) << "DOMCSSStyleDeclaration: converting to css property name: " << p << (asNumber ? "px" : "") << endl;
#endif

    if(asNumber)
    {
        DOM::CSSValue v = styleDecl.getPropertyCSSValue(p);
        if(!v.isNull() && v.cssValueType() == DOM::CSSValue::CSS_PRIMITIVE_VALUE)
            return Number(static_cast< DOM::CSSPrimitiveValue >(v).getFloatValue(DOM::CSSPrimitiveValue::CSS_PX));
    }

    DOM::DOMString str = const_cast< DOM::CSSStyleDeclaration & >(styleDecl).getPropertyValue(p);
    if(!str.isNull())
        return String(str);

    // see if we know this css property, return empty then
    if(DOM::getPropertyID(p.latin1(), p.length()))
        return String(DOM::DOMString(""));

    return DOMObject::tryGet(exec, propertyName);
}
Beispiel #21
0
JSObject* ScriptInterface::CreateCustomObject(const std::string & typeName)
{
	std::map < std::string, CustomType > ::iterator it = m_CustomObjectTypes.find(typeName);

	if (it == m_CustomObjectTypes.end())
		throw PSERROR_Scripting_TypeDoesNotExist();

	JS::RootedObject prototype(m->m_cx, it->second.m_Prototype.get());
	return JS_NewObject(m->m_cx, (*it).second.m_Class, prototype, JS::NullPtr());
}
Beispiel #22
0
// TODO: write buildInterpreter for local function node
ExprType ExprLocalFunctionNode::prep(ExprFuncNode* callerNode, bool scalarWanted, ExprVarEnvBuilder& envBuilder) const {
#if 0
    bool error = false;
    callerNode->checkCondition(callerNode->numChildren() == prototype()->numChildren(),
                               "Incorrect number of arguments to function call",
                               error);
    for (int i = 0; i < callerNode->numChildren(); i++) {
        // TODO: is this right?
        // bool compatible=ExprType::valuesCompatible(callerNode->child(i)->prep(false,env), prototype()->argType(i));
        if (!callerNode->checkArg(i, prototype()->argType(i), envBuilder)) error = true;
        // callerNode->child(i)->checkCondition(compatible,"Incorrect type for argument",error);
    }
    return error ? ExprType().Error() : prototype()->returnType();
#else
    bool error=false;
    callerNode->checkCondition(false,"Local functions are currently not supported.",error);
    return ExprType().Error();
#endif
}
Beispiel #23
0
bool ScriptInterface::EnumeratePropertyNamesWithPrefix(JS::HandleValue objVal, const char* prefix, std::vector<std::string>& out)
{
	JSAutoRequest rq(m->m_cx);
	
	if (!objVal.isObjectOrNull())
	{
		LOGERROR("EnumeratePropertyNamesWithPrefix expected object type!");
		return false;
	}
		
	if(objVal.isNull())
		return true; // reached the end of the prototype chain
	
	JS::RootedObject obj(m->m_cx, &objVal.toObject());
	JS::RootedObject it(m->m_cx, JS_NewPropertyIterator(m->m_cx, obj));
	if (!it)
		return false;

	while (true)
	{
		JS::RootedId idp(m->m_cx);
		JS::RootedValue val(m->m_cx);
		if (! JS_NextProperty(m->m_cx, it, idp.address()) || ! JS_IdToValue(m->m_cx, idp, &val))
			return false;

		if (val.isUndefined())
			break; // end of iteration
		if (!val.isString())
			continue; // ignore integer properties

		JS::RootedString name(m->m_cx, val.toString());
		size_t len = strlen(prefix)+1;
		std::vector<char> buf(len);
		size_t prefixLen = strlen(prefix) * sizeof(char);
		JS_EncodeStringToBuffer(m->m_cx, name, &buf[0], prefixLen);
		buf[len-1]= '\0';
		if(0 == strcmp(&buf[0], prefix))
		{
			size_t len;
			const jschar* chars = JS_GetStringCharsAndLength(m->m_cx, name, &len);
			out.push_back(std::string(chars, chars+len));
		}
	}

	// Recurse up the prototype chain
	JS::RootedObject prototype(m->m_cx);
	if (JS_GetPrototype(m->m_cx, obj, &prototype))
	{
		JS::RootedValue prototypeVal(m->m_cx, JS::ObjectOrNullValue(prototype));
		if (! EnumeratePropertyNamesWithPrefix(prototypeVal, prefix, out))
			return false;
	}

	return true;
}
Beispiel #24
0
void JSGlobalObject::init(JSObject* thisValue)
{
    ASSERT(vm().apiLock().currentThreadIsHoldingLock());

    setGlobalThis(vm(), thisValue);
    JSGlobalObject::globalExec()->init(0, 0, this, CallFrame::noCaller(), 0, 0);

    m_debugger = 0;

    reset(prototype());
}
Beispiel #25
0
	Ref<Object> Object::lookup(Frame * frame, Symbol * identifier) {
		if (Object::equal(identifier, identity(frame))) {
			return NULL;
		}
		
		Ref<Object> _prototype = prototype(frame);
		
		if (_prototype)
			return _prototype->lookup(frame, identifier);
		else
			return NULL;		
	}
Beispiel #26
0
bool
gjs_define_interface_class(JSContext              *context,
                           JS::HandleObject        in_object,
                           GIInterfaceInfo        *info,
                           GType                   gtype,
                           JS::MutableHandleObject constructor)
{
    Interface *priv;
    const char *constructor_name;
    const char *ns;
    JS::RootedObject prototype(context);

    ns = gjs_get_names_from_gtype_and_gi_info(gtype, (GIBaseInfo *) info,
                                              &constructor_name);

    if (!gjs_init_class_dynamic(context, in_object,
                                JS::NullPtr(),
                                ns,
                                constructor_name,
                                &gjs_interface_class,
                                gjs_interface_constructor, 0,
                                /* props of prototype */
                                &gjs_interface_proto_props[0],
                                /* funcs of prototype */
                                &gjs_interface_proto_funcs[0],
                                /* props of constructor, MyConstructor.myprop */
                                NULL,
                                /* funcs of constructor, MyConstructor.myfunc() */
                                NULL,
                                &prototype,
                                constructor)) {
        g_error("Can't init class %s", constructor_name);
    }

    GJS_INC_COUNTER(interface);
    priv = g_slice_new0(Interface);
    priv->info = info == NULL ? NULL : g_base_info_ref((GIBaseInfo *) info);
    priv->gtype = gtype;
    priv->vtable = (GTypeInterface *) g_type_default_interface_ref(gtype);
    JS_SetPrivate(prototype, priv);

    /* If we have no GIRepository information, then this interface was defined
     * from within GJS and therefore has no C static methods to be defined. */
    if (priv->info)
        gjs_define_static_methods(context, constructor, priv->gtype, priv->info);

    JS::RootedObject gtype_obj(context,
        gjs_gtype_create_gtype_wrapper(context, priv->gtype));
    JS_DefineProperty(context, constructor, "$gtype", gtype_obj, JSPROP_PERMANENT);

    return true;
}
void JSDOMWindowShell::setWindow(PassRefPtr<DOMWindow> domWindow)
{
    // Explicitly protect the global object's prototype so it isn't collected
    // when we allocate the global object. (Once the global object is fully
    // constructed, it can mark its own prototype.)
    Structure* prototypeStructure = JSDOMWindowPrototype::createStructure(*JSDOMWindow::commonJSGlobalData(), jsNull());
    Strong<JSDOMWindowPrototype> prototype(*JSDOMWindow::commonJSGlobalData(), new JSDOMWindowPrototype(*JSDOMWindow::commonJSGlobalData(), 0, prototypeStructure));

    Structure* structure = JSDOMWindow::createStructure(*JSDOMWindow::commonJSGlobalData(), prototype.get());
    JSDOMWindow* jsDOMWindow = new (JSDOMWindow::commonJSGlobalData()) JSDOMWindow(*JSDOMWindow::commonJSGlobalData(), structure, domWindow, this);
    prototype->putAnonymousValue(*JSDOMWindow::commonJSGlobalData(), 0, jsDOMWindow);
    setWindow(*JSDOMWindow::commonJSGlobalData(), jsDOMWindow);
}
Beispiel #28
0
void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
{
    m_structureID->propertyMap().getEnumerablePropertyNames(propertyNames);

    // Add properties from the static hashtables of properties
    for (const ClassInfo* info = classInfo(); info; info = info->parentClass) {
        const HashTable* table = info->propHashTable(exec);
        if (!table)
            continue;
        table->initializeIfNeeded(exec);
        ASSERT(table->table);
        int hashSizeMask = table->hashSizeMask;
        const HashEntry* entry = table->table;
        for (int i = 0; i <= hashSizeMask; ++i, ++entry) {
            if (entry->key && !(entry->attributes & DontEnum))
                propertyNames.add(entry->key);
        }
    }

    if (prototype()->isObject())
        static_cast<JSObject*>(prototype())->getPropertyNames(exec, propertyNames);
}
Beispiel #29
0
AudioType* makeTupletType(const vector<Type>& vt)
{
    TupletType  prototype(vt);
    Tree        code = codeAudioType(&prototype);

    AudioType*  t;
    if (gGlobal->gMemoizedTypes->get(code, t)) {
        return t;
    } else {
        gGlobal->gAllocationCount++;
        t = new TupletType(vt);
        gGlobal->gMemoizedTypes->set(code, t);
        t->setCode(code);
        return t;
    }
}
Beispiel #30
0
AudioType* makeTupletType(const vector<Type>& vt, int n, int v, int c, int vec, int b, const interval& i)
{
    TupletType  prototype(vt,n,v,c,vec,b,i);
    Tree        code = codeAudioType(&prototype);

    AudioType*  t;
    if (gGlobal->gMemoizedTypes->get(code, t)) {
        return t;
    } else {
        gGlobal->gAllocationCount++;
        t = new TupletType(vt,n,v,c,vec,b,i);
        gGlobal->gMemoizedTypes->set(code, t);
        t->setCode(code);
        return t;
    }
}