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


C++ Toplevel::throwArgumentError方法代码示例

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


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

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

示例2:

    /*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

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

示例4:

    /*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

示例5: memcpy

    /*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

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

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

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

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

示例10:

    /*static*/ void CSysSelectClass::_avm_FD_ZERO(ScriptObject* self, Cfd_setObject* fdsetp)
    {
        Toplevel* toplevel = self->toplevel();

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

        VMPI_FD_ZERO( &fdsetp->fds );
    }
开发者ID:Adime,项目名称:redtamarin,代码行数:11,代码来源:CSysSelectClass.cpp

示例11: return

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

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

        return (double)VMPI_telldir( dirp->read() );
    }
开发者ID:Adime,项目名称:redtamarin,代码行数:11,代码来源:CDirentClass.cpp

示例12: VMPI_dirfd

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

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

        return VMPI_dirfd( dirp->read() );
    }
开发者ID:Adime,项目名称:redtamarin,代码行数:11,代码来源:CDirentClass.cpp

示例13: VMPI_mkstemp

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

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

        StUTF8String templateUTF8(templ);
        return VMPI_mkstemp( (char*)templateUTF8.c_str() );
    }
开发者ID:Adime,项目名称:redtamarin,代码行数:12,代码来源:CStdlibClass.cpp

示例14: VMPI_atol

    /*static*/ double CStdlibClass::atol(ScriptObject* self, Stringp str)
    {
        Toplevel* toplevel = self->toplevel();

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

        StUTF8String strUTF8(str);

        return VMPI_atol( strUTF8.c_str() );
    }
开发者ID:Adime,项目名称:redtamarin,代码行数:12,代码来源:CStdlibClass.cpp

示例15: VMPI_mblen

    /*static*/ int CStdlibClass::mblen(ScriptObject* self, Stringp s, int i)
    {
        Toplevel* toplevel = self->toplevel();

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

        StUTF8String sUTF8(s);
        return VMPI_mblen( sUTF8.c_str(), i );
    }
开发者ID:Adime,项目名称:redtamarin,代码行数:12,代码来源:CStdlibClass.cpp


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