当前位置: 首页>>代码示例>>C++>>正文


C++ AvmCore类代码示例

本文整理汇总了C++中AvmCore的典型用法代码示例。如果您正苦于以下问题:C++ AvmCore类的具体用法?C++ AvmCore怎么用?C++ AvmCore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AvmCore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: implToString

 Stringp ClassClosure::implToString() const
 {
     AvmCore* core = this->core();
     Traits* t = this->traits()->itraits;
     Stringp s = core->concatStrings(core->newConstantStringLatin1("[class "), t->name());
     return core->concatStrings(s, core->newConstantStringLatin1("]"));
 }
开发者ID:AdiKo,项目名称:avmplus,代码行数:7,代码来源:ClassClosure.cpp

示例2: toString

    // Execute the ToString algorithm as described in ECMA-262 Section 9.8.
    // This is ToString(ToPrimitive(input argument, hint String))
    // ToPrimitive(input argument, hint String) calls [[DefaultValue]]
    // described in ECMA-262 8.6.2.6.  The [[DefaultValue]] algorithm
    // with hint String is inlined here.
    Stringp ScriptObject::toString()
    {
        AvmCore *core = this->core();
        Toplevel* toplevel = this->toplevel();

        Atom atomv_out[1];

        // call this.toString()
        // NOTE use callers versioned public to get correct toString
        Multiname tempname(core->findPublicNamespace(), core->ktoString);
        atomv_out[0] = atom();
        Atom result = toplevel->callproperty(atom(), &tempname, 0, atomv_out, vtable);

        // if result is primitive, return its ToString
        if (atomKind(result) != kObjectType)
            return core->string(result);

        // otherwise call this.valueOf()
        tempname.setName(core->kvalueOf);
        atomv_out[0] = atom();
        result = toplevel->callproperty(atom(), &tempname, 0, atomv_out, vtable);

        // if result is primitive, return it
        if (atomKind(result) != kObjectType)
            return core->string(result);

        // could not convert to primitive.
        toplevel->throwTypeError(kConvertToPrimitiveError, core->toErrorString(traits()));
        return NULL; // unreachable
    }
开发者ID:bsdf,项目名称:trx,代码行数:35,代码来源:ScriptObject.cpp

示例3: VMPI_readdir

    /*static*/ CdirentObject* CDirentClass::readdir(ScriptObject* self, CDIRObject* dirp)
    {
        Toplevel* toplevel = self->toplevel();

        if( !dirp )
        {
            toplevel->throwArgumentError(kNullArgumentError, "dirp");
        }

        dirent *entry = VMPI_readdir( dirp->read() );

        if( entry )
        {
            ShellToplevel* shelltop = (ShellToplevel*)self->toplevel();
            CdirentClass *direc = shelltop->getShellClasses()->get_direntClass();
            CdirentObject *direo = direc->constructObject();

            direo->write( entry );

            AvmCore *core = self->core();

            direo->set_d_ino( entry->d_ino );
            direo->set_d_name( core->newStringUTF8( entry->d_name ) );

            return direo;
        }

        return NULL;
    }
开发者ID:Adime,项目名称:redtamarin,代码行数:29,代码来源:CDirentClass.cpp

示例4: convertForm

	ArrayObject* HTTPFormClass::convertForm(std::vector<FormEntry>& vec)
	{
		AvmCore *core = this->core();
		ArrayObject *out = this->toplevel()->arrayClass->newArray();

		for (std::vector<FormEntry>::iterator it=vec.begin(); it!=vec.end(); it++)
		{
	    	ArrayObject* arr;
	    	Stringp key = core->internStringUTF8((*it).name.data(), (*it).name.length());
	    	Stringp value = core->internStringUTF8((*it).value.data(), (*it).value.length());
	    	//we have it, append
	    	if (out->hasStringProperty(key))
	    	{
	    		arr = (ArrayObject*) core->atomToScriptObject(out->getStringProperty(key));
		    	arr->setUintProperty(arr->get_length(), value->atom());
	    	}
	    	//create array
	    	else
	    	{
		    	arr = this->toplevel()->arrayClass->newArray();
		    	arr->setUintProperty(0, value->atom());
		    	out->setStringProperty(key, arr->atom());
	    	}
		}
		return out;
	}
开发者ID:weimingtom,项目名称:mod-actionscript,代码行数:26,代码来源:HTTPFormClass.cpp

示例5: implToString

 Stringp ScriptObject::implToString() const
 {
     AvmCore* core = this->core();
     Traits* t = this->traits();
     Stringp s = core->concatStrings(core->newConstantStringLatin1("[object "), t->name());
     return core->concatStrings(s, core->newConstantStringLatin1("]"));
 }
