Merge: Extract sdl, mnit_display and mnit_input from mnit
authorJean Privat <jean@pryen.org>
Mon, 7 Apr 2014 17:37:47 +0000 (13:37 -0400)
committerJean Privat <jean@pryen.org>
Mon, 7 Apr 2014 17:37:47 +0000 (13:37 -0400)
This is the beginning of the division of mnitt into a portable application framework (paninit) and the game framework (gammit). For now, allows to write an SDL application without all of the portable part of mnit.

Also solves problems as noted in #236.

#193 will be fixed after the numerics are merged.

Pull-Request: #384
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>

20 files changed:
lib/curl/curl_c.nit.args [deleted file]
lib/curses/curses.nit.args [deleted file]
lib/gtk3_4/gtk3_4.nit.args [deleted file]
lib/gtk3_6/gtk3_6.nit.args [deleted file]
lib/json/jsonable.nit.args [deleted file]
lib/mnit/app.nit
lib/mnit/assets.nit
lib/mnit/opengles1.nit
lib/mnit_display.nit [moved from lib/mnit/display.nit with 98% similarity]
lib/mnit_input.nit [moved from lib/mnit/input_events.nit with 99% similarity]
lib/mnit_linux/linux_opengles1.nit
lib/mnit_linux/linux_opengles1.nit.args [deleted file]
lib/mnit_linux/sdl.nit.args [deleted file]
lib/realtime.nit.args [deleted file]
lib/sdl.nit [moved from lib/mnit_linux/sdl.nit with 56% similarity]
lib/sqlite3/sqlite3.nit.args [deleted file]
src/modelize_class.nit
tests/sav/mnit_display.res [new file with mode: 0644]
tests/sav/mnit_input.res [new file with mode: 0644]
tests/sav/sdl.res [new file with mode: 0644]

diff --git a/lib/curl/curl_c.nit.args b/lib/curl/curl_c.nit.args
deleted file mode 100644 (file)
index bfd2c46..0000000
+++ /dev/null
@@ -1 +0,0 @@
---cc-lib-name curl
diff --git a/lib/curses/curses.nit.args b/lib/curses/curses.nit.args
deleted file mode 100644 (file)
index 4d2244b..0000000
+++ /dev/null
@@ -1 +0,0 @@
---cc-lib-name curses
diff --git a/lib/gtk3_4/gtk3_4.nit.args b/lib/gtk3_4/gtk3_4.nit.args
deleted file mode 100644 (file)
index 9df1550..0000000
+++ /dev/null
@@ -1 +0,0 @@
---cc-lib-name gtk-3 --cc-lib-name gdk-3 --cc-lib-name atk-1.0 --cc-lib-name gio-2.0 --cc-lib-name pangocairo-1.0 --cc-lib-name gdk_pixbuf-2.0 --cc-lib-name cairo-gobject --cc-lib-name pango-1.0 --cc-lib-name cairo --cc-lib-name gobject-2.0 --cc-lib-name glib-2.0 --cc-header-path /usr/include/gtk-3.0 --cc-header-path /usr/include/atk-1.0 --cc-header-path /usr/include/at-spi2-atk/2.0 --cc-header-path /usr/include/pango-1.0 --cc-header-path /usr/include/gio-unix-2.0/ --cc-header-path /usr/include/cairo --cc-header-path /usr/include/gdk-pixbuf-2.0 --cc-header-path /usr/include/glib-2.0 --cc-header-path /usr/lib/x86_64-linux-gnu/glib-2.0/include --cc-header-path /usr/include/freetype2 --cc-header-path /usr/include/pixman-1 --cc-header-path /usr/include/libpng12  
diff --git a/lib/gtk3_6/gtk3_6.nit.args b/lib/gtk3_6/gtk3_6.nit.args
deleted file mode 100644 (file)
index 9df1550..0000000
+++ /dev/null
@@ -1 +0,0 @@
---cc-lib-name gtk-3 --cc-lib-name gdk-3 --cc-lib-name atk-1.0 --cc-lib-name gio-2.0 --cc-lib-name pangocairo-1.0 --cc-lib-name gdk_pixbuf-2.0 --cc-lib-name cairo-gobject --cc-lib-name pango-1.0 --cc-lib-name cairo --cc-lib-name gobject-2.0 --cc-lib-name glib-2.0 --cc-header-path /usr/include/gtk-3.0 --cc-header-path /usr/include/atk-1.0 --cc-header-path /usr/include/at-spi2-atk/2.0 --cc-header-path /usr/include/pango-1.0 --cc-header-path /usr/include/gio-unix-2.0/ --cc-header-path /usr/include/cairo --cc-header-path /usr/include/gdk-pixbuf-2.0 --cc-header-path /usr/include/glib-2.0 --cc-header-path /usr/lib/x86_64-linux-gnu/glib-2.0/include --cc-header-path /usr/include/freetype2 --cc-header-path /usr/include/pixman-1 --cc-header-path /usr/include/libpng12  
diff --git a/lib/json/jsonable.nit.args b/lib/json/jsonable.nit.args
deleted file mode 100644 (file)
index a21170f..0000000
+++ /dev/null
@@ -1 +0,0 @@
---cc-lib-name json
index 1e8ac63..4fb0fcf 100644 (file)
@@ -17,7 +17,7 @@
 # General Mnit application structure
 module app
 
-import display
+import mnit_display
 
 # An App instance serves as base to every Mnit projects.
 #
index bd23f0a..d538f03 100644 (file)
@@ -18,7 +18,7 @@
 module assets
 
 import app
-import display
+import mnit_display
 
 # General asset
 interface Asset
index 347613f..1f081d6 100644 (file)
@@ -15,9 +15,9 @@
 # limitations under the License.
 
 # OpenGL ES1 general support (most of it)
-module opengles1
+module opengles1 is pkgconfig("glesv1_cm", "x11", "egl")
 
-import display
+import mnit_display
 
 in "C header" `{
        #include <EGL/egl.h>
similarity index 98%
rename from lib/mnit/display.nit
rename to lib/mnit_display.nit
index 06a7572..26a4bde 100644 (file)
@@ -15,9 +15,9 @@
 # limitations under the License.
 
 # Defines abstract display classes
-module display
+module mnit_display
 
-import input_events
+import mnit_input
 
 # Any class with a size
 interface Sized
similarity index 99%
rename from lib/mnit/input_events.nit
rename to lib/mnit_input.nit
index 09db4c8..0536660 100644 (file)
@@ -16,7 +16,7 @@
 
 # Defines abstract classes for user and general inputs to the application.
 # Implemented independantly for each platforms and technologies.
-module input_events
+module mnit_input
 
 # Input to the App, propagated through `App::input`.
 interface InputEvent
index 00a037f..00a1175 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-module linux_opengles1 is
-       pkgconfig("glesv1_cm", "x11", "egl")
-       c_compiler_option(exec("sdl-config", "--cflags"))
-       c_linker_option(exec("sdl-config", "--libs"), "-lSDL_image -lSDL_ttf")
-end
+module linux_opengles1
 
 import mnit # for
 # import opengles1
diff --git a/lib/mnit_linux/linux_opengles1.nit.args b/lib/mnit_linux/linux_opengles1.nit.args
deleted file mode 100644 (file)
index 938ee9a..0000000
+++ /dev/null
@@ -1 +0,0 @@
---cc-lib-name EGL --cc-lib-name GLESv1_CM --cc-lib-name X11
diff --git a/lib/mnit_linux/sdl.nit.args b/lib/mnit_linux/sdl.nit.args
deleted file mode 100644 (file)
index 9536bdf..0000000
+++ /dev/null
@@ -1 +0,0 @@
---cc-lib-name SDL --cc-lib-name SDL_ttf --cc-lib-name SDL_image
diff --git a/lib/realtime.nit.args b/lib/realtime.nit.args
deleted file mode 100644 (file)
index f47f4ce..0000000
+++ /dev/null
@@ -1 +0,0 @@
---cc-lib-name rt
similarity index 56%
rename from lib/mnit_linux/sdl.nit
rename to lib/sdl.nit
index 527624a..0ac97b4 100644 (file)
 # SDL display support (used in Linux for windows and inputes only)
 module sdl is
        c_compiler_option(exec("sdl-config", "--cflags"))
-       c_linker_option(exec("sdl-config", "--libs"), "-lSDL_ttf")
+       c_linker_option(exec("sdl-config", "--libs"), "-lSDL_image -lSDL_ttf")
 end
 
-import mnit # for
-# import display
-# mport input_events
+import mnit_display
 
 in "C header" `{
-#include <unistd.h>
-#include <SDL/SDL.h>
-#include <SDL/SDL_syswm.h>
-#include <SDL/SDL_image.h>
-#include <SDL/SDL_ttf.h>
+       #include <unistd.h>
+       #include <SDL/SDL.h>
+       #include <SDL/SDL_syswm.h>
+       #include <SDL/SDL_image.h>
+       #include <SDL/SDL_ttf.h>
 `}
 
 # Represent a screen surface
-extern SDLDisplay in "C" `{SDL_Surface *`}
+extern class SDLDisplay `{SDL_Surface *`}
        super Display
 
        redef type I: SDLImage
 
        # Initialize a surface with width and height
-       new ( w, h: Int) is extern import enable_mouse_motion_events `{
+       new (w, h: Int) import enable_mouse_motion_events `{
                SDL_Init(SDL_INIT_VIDEO);
 
                if(TTF_Init()==-1) {
@@ -47,11 +45,11 @@ extern SDLDisplay in "C" `{SDL_Surface *`}
                        exit(2);
                }
 
-               SDL_Surface *self = SDL_SetVideoMode( w, h, 24, SDL_HWSURFACE );
+               SDL_Surface *self = SDL_SetVideoMode(w, h, 24, SDL_HWSURFACE);
 
                if (!SDLDisplay_enable_mouse_motion_events(self)) {
                        /* ignores mousemotion for performance reasons */
-                       SDL_EventState( SDL_MOUSEMOTION, SDL_IGNORE );
+                       SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
                }
 
                return self;
@@ -63,45 +61,45 @@ extern SDLDisplay in "C" `{SDL_Surface *`}
        fun enable_mouse_motion_events: Bool do return false
 
        # Destroy the surface
-       fun destroy is extern `{
-       if ( SDL_WasInit( SDL_INIT_VIDEO ) )
-               SDL_Quit();
+       fun destroy `{
+               if (SDL_WasInit(SDL_INIT_VIDEO))
+                       SDL_Quit();
 
-       if ( TTF_WasInit() )
-               TTF_Quit();
+               if (TTF_WasInit())
+                       TTF_Quit();
        `}
 
-       redef fun finish is extern `{ SDL_Flip( recv ); `}
+       redef fun finish `{ SDL_Flip(recv); `}
 
        # Clear the entire window with given RGB color (integer values)
-       fun clear_int( r, g, b: Int ) is extern `{
-               SDL_FillRect( recv, NULL, SDL_MapRGB(recv->format,r,g,b) ); 
+       fun clear_int(r, g, b: Int) `{
+               SDL_FillRect(recv, NULL, SDL_MapRGB(recv->format,r,g,b)); 
        `}
 
-       redef fun width: Int is extern `{ return recv->w; `}
-       redef fun height: Int is extern `{ return recv->h; `}
+       redef fun width: Int `{ return recv->w; `}
+       redef fun height: Int `{ return recv->h; `}
 
        # Fill a rectangle with given color
-       fun fill_rect( rect: SDLRectangle, r, g, b: Int ) is extern `{
-               SDL_FillRect( recv, rect,  SDL_MapRGB(recv->format,r,g,b) );
+       fun fill_rect(rect: SDLRectangle, r, g, b: Int) `{
+               SDL_FillRect(recv, rect,  SDL_MapRGB(recv->format,r,g,b));
        `}
 
-       redef fun clear( r, g, b: Float ) is extern `{
+       redef fun clear(r, g, b: Float) `{
                Uint8 ri, gi, bi;
                ri = (Uint8)r*255;
                gi = (Uint8)g*255;
                bi = (Uint8)b*255;
-               SDL_FillRect( recv, NULL, SDL_MapRGB(recv->format,ri,gi,bi) );
+               SDL_FillRect(recv, NULL, SDL_MapRGB(recv->format,ri,gi,bi));
        `}
 
-       fun events: Sequence[ IE ]
+       fun events: Sequence[IE]
        do
                var new_event: nullable Object = null
-               var events = new List[ IE ]
+               var events = new List[IE]
                loop
                        new_event = poll_event
                        if new_event != null then # new_event isa Event then #
-                               events.add( new_event )
+                               events.add(new_event)
                        else
                                break
                        end
@@ -109,14 +107,14 @@ extern SDLDisplay in "C" `{SDL_Surface *`}
                return events
        end
 
-       private fun poll_event: nullable IE is extern import SDLKeyEvent, SDLMouseButtonEvent, SDLMouseMotionEvent, SDLQuitEvent, NativeString.to_s, SDLMouseButtonEvent.as(nullable IE), SDLMouseMotionEvent.as(nullable IE), SDLKeyEvent.as(nullable IE), SDLQuitEvent.as(nullable IE) `{
+       private fun poll_event: nullable IE import SDLKeyEvent, SDLMouseButtonEvent, SDLMouseMotionEvent, SDLQuitEvent, NativeString.to_s, SDLMouseButtonEvent.as(nullable IE), SDLMouseMotionEvent.as(nullable IE), SDLKeyEvent.as(nullable IE), SDLQuitEvent.as(nullable IE) `{
                SDL_Event event;
 
                SDL_PumpEvents();
 
-               if ( SDL_PollEvent(&event) )
+               if (SDL_PollEvent(&event))
                {
-                       switch (event.type ) {
+                       switch (event.type) {
                                case SDL_KEYDOWN:
                                case SDL_KEYUP:
        #ifdef DEBUG
@@ -125,9 +123,9 @@ extern SDLDisplay in "C" `{SDL_Surface *`}
        #endif
 
                                        return SDLKeyEvent_as_nullable_IE(
-                                                       new_SDLKeyEvent( NativeString_to_s(
-                                                               SDL_GetKeyName(event.key.keysym.sym) ),
-                                                               event.type==SDL_KEYDOWN ) );
+                                                       new_SDLKeyEvent(NativeString_to_s(
+                                                               SDL_GetKeyName(event.key.keysym.sym)),
+                                                               event.type==SDL_KEYDOWN));
 
                                case SDL_MOUSEMOTION:
        #ifdef DEBUG
@@ -137,8 +135,8 @@ extern SDLDisplay in "C" `{SDL_Surface *`}
        #endif
 
                                        return SDLMouseMotionEvent_as_nullable_IE(
-                                                       new_SDLMouseMotionEvent( event.motion.x, event.motion.y,
-                                                               event.motion.xrel, event.motion.yrel, SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1)) );
+                                                       new_SDLMouseMotionEvent(event.motion.x, event.motion.y,
+                                                               event.motion.xrel, event.motion.yrel, SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1)));
 
                                case SDL_MOUSEBUTTONDOWN:
                                case SDL_MOUSEBUTTONUP:
@@ -147,14 +145,14 @@ extern SDLDisplay in "C" `{SDL_Surface *`}
                                                   event.button.button, event.button.x, event.button.y);
        #endif
                                        return SDLMouseButtonEvent_as_nullable_IE(
-                                                       new_SDLMouseButtonEvent( event.button.x, event.button.y,
-                                                               event.button.button, event.type == SDL_MOUSEBUTTONDOWN ) );
+                                                       new_SDLMouseButtonEvent(event.button.x, event.button.y,
+                                                               event.button.button, event.type == SDL_MOUSEBUTTONDOWN));
 
                                case SDL_QUIT:
        #ifdef DEBUG
                                        printf("Quit event\n");
        #endif
-                                       return SDLQuitEvent_as_nullable_IE( new_SDLQuitEvent() );
+                                       return SDLQuitEvent_as_nullable_IE(new_SDLQuitEvent());
                        }
                }
 
@@ -162,84 +160,80 @@ extern SDLDisplay in "C" `{SDL_Surface *`}
        `}
 
        # Set the position of the cursor to x,y
-       fun warp_mouse( x,y: Int ) `{ SDL_WarpMouse( x, y ); `}
+       fun warp_mouse(x,y: Int) `{ SDL_WarpMouse(x, y); `}
 
        # Show or hide the cursor
-       fun show_cursor( show: Bool ) `{ SDL_ShowCursor( show ); `}
+       fun show_cursor(show: Bool) `{ SDL_ShowCursor(show); `}
 end
 
 # Basic Drawing figures
-extern SDLDrawable in "C" `{SDL_Surface*`}
+extern class SDLDrawable `{SDL_Surface*`}
        super Drawable
 
        redef type I: SDLImage
 
-       redef fun blit( img, x, y ) is extern `{
+       redef fun blit(img, x, y) `{
                SDL_Rect dst;
                dst.x = x;
                dst.y = y;
                dst.w = 0;
                dst.h = 0;
 
-               SDL_BlitSurface( img, NULL, recv, &dst );
+               SDL_BlitSurface(img, NULL, recv, &dst);
        `}
 
-       redef fun blit_centered( img, x, y )
+       redef fun blit_centered(img, x, y)
        do
                x = x - img.width / 2
                y = y - img.height / 2
-               blit( img, x, y )
+               blit(img, x, y)
        end
 end
 
 # A drawable Image
-extern SDLImage in "C" `{SDL_Surface*`} # TODO remove
+extern class SDLImage
        super DrawableImage
        super SDLDrawable
 
        # Import image from a file
-       new from_file( path: String ) is extern import String.to_cstring `{
-               SDL_Surface *image = IMG_Load( String_to_cstring( path ) );
+       new from_file(path: String) import String.to_cstring `{
+               SDL_Surface *image = IMG_Load(String_to_cstring(path));
                return image;
        `}
 
-
-       new partial( original: Image, clip: SDLRectangle ) is extern `{
-               return NULL;
-       `}
-
        # Copy of an existing SDLImage
-       new copy_of( image: SDLImage ) is extern `{
-               SDL_Surface *new_image = SDL_CreateRGBSurface( image->flags, image->w, image->h, 24,
-                                                         0, 0, 0, 0 );
+       new copy_of(image: SDLImage) `{
+               SDL_Surface *new_image = SDL_CreateRGBSurface(
+                       image->flags, image->w, image->h, 24,
+                       0, 0, 0, 0);
 
                SDL_Rect dst;
                dst.x = 0;
                dst.y = 0;
                dst.w = image->w;
                dst.h = image->h;
-               SDL_BlitSurface( image, NULL, new_image, &dst );
+               SDL_BlitSurface(image, NULL, new_image, &dst);
 
                return new_image;
        `}
 
        # Save the image into the specified file
-       fun save_to_file( path: String ) is extern import String::to_cstring `{ `}
+       fun save_to_file(path: String) import String::to_cstring `{ `}
 
        # Destroy the image and free the memory
-       redef fun destroy is extern `{ SDL_FreeSurface( recv ); `}
+       redef fun destroy `{ SDL_FreeSurface(recv); `}
 
-       redef fun width: Int is extern `{ return recv->w; `}
-       redef fun height: Int is extern `{ return recv->h; `}
+       redef fun width: Int `{ return recv->w; `}
+       redef fun height: Int `{ return recv->h; `}
 
-       fun is_ok: Bool do return true # TODO
+       fun is_ok: Bool do return not address_is_null
 end
 
 # A simple rectangle
-extern SDLRectangle in "C" `{SDL_Rect*`}
+extern class SDLRectangle `{SDL_Rect*`}
        # Constructor with x,y positions width and height of the rectangle
-       new ( x: Int, y: Int, w: Int, h: Int ) is extern `{
-               SDL_Rect *rect = malloc( sizeof( SDL_Rect ) );
+       new (x: Int, y: Int, w: Int, h: Int) `{
+               SDL_Rect *rect = malloc(sizeof(SDL_Rect));
                rect->x = (Sint16)x;
                rect->y = (Sint16)y;
                rect->w = (Uint16)w;
@@ -247,19 +241,17 @@ extern SDLRectangle in "C" `{SDL_Rect*`}
                return rect;
        `}
 
-       fun x=( v: Int ) is extern `{ recv->x = (Sint16)v; `}
-       fun x: Int is extern `{ return recv->x; `}
-
-       fun y=( v: Int ) is extern `{ recv->y = (Sint16)v; `}
-       fun y: Int is extern `{ return recv->y; `}
+       fun x=(v: Int) `{ recv->x = (Sint16)v; `}
+       fun x: Int `{ return recv->x; `}
 
-       fun w=( v: Int ) is extern `{ recv->w = (Uint16)v; `}
-       fun w: Int is extern `{ return recv->w; `}
+       fun y=(v: Int) `{ recv->y = (Sint16)v; `}
+       fun y: Int `{ return recv->y; `}
 
-       fun h=( v: Int ) is extern `{ recv->h = (Uint16)v; `}
-       fun h: Int is extern `{ return recv->h; `}
+       fun w=(v: Int) `{ recv->w = (Uint16)v; `}
+       fun w: Int `{ return recv->w; `}
 
-       fun destroy is extern `{ `}
+       fun h=(v: Int) `{ recv->h = (Uint16)v; `}
+       fun h: Int `{ return recv->h; `}
 end
 
 interface SDLInputEvent
@@ -274,7 +266,7 @@ class SDLMouseEvent
        redef var x: Float
        redef var y: Float
 
-       private init ( x, y: Float )
+       private init (x, y: Float)
        do
                self.x = x
                self.y = y
@@ -290,9 +282,9 @@ class SDLMouseButtonEvent
        redef var pressed: Bool
        redef fun depressed: Bool do return not pressed
 
-       init ( x, y: Float, button: Int, pressed: Bool )
+       init (x, y: Float, button: Int, pressed: Bool)
        do
-               super( x, y )
+               super(x, y)
 
                self.button = button
                self.pressed = pressed
@@ -318,9 +310,9 @@ class SDLMouseMotionEvent
        redef var pressed: Bool
        redef fun depressed: Bool do return not pressed
 
-       init ( x, y, rel_x, rel_y: Float, pressed: Bool )
+       init (x, y, rel_x, rel_y: Float, pressed: Bool)
        do
-               super( x, y )
+               super(x, y)
 
                self.rel_x = rel_x
                self.rel_y = rel_y
@@ -338,7 +330,7 @@ class SDLKeyEvent
        var key_name: String
        var down: Bool
 
-       init ( key_name: String, down: Bool )
+       init (key_name: String, down: Bool)
        do
                self.key_name = key_name
                self.down = down
@@ -378,28 +370,28 @@ class SDLQuitEvent
 end
 
 redef class Int
-       fun delay is extern `{ SDL_Delay( recv ); `}
+       fun delay `{ SDL_Delay(recv); `}
 end
 
 # Class to load and use TTF_Font
-extern SDLFont in "C" `{TTF_Font *`}
+extern class SDLFont `{TTF_Font *`}
        # Load a font with a specified name and size
-       new ( name: String, points: Int ) is extern import String.to_cstring `{
-       char * cname = String_to_cstring( name );
+       new (name: String, points: Int) import String.to_cstring `{
+       char * cname = String_to_cstring(name);
 
-       TTF_Font *font = TTF_OpenFont( cname, (int)points);
+       TTF_Font *font = TTF_OpenFont(cname, (int)points);
        if(!font) {
                printf("TTF_OpenFont: %s\n", TTF_GetError());
-               exit( 1 );
+               exit(1);
        }
 
        return font;
        `}
 
-       fun destroy is extern `{ TTF_CloseFont( recv ); `}
+       fun destroy `{ TTF_CloseFont(recv); `}
 
        # Create a String with the specified color, return an SDLImage
-       fun render( text: String, r, g, b: Int ): SDLImage is extern import String.to_cstring `{
+       fun render(text: String, r, g, b: Int): SDLImage import String.to_cstring `{
                SDL_Color color;
                SDL_Surface *text_surface;
                char *ctext;
@@ -408,74 +400,74 @@ extern SDLFont in "C" `{TTF_Font *`}
                color.g = g;
                color.b = b;
 
-               ctext = String_to_cstring( text );
-               if( !(text_surface=TTF_RenderText_Blended( recv, ctext, color )) )
+               ctext = String_to_cstring(text);
+               if(!(text_surface=TTF_RenderText_Blended(recv, ctext, color)))
                {
-                       fprintf( stderr, "SDL TFF error: %s\n", TTF_GetError() );
-                       exit( 1 );
+                       fprintf(stderr, "SDL TFF error: %s\n", TTF_GetError());
+                       exit(1);
                }
                else
                        return text_surface;
        `}
 
        # TODO reactivate fun below when updating libsdl_ttf to 2.0.10 or above
-       #fun outline: Int is extern # TODO check to make inline/nitside only
-       #fun outline=( v: Int ) is extern
+       #fun outline: Int # TODO check to make inline/nitside only
+       #fun outline=(v: Int) is extern
 
        #fun kerning: Bool is extern
-       #fun kerning=( v: Bool ) is extern
+       #fun kerning=(v: Bool) is extern
 
        # Maximum pixel height of all glyphs of this font.
-       fun height: Int is extern `{
-               return TTF_FontHeight( recv );
+       fun height: Int `{
+               return TTF_FontHeight(recv);
        `}
 
-       fun ascent: Int is extern `{
-               return TTF_FontAscent( recv );
+       fun ascent: Int `{
+               return TTF_FontAscent(recv);
        `}
 
-       fun descent: Int is extern `{
-               return TTF_FontDescent( recv );
+       fun descent: Int `{
+               return TTF_FontDescent(recv);
        `}
 
        # Get the recommended pixel height of a rendered line of text of the loaded font. This is usually larger than the Font.height.
-       fun line_skip: Int is extern `{
-               return TTF_FontLineSkip( recv );
+       fun line_skip: Int `{
+               return TTF_FontLineSkip(recv);
        `}
 
        # Return true is the font used fixed width for each char
-       fun is_fixed_width: Bool is extern `{
-               return TTF_FontFaceIsFixedWidth( recv );
+       fun is_fixed_width: Bool `{
+               return TTF_FontFaceIsFixedWidth(recv);
        `}
 
        # Return the family name of the font
-       fun family_name: nullable String is extern import String.to_cstring, String as nullable `{
-               char *fn = TTF_FontFaceFamilyName( recv );
+       fun family_name: nullable String import String.to_cstring, String as nullable `{
+               char *fn = TTF_FontFaceFamilyName(recv);
 
-               if ( fn == NULL )
+               if (fn == NULL)
                        return null_String();
                else
-                       return String_as_nullable( NativeString_to_s( fn ) );
+                       return String_as_nullable(NativeString_to_s(fn));
        `}
 
        # Return the style name of the font
-       fun style_name: nullable String is extern import String.to_cstring, String as nullable `{
-               char *sn = TTF_FontFaceStyleName( recv );
+       fun style_name: nullable String import String.to_cstring, String as nullable `{
+               char *sn = TTF_FontFaceStyleName(recv);
 
-               if ( sn == NULL )
+               if (sn == NULL)
                        return null_String();
                else
-                       return String_as_nullable( NativeString_to_s( sn ) );
+                       return String_as_nullable(NativeString_to_s(sn));
        `}
 
        # Return the estimated width of a String if used with the current font
-       fun width_of( text: String ): Int is extern import NativeString.to_s `{
-               char *ctext = String_to_cstring( text );
+       fun width_of(text: String): Int import NativeString.to_s `{
+               char *ctext = String_to_cstring(text);
                int w;
-               if ( TTF_SizeText( recv, ctext, &w, NULL ) )
+               if (TTF_SizeText(recv, ctext, &w, NULL))
                {
-                       fprintf( stderr, "SDL TFF error: %s\n", TTF_GetError() );
-                       exit( 1 );
+                       fprintf(stderr, "SDL TFF error: %s\n", TTF_GetError());
+                       exit(1);
                }
                else
                        return w;
diff --git a/lib/sqlite3/sqlite3.nit.args b/lib/sqlite3/sqlite3.nit.args
deleted file mode 100644 (file)
index ffefc2b..0000000
+++ /dev/null
@@ -1 +0,0 @@
---cc-lib-name sqlite3
index 2d1dc58..a55d4c4 100644 (file)
@@ -182,7 +182,13 @@ redef class ModelBuilder
                var mclass = nclassdef.mclass.as(not null)
                var mclassdef = nclassdef.mclassdef.as(not null)
 
+               # Do we need to specify Object as a super class?
                var specobject = true
+
+               # Do we need to specify Pointer as a super class? (is only valid
+               # if `nclassdef` is an extern class)
+               var specpointer = true
+
                var supertypes = new Array[MClassType]
                if nclassdef isa AStdClassdef then
                        for nsc in nclassdef.n_superclasses do
@@ -196,16 +202,16 @@ redef class ModelBuilder
                                end
                                supertypes.add mtype
                                #print "new super : {mclass} < {mtype}"
+                               if mtype.mclass.kind == extern_kind then specpointer = false
                        end
                end
-               if specobject and mclassdef.is_intro then
-                       if mclass.kind == extern_kind then
-                               if mclass.name == "Pointer" then
-                                       supertypes.add objectclass.mclass_type
-                               else
-                                       supertypes.add pointerclass.mclass_type
-                               end
-                       else if mclass.name != "Object" and objectclass != null then
+
+               if mclassdef.is_intro and objectclass != null then
+                       if mclass.kind == extern_kind and mclass.name != "Pointer" then
+                               # it is an extern class, but not a Pointer
+                               if specpointer then supertypes.add pointerclass.mclass_type
+                       else if specobject and mclass.name != "Object" then
+                               # it is a standard class without super class (but is not Object)
                                supertypes.add objectclass.mclass_type
                        end
                end
diff --git a/tests/sav/mnit_display.res b/tests/sav/mnit_display.res
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/sav/mnit_input.res b/tests/sav/mnit_input.res
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/sav/sdl.res b/tests/sav/sdl.res
new file mode 100644 (file)
index 0000000..e69de29