本文整理汇总了C++中shim函数的典型用法代码示例。如果您正苦于以下问题:C++ shim函数的具体用法?C++ shim怎么用?C++ shim使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shim函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shim
void DefaultGCActivityCallbackPlatformData::trigger(CFRunLoopTimerRef timer, void *info)
{
Heap* heap = static_cast<Heap*>(info);
APIEntryShim shim(heap->globalData());
heap->collectAllGarbage();
CFRunLoopTimerSetNextFireDate(timer, CFAbsoluteTimeGetCurrent() + decade);
}
示例2: foo
/*!
Returns true if the function was called as a constructor
(e.g. \c{"new foo()"}); otherwise returns false.
When a function is called as constructor, the thisObject()
contains the newly constructed object to be initialized.
\note This function is only guaranteed to work for a context
corresponding to native functions.
*/
bool QScriptContext::isCalledAsConstructor() const
{
JSC::CallFrame *frame = const_cast<JSC::ExecState*>(QScriptEnginePrivate::frameForContext(this));
QScript::APIShim shim(QScript::scriptEngineFromExec(frame));
//For native functions, look up flags.
uint flags = QScriptEnginePrivate::contextFlags(frame);
if (flags & QScriptEnginePrivate::NativeContext)
return flags & QScriptEnginePrivate::CalledAsConstructorContext;
//Not a native function, try to look up in the bytecode if we where called from op_construct
JSC::Instruction* returnPC = frame->returnPC();
if (!returnPC)
return false;
JSC::CallFrame *callerFrame = QScriptEnginePrivate::frameForContext(parentContext());
if (!callerFrame)
return false;
if (returnPC[-JSC::op_construct_length].u.opcode == frame->interpreter()->getOpcode(JSC::op_construct)) {
//We are maybe called from the op_construct opcode which has 6 opperands.
//But we need to check we are not called from op_call with 4 opperands
//we make sure that the returnPC[-1] (thisRegister) is smaller than the returnPC[-3] (registerOffset)
//as if it was an op_call, the returnPC[-1] would be the registerOffset, bigger than returnPC[-3] (funcRegister)
return returnPC[-1].u.operand < returnPC[-3].u.operand;
}
return false;
}
示例3: throwValue
/*!
\overload
Throws an error with the given \a text.
Returns the created error object.
\sa throwValue(), state()
*/
QScriptValue QScriptContext::throwError(const QString &text)
{
JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
QScript::APIShim shim(QScript::scriptEngineFromExec(frame));
JSC::JSObject *result = JSC::throwError(frame, JSC::GeneralError, text);
return QScript::scriptEngineFromExec(frame)->scriptValueFromJSCValue(result);
}
示例4: activationObject
/*!
\internal
\since 4.5
Adds the given \a object to the front of this context's scope chain.
If \a object is not an object, this function does nothing.
*/
void QScriptContext::pushScope(const QScriptValue &object)
{
activationObject(); //ensure the creation of the normal scope for native context
if (!object.isObject())
return;
else if (object.engine() != engine()) {
qWarning("QScriptContext::pushScope() failed: "
"cannot push an object created in "
"a different engine");
return;
}
JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame);
QScript::APIShim shim(engine);
JSC::JSObject *jscObject = JSC::asObject(engine->scriptValueToJSCValue(object));
if (jscObject == engine->originalGlobalObjectProxy)
jscObject = engine->originalGlobalObject();
JSC::ScopeChainNode *scope = frame->scopeChain();
Q_ASSERT(scope != 0);
if (!scope->object) {
// pushing to an "empty" chain
if (!jscObject->isGlobalObject()) {
qWarning("QScriptContext::pushScope() failed: initial object in scope chain has to be the Global Object");
return;
}
scope->object = jscObject;
}
else
frame->setScopeChain(scope->push(jscObject));
}
示例5: shim
/*!
Sets the `this' object associated with this QScriptContext to be
\a thisObject.
If \a thisObject is not an object, this function does nothing.
*/
void QScriptContext::setThisObject(const QScriptValue &thisObject)
{
JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
QScript::APIShim shim(QScript::scriptEngineFromExec(frame));
if (!thisObject.isObject())
return;
if (thisObject.engine() != engine()) {
qWarning("QScriptContext::setThisObject() failed: "
"cannot set an object created in "
"a different engine");
return;
}
if (frame == frame->lexicalGlobalObject()->globalExec()) {
engine()->setGlobalObject(thisObject);
return;
}
JSC::JSValue jscThisObject = QScript::scriptEngineFromExec(frame)->scriptValueToJSCValue(thisObject);
JSC::CodeBlock *cb = frame->codeBlock();
if (cb != 0) {
frame[cb->thisRegister()] = jscThisObject;
} else {
JSC::Register* thisRegister = QScriptEnginePrivate::thisRegisterForFrame(frame);
thisRegister[0] = jscThisObject;
}
}
示例6: shim
void Dawg::iterate_words(const UNICHARSET &unicharset,
TessCallback1<const char *> *cb) const {
std::unique_ptr<TessCallback1<const WERD_CHOICE *>> shim(
NewPermanentTessCallback(CallWithUTF8, cb));
WERD_CHOICE word(&unicharset);
iterate_words_rec(word, 0, shim.get());
}
示例7: shim
QScriptProgramPrivate::~QScriptProgramPrivate()
{
if (engine) {
QScript::APIShim shim(engine);
_executable.clear();
}
}
示例8: if
void HeapTimer::timerDidFire(CFRunLoopTimerRef timer, void* context)
{
JSLock* apiLock = static_cast<JSLock*>(context);
apiLock->lock();
VM* vm = apiLock->vm();
// The VM has been destroyed, so we should just give up.
if (!vm) {
apiLock->unlock();
return;
}
HeapTimer* heapTimer = 0;
if (vm->heap.activityCallback()->m_timer.get() == timer)
heapTimer = vm->heap.activityCallback();
else if (vm->heap.sweeper()->m_timer.get() == timer)
heapTimer = vm->heap.sweeper();
else
RELEASE_ASSERT_NOT_REACHED();
{
APIEntryShim shim(vm);
heapTimer->doWork();
}
apiLock->unlock();
}
示例9: thrown
/*!
Throws an exception with the given \a value.
Returns the value thrown (the same as the argument).
\sa throwError(), state()
*/
QScriptValue QScriptContext::throwValue(const QScriptValue &value)
{
JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
QScript::APIShim shim(QScript::scriptEngineFromExec(frame));
JSC::JSValue jscValue = QScript::scriptEngineFromExec(frame)->scriptValueToJSCValue(value);
frame->setException(jscValue);
return value;
}
示例10: shim
QScriptProgramPrivate::~QScriptProgramPrivate()
{
if (engine) {
QScript::APIShim shim(engine);
_executable.clear();
engine->unregisterScriptProgram(this);
}
}
示例11: next
/*!
Returns the flags of the last property that was jumped over using
next() or previous().
\sa value()
*/
QScriptValue::PropertyFlags QScriptValueIterator::flags() const
{
Q_D(const QScriptValueIterator);
if (!d || !d->initialized || !d->engine())
return 0;
QScript::APIShim shim(d->engine());
return d->object()->propertyFlags(*d->current);
}
示例12: shim
QScriptDeclarativeClass::PersistentIdentifier::~PersistentIdentifier()
{
if (engine) {
QScript::APIShim shim(engine);
((JSC::Identifier &)d).JSC::Identifier::~Identifier();
} else {
((JSC::Identifier &)d).JSC::Identifier::~Identifier();
}
}
示例13: engine
~QScriptValueIteratorPrivate()
{
if (!initialized)
return;
QScriptEnginePrivate *eng_p = engine();
if (!eng_p)
return;
QScript::APIShim shim(eng_p);
propertyNames.clear(); //destroying the identifiers need to be done under the APIShim guard
}
示例14: shim
bool HeapTimer::timerEvent(void* info)
{
HeapTimer* agent = static_cast<HeapTimer*>(info);
APIEntryShim shim(agent->m_vm);
agent->doWork();
agent->m_timer = 0;
return ECORE_CALLBACK_CANCEL;
}
示例15: lock
void HeapTimer::timerEvent(QTimerEvent*)
{
QMutexLocker lock(&m_mutex);
if (m_newThread) {
// We need to wait with processing until we are on the right thread.
return;
}
APIEntryShim shim(m_vm);
doWork();
}