开发者ID:bsdf,项目名称:trx,代码行数:7,代码来源:ScriptObject.cpp

示例6: filter

	Atom VectorBaseObject::filter(ScriptObject *callback, Atom thisObject)
	{
		AvmCore* core = this->core();
		VectorBaseObject *r = newVector();

		if (!callback)
			return r->atom();

		ScriptObject *d = this;
		uint32 len = m_length;

		// If thisObject is null, the call function will substitute the global object 
		Atom args[4] = { thisObject, nullObjectAtom, nullObjectAtom, this->atom() };

		for (uint32 i = 0, k = 0; i < len; i++)
		{
			args[1] = d->getUintProperty (i); // element
			args[2] = core->uintToAtom (i); // index

			Atom result = callback->call(3, args);

			if (result == trueAtom)
			{
				r->setUintProperty (k++, args[1]);
			}
		}

		return r->atom();
	}
开发者ID:weimingtom,项目名称:mod-actionscript,代码行数:29,代码来源:VectorClass.cpp

示例7: while

    ArrayObject * ProgramClass::_getEnviron()
    {
        Toplevel *toplevel = this->toplevel();
        AvmCore *core = this->core();

        ArrayObject *array = toplevel->arrayClass()->newArray();

        #if AVMSYSTEM_WIN32
            wchar **cur = VMPI_GetEnviron16();
            int i = 0;
            while( cur[i] )
            {
                Stringp value = core->newStringUTF16(cur[i]);
                StUTF8String valueUTF8(value);

                array->setUintProperty( i, core->newStringUTF8( valueUTF8.c_str() )->atom() );
                i++;
            }
        #else
            char **cur = VMPI_GetEnviron();
            int i = 0;
            while( cur[i] )
            {
                array->setUintProperty( i, core->newStringUTF8( cur[i] )->atom() );
                i++;
            }
        #endif
        
        return array;
    }
开发者ID:Adime,项目名称:redtamarin,代码行数:30,代码来源:ProgramClass.cpp

示例8: filter

    Atom VectorBaseObject::filter(ScriptObject *callback, Atom thisObject)
    {
        AvmCore* core = this->core();
        VectorBaseObject *r = newVector();

        if (!callback)
            return r->atom();

        ScriptObject *d = this;
        uint32 len = m_length;

        for (uint32 i = 0, k = 0; i < len; i++)
        {
            // If thisObject is null, the call function will substitute the global object
            // args are modified in place by callee
            Atom element = d->getUintProperty(i);
            Atom args[4] = {
                thisObject,
                element,
                core->uintToAtom(i), // index
                this->atom()
            };
            Atom result = callback->call(3, args);
            if (result == trueAtom)
                r->setUintProperty(k++, element);
        }

        return r->atom();
    }
开发者ID:changm,项目名称:tessa,代码行数:29,代码来源:VectorClass.cpp

示例9: toplevel

	// this = argv[0] (ignored)
	// arg1 = argv[1]
	// argN = argv[argc]
	Atom RegExpClass::construct(int argc, Atom* argv)
	{
		AvmCore* core = this->core();
		Stringp pattern;

		Atom patternAtom = (argc>0) ? argv[1] : undefinedAtom;
		Atom optionsAtom = (argc>1) ? argv[2] : undefinedAtom;

		if (AvmCore::istype(patternAtom, traits()->itraits)) {
			// Pattern is a RegExp object
			if (optionsAtom != undefinedAtom) {
				// ECMA 15.10.4.1 says to throw an error if flags specified
				toplevel()->throwTypeError(kRegExpFlagsArgumentError);
			}
			// Return a clone of the RegExp object
			RegExpObject* regExpObject = (RegExpObject*)AvmCore::atomToScriptObject(patternAtom);
			return (new (core->GetGC(), ivtable()->getExtraSize()) RegExpObject(regExpObject))->atom();
		} else {
			if (patternAtom != undefinedAtom) {
				pattern = core->string(argv[1]);
			} else {
				// cn:  disable this, breaking ecma3 tests.   was: todo look into this. it's what SpiderMonkey does.
				pattern = core->kEmptyString; //core->newConstantStringLatin1("(?:)");
			}
		}

		Stringp options = NULL;
		if (optionsAtom != undefinedAtom) {
			options = core->string(optionsAtom);
		}

		RegExpObject* inst = new (core->GetGC(), ivtable()->getExtraSize()) RegExpObject(this, pattern, options);
		return inst->atom();
	}
开发者ID:Jeffxz,项目名称:nodeas,代码行数:37,代码来源:RegExpClass.cpp

示例10: 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;
    }
