• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Toplevel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: initPrototype

	void ObjectClass::initPrototype()
	{
		// patch global.__proto__ = Object.prototype
		Toplevel* toplevel = this->toplevel();
		toplevel->setDelegate( prototype );						// global.__proto__ = Object.prototype
		this->setDelegate( toplevel->classClass->prototype );	// Object.__proto__ = Class.prototype
	}
开发者ID:PushButtonLabs,项目名称:PBNetworking,代码行数:7,代码来源:ObjectClass.cpp


示例3:

    /*static*/ int CSysStatClass::fstat(ScriptObject* self, int fildes, CStatusObject* buf)
    {
        Toplevel* toplevel = self->toplevel();

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

        struct stat statbuf;
        int result = VMPI_fstat( fildes, &statbuf );

        if( result != -1 )
        {
            buf->set_st_dev( statbuf.st_dev );
            buf->set_st_ino( statbuf.st_ino );
            buf->set_st_mode( statbuf.st_mode );
            buf->set_st_nlink( statbuf.st_nlink );
            buf->set_st_uid( statbuf.st_uid );
            buf->set_st_gid( statbuf.st_gid );
            buf->set_st_rdev( statbuf.st_rdev );
            buf->set_st_size( (double) statbuf.st_size );
            buf->set_st_atime( (double) statbuf.st_atime );
            buf->set_st_mtime( (double) statbuf.st_mtime );
            buf->set_st_ctime( (double) statbuf.st_ctime );
        }

        return result;
    }
开发者ID:Adime,项目名称:redtamarin,代码行数:28,代码来源:CSysStatClass.cpp


示例4: VMPI_getprotoent

    /*static*/ CprotoentObject* CNetdbClass::getprotoent(ScriptObject* self)
    {
        struct protoent *pp;

        pp = VMPI_getprotoent();

        if( pp )
        {
            ShellToplevel* shelltop = (ShellToplevel*)self->toplevel();
            CprotoentClass *pc = shelltop->getShellClasses()->get_protoentClass();
            CprotoentObject *po = pc->constructObject();

            po->set_p_name( self->core()->newStringUTF8( pp->p_name ) );
            po->set_p_proto( pp->p_proto );

            Toplevel* toplevel = self->toplevel();
            ArrayObject *aliases = toplevel->arrayClass()->newArray();
            int count = 0;
            int i;
            for( i=0; pp->p_aliases[i] != NULL; ++i )
            {
                aliases->setUintProperty( count++, self->core()->newStringUTF8( pp->p_aliases[i] )->atom());
            }
            po->set_p_aliases( aliases );

            return po;
        }

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


示例5: initnamensx

Atom Stubs::do_abc_getpropnsx(MethodFrame* f, const Multiname* name, Atom ns,
                              Atom index, Atom object) {
  Multiname tempname;
  initnamensx(env(f), name, ns, index, &tempname);
  Toplevel* t = toplevel(f);
  return t->getproperty(object, &tempname, toVTable(t, object));
}
开发者ID:AdiKo,项目名称:avmplus,代码行数:7,代码来源:hm-stubs.cpp


示例6: VMPI_setenv

    /*static*/ int CStdlibClass::setenv(ScriptObject* self, Stringp name, Stringp value, bool overwrite)
    {
        Toplevel* toplevel = self->toplevel();

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

        int writeover = 0;
        if( overwrite ) { writeover = 1; }
        
        #if AVMSYSTEM_WIN32
            StUTF16String nameUTF16(name);
            StUTF16String valueUTF16(value);
            return VMPI_setenv16( nameUTF16.c_str(), valueUTF16.c_str(), writeover );
        #else
            StUTF8String nameUTF8(name);
            StUTF8String valueUTF8(value);
            return VMPI_setenv( nameUTF8.c_str(), valueUTF8.c_str(), writeover );
        #endif
    }
开发者ID:Adime,项目名称:redtamarin,代码行数:27,代码来源:CStdlibClass.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: 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


示例9: free

    /*static*/ int CStdlibClass::putenv(ScriptObject* self, Stringp name)
    {
        Toplevel* toplevel = self->toplevel();

        if( !name )
        {
            toplevel->throwArgumentError(kNullArgumentError, "name");
        }
        
        #if AVMSYSTEM_WIN32
            StUTF16String nameUTF16(name);
            
            wchar * str = VMPI_strdup16( nameUTF16.c_str() );
            int result  = VMPI_putenv16( str );
        #else
            StUTF8String nameUTF8(name);
            
            char * str = VMPI_strdup( nameUTF8.c_str() );
            int result = VMPI_putenv( str );
        #endif

        /* note:
           do not free() after strdup() or the string ref will be lost
           so yeah it create a small memory leak
           need to investigate if AVM2 intern string can solve this
           or maybe create a special string pool to save such ref
           that we could clean before the VM exit
        */
        //VMPI_free(str);
        return result;
    }
开发者ID:Adime,项目名称:redtamarin,代码行数:31,代码来源:CStdlibClass.cpp


示例10: 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


示例11: initnamex

Atom Stubs::do_abc_callpropx(MethodFrame* f, const Multiname* name, Atom index,
                             int argc, Atom* args) {
  Multiname tempname;
  initnamex(core(f), name, index, &tempname);
  Toplevel* t = toplevel(f);
  return t->callproperty(args[0], &tempname, argc - 1, args,
                         toVTable(t, args[0]));
}
开发者ID:AdiKo,项目名称:avmplus,代码行数:8,代码来源:hm-stubs.cpp


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


示例13: 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


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


示例15: callProperty

 // this = argv[0] (ignored)
 // arg1 = argv[1]
 // argN = argv[argc]
 Atom ScriptObject::callProperty(const Multiname* multiname, int argc, Atom* argv)
 {
     Toplevel* toplevel = this->toplevel();
     Atom method = getMultinameProperty(multiname);
     if (!AvmCore::isObject(method))
         toplevel->throwTypeError(kCallOfNonFunctionError, core()->toErrorString(multiname));
     argv[0] = atom(); // replace receiver
     return toplevel->op_call(method, argc, argv);
 }
开发者ID:bsdf,项目名称:trx,代码行数:12,代码来源:ScriptObject.cpp


示例16: nameUTF8

    /*static*/ ChostentObject* CNetdbClass::gethostbyname(ScriptObject* self, Stringp name)
    {
        AvmCore *core = self->core();
        Toplevel* toplevel = self->toplevel();

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

        struct hostent *he;
        StUTF8String nameUTF8(name);

        he = VMPI_gethostbyname( nameUTF8.c_str() );

        if( he )
        {
            ShellToplevel* shelltop = (ShellToplevel*)self->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() );                

                //addrlist->setUintProperty( count++, core->newStringUTF8( inet_ntoa(in) )->atom() );
            }
            ho->set_h_addr_list( addrlist );

            return ho;
        }

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


