ViewData ViewSettings::getViewData() { return self().data; }
void ShortcutSelf::removeUpdateHandler(ShortcutHandler handler) { self()->handlers.removeOne(handler); }
void Usd_PrimData::_ComposeAndCacheFlags(Usd_PrimDataConstPtr parent, bool isMasterPrim) { // We do not have to clear _flags here since in the pseudo root or instance // master case the values never change, and in the ordinary prim case we set // every flag. // Special-case the root (the only prim which has no parent) and // instancing masters. if (ARCH_UNLIKELY(!parent || isMasterPrim)) { _flags[Usd_PrimActiveFlag] = true; _flags[Usd_PrimLoadedFlag] = true; _flags[Usd_PrimModelFlag] = true; _flags[Usd_PrimGroupFlag] = true; _flags[Usd_PrimDefinedFlag] = true; _flags[Usd_PrimMasterFlag] = isMasterPrim; } else { // Compose and cache 'active'. UsdPrim self(Usd_PrimDataIPtr(this), SdfPath()); bool active = true; self.GetMetadata(SdfFieldKeys->Active, &active); _flags[Usd_PrimActiveFlag] = active; // Cache whether or not this prim has a payload. bool hasPayload = _primIndex->HasPayload(); _flags[Usd_PrimHasPayloadFlag] = hasPayload; // An active prim is loaded if it's loadable and in the load set, or // it's not loadable and its parent is loaded. _flags[Usd_PrimLoadedFlag] = active && (hasPayload ? _stage->_GetPcpCache()->IsPayloadIncluded(_primIndex->GetPath()) : parent->IsLoaded()); // According to Model hierarchy rules, only Model Groups may have Model // children (groups or otherwise). So if our parent is not a Model // Group, then this prim cannot be a model (or a model group). // Otherwise we look up the kind metadata and consult the kind registry. bool isGroup = false, isModel = false; if (parent->IsGroup()) { static TfToken kindToken("kind"); TfToken kind; self.GetMetadata(kindToken, &kind); // Use the kind registry to determine model/groupness. if (!kind.IsEmpty()) { isGroup = KindRegistry::IsA(kind, KindTokens->group); isModel = isGroup || KindRegistry::IsA(kind, KindTokens->model); } } _flags[Usd_PrimGroupFlag] = isGroup; _flags[Usd_PrimModelFlag] = isModel; // Get specifier. SdfSpecifier specifier = GetSpecifier(); // This prim is abstract if its parent is or if it's a class. _flags[Usd_PrimAbstractFlag] = parent->IsAbstract() || specifier == SdfSpecifierClass; // Cache whether or not this prim has an authored defining specifier. const bool isDefiningSpec = SdfIsDefiningSpecifier(specifier); _flags[Usd_PrimHasDefiningSpecifierFlag] = isDefiningSpec; // This prim is defined if its parent is and its specifier is defining. _flags[Usd_PrimDefinedFlag] = isDefiningSpec && parent->IsDefined(); // The presence of clips that may affect attributes on this prim // is computed and set in UsdStage. Default to false. _flags[Usd_PrimClipsFlag] = false; // These flags indicate whether this prim is an instance or an // instance master. _flags[Usd_PrimInstanceFlag] = active && _primIndex->IsInstanceable(); _flags[Usd_PrimMasterFlag] = parent->IsInMaster(); } }
/*! \brief Create stereo demodulator object. * * Use make_stereo_demod() instead. */ stereo_demod::stereo_demod(float input_rate, float audio_rate, bool stereo) : gr::hier_block2("stereo_demod", gr::io_signature::make (MIN_IN, MAX_IN, sizeof (float)), gr::io_signature::make (MIN_OUT, MAX_OUT, sizeof (float))), d_input_rate(input_rate), d_audio_rate(audio_rate), d_stereo(stereo) { lpf0 = make_lpf_ff(d_input_rate, 17e3, 2e3); // FIXME audio_rr0 = make_resampler_ff(d_audio_rate/d_input_rate); if (d_stereo) { lpf1 = make_lpf_ff(d_input_rate, 17e3, 2e3); // FIXME audio_rr1 = make_resampler_ff(d_audio_rate/d_input_rate); d_tone_taps = gr::filter::firdes::complex_band_pass( 1.0, // gain, d_input_rate, // sampling_freq 18800., // low_cutoff_freq 19200., // high_cutoff_freq 300.); // transition_width tone = gr::filter::fir_filter_fcc::make(1, d_tone_taps); pll = gr::analog::pll_refout_cc::make(0.001, // loop_bw FIXME 2*M_PI * 19200 / input_rate, // max_freq 2*M_PI * 18800 / input_rate); // min_freq subtone = gr::blocks::multiply_cc::make(); lo = gr::blocks::complex_to_imag::make(); #ifdef STEREO_DEMOD_PARANOIC d_pll_taps = gr::filter::firdes::band_pass( 1.0, // gain, d_input_rate, // sampling_freq 37600., // low_cutoff_freq 38400., // high_cutoff_freq 400.); // transition_width lo2 = gr::filter::fir_filter_fff::make(1, d_pll_taps); #endif mixer = gr::blocks::multiply_ff::make(); cdp = gr::blocks::multiply_const_ff::make( 2.); // FIXME cdm = gr::blocks::multiply_const_ff::make(-2.); // FIXME add0 = gr::blocks::add_ff::make(); add1 = gr::blocks::add_ff::make(); /* connect block */ connect(self(), 0, tone, 0); connect(tone, 0, pll, 0); connect(pll, 0, subtone, 0); connect(pll, 0, subtone, 1); connect(subtone, 0, lo, 0); #ifdef STEREO_DEMOD_PARANOIC connect(lo, 0, lo2, 0); connect(lo2, 0, mixer, 0); #else connect(lo, 0, mixer, 0); #endif connect(self(), 0, mixer, 1); connect(self(), 0, lpf0, 0); connect(mixer, 0, lpf1, 0); connect(lpf0, 0, audio_rr0, 0); // sum connect(lpf1, 0, audio_rr1, 0); connect(audio_rr1, 0, cdp, 0); // +delta connect(audio_rr1, 0, cdm, 0); // -delta connect(audio_rr0, 0, add0, 0); connect(cdp, 0, add0, 1); connect(add0, 0, self(), 0); // left = sum + delta connect(audio_rr0, 0, add1, 0); connect(cdm, 0, add1, 1); connect(add1, 0, self(), 1); // right = sum + delta } else // if (!d_stereo) { /* connect block */ connect(self(), 0, lpf0, 0); connect(lpf0, 0, audio_rr0, 0); connect(audio_rr0, 0, self(), 0); connect(audio_rr0, 0, self(), 1); } }
v8::Local<v8::Object> object() { return _objMap[self()]; }
int32_t OMR::X86::I386::CodeGenerator::getMaximumNumberOfGPRsAllowedAcrossEdge(TR::Node *node) { // TODO: Currently, lookupEvaluator doesn't deal properly with different // glRegDeps on different cases of a lookupswitch. // static const char *enableLookupswitch = feGetEnv("TR_enableGRAAcrossLookupSwitch"); if (!enableLookupswitch && node->getOpCode().getOpCodeValue()==TR::lookup) return 1; if (node->getOpCode().getOpCodeValue()==TR::table) { // 1 for jump table base reg, which is not apparent in the trees // 1 for ebp when it is needed for the VMThread // return self()->getNumberOfGlobalGPRs() - 2; } if (node->getOpCode().isIf()) { // we run out of all but one/two registers in these cases // if (node->getFirstChild()->getType().isInt64()) { if (node->getOpCode().isBranch()) { TR::Node *firstChild = node->getFirstChild(); TR::Node *secondChild = node->getSecondChild(); int extraRegsAvailable = 0; if(firstChild->getOpCodeValue() == TR::d2l || secondChild->getOpCodeValue() == TR::d2l) { return 1; } if ((firstChild->getReferenceCount() == 1 && firstChild->getOpCode().isLoadVarDirect()) || (secondChild->getReferenceCount() == 1 && firstChild->getOpCode().isLoadVarDirect())) extraRegsAvailable += 0; // TODO: put it back to 2 when looking at GRA, GRA pushes allocation of 8 registers return 2 + extraRegsAvailable; } else { // TR_lcmpXX opcodes take up 5 regs // return 1; } } // we run out of all but one register in these cases....last time I tried.... // if (node->getFirstChild()->getOpCodeValue() == TR::instanceof) { if (!TR::TreeEvaluator::instanceOfOrCheckCastNeedSuperTest(node->getFirstChild(), self()) && TR::TreeEvaluator::instanceOfOrCheckCastNeedEqualityTest(node->getFirstChild(), self())) return self()->getNumberOfGlobalGPRs() - 4; // ebp plus three other regs if vft masking is enabled else return 0; } // All other conditional branches, we usually need one reg for the compare and possibly one for the vmthread //return getNumberOfGlobalGPRs() - 1 - (node->isVMThreadRequired()? 1 : 0); // vmThread required might be set on a node after GRA has ran return self()->getNumberOfGlobalGPRs() - 2; } return INT_MAX; }
void context::run() { conn_->async_prepare_request(this,boost::bind(&context::on_request_ready,self(),_1)); }
void ViewSettings::resetViewTop() { self().data.rotation[0] = -0.5; self().data.rotation[1] = 0.5; }
void ViewSettings::resetViewSide() { self().data.rotation[0] = 0.0; self().data.rotation[1] = 0.25; }
void ViewSettings::toggleSphereRendering() { self().data.sphere = ! self().data.sphere; }
void ViewSettings::resetViewFront() { self().data.rotation[0] = 0.0; self().data.rotation[1] = 0.5; }
bool ViewSettings::sphereRendering() { return self().data.sphere; }
void ViewSettings::toggleProjection() { self().data.projection = !self().data.projection; }
bool ViewSettings::projection() { return self().data.projection; }
ShadowProg(void) : Program(make()) , projection_matrix(self(), "ProjectionMatrix") , camera_matrix(self(), "CameraMatrix") , fade(self(), "Fade") { }
Handler< ::donut::Object> AngelElementTarget::createDonutObject(Handler< ::donut::Heap> const& heap) { return Handler< ::donut::Object>( world()->patron()->angelElementTargetProvider()->newInstance(heap, self()) ); }
TR_GlobalRegisterNumber OMR::X86::I386::CodeGenerator::pickRegister( TR_RegisterCandidate *rc, TR::Block **allBlocks, TR_BitVector &availableRegisters, TR_GlobalRegisterNumber &highRegisterNumber, TR_LinkHead<TR_RegisterCandidate> *candidates) { if (!self()->comp()->getOption(TR_DisableRegisterPressureSimulation)) { if (self()->comp()->getOption(TR_AssignEveryGlobalRegister)) { // This is not really necessary except for testing purposes. // Conceptually, the common pickRegister code should be free to make // its choices based only on performance considerations, and shouldn't // need to worry about correctness. When SupportsVMThreadGRA is not set, // it is incorrect to choose the VMThread register. Therefore we mask // it out here. // // Having said that, the common code *does* already mask out the // VMThread register for convenience, so under normal circumstances, // this code is redundant. It is only necessary when // TR_AssignEveryGlobalRegister is set. // availableRegisters -= *self()->getGlobalRegisters(TR_vmThreadSpill, self()->comp()->getMethodSymbol()->getLinkageConvention()); } return OMR::CodeGenerator::pickRegister(rc, allBlocks, availableRegisters, highRegisterNumber, candidates); } if ((rc->getSymbol()->getDataType() == TR::Float) || (rc->getSymbol()->getDataType() == TR::Double)) { if (availableRegisters.get(7)) return 7; if (availableRegisters.get(8)) return 8; if (availableRegisters.get(9)) return 9; if (availableRegisters.get(10)) return 10; if (availableRegisters.get(11)) return 11; if (availableRegisters.get(12)) return 12; return -1; } if (!_assignedGlobalRegisters) _assignedGlobalRegisters = new (self()->trStackMemory()) TR_BitVector(self()->comp()->getSymRefCount(), self()->trMemory(), stackAlloc, growable); if (availableRegisters.get(5)) return 5; // esi if (availableRegisters.get(2)) return 2; // ecx static char *dontUseEBXasGPR = feGetEnv("dontUseEBXasGPR"); if (!dontUseEBXasGPR && availableRegisters.get(1)) return 1; #ifdef J9_PROJECT_SPECIFIC TR::RecognizedMethod rm = self()->comp()->getMethodSymbol()->getRecognizedMethod(); if (rm == TR::java_util_HashtableHashEnumerator_hasMoreElements) { if (availableRegisters.get(4)) return 4; // edi if (availableRegisters.get(3)) return 3; // edx } else #endif { int32_t numExtraRegs = 0; int32_t maxRegisterPressure = 0; vcount_t visitCount = self()->comp()->incVisitCount(); TR_BitVectorIterator bvi(rc->getBlocksLiveOnEntry()); int32_t maxFrequency = 0; while (bvi.hasMoreElements()) { int32_t liveBlockNum = bvi.getNextElement(); TR::Block *block = allBlocks[liveBlockNum]; if (block->getFrequency() > maxFrequency) maxFrequency = block->getFrequency(); } int32_t maxStaticFrequency = 0; if (maxFrequency == 0) { bvi.setBitVector(rc->getBlocksLiveOnEntry()); while (bvi.hasMoreElements()) { int32_t liveBlockNum = bvi.getNextElement(); TR::Block *block = allBlocks[liveBlockNum]; TR_BlockStructure *blockStructure = block->getStructureOf(); int32_t blockWeight = 1; if (blockStructure && !block->isCold()) { blockStructure->calculateFrequencyOfExecution(&blockWeight); if (blockWeight > maxStaticFrequency) maxStaticFrequency = blockWeight; } } } bool assigningEDX = false; if (!availableRegisters.get(4) && availableRegisters.get(3)) assigningEDX = true; bool vmThreadUsed = false; bvi.setBitVector(rc->getBlocksLiveOnEntry()); while (bvi.hasMoreElements()) { int32_t liveBlockNum = bvi.getNextElement(); TR::Block *block = allBlocks[liveBlockNum]; _assignedGlobalRegisters->empty(); int32_t numAssignedGlobalRegs = 0; TR_RegisterCandidate *prev; for (prev = candidates->getFirst(); prev; prev = prev->getNext()) { bool gprCandidate = true; if ((prev->getSymbol()->getDataType() == TR::Float) || (prev->getSymbol()->getDataType() == TR::Double)) gprCandidate = false; if (gprCandidate && prev->getBlocksLiveOnEntry().get(liveBlockNum)) { numAssignedGlobalRegs++; if (prev->getDataType() == TR::Int64) numAssignedGlobalRegs++; _assignedGlobalRegisters->set(prev->getSymbolReference()->getReferenceNumber()); } } maxRegisterPressure = self()->estimateRegisterPressure(block, visitCount, maxStaticFrequency, maxFrequency, vmThreadUsed, numAssignedGlobalRegs, _assignedGlobalRegisters, rc->getSymbolReference(), assigningEDX); if (maxRegisterPressure >= self()->getMaximumNumbersOfAssignableGPRs()) break; } // Determine if we can spare any extra registers for this candidate without spilling // in any hot (critical) blocks // if (maxRegisterPressure < self()->getMaximumNumbersOfAssignableGPRs()) numExtraRegs = self()->getMaximumNumbersOfAssignableGPRs() - maxRegisterPressure; //dumpOptDetails("For global register candidate %d reg pressure is %d maxRegs %d numExtraRegs %d\n", rc->getSymbolReference()->getReferenceNumber(), maxRegisterPressure, comp()->cg()->getMaximumNumbersOfAssignableGPRs(), numExtraRegs); if (numExtraRegs > 0) { if (availableRegisters.get(4)) return 4; // edi if (availableRegisters.get(3)) return 3; // edx } } return -1; // -1 ==> don't use a global register }
Handler<AngelElementTarget> AngelElementTarget::toElementTarget() { return self(); }
OMR::X86::I386::CodeGenerator::CodeGenerator() : OMR::X86::CodeGenerator() { // Common X86 initialization // self()->initialize( self()->comp() ); self()->setUsesRegisterPairsForLongs(); if (debug("supportsArrayTranslateAndTest")) self()->setSupportsArrayTranslateAndTest(); if (debug("supportsArrayCmp")) self()->setSupportsArrayCmp(); self()->setSupportsDoubleWordCAS(); self()->setSupportsDoubleWordSet(); if (TR::Compiler->target.isWindows()) { if (self()->comp()->getOption(TR_DisableTraps)) { _numberBytesReadInaccessible = 0; _numberBytesWriteInaccessible = 0; } else { _numberBytesReadInaccessible = 4096; _numberBytesWriteInaccessible = 4096; self()->setHasResumableTrapHandler(); self()->setEnableImplicitDivideCheck(); } self()->setSupportsDivCheck(); self()->setJNILinkageCalleeCleanup(); self()->setRealVMThreadRegister(self()->machine()->getRealRegister(TR::RealRegister::ebp)); } else if (TR::Compiler->target.isLinux()) { if (self()->comp()->getOption(TR_DisableTraps)) { _numberBytesReadInaccessible = 0; _numberBytesWriteInaccessible = 0; } else { _numberBytesReadInaccessible = 4096; _numberBytesWriteInaccessible = 4096; self()->setHasResumableTrapHandler(); self()->setEnableImplicitDivideCheck(); } self()->setRealVMThreadRegister(self()->machine()->getRealRegister(TR::RealRegister::ebp)); self()->setSupportsDivCheck(); } else { TR_ASSERT(0, "unknown target"); } self()->setSupportsInlinedAtomicLongVolatiles(); static char *dontConsiderAllAutosForGRA = feGetEnv("TR_dontConsiderAllAutosForGRA"); if (!dontConsiderAllAutosForGRA) self()->setConsiderAllAutosAsTacticalGlobalRegisterCandidates(); }
bool QDBusMarshaller::appendRegisteredType(const QVariant &arg) { ref.ref(); // reference up QDBusArgument self(QDBusArgumentPrivate::create(this)); return QDBusMetaType::marshall(self, arg.userType(), arg.constData()); }
Context::~Context() { if (self() == this) set_current(nullptr); }
void SocketAdapter::onSocketConnect() { Connect.emit(self()); }
JSObject * GlobalObject::initFunctionAndObjectClasses(JSContext *cx) { Rooted<GlobalObject*> self(cx, this); JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment); JS_ASSERT(isNative()); /* * Calling a function from a cleared global triggers this (yeah, I know). * Uncomment this once bug 470510 is fixed (if that bug doesn't remove * isCleared entirely). */ // JS_ASSERT(!isCleared()); /* If cx has no global object, make this the global object. */ if (!cx->globalObject) JS_SetGlobalObject(cx, self); RootedObject objectProto(cx); /* * Create |Object.prototype| first, mirroring CreateBlankProto but for the * prototype of the created object. */ objectProto = NewObjectWithGivenProto(cx, &ObjectClass, NULL, self); if (!objectProto || !objectProto->setSingletonType(cx)) return NULL; /* * The default 'new' type of Object.prototype is required by type inference * to have unknown properties, to simplify handling of e.g. heterogenous * objects in JSON and script literals. */ if (!objectProto->setNewTypeUnknown(cx)) return NULL; /* Create |Function.prototype| next so we can create other functions. */ RootedFunction functionProto(cx); { JSObject *functionProto_ = NewObjectWithGivenProto(cx, &FunctionClass, objectProto, self); if (!functionProto_) return NULL; functionProto = functionProto_->toFunction(); /* * Bizarrely, |Function.prototype| must be an interpreted function, so * give it the guts to be one. */ JSObject *proto = js_NewFunction(cx, functionProto, NULL, 0, JSFUN_INTERPRETED, self, NULL); if (!proto) return NULL; JS_ASSERT(proto == functionProto); functionProto->flags |= JSFUN_PROTOTYPE; const char *rawSource = "() {\n}"; size_t sourceLen = strlen(rawSource); jschar *source = InflateString(cx, rawSource, &sourceLen); if (!source) return NULL; ScriptSource *ss = ScriptSource::createFromSource(cx, source, sourceLen); cx->free_(source); if (!ss) return NULL; Rooted<JSScript*> script(cx, JSScript::Create(cx, /* enclosingScope = */ NullPtr(), /* savedCallerFun = */ false, /* principals = */ NULL, /* originPrincipals = */ NULL, /* compileAndGo = */ false, /* noScriptRval = */ true, JSVERSION_DEFAULT, /* staticLevel = */ 0, ss, 0, ss->length())); ss->attachToRuntime(cx->runtime); if (!script || !JSScript::fullyInitTrivial(cx, script)) return NULL; functionProto->initScript(script); functionProto->getType(cx)->interpretedFunction = functionProto; script->setFunction(functionProto); if (!functionProto->setSingletonType(cx)) return NULL; /* * The default 'new' type of Function.prototype is required by type * inference to have unknown properties, to simplify handling of e.g. * CloneFunctionObject. */ if (!functionProto->setNewTypeUnknown(cx)) return NULL; } /* Create the Object function now that we have a [[Prototype]] for it. */ RootedFunction objectCtor(cx); { JSObject *ctor = NewObjectWithGivenProto(cx, &FunctionClass, functionProto, self); if (!ctor) return NULL; objectCtor = js_NewFunction(cx, ctor, js_Object, 1, JSFUN_CONSTRUCTOR, self, CLASS_NAME(cx, Object)); if (!objectCtor) return NULL; } /* * Install |Object| and |Object.prototype| for the benefit of subsequent * code that looks for them. */ self->setObjectClassDetails(objectCtor, objectProto); /* Create |Function| so it and |Function.prototype| can be installed. */ RootedFunction functionCtor(cx); { // Note that ctor is rooted purely for the JS_ASSERT at the end RootedObject ctor(cx, NewObjectWithGivenProto(cx, &FunctionClass, functionProto, self)); if (!ctor) return NULL; functionCtor = js_NewFunction(cx, ctor, Function, 1, JSFUN_CONSTRUCTOR, self, CLASS_NAME(cx, Function)); if (!functionCtor) return NULL; JS_ASSERT(ctor == functionCtor); } /* * Install |Function| and |Function.prototype| so that we can freely create * functions and objects without special effort. */ self->setFunctionClassDetails(functionCtor, functionProto); /* * The hard part's done: now go back and add all the properties these * primordial values have. */ if (!LinkConstructorAndPrototype(cx, objectCtor, objectProto) || !DefinePropertiesAndBrand(cx, objectProto, NULL, object_methods)) { return NULL; } /* * Add an Object.prototype.__proto__ accessor property to implement that * extension (if it's actually enabled). Cache the getter for this * function so that cross-compartment [[Prototype]]-getting is implemented * in one place. */ Rooted<JSFunction*> getter(cx, js_NewFunction(cx, NULL, ProtoGetter, 0, 0, self, NULL)); if (!getter) return NULL; #if JS_HAS_OBJ_PROTO_PROP Rooted<JSFunction*> setter(cx, js_NewFunction(cx, NULL, ProtoSetter, 0, 0, self, NULL)); if (!setter) return NULL; if (!objectProto->defineProperty(cx, cx->runtime->atomState.protoAtom, UndefinedValue(), JS_DATA_TO_FUNC_PTR(PropertyOp, getter.get()), JS_DATA_TO_FUNC_PTR(StrictPropertyOp, setter.get()), JSPROP_GETTER | JSPROP_SETTER | JSPROP_SHARED)) { return NULL; } #endif /* JS_HAS_OBJ_PROTO_PROP */ self->setProtoGetter(getter); if (!DefinePropertiesAndBrand(cx, objectCtor, NULL, object_static_methods) || !LinkConstructorAndPrototype(cx, functionCtor, functionProto) || !DefinePropertiesAndBrand(cx, functionProto, NULL, function_methods) || !DefinePropertiesAndBrand(cx, functionCtor, NULL, NULL)) { return NULL; } /* Add the global Function and Object properties now. */ jsid objectId = NameToId(CLASS_NAME(cx, Object)); if (!self->addDataProperty(cx, objectId, JSProto_Object + JSProto_LIMIT * 2, 0)) return NULL; jsid functionId = NameToId(CLASS_NAME(cx, Function)); if (!self->addDataProperty(cx, functionId, JSProto_Function + JSProto_LIMIT * 2, 0)) return NULL; /* Heavy lifting done, but lingering tasks remain. */ /* ES5 15.1.2.1. */ RootedId id(cx, NameToId(cx->runtime->atomState.evalAtom)); JSObject *evalobj = js_DefineFunction(cx, self, id, IndirectEval, 1, JSFUN_STUB_GSOPS); if (!evalobj) return NULL; self->setOriginalEval(evalobj); /* ES5 13.2.3: Construct the unique [[ThrowTypeError]] function object. */ RootedFunction throwTypeError(cx); throwTypeError = js_NewFunction(cx, NULL, ThrowTypeError, 0, 0, self, NULL); if (!throwTypeError) return NULL; if (!throwTypeError->preventExtensions(cx)) return NULL; self->setThrowTypeError(throwTypeError); /* * The global object should have |Object.prototype| as its [[Prototype]]. * Eventually we'd like to have standard classes be there from the start, * and thus we would know we were always setting what had previously been a * null [[Prototype]], but right now some code assumes it can set the * [[Prototype]] before standard classes have been initialized. For now, * only set the [[Prototype]] if it hasn't already been set. */ if (self->shouldSplicePrototype(cx) && !self->splicePrototype(cx, objectProto)) return NULL; /* * Notify any debuggers about the creation of the script for * |Function.prototype| -- after all initialization, for simplicity. */ js_CallNewScriptHook(cx, functionProto->script(), functionProto); return functionProto; }
void SocketAdapter::onSocketRecv(const MutableBuffer& buffer, const Address& peerAddress) { Recv.emit(self(), buffer, peerAddress); }
void ShortcutSelf::addUpdateHandler(ShortcutHandler handler) { if (!self()->handlers.contains(handler)) self()->handlers.append(handler); }
void SocketAdapter::onSocketError(const scy::Error& error) //const Error& error { Error.emit(self(), error); }
QJSValue Image::setScaledClipRect(int x, int y, int w, int h) { m_reader->setClipRect(QRect(x, y, w, h)); return self(); }
void SocketAdapter::onSocketClose() { Close.emit(self()); }
// static void KDialogQueue::queueDialog(QDialog *dialog) { KDialogQueue *_this = self(); _this->d->queue.append(dialog); QTimer::singleShot(0, _this, SLOT(slotShowQueuedDialog())); }
JSObject * GlobalObject::initFunctionAndObjectClasses(JSContext *cx) { Rooted<GlobalObject*> self(cx, this); JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment); JS_ASSERT(isNative()); /* * Calling a function from a cleared global triggers this (yeah, I know). * Uncomment this once bug 470510 is fixed (if that bug doesn't remove * isCleared entirely). */ // JS_ASSERT(!isCleared()); /* If cx has no global object, make this the global object. */ if (!cx->globalObject) JS_SetGlobalObject(cx, self); RootedObject objectProto(cx); /* * Create |Object.prototype| first, mirroring CreateBlankProto but for the * prototype of the created object. */ objectProto = NewObjectWithGivenProto(cx, &ObjectClass, NULL, self); if (!objectProto || !objectProto->setSingletonType(cx)) return NULL; /* * The default 'new' type of Object.prototype is required by type inference * to have unknown properties, to simplify handling of e.g. heterogenous * objects in JSON and script literals. */ if (!objectProto->setNewTypeUnknown(cx)) return NULL; /* Create |Function.prototype| next so we can create other functions. */ RootedFunction functionProto(cx); { JSObject *functionProto_ = NewObjectWithGivenProto(cx, &FunctionClass, objectProto, self); if (!functionProto_) return NULL; functionProto = functionProto_->toFunction(); /* * Bizarrely, |Function.prototype| must be an interpreted function, so * give it the guts to be one. */ JSObject *proto = js_NewFunction(cx, functionProto, NULL, 0, JSFUN_INTERPRETED, self, NULL); if (!proto) return NULL; JS_ASSERT(proto == functionProto); functionProto->flags |= JSFUN_PROTOTYPE; JSScript *script = JSScript::NewScript(cx, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, JSVERSION_DEFAULT); if (!script) return NULL; script->noScriptRval = true; script->code[0] = JSOP_STOP; script->code[1] = SRC_NULL; functionProto->initScript(script); functionProto->getType(cx)->interpretedFunction = functionProto; script->setFunction(functionProto); if (!functionProto->setSingletonType(cx)) return NULL; /* * The default 'new' type of Function.prototype is required by type * inference to have unknown properties, to simplify handling of e.g. * CloneFunctionObject. */ if (!functionProto->setNewTypeUnknown(cx)) return NULL; } /* Create the Object function now that we have a [[Prototype]] for it. */ RootedFunction objectCtor(cx); { JSObject *ctor = NewObjectWithGivenProto(cx, &FunctionClass, functionProto, self); if (!ctor) return NULL; objectCtor = js_NewFunction(cx, ctor, js_Object, 1, JSFUN_CONSTRUCTOR, self, CLASS_NAME(cx, Object)); if (!objectCtor) return NULL; } /* * Install |Object| and |Object.prototype| for the benefit of subsequent * code that looks for them. */ self->setObjectClassDetails(objectCtor, objectProto); /* Create |Function| so it and |Function.prototype| can be installed. */ RootedFunction functionCtor(cx); { JSObject *ctor = NewObjectWithGivenProto(cx, &FunctionClass, functionProto, self); if (!ctor) return NULL; functionCtor = js_NewFunction(cx, ctor, Function, 1, JSFUN_CONSTRUCTOR, self, CLASS_NAME(cx, Function)); if (!functionCtor) return NULL; JS_ASSERT(ctor == functionCtor); } /* * Install |Function| and |Function.prototype| so that we can freely create * functions and objects without special effort. */ self->setFunctionClassDetails(functionCtor, functionProto); /* * The hard part's done: now go back and add all the properties these * primordial values have. */ if (!LinkConstructorAndPrototype(cx, objectCtor, objectProto) || !DefinePropertiesAndBrand(cx, objectProto, object_props, object_methods) || !DefinePropertiesAndBrand(cx, objectCtor, NULL, object_static_methods) || !LinkConstructorAndPrototype(cx, functionCtor, functionProto) || !DefinePropertiesAndBrand(cx, functionProto, NULL, function_methods) || !DefinePropertiesAndBrand(cx, functionCtor, NULL, NULL)) { return NULL; } /* Add the global Function and Object properties now. */ jsid objectId = NameToId(CLASS_NAME(cx, Object)); if (!self->addDataProperty(cx, objectId, JSProto_Object + JSProto_LIMIT * 2, 0)) return NULL; jsid functionId = NameToId(CLASS_NAME(cx, Function)); if (!self->addDataProperty(cx, functionId, JSProto_Function + JSProto_LIMIT * 2, 0)) return NULL; /* Heavy lifting done, but lingering tasks remain. */ /* ES5 15.1.2.1. */ RootedId id(cx, NameToId(cx->runtime->atomState.evalAtom)); JSObject *evalobj = js_DefineFunction(cx, self, id, eval, 1, JSFUN_STUB_GSOPS); if (!evalobj) return NULL; self->setOriginalEval(evalobj); /* ES5 13.2.3: Construct the unique [[ThrowTypeError]] function object. */ RootedFunction throwTypeError(cx); throwTypeError = js_NewFunction(cx, NULL, ThrowTypeError, 0, 0, self, NULL); if (!throwTypeError) return NULL; if (!throwTypeError->preventExtensions(cx)) return NULL; self->setThrowTypeError(throwTypeError); /* * The global object should have |Object.prototype| as its [[Prototype]]. * Eventually we'd like to have standard classes be there from the start, * and thus we would know we were always setting what had previously been a * null [[Prototype]], but right now some code assumes it can set the * [[Prototype]] before standard classes have been initialized. For now, * only set the [[Prototype]] if it hasn't already been set. */ if (self->shouldSplicePrototype(cx) && !self->splicePrototype(cx, objectProto)) return NULL; /* * Notify any debuggers about the creation of the script for * |Function.prototype| -- after all initialization, for simplicity. */ js_CallNewScriptHook(cx, functionProto->script(), functionProto); return functionProto; }