Пример #1
0
BBString *bbStringFromUTF8String( const char *p ){
	int c,n;
	short *d,*q;
	BBString *str;

	if( !p ) return &bbEmptyString;
	
	n=strlen(p);
	d=(short*)malloc( n*2 );
	q=d;
	
	while( c=*p++ & 0xff ){
		if( c<0x80 ){
			*q++=c;
		}else{
			int d=*p++ & 0x3f;
			if( c<0xe0 ){
				*q++=((c&31)<<6) | d;
			}else{
				int e=*p++ & 0x3f;
				if( c<0xf0 ){
					*q++=((c&15)<<12) | (d<<6) | e;
				}else{
					int f=*p++ & 0x3f;
					int v=((c&7)<<18) | (d<<12) | (e<<6) | f;
					if( v & 0xffff0000 ) bbExThrowCString( "Unicode character out of UCS-2 range" );
					*q++=v;
				}
			}
		}
	}
	str=bbStringFromShorts( d,q-d );
	free( d );
	return str;
}
Пример #2
0
/* Internal
  Places the offset of an instance variable for a class into the global list of glue info
  An exception is thrown if you pass a NULL pointer for the class
*/
void p_lugi_register_field(int offset, int type, BBString *name, BBClass *clas) {
    if ( clas == NULL )
        bbExThrowCString(ERRORSTR("@lugi_register_field: Cannot pass Null BBClass for field."));
    glueinfo_t *info;
    char *cname = bbStringToCString(name);

    info = lugi_g_infohead;
    while (info != NULL) {
        if ( info->type == FIELDTYPE && info->clas == clas &&
                strcmp(cname, info->name) == 0 && info->data.field.offset == offset &&
                info->data.field.type == type ) {
            // then
            bbMemFree(cname);
            return;
        }

        info = info->next;
    }


    info = (glueinfo_t*)bbMemAlloc(sizeof(glueinfo_t));
    info->type = FIELDTYPE;
    info->data.field.offset = static_cast<ptrdiff_t>(offset);
    info->data.field.type = static_cast<fieldtype_e>(type);
    info->clas = clas;
    info->name = cname;
    info->next = lugi_g_infohead;
    lugi_g_infohead = info;
}
Пример #3
0
void bmx_stringbuffer_append_utf8string(struct MaxStringBuffer * buf, const char * chars) {
    int length = strlen(chars);
    if (length > 0) {
        int count = 0;

        bmx_stringbuffer_resize(buf, buf->count + length);

        int c;
        char * p = chars;
        BBChar * b = buf->buffer + buf->count;

        while( c=*p++ & 0xff ) {
            if( c<0x80 ) {
                *b++=c;
            } else {
                int d=*p++ & 0x3f;
                if( c<0xe0 ) {
                    *b++=((c&31)<<6) | d;
                } else {
                    int e=*p++ & 0x3f;
                    if( c<0xf0 ) {
                        *b++=((c&15)<<12) | (d<<6) | e;
                    } else {
                        int f=*p++ & 0x3f;
                        int v=((c&7)<<18) | (d<<12) | (e<<6) | f;
                        if( v & 0xffff0000 ) bbExThrowCString( "Unicode character out of UCS-2 range" );
                        *b++=v;
                    }
                }
            }
            count++;
        }

        buf->count += count;
    }
}
Пример #4
0
void bbObjectReserved(){
	bbExThrowCString( "Illegal call to reserved method" );
}
Пример #5
0
void bbCAssertEx() {
    bbExThrowCString( "C Assert failed" );
}
static void gcError( void *p,const char *msg ){
	printf( "GC ERROR: %s, object=$%p\n",msg,p );
	fflush( stdout );	
	bbExThrowCString( msg );
}
Пример #7
0
static _stdcall long _wndProc( HWND hwnd,UINT msg,WPARAM wp,LPARAM lp ){

	static HWND _fullScreen;

	BBGLContext *c;
	for( c=_contexts;c && c->hwnd!=hwnd;c=c->succ ){}
	if( !c ){
		return _bbusew ? DefWindowProcW( hwnd,msg,wp,lp ) : DefWindowProc( hwnd,msg,wp,lp );
	}

	bbSystemEmitOSEvent( hwnd,msg,wp,lp,&bbNullObject );

	switch( msg ){
	case WM_CLOSE:
		return 0;
	case WM_SYSCOMMAND:
		if (wp==SC_SCREENSAVE) return 1;
		if (wp==SC_MONITORPOWER) return 1;
		break;
	case WM_SYSKEYDOWN:
		if( wp!=VK_F4 ) return 0;
		break;
	case WM_SETFOCUS:
		if( c && c->mode==MODE_DISPLAY && hwnd!=_fullScreen ){
			DEVMODE dm;
			int swapInt=0;
			memset( &dm,0,sizeof(dm) );
			dm.dmSize=sizeof(dm);
			dm.dmPelsWidth=c->width;
			dm.dmPelsHeight=c->height;
			dm.dmBitsPerPel=c->depth;
			dm.dmFields=DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL;
			if( c->hertz ){
				dm.dmDisplayFrequency=c->hertz;
				dm.dmFields|=DM_DISPLAYFREQUENCY;
				swapInt=1;
			}
			if( ChangeDisplaySettings( &dm,CDS_FULLSCREEN )==DISP_CHANGE_SUCCESSFUL ){
				_fullScreen=hwnd;
			}else if( dm.dmFields & DM_DISPLAYFREQUENCY ){
				dm.dmDisplayFrequency=0;
				dm.dmFields&=~DM_DISPLAYFREQUENCY;
				if( ChangeDisplaySettings( &dm,CDS_FULLSCREEN )==DISP_CHANGE_SUCCESSFUL ){
					_fullScreen=hwnd;
					swapInt=0;
				}
			}

			if( !_fullScreen ) bbExThrowCString( "GLGraphicsDriver failed to set display mode" );
			
			_setSwapInterval( swapInt );
		}
		return 0;
	case WM_DESTROY:
	case WM_KILLFOCUS:
		if( hwnd==_fullScreen ){
			ChangeDisplaySettings( 0,CDS_FULLSCREEN );
			ShowWindow( hwnd,SW_MINIMIZE );
			_setSwapInterval( 0 );
			_fullScreen=0;
		}
		return 0;
	case WM_PAINT:
		ValidateRect( hwnd,0 );
		return 0;
	case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MBUTTONDOWN:
		if( !_fullScreen ) SetCapture( hwnd );
		return 0;
	case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MBUTTONUP:
		if( !_fullScreen ) ReleaseCapture();
		return 0;
	}
	return _bbusew ? DefWindowProcW( hwnd,msg,wp,lp ) : DefWindowProc( hwnd,msg,wp,lp );
}