示例17: read

	Stringp FileClass::read(Stringp filename)
	{
		Toplevel* toplevel = this->toplevel();
		AvmCore* core = this->core();

		if (!filename) {
			toplevel->throwArgumentError(kNullArgumentError, "filename");
		}
		StUTF8String filenameUTF8(filename);
		File* fp = Platform::GetInstance()->createFile();
		if(!fp || !fp->open(filenameUTF8.c_str(), File::OPEN_READ))
		{
			if(fp)
			{
				Platform::GetInstance()->destroyFile(fp);
			}

			toplevel->throwError(kFileOpenError, filename);
		}

		int64_t fileSize = fp->size();
		if(fileSize >= (int64_t)INT32_T_MAX) //File APIs cannot handle files > 2GB
		{
			toplevel->throwRangeError(kOutOfRangeError, filename);
		}

		int len = (int)fileSize;

		MMgc::GC::AllocaAutoPtr _c;
		union {
			uint8_t* c;
			wchar* c_w;
		};
		c = (uint8_t*)VMPI_alloca(core, _c, len+1);

		len = (int)fp->read(c, len); //need to force since the string creation functions expect an int
		c[len] = 0;
		
		fp->close();
		Platform::GetInstance()->destroyFile(fp);

		if (len >= 3)
		{
			// UTF8 BOM
			if ((c[0] == 0xef) && (c[1] == 0xbb) && (c[2] == 0xbf))
			{
				return core->newStringUTF8((const char*)c + 3, len - 3);
			}
			else if ((c[0] == 0xfe) && (c[1] == 0xff))
			{
				//UTF-16 big endian
				c += 2;
				len = (len - 2) >> 1;
				return core->newStringEndianUTF16(/*littleEndian*/false, c_w, len);
			}
			else if ((c[0] == 0xff) && (c[1] == 0xfe))
开发者ID:Jeffxz,项目名称:nodeas,代码行数:56,代码来源:FileClass.cpp


示例18: 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);
 }
