本文整理汇总了C++中Toplevel::core方法的典型用法代码示例。如果您正苦于以下问题:C++ Toplevel::core方法的具体用法?C++ Toplevel::core怎么用?C++ Toplevel::core使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Toplevel
的用法示例。
在下文中一共展示了Toplevel::core方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_stack
bool SamplerScript::set_stack(ScriptObject* self, ClassFactoryClass* cf, const Sample& sample, SampleObject* sam)
{
if (sample.stack.depth > 0)
{
Toplevel* toplevel = self->toplevel();
AvmCore* core = toplevel->core();
Sampler* s = core->get_sampler();
StackFrameClass* sfcc = (StackFrameClass*)cf->get_StackFrameClass();
ArrayObject* stack = toplevel->arrayClass()->newArray(sample.stack.depth);
StackTrace::Element* e = (StackTrace::Element*)sample.stack.trace;
for(uint32_t i=0; i < sample.stack.depth; i++, e++)
{
StackFrameObject* sf = sfcc->constructObject();
// at every allocation the sample buffer could overflow and the samples could be deleted
// the StackTrace::Element pointer is a raw pointer into that buffer so we need to check
// that its still around before dereferencing e
uint32_t num;
if (s->getSamples(num) == NULL)
return false;
sf->setconst_name(e->name()); // NOT e->info()->name() because e->name() can be a fake name
sf->setconst_file(e->filename());
sf->setconst_line(e->linenum());
sf->setconst_scriptID(static_cast<double>(e->functionId()));
stack->setUintProperty(i, sf->atom());
}
sam->setconst_stack(stack);
}
return true;
}
示例2: newParameterizedVTable
VTable* VTable::newParameterizedVTable(Traits* param_traits, Stringp fullname)
{
Toplevel* toplevel = this->toplevel();
AvmCore* core = toplevel->core();
Namespacep traitsNs = this->traits->ns();
GCRef<builtinClassManifest> builtinClasses = toplevel->builtinClasses();
GCRef<ObjectVectorClass> vectorobj_cls = builtinClasses->get_Vector_objectClass();
GCRef<ScopeChain> vectorobj_cscope = vectorobj_cls->vtable->init->scope();
GCRef<ScopeChain> vectorobj_iscope = vectorobj_cls->ivtable()->init->scope();
VTable* objVecVTable = vectorobj_cls->vtable;
AbcEnv* objVecAbcEnv = vectorobj_cscope->abcEnv();
Toplevel* objVecToplevel = objVecVTable->toplevel();
VTable* objVecIVTable = objVecVTable->ivtable;
// these cases should all be filtered out by the caller;
// we only want to handle Vector<SomeObject> here
AvmAssert(param_traits != NULL &&
param_traits != toplevel->intClass()->vtable->traits->itraits &&
param_traits != toplevel->uintClass()->vtable->traits->itraits &&
param_traits != toplevel->numberClass()->vtable->traits->itraits);
PoolObject* traitsPool = this->traits->pool;
Stringp classname = core->internString(fullname->appendLatin1("$"));
Traits* ctraits = core->domainMgr()->findTraitsInPoolByNameAndNS(traitsPool, classname, traitsNs);
Traits* itraits;
if (!ctraits)
{
// important: base the new ctraits on objVecVTable->traits, *not* this->traits;
// we want the result to be based off ObjectVectorClass, not VectorClass
// (otherwise sizeofInstance would be too small and we'd be crashy)
ctraits = objVecVTable->traits->newParameterizedCTraits(classname, traitsNs);
ctraits->verifyBindings(toplevel);
itraits = traitsPool->resolveParameterizedType(toplevel, this->ivtable->traits, param_traits);
ctraits->itraits = itraits;
}
else
{
itraits = ctraits->itraits;
}
AvmAssert(itraits != NULL);
VTable* class_ivtable = builtinClasses->get_ClassClass()->ivtable();
VTable* cvtab = core->newVTable(ctraits, class_ivtable, objVecToplevel);
ScopeChain* cvtab_cscope = vectorobj_cscope->cloneWithNewVTable(core->GetGC(), cvtab, objVecAbcEnv);
VTable* ivtab = core->newVTable(itraits, objVecIVTable, objVecToplevel);
ScopeChain* ivtab_iscope = vectorobj_iscope->cloneWithNewVTable(core->GetGC(), ivtab, objVecAbcEnv);
cvtab->ivtable = ivtab;
ivtab->init = objVecIVTable->init;
cvtab->resolveSignatures(cvtab_cscope);
ivtab->resolveSignatures(ivtab_iscope);
return cvtab;
}
示例3: setLengthProperty
void ScriptObject::setLengthProperty(uint32_t newLen)
{
Toplevel* toplevel = this->toplevel();
AvmCore* core = toplevel->core();
Multiname mname(core->getAnyPublicNamespace(), core->klength);
Atom lenAtm = core->uintToAtom(newLen);
toplevel->setproperty(this->atom(), &mname, lenAtm, this->vtable);
}
示例4: getLengthProperty
uint32_t ScriptObject::getLengthProperty()
{
Toplevel* toplevel = this->toplevel();
AvmCore* core = toplevel->core();
Multiname mname(core->getAnyPublicNamespace(), core->klength);
Atom lenAtm = toplevel->getproperty(this->atom(), &mname, this->vtable);
return AvmCore::toUInt32(lenAtm);
}
示例5: makeSample
ScriptObject* SamplerScript::makeSample(ScriptObject* self, ClassFactoryClass* cf, const Sample& sample)
{
Toplevel* toplevel = self->toplevel();
AvmCore* core = toplevel->core();
Sampler* s = core->get_sampler();
if (!s)
return NULL;
switch (sample.sampleType)
{
case Sampler::RAW_SAMPLE:
{
SampleClass* cls = (SampleClass*)cf->get_SampleClass();
SampleObject* sam = cls->constructObject();
sam->setconst_time(static_cast<double>(sample.micros));
if (!set_stack(self, cf, sample, sam))
return NULL;
return sam;
}
case Sampler::DELETED_OBJECT_SAMPLE:
{
DeleteObjectSampleClass* cls = (DeleteObjectSampleClass*)cf->get_DeleteObjectSampleClass();
DeleteObjectSampleObject* dsam = cls->constructObject();
dsam->setconst_time(static_cast<double>(sample.micros));
dsam->setconst_id(static_cast<double>(sample.id));
dsam->setconst_size(static_cast<double>(sample.size));
return dsam;
}
case Sampler::NEW_OBJECT_SAMPLE:
{
NewObjectSampleClass* cls = (NewObjectSampleClass*)cf->get_NewObjectSampleClass();
NewObjectSampleObject* nsam = cls->constructObject();
nsam->setconst_time(static_cast<double>(sample.micros));
nsam->setconst_id(static_cast<double>(sample.id));
if (!set_stack(self, cf, sample, nsam))
return NULL;
if (sample.ptr != NULL )
nsam->setRef((AvmPlusScriptableObject*)sample.ptr);
nsam->setconst_type(getType(toplevel, sample.sot, sample.ptr));
nsam->setSize(sample.alloc_size);
return nsam;
}
case Sampler::NEW_AUX_SAMPLE:
{
NewObjectSampleClass* cls = (NewObjectSampleClass*)cf->get_NewObjectSampleClass();
NewObjectSampleObject* nsam = cls->constructObject();
nsam->setconst_time(static_cast<double>(sample.micros));
nsam->setconst_id(static_cast<double>(sample.id));
if (!set_stack(self, cf, sample, nsam))
return NULL;
nsam->setSize(sample.alloc_size);
return nsam;
}
}
AvmAssert(0);
return NULL;
}
示例6: call
// this = argv[0]
// arg1 = argv[1]
// argN = argv[argc]
Atom ClassClosure::call(int argc, Atom* argv)
{
Toplevel* toplevel = this->toplevel();
// explicit coercion of a class object.
if (argc != 1)
{
toplevel->throwArgumentError(kCoerceArgumentCountError, toplevel->core()->toErrorString(argc));
}
return toplevel->coerce(argv[1], (Traits*)ivtable()->traits);
}
示例7: if
ClassClosure *SamplerScript::getType(Toplevel* ss_toplevel, SamplerObjectType sot, const void *ptr)
{
Toplevel* tl;
switch (sotGetKind(sot))
{
case kSOT_String:
{
// toplevel can be null here if there was no CodeContext active
// when the sample was taken (ie, string was allocated from C++ code).
// in that case, use the TL from the SamplerScript itself... it isn't
// technically the right one to use, but is adequate for our purposes here
// (it will return a stringClass or namespaceClass that will be valid
// for the sampler)
tl = sotGetToplevel(sot);
if (!tl) tl = ss_toplevel;
return tl->stringClass();
}
case kSOT_Namespace:
{
tl = sotGetToplevel(sot);
if (!tl) tl = ss_toplevel;
return tl->namespaceClass();
}
default:
AvmAssert(0);
case kSOT_Object:
break;
}
VTable* vt = sotGetVTable(sot);
tl = vt->toplevel();
AvmCore* core = tl->core();
ClassClosure *type;
ScriptObject* obj = (ScriptObject*)ptr;
if (obj && AvmCore::istype(obj->atom(), core->traits.class_itraits))
{
type = tl->classClass();
}
else if (obj && AvmCore::istype(obj->atom(), core->traits.function_itraits))
{
type = tl->functionClass();
}
else if (obj && obj->traits()->isActivationTraits())
{
type = tl->objectClass;
}
else
{
// fallback answer
type = tl->objectClass;
// note that note all types will have an init method,
// so those types may get reported as "objectClass" rather
// than something more specific. However, it's not clear
// that the Sampler ever really cared about reporting those
// objects well in the first place (eg activation or catch objects),
// so it doesn't seem we're a lot worse off than before.
ScopeChain* sc = NULL;
if (vt->init)
sc = vt->init->scope();
if (sc && sc->getSize() <= 1)
{
if(sc->getSize() == 1)
type = tl->classClass();
}
else if (sc)
{
Atom ccAtom = sc->getScope(sc->getSize()-1);
if(AvmCore::isObject(ccAtom))
{
type = (ClassClosure*) AvmCore::atomToScriptObject(ccAtom);
if(!AvmCore::istype(type->atom(), core->traits.class_itraits))
{
// obj is a ClassClosure
type = tl->classClass();
}
}
}
}
AvmAssert(AvmCore::istype(type->atom(), core->traits.class_itraits));
return type;
}
示例8: memcpy
ChostentObject* CNetdbClass::gethostbyaddr4(CIn_AddrObject* addr, int type)
{
Toplevel* toplevel = this->toplevel();
AvmCore* core = toplevel->core();
if( !addr )
{
toplevel->throwArgumentError(kNullArgumentError, "addr");
}
struct hostent *he;
struct in_addr ipv4addr;
ipv4addr.s_addr = addr->get_s_addr(); //uint
if( addr->call_isValid() == false )
{
return NULL;
}
he = VMPI_gethostbyaddr( (char *)&ipv4addr, sizeof ipv4addr, type );
if( he )
{
ShellToplevel* shelltop = (ShellToplevel*)this->toplevel();
ChostentClass *hc = shelltop->getShellClasses()->get_hostentClass();
ChostentObject *ho = hc->constructObject();
ho->set_h_name( core->newStringUTF8( he->h_name ) );
ArrayObject *aliases = toplevel->arrayClass()->newArray();
int count = 0;
int i;
for( i=0; he->h_aliases[i] != NULL; ++i )
{
aliases->setUintProperty( count++, core->newStringUTF8( he->h_aliases[i] )->atom() );
}
ho->set_h_aliases( aliases );
ho->set_h_addrtype( he->h_addrtype );
ho->set_h_length( he->h_length );
ArrayObject *addrlist = toplevel->arrayClass()->newArray();
count = 0;
for( i=0; he->h_addr_list[i] != NULL; ++i )
{
struct in_addr in;
memcpy(&in.s_addr, he->h_addr_list[i], sizeof (in.s_addr));
CIn_AddrClass *ac = shelltop->getShellClasses()->get_in_addrClass();
CIn_AddrObject *ao = ac->constructObject();
ao->set_s_addr( in.s_addr );
addrlist->setUintProperty( count++, ao->toAtom() );
}
ho->set_h_addr_list( addrlist );
return ho;
}
return NULL;
}