开发者ID:DaZhu,项目名称:crossbridge,代码行数:33,代码来源:SamplerScript.cpp

示例11: toplevel

	void SystemClass::trace(ArrayObject* a)
	{
		if (!a)
			toplevel()->throwArgumentError(kNullArgumentError, "array");
		AvmCore* core = this->core();
		PrintWriter& console = core->console;
		for (int i=0, n = a->getLength(); i < n; i++)
		{
			if (i > 0)
                console << ' ';
			Stringp s = core->string(a->getUintProperty(i));
			for (int j = 0; j < s->length(); j++)
			{
				wchar c = (*s)[j];
				// '\r' gets converted into '\n'
				// '\n' is left alone
				// '\r\n' is left alone
				if (c == '\r')
				{
					if (((j+1) < s->length()) && (*s)[j+1] == '\n')
					{
						console << '\r';	
						j++;
					}

					console << '\n';
				}
				else
				{
					console << c;
				}
			}
		}
		console << '\n';
	}
开发者ID:Jeffxz,项目名称:nodeas,代码行数:35,代码来源:SystemClass.cpp

示例12: ToString

    /**
        15.2.4.5 Object.prototype.hasOwnProperty (V)
        When the hasOwnProperty method is called with argument V, the following steps are taken:
        1. Let O be this object.
        2. Call ToString(V).
        3. If O doesn't have a property with the name given by Result(2), return false.
        4. Return true.
        NOTE Unlike [[HasProperty]] (section 8.6.2.4), this method does not consider objects in the prototype chain.
     */
    bool ObjectClass::_hasOwnProperty(Atom thisAtom, Stringp name)
    {
        AvmCore* core = this->core();
        name = name ? core->internString(name) : (Stringp)core->knull;

        Traitsp t = NULL;
        switch (atomKind(thisAtom))
        {
            case kObjectType:
            {
                // ISSUE should this look in traits and dynamic vars, or just dynamic vars.
                ScriptObject* obj = AvmCore::atomToScriptObject(thisAtom);
                // TODO
                // The change below is important as otherwise we will throw error in a call to hasAtomProperty for ByteArrayObject.
                // This gets us back to the behaviour which we had in Marlin.
                // A bugzilla bug [ 562224 ] has been created to address this issue more cleanly in near future
                return obj->traits()->getTraitsBindings()->findBinding(name, core->findPublicNamespace()) != BIND_NONE ||
                    obj->hasStringProperty(name);
            }
            case kNamespaceType:
            case kStringType:
            case kBooleanType:
            case kDoubleType:
            case kIntptrType:
                t = toplevel()->toTraits(thisAtom);
                break;
            default:
                return false;
        }
        // NOTE use caller's public namespace
        return t->getTraitsBindings()->findBinding(name, core->findPublicNamespace()) != BIND_NONE;
    }
开发者ID:bsdf,项目名称:trx,代码行数:41,代码来源:ObjectClass.cpp

示例13: ToString

	/**
		15.2.4.5 Object.prototype.hasOwnProperty (V)
		When the hasOwnProperty method is called with argument V, the following steps are taken:
		1. Let O be this object.
		2. Call ToString(V).
		3. If O doesn’t have a property with the name given by Result(2), return false.
		4. Return true.
		NOTE Unlike [[HasProperty]] (section 8.6.2.4), this method does not consider objects in the prototype chain.
     */
	bool ObjectClass::_hasOwnProperty(Atom thisAtom, Stringp name)
	{
		AvmCore* core = this->core();
		name = name ? core->internString(name) : (Stringp)core->knull;

		Traitsp t = NULL;
		switch (atomKind(thisAtom))
		{
			case kObjectType:
			{
				// ISSUE should this look in traits and dynamic vars, or just dynamic vars.
				ScriptObject* obj = AvmCore::atomToScriptObject(thisAtom);
				if (obj->hasStringProperty(name))
					return true;
				t = obj->traits();
				break;
			}
			case kNamespaceType:
			case kStringType:
			case kBooleanType:
			case kDoubleType:
			case kIntegerType:
				t = toplevel()->toTraits(thisAtom);
				break;
			default:
				return false;
		}
		return t->getTraitsBindings()->findBinding(name, core->publicNamespace) != BIND_NONE;
	}
开发者ID:PushButtonLabs,项目名称:PBNetworking,代码行数:38,代码来源:ObjectClass.cpp

示例14: mname

 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);
 }
开发者ID:bsdf,项目名称:trx,代码行数:8,代码来源:ScriptObject.cpp

示例15: 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);
 }
开发者ID:bsdf,项目名称:trx,代码行数:8,代码来源:ScriptObject.cpp


注:本文中的AvmCore类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。