开发者ID:AdiKo,项目名称:avmplus,代码行数:13,代码来源:ClassClosure.cpp


示例19: if

    /*static*/ int CSysSelectClass::select(ScriptObject* self, int nfds, Cfd_setObject* readfds, Cfd_setObject* writefds, Cfd_setObject* errorfds, CtimevalObject* timeout)
    {
        Toplevel* toplevel = self->toplevel();

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

		struct timeval tv;
    	tv = timeout->toStruct();

        int result = -1;
        
        if( !readfds && !writefds && !errorfds )
        {
        	result = VMPI_select( nfds, NULL, NULL, NULL, &tv );
        }
        else if( !writefds && !errorfds )
        {
        	result = VMPI_select( nfds, &readfds->fds, NULL, NULL, &tv );
        }
        else if( !errorfds )
        {
        	result = VMPI_select( nfds, &readfds->fds, &writefds->fds, NULL, &tv );
        }
        else if( !writefds )
        {
        	result = VMPI_select( nfds, &readfds->fds, NULL, &errorfds->fds, &tv );
        }
        else if( !readfds )
        {
        	result = VMPI_select( nfds, NULL, &writefds->fds, &errorfds->fds, &tv );
        }
        else if( !readfds && !writefds )
        {
        	result = VMPI_select( nfds, NULL, NULL, &errorfds->fds, &tv );
        }
        else if( !readfds && !errorfds )
        {
        	result = VMPI_select( nfds, NULL, &writefds->fds, NULL, &tv );
        }
        else
        {
            result = VMPI_select( nfds, &readfds->fds, &writefds->fds, &errorfds->fds, &tv );
        }


        if( result != -1 )
        {
            timeout->fromStruct( tv );
        }

        return result;
    }
开发者ID:Adime,项目名称:redtamarin,代码行数:55,代码来源:CSysSelectClass.cpp


示例20: read

    Stringp FileClass::read(Stringp filename)
    {
        Toplevel* toplevel = this->toplevel();
        AvmCore* core = this->core();

        if (!filename) {
            toplevel->throwArgumentError(kNullArgumentError, "filename");
        }
        StUTF8String filenameUTF8(filename);
        File* fp = Platform::GetInstance()->createFile();
        if(!fp || !fp->open(filenameUTF8.c_str(), File::OPEN_READ))
        {
            if(fp)
            {
                Platform::GetInstance()->destroyFile(fp);
            }

            toplevel->throwError(kFileOpenError, filename);
        }

        int64_t fileSize = fp->size();
        if(fileSize >= (int64_t)INT32_T_MAX) //File APIs cannot handle files > 2GB
        {
            toplevel->throwRangeError(kOutOfRangeError, filename);
        }

        int len = (int)fileSize;

        // Avoid VMPI_alloca - the buffer can be large and the memory is non-pointer-containing,
        // but the GC will scan it conservatively.
        uint8_t* c = (uint8_t*)core->gc->Alloc(len+1);
        
        len = (int)fp->read(c, len); //need to force since the string creation functions expect an int
        c[len] = 0;

        fp->close();
        Platform::GetInstance()->destroyFile(fp);

        Stringp ret = NULL;

        if (len >= 3)
        {
            // UTF8 BOM
            if ((c[0] == 0xef) && (c[1] == 0xbb) && (c[2] == 0xbf))
            {
                ret = core->newStringUTF8((const char*)c + 3, len - 3);
            }
            else if ((c[0] == 0xfe) && (c[1] == 0xff))
            {
                //UTF-16 big endian
                c += 2;
                len = (len - 2) >> 1;
                ret = core->newStringEndianUTF16(/*littleEndian*/false, (wchar*)(void*)c, len);
            }
            else if ((c[0] == 0xff) && (c[1] == 0xfe))
开发者ID:bsdf,项目名称:AVMPLUS_MAC,代码行数:55,代码来源:FileClass.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TopoDS_Edge类代码示例发布时间:2022-05-31
下一篇:
C++ TopicPrx类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap