コード例 #1
0
ファイル: sys_bmx.cpp プロジェクト: Chaduke/bah.mod
void TCOD_sys_set_custom_font(const char *fontFile, int nbcw, int nbch, int flags) {
	_bah_libtcod_TCODSystem__SetCustomFont(bbStringFromCString(fontFile), flags, nbcw, nbch);
	if (has_startup && !(flags & TCOD_FONT_LAYOUT_TCOD)) {
		// apply standard ascii mapping
		for (int i=0; i < TCOD_max_font_chars; i++ ) TCOD_font_chars[i].ascii_to_tcod=i;
	}

}
コード例 #2
0
ファイル: glue.cpp プロジェクト: Chaduke/bah.mod
BBString * bmx_gme_open_file( MaxMusicEmu * emu, BBString * path, long sample_rate) {

	char *p = bbStringToCString( path );
	BBString * ret = bbStringFromCString(gme_open_file(p, &emu->emu, sample_rate));
	bbMemFree( p );
	
	return ret;
}
コード例 #3
0
ファイル: stdc.c プロジェクト: GWRon/pub.mod-vanilla
BBString *readdir_( int dir ){
	if( _bbusew ){
		struct _wdirent *t=_wreaddir( (_WDIR*)dir );
		return t ? bbStringFromWString( t->d_name ) : &bbEmptyString;
	}
	struct dirent *t=readdir( (DIR*)dir );
	return t ? bbStringFromCString( t->d_name ) : &bbEmptyString;
}
コード例 #4
0
ファイル: stdc.c プロジェクト: GWRon/pub.mod-vanilla
BBString *getcwd_(){
	if( _bbusew ){
		wchar_t buf[MAX_PATH];
		_wgetcwd( buf,MAX_PATH );
		return bbStringFromWString( buf );
	}else{
		char buf[MAX_PATH];
		_getcwd( buf,MAX_PATH );
		return bbStringFromCString( buf );
	}
	return &bbEmptyString;
}
コード例 #5
0
ファイル: system.win32.c プロジェクト: STLVNUB/blitzmax
BBString *bbSystemRequestDir( BBString *text,BBString *dir ){

	BBString *str=&bbEmptyString;

	if( _usew ){
		LPMALLOC shm;
		ITEMIDLIST *idlist;
		BROWSEINFOW bi={0};
		wchar_t buf[MAX_PATH],*p;

		GetFullPathNameW( bbTmpWString(dir),MAX_PATH,buf,&p );
		
		bi.hwndOwner=GetActiveWindow();
		bi.lpszTitle=bbTmpWString( text );
		bi.ulFlags=BIF_RETURNONLYFSDIRS|BIF_NEWDIALOGSTYLE;
		bi.lpfn=BrowseForFolderCallbackW;
		bi.lParam=(LPARAM)buf;
		
		beginPanel();
		idlist=SHBrowseForFolderW(&bi);
		endPanel();
		
		if( idlist ){
			SHGetPathFromIDListW( idlist,buf );
			str=bbStringFromWString( buf );
			//SHFree( idlist );	//?!?	
		}
	} else {
		LPMALLOC shm;
		ITEMIDLIST *idlist;
		BROWSEINFOA bi={0};
		char buf[MAX_PATH],*p;
		
		GetFullPathNameA( bbTmpCString(dir),MAX_PATH,buf,&p );

		bi.hwndOwner=GetActiveWindow();
		bi.lpszTitle=bbTmpCString( text );
		bi.ulFlags=BIF_RETURNONLYFSDIRS|BIF_NEWDIALOGSTYLE;
		bi.lpfn=BrowseForFolderCallbackA;
		bi.lParam=(LPARAM)buf;
		
		beginPanel();
		idlist=SHBrowseForFolderA(&bi);
		endPanel();
		
		if( idlist ){
			SHGetPathFromIDListA( idlist,buf );
			str=bbStringFromCString( buf );
			//SHFree( idlist );	//?!?	
		}
	}
	return str;
}
コード例 #6
0
ファイル: glue.cpp プロジェクト: Chaduke/bah.mod
BBString * _formatDate(BBString * format, int y, int m, int d, int hh, int mm, int ss) {

	char buffer [1024];
	tm stm;
	char * p = bbStringToCString(format);

	stm.tm_year = y - 1900;
	stm.tm_mon = m - 1;
	stm.tm_mday = d;
	stm.tm_hour = hh;
	stm.tm_min = mm;
	stm.tm_sec = ss;

	strftime (buffer, 1024, p, &stm);
	
	bbMemFree(p);
	
	return bbStringFromCString(buffer);
}
コード例 #7
0
ファイル: glue.cpp プロジェクト: Chaduke/bah.mod
BBString * bmx_profanityfilter_FilterProfanity(ProfanityFilter * filter, BBString * text, int f, int * ret) {
	char * t = bbStringToCString(text);

	char * output = 0;
	if (filter) {
		output = (char *) malloc(strlen(t) + 1);
	}
	
	*ret = filter->FilterProfanity(t, output, static_cast<bool>(f));
	
	bbMemFree(t);
	
	BBString * o = 0;
	if (output) {
		o = bbStringFromCString(output);
		free(output);
	} else {
		o = text;
	}
	
	return o;
}
コード例 #8
0
ファイル: rarstream.cpp プロジェクト: BlitzMaxModules/wx.mod
bool wxRarInputStream::OpenNextFile()
{
	RARHeaderData hd;

    int nError;

    if ((nError = RARReadHeader(m_hRar, &hd)) != 0)
    {
        //wxMessageBox(wxString::Format(_T("AHH  %ld"), nError));
		if (nError != ERAR_END_ARCHIVE) {
			wxLogSysError(wxString::Format(_("Error : %ld"), nError));
		}
        return false;
	}

	m_Info.szName = wxStringFromBBString(bbStringFromCString(hd.FileName));
	m_Info.szComment = hd.CmtBuf;
	m_Info.dwUncompressedSize = hd.UnpSize;
	m_Info.dwCompressedSize = hd.PackSize;
	m_Info.dwTime = hd.FileTime;
	
	return true;
}
コード例 #9
0
ファイル: glue.cpp プロジェクト: Chaduke/bah.mod
int bmx_libwebsockets_callback(struct libwebsocket_context * context, struct libwebsocket * wsi, enum libwebsocket_callback_reasons reason, void * user, void * in, size_t len, struct libwebsocket_protocols * protocol) {
	BBString * name = bbStringFromCString(protocol->name);
	struct per_session_data_obj *maxObj = (struct per_session_data_obj *)user;
	
	if (reason == LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION) {
		maxObj = 0;
	}

	// on a new connection, we should initialise the object
	if (maxObj && ((reason == LWS_CALLBACK_ESTABLISHED) || (!maxObj->handle))) {
		if (maxObj->handle && maxObj->handle != &bbNullObject) {
			BBRELEASE(maxObj->handle);
		}

		// call the object creation function
		maxObj->handle = CB_PREF(bah_libwebsockets_TLWSProtocol__objectCallback)(name);

		// prevent early GC
		if (maxObj->handle != &bbNullObject) {
			BBRETAIN(maxObj->handle);
		}
	}
	
	int result = CB_PREF(bah_libwebsockets_TLWSProtocol__callback)(name, context, wsi, reason, (maxObj) ? maxObj->handle : &bbNullObject, in, len);

	// release on close of connection
	if (reason == LWS_CALLBACK_CLOSED) {
		if (maxObj && maxObj->handle) {
			if (maxObj->handle != &bbNullObject) {
				BBRELEASE(maxObj->handle);
			}
		}
	}
	
	return result;
}
コード例 #10
0
ファイル: blitz_string.c プロジェクト: kfprimm/brl.mod
BBString *bbStringFromDouble( double n ){
	char buf[64];
	sprintf( buf,"%#.17lg",n );
	return bbStringFromCString(buf);
}
コード例 #11
0
ファイル: blitz_string.c プロジェクト: kfprimm/brl.mod
BBString *bbStringFromFloat( float n ){
	char buf[64];
	sprintf( buf,"%#.9g",n );
	return bbStringFromCString(buf);
}
コード例 #12
0
ファイル: lgcore.cpp プロジェクト: EdibleGhost/lugi.mod
/* table[key] = value OR table.key = value */
static int lugi_newindex_object(lua_State *state) {
    if (lua_type(state, 2) == LUA_TSTRING) {

        BBObject *obj = lua_tobmaxobject(state, 1);
        BBClass *clas = obj->clas;

        /* while class != NULL */
        do {
            /* get class VMT */
            lua_pushlightuserdata(state, clas);
            lua_gettable(state, LUA_REGISTRYINDEX);

            if ( lua_type(state, -1) == LUA_TTABLE ) /* there's a lookup table for the class.. */
            {
                lua_pushvalue(state, 2);
                lua_rawget(state, -2);

                if (lua_type(state, -1) == LUA_TUSERDATA) {		/* getting the value of a field */
                    fieldinfo_t *info = (fieldinfo_t*)lua_touserdata(state, -1);;
                    bmx_field *field = (bmx_field*)((char*)obj+info->offset);

                    clas = NULL;

                    switch (info->type) /* set the value of a field */
                    {
                    case BYTEFIELD:
                        if (lua_type(state, 3) == LUA_TBOOLEAN) {
                            field->byte_value = (unsigned char)lua_toboolean(state, 3);
                        }
                        else {
                            field->byte_value = (unsigned char)lua_tointeger(state, 3);
                        }
                        break;

                    case SHORTFIELD:
                        if (lua_type(state, 3) == LUA_TBOOLEAN) {
                            field->short_value = (unsigned short)lua_toboolean(state, 3);
                        }
                        else {
                            field->short_value = (unsigned short)lua_tointeger(state, 3);
                        }
                        break;

                    case INTFIELD:
                        if (lua_type(state, 3) == LUA_TBOOLEAN) {
                            field->int_value = lua_toboolean(state, 3);
                        }
                        else {
                            field->int_value = lua_tointeger(state, 3);
                        }
                        break;

                    case FLOATFIELD:
                        field->float_value = (float)lua_tonumber(state, 3);
                        break;

                    case DOUBLEFIELD:
                        field->double_value = lua_tonumber(state, 3);
                        break;

                    case LONGFIELD:
                        if (lua_type(state, 3) == LUA_TBOOLEAN) {
                            field->long_value = lua_toboolean(state, 3);
                        }
                        else {
                            field->long_value = lua_tointeger(state, 3);
                        }
                        break;

                    case STRINGFIELD: {
                        const char *strbuf = lua_tostring(state, 3);
                        BBString *last = field->string_value;
                        BBRETAIN((BBObject*)(field->string_value = bbStringFromCString(strbuf)));
                        BBRELEASE((BBObject*)last);
                    }
                    break;

                    case ARRAYFIELD: {
                        BBArray *last = field->arr_value;
                        BBRETAIN((BBObject*)(field->arr_value = lua_tobmaxarray(state, 3)));
                        BBRELEASE((BBObject*)last);
                    }
                    break;

                    case OBJECTFIELD: {
                        BBObject *last = field->obj_value;
                        BBRETAIN(field->obj_value = lua_tobmaxobject(state, 3));
                        BBRELEASE(last);
                    }
                    break;

                    default:
                        return luaL_error(state, ERRORSTR("@lugi_newindex_object: Unrecognized field type (%d)."), info->type);
                        break;
                    } /* set value based on type */
                    return 0;
                }
                else {
                    lua_pop(state, 1);
                }
            } /* VMT found */

            lua_pop(state, 1);

            clas = clas->super; /* iterate to a superclass if nothing is found in the class */

        } while (clas != NULL);
    } /* key is string */

#if BMX_TABLE_SUPPORT < 1
    const char *objtype="null";
    if (lua_isbmaxobject(state, 1))
        objtype = lua_tobmaxobject(state, 1)->clas->debug_scope->name;

    if ((LUA_TNUMBER|LUA_TSTRING)&lua_type(state,2))
        return luaL_error(state, ERRORSTR("@lugi_newindex_object: Index (%s) for object<%s> is not a valid field or method."), lua_tostring(state, 2), objtype);
    else
        return luaL_error(state, ERRORSTR("@lugi_newindex_object: Index for object<%s> is not a valid field or method."), objtype);
#else
    /* prior table behavior for BMax objects - disabled by default */
    lua_settop(state, 3);

    lua_getfenv(state, 1);
    lua_insert(state, 2);
    lua_settable(state, 2);

    return 0;
#endif
}
コード例 #13
0
ファイル: lgcore.cpp プロジェクト: EdibleGhost/lugi.mod
/* Converts a Lua table to a BMax array - the type of the array is determined by the first value in the table (at index 1) */
BBArray *lua_tobmaxarray(lua_State *state, int index) {
    switch (lua_type(state, index))
    {
    case LUA_TNONE:
        luaL_error(state, ERRORSTR("@lua_tobmaxarray: Invalid index (%d)"), index);
        return &bbEmptyArray;

    case LUA_TNIL:
        return &bbEmptyArray;

    case LUA_TUSERDATA:
        if ( lua_isbmaxobject(state, index) ) {
            BBObject *obj = lua_tobmaxobject(state, index);
            if ( obj->clas == &bbArrayClass ) {
                return (BBArray*)obj;
            }
            else {
                luaL_error(state, ERRORSTR("@lua_tobmaxarray: Value at index (%d) is not an array."), index);
                return &bbEmptyArray;
            }
        }

    case LUA_TTABLE: /* code below */
        break;

    default:
        if (lua_type(state, index) != LUA_TTABLE) {
            luaL_error(state, ERRORSTR("@lua_tobmaxarray: Value at index (%d) is not a table."), index);
            return &bbEmptyArray;
        }
    }

    /* make the index absolute, since we're now dealing with more than one value on the stack */
    if (index < 0 && index > LUA_REGISTRYINDEX)
        index = lua_gettop(state)+(index+1);

    /* the index into the array */
    size_t table_index;
    BBArray *arr = NULL;
    size_t len = lua_objlen(state, index);

    if ( len == 0 )
        return &bbEmptyArray;

    /* get the first item of the table */
    lua_pushinteger(state, 1);
    lua_gettable(state, index);

    /* starting at index 2 when iterating */
    table_index = 2;

    /* determine what type of array to create based on the first value in the table (at index 0) */
    switch (lua_type(state, -1)) {
    case LUA_TNUMBER: {		/* array of doubles */
        double *p;

        arr = bbArrayNew1D("d", len);
        p = (double*)BBARRAYDATA(arr, arr->dims);

        *p++ = lua_tonumber(state, -1);
        lua_pop(state, 1);

        for (; table_index <= len; ++table_index) {
            lua_pushinteger(state, table_index);
            lua_gettable(state, index);

            *p++ = lua_tonumber(state, -1);

            lua_pop(state, 1);
        }

        return arr;
    }

    case LUA_TBOOLEAN: {		/* array of integers */
        int *p;

        arr = bbArrayNew1D("i", len);
        p = (int*)BBARRAYDATA(arr, arr->dims);

        *p++ = lua_toboolean(state, -1);
        lua_pop(state, 1);

        for (; table_index <= len; ++table_index) {
            lua_pushinteger(state, table_index);
            lua_gettable(state, index);

            *p++ = lua_toboolean(state, -1);

            lua_pop(state, 1);
        }

        return arr;
    }

    case LUA_TSTRING: {		/* array of strings */
        BBString **p;

        arr = bbArrayNew1D("$", len);
        p = (BBString**)BBARRAYDATA(arr, arr->dims);

        *p = bbStringFromCString(lua_tostring(state, -1));
        BBRETAIN((BBObject*)*p++);
        lua_pop(state, 1);

        for (; table_index <= len; ++table_index) {
            lua_pushinteger(state, table_index);
            lua_gettable(state, index);

            *p = bbStringFromCString(lua_tostring(state, -1));
            BBRETAIN((BBObject*)*p++);

            lua_pop(state, 1);
        }

        return arr;
    }

    case LUA_TTABLE:		/* array of arrays (arrays inside of arrays do not have to be the same type) */
    case LUA_TUSERDATA:
    {
        BBObject **p;

        arr = bbArrayNew1D(":Object", len);
        p = (BBObject**)BBARRAYDATA(arr, arr->dims);

        *p = lua_tobmaxobject(state, -1);
        BBRETAIN(*p++);
        lua_pop(state, 1);

        for (; table_index <= len; ++table_index) {
            lua_pushinteger(state, table_index);
            lua_gettable(state, index);

            *p = lua_tobmaxobject(state, -1);
            BBRETAIN(*p++);

            lua_pop(state, 1);
        }

        return arr;
    }

    default:
        luaL_error(state, ERRORSTR("@lua_tobmaxarray: Arrays of type %s are not unsupported"), lua_typename(state, lua_type(state, -1)));
        return &bbEmptyArray;
    } /* switch lua type */

    return arr;
} /* lua_tobmaxarray */
コード例 #14
0
ファイル: glue.cpp プロジェクト: Chaduke/bah.mod
BBString * bmx_gme_trackinfo_copyright(gme_info_t * info) {
	return bbStringFromCString(info->copyright);
}
コード例 #15
0
ファイル: blitz_object.c プロジェクト: juankprada/brl.mod
BBString *bbObjectToString( BBObject *o ){
	char buf[32];
	sprintf( buf,"%p",o );
	return bbStringFromCString( buf );
}
コード例 #16
0
ファイル: sys_bmx.cpp プロジェクト: Chaduke/bah.mod
void TCOD_sys_set_window_title(const char *title) {
	bbAppTitle = bbStringFromCString(title);
}
コード例 #17
0
ファイル: glue.cpp プロジェクト: Chaduke/bah.mod
BBString * bmx_gme_seek(MaxMusicEmu * emu, long msec) {
	return bbStringFromCString(gme_seek(emu->emu, msec));
}
コード例 #18
0
ファイル: glue.cpp プロジェクト: Chaduke/bah.mod
BBString * bmx_gme_trackinfo_game(gme_info_t * info) {
	return bbStringFromCString(info->game);
}
コード例 #19
0
ファイル: glue.cpp プロジェクト: Chaduke/bah.mod
BBString * bmx_gme_play(MaxMusicEmu * emu, long count, short * out) {
	return bbStringFromCString(gme_play(emu->emu, count, out));
}
コード例 #20
0
ファイル: glue.cpp プロジェクト: Chaduke/bah.mod
BBString * bmx_gme_start_track(MaxMusicEmu * emu, int index) {
	return bbStringFromCString(gme_start_track(emu->emu, index));
}
コード例 #21
0
ファイル: glue.cpp プロジェクト: Chaduke/bah.mod
BBString * bmx_gme_trackinfo_song(gme_info_t * info) {
	return bbStringFromCString(info->song);
}
コード例 #22
0
ファイル: glue.cpp プロジェクト: Chaduke/bah.mod
BBString * bmx_gme_trackinfo_dumper(gme_info_t * info) {
	return bbStringFromCString(info->dumper);
}
コード例 #23
0
ファイル: glue.cpp プロジェクト: Chaduke/bah.mod
BBString * bmx_gme_trackinfo_comment(gme_info_t * info) {
	return bbStringFromCString(info->comment);
}
コード例 #24
0
ファイル: glue.cpp プロジェクト: GWRon/wx.mod
BBString * bmx_wxserialportdcs_getsettings(wxSerialPort_DCS * dcs) {
	return bbStringFromCString(dcs->GetSettings());
}
コード例 #25
0
ファイル: glue.cpp プロジェクト: Chaduke/bah.mod
BBString * bmx_gme_get_trackinfo(MaxMusicEmu * emu, gme_info_t ** info, int track) {
	return bbStringFromCString(gme_track_info(emu->emu, info, track));
}
コード例 #26
0
ファイル: glue.cpp プロジェクト: Chaduke/bah.mod
BBString * bmx_gme_trackinfo_system(gme_info_t * info) {
	return bbStringFromCString(info->system);
}
コード例 #27
0
ファイル: sys_bmx.cpp プロジェクト: Chaduke/bah.mod
void *TCOD_sys_load_image(const char *filename) {
	BBObject * obj = _bah_libtcod_TCODSystem__LoadImage(bbStringFromCString(filename));
	BBRETAIN(obj);
	return obj;
}
コード例 #28
0
ファイル: lgcore.cpp プロジェクト: EdibleGhost/lugi.mod
static int lugi_newindex_array(lua_State *state) {
    if (lua_isnumber(state, 2) == 1) {
        BBArray *arr = lua_tobmaxarray(state, 1);

        lua_Integer index = lua_tointeger(state, 2);
        if ( index < 0 || arr->scales[0] <= index ) {
            return luaL_error(state, ERRORSTR("@lugi_newindex_array: Attempt to index array failed: index (%d) out of bounds"), index);
        }

        switch (arr->type[0]) {
        case 'b':	/* byte */
            if ( lua_isnumber(state, 3) ) {
                ((BBBYTE*)BBARRAYDATA(arr, arr->dims))[index] = (BBBYTE)lua_tointeger(state, 3);
            }
            else {
                return luaL_error(state, ERRORSTR("@lugi_newindex_array: Cannot assign value with type %s to element of byte array"), lua_typename(state, lua_type(state, 3)));
            }
            break;

        case 's':	/* short */
            if ( lua_isnumber(state, 3) ) {
                ((BBSHORT*)BBARRAYDATA(arr, arr->dims))[index] = (BBSHORT)lua_tointeger(state, 3);
            }
            else {
                return luaL_error(state, ERRORSTR("@lugi_newindex_array: Cannot assign value with type %s to element of short array"), lua_typename(state, lua_type(state, 3)));
            }
            break;

        case 'i':	/* int */
            if ( lua_isnumber(state, 3) ) {
                ((BBINT*)BBARRAYDATA(arr, arr->dims))[index] = (BBINT)lua_tointeger(state, 3);
            }
            else {
                return luaL_error(state, ERRORSTR("@lugi_newindex_array: Cannot assign value with type %s to element of integer array"), lua_typename(state, lua_type(state, 3)));
            }
            break;

        case 'l':	/* long */
            if ( lua_isnumber(state, 3) ) {
                ((BBLONG*)BBARRAYDATA(arr, arr->dims))[index] = (BBLONG)lua_tointeger(state, 3);
            }
            else {
                return luaL_error(state, ERRORSTR("@lugi_newindex_array: Cannot assign value with type %s to element of long array"), lua_typename(state, lua_type(state, 3)));
            }
            break;

        case 'f':	/* float */
            if ( lua_isnumber(state, 3) ) {
                ((BBFLOAT*)BBARRAYDATA(arr, arr->dims))[index] = (BBFLOAT)lua_tonumber(state, 3);
            }
            else {
                return luaL_error(state, ERRORSTR("@lugi_newindex_array: Cannot assign value with type %s to element of short array"), lua_typename(state, lua_type(state, 3)));
            }
            break;

        case 'd':	/* double */
            if ( lua_isnumber(state, 3) ) {
                ((BBDOUBLE*)BBARRAYDATA(arr, arr->dims))[index] = (BBDOUBLE)lua_tonumber(state, 3);
            }
            else {
                return luaL_error(state, ERRORSTR("@lugi_newindex_array: Cannot assign value with type %s to element of short array"), lua_typename(state, lua_type(state, 3)));
            }
            break;

        case '$':	/* string */
        {
            BBString **data = ((BBString**)BBARRAYDATA(arr, arr->dims));
            if ( lua_isstring(state, 3) ) {
                BBString *newstring = bbStringFromCString(lua_tostring(state, 3));
                BBRETAIN((BBObject*)newstring);
                BBRELEASE((BBObject*)data[index]);
                data[index] = newstring;
            }
            else if ( lua_isnil(state, 3 ) ) {
                BBRELEASE((BBObject*)data[index]);
                data[index] = &bbEmptyString;
            }
            else {
                return luaL_error(state, ERRORSTR("@lugi_newindex_array: Cannot assign value with type %s to element of string array"), lua_typename(state, lua_type(state, 3)));
            }
        }
        break;

        case ':':	/* any type of object */
        {
            BBObject *value = lua_tobmaxobject(state, 3);
            BBClass *arrclas = NULL;

            {   /* search for the array element type's class */
                const char *arrtypename = arr->type+1;
                int numTypes = 0;
                int regidx = 0;
                BBClass **regtypes = bbObjectRegisteredTypes(&numTypes);

                for (; regidx < numTypes; ++regidx) {
                    if ( strcmp(regtypes[regidx]->debug_scope->name, arrtypename) == 0 ) {
                        arrclas = regtypes[regidx];
                        break;
                    }
                }
            }

            if ( arrclas == NULL ) {
                return luaL_error(state, ERRORSTR("@lugi_newindex_array: Undefined array type encountered: %s"), arr->type);
            }

            value = bbObjectDowncast(value, arrclas);

            BBObject **data = (BBObject**)BBARRAYDATA(arr, arr->dims);
            BBRETAIN(value);
            BBRELEASE(data[index]);
            data[index] = value;
        }
        break;

        case '[': {
            BBArray *value = lua_tobmaxarray(state, 3);
            if ( (BBObject*)value == &bbNullObject ) {
                value = &bbEmptyArray;
            }

            if ( value == &bbEmptyArray || strcmp(arr->type+2, value->type) == 0 ) {
                BBArray **data = (BBArray**)BBARRAYDATA(arr, arr->dims);
                BBRETAIN((BBObject*)value);
                BBRELEASE((BBObject*)data[index]);
                data[index] = value;
            }
            else {
                return luaL_error(state, ERRORSTR("@lugi_newindex_array: Cannot assign array value to an element of an array of a differing type"));
            }
        }
        break;

        default:
            return luaL_error(state, ERRORSTR("@lugi_newindex_array: Unsupported array element type: %s"), arr->type);
        }

        return 0;
    } /* key is a valid type of index for an array */

    return luaL_error(state, ERRORSTR("@lugi_newindex_array: Invalid type for an array index (%s), must be an integer or a string convertible to an integer"), lua_typename(state, lua_type(state, 2)));
}
コード例 #29
0
ファイル: glue.cpp プロジェクト: Chaduke/bah.mod
BBString * bmx_gme_open_data( MaxMusicEmu * emu, const void * data, long size, long sample_rate) {
	return bbStringFromCString(gme_open_data(data, size, &emu->emu, sample_rate));
}
コード例 #30
0
ファイル: glue.cpp プロジェクト: Chaduke/bah.mod
BBString * bmx_gme_trackinfo_author(gme_info_t * info) {
	return bbStringFromCString(info->author);
}