changed the compiler to support module loading in class definition

This commit is contained in:
hyunghwan.chung
2016-11-29 05:25:08 +00:00
parent 394a21b8d6
commit 7b5fc708f7
14 changed files with 616 additions and 419 deletions

View File

@ -48,7 +48,7 @@ struct console_t
};
/* ------------------------------------------------------------------------ */
static int prim_open (stix_t* stix, stix_ooi_t nargs)
static int pf_open (stix_t* stix, stix_ooi_t nargs)
{
#if defined(_WIN32)
HANDLE h;
@ -123,7 +123,7 @@ static int prim_open (stix_t* stix, stix_ooi_t nargs)
return 1;
}
static int prim_close (stix_t* stix, stix_ooi_t nargs)
static int pf_close (stix_t* stix, stix_ooi_t nargs)
{
#if defined(_WIN32)
HANDLE h;
@ -142,7 +142,7 @@ static int prim_close (stix_t* stix, stix_ooi_t nargs)
return 1;
}
static int prim_write (stix_t* stix, stix_ooi_t nargs)
static int pf_write (stix_t* stix, stix_ooi_t nargs)
{
console_t* con;
stix_oop_char_t oomsg;
@ -185,7 +185,7 @@ static int prim_write (stix_t* stix, stix_ooi_t nargs)
return 1;
}
static int prim_clear (stix_t* stix, stix_ooi_t nargs)
static int pf_clear (stix_t* stix, stix_ooi_t nargs)
{
console_t* con;
@ -197,7 +197,7 @@ static int prim_clear (stix_t* stix, stix_ooi_t nargs)
return 1;
}
static int prim_setcursor (stix_t* stix, stix_ooi_t nargs)
static int pf_setcursor (stix_t* stix, stix_ooi_t nargs)
{
console_t* con;
stix_oop_oop_t point;
@ -221,7 +221,7 @@ static int prim_setcursor (stix_t* stix, stix_ooi_t nargs)
#if 0
static int prim_setcursorto (stix_t* stix, stix_ooi_t nargs)
static int pf_setcursorto (stix_t* stix, stix_ooi_t nargs)
{
console_t* con;
stix_oop_oop_t point;
@ -253,21 +253,21 @@ typedef struct fnctab_t fnctab_t;
struct fnctab_t
{
const stix_bch_t* name;
stix_prim_impl_t handler;
stix_pfimpl_t handler;
};
static fnctab_t fnctab[] =
{
{ "clear", prim_clear },
{ "close", prim_close },
{ "open", prim_open },
{ "setcursor", prim_setcursor },
{ "write", prim_write },
{ "clear", pf_clear },
{ "close", pf_close },
{ "open", pf_open },
{ "setcursor", pf_setcursor },
{ "write", pf_write },
};
/* ------------------------------------------------------------------------ */
static stix_prim_impl_t query (stix_t* stix, stix_mod_t* mod, const stix_ooch_t* name)
static stix_pfimpl_t query (stix_t* stix, stix_mod_t* mod, const stix_ooch_t* name)
{
int left, right, mid, n;
@ -311,11 +311,11 @@ int stix_mod_console (stix_t* stix, stix_mod_t* mod)
c = stix_findclass (stix, "Console");
if (!c) c = stix_makeclass (stix, "Console", "x y"); <- provides an API to create a simple class
stix_addmethod (stix, c, "open", prim_open);
stix_addmethod (stix, c, "close:", prim_close);
stix_addmethod (stix, c, "setCursorTo:", prim_setcursor);
stix_addmethod (stix, c, "clear", prim_clear );
stix_addmethod (stix, c, "write", prim_write );
stix_addmethod (stix, c, "open", pf_open);
stix_addmethod (stix, c, "close:", pf_close);
stix_addmethod (stix, c, "setCursorTo:", pf_setcursor);
stix_addmethod (stix, c, "clear", pf_clear );
stix_addmethod (stix, c, "write", pf_write );

View File

@ -29,14 +29,14 @@
#include <stix-utl.h>
/* ------------------------------------------------------------------------ */
static int prim_open (stix_t* stix, stix_ooi_t nargs)
static int pf_open (stix_t* stix, stix_ooi_t nargs)
{
printf ("<<<<<<<<<<<SND OPEN>>>>>>>>>>>>>>>>>>\n");
STIX_STACK_POPS (stix, nargs);
return 1;
}
static int prim_close (stix_t* stix, stix_ooi_t nargs)
static int pf_close (stix_t* stix, stix_ooi_t nargs)
{
printf ("<<<<<<<<<<<<<<<<<<<<SND CLOSE>>>>>>>>>>>>>>>>>>>>>>\n");
STIX_STACK_POPS (stix, nargs);
@ -47,19 +47,19 @@ typedef struct fnctab_t fnctab_t;
struct fnctab_t
{
const stix_bch_t* name;
stix_prim_impl_t handler;
stix_pfimpl_t handler;
};
static fnctab_t fnctab[] =
{
{ "close", prim_close },
{ "open", prim_open }
{ "close", pf_close },
{ "open", pf_open }
};
/* ------------------------------------------------------------------------ */
static stix_prim_impl_t query (stix_t* stix, stix_mod_t* mod, const stix_ooch_t* name)
static stix_pfimpl_t query (stix_t* stix, stix_mod_t* mod, const stix_ooch_t* name)
{
int left, right, mid, n;

View File

@ -38,7 +38,7 @@ struct stdio_t
FILE* fp;
};
static int prim_open (stix_t* stix, stix_ooi_t nargs)
static int pf_open (stix_t* stix, stix_ooi_t nargs)
{
stix_oop_char_t name;
stix_oop_char_t mode;
@ -81,7 +81,7 @@ STIX_DEBUG3 (stix, "opened %s for %s - %p\n", namebuf, modebuf, rcv->fp);
return 1;
}
static int prim_close (stix_t* stix, stix_ooi_t nargs)
static int pf_close (stix_t* stix, stix_ooi_t nargs)
{
stdio_t* rcv;
@ -97,7 +97,7 @@ STIX_DEBUG1 (stix, "closing %p\n", rcv->fp);
return 1;
}
static int prim_puts (stix_t* stix, stix_ooi_t nargs)
static int pf_puts (stix_t* stix, stix_ooi_t nargs)
{
/* return how many bytes have been written.. */
@ -105,7 +105,7 @@ static int prim_puts (stix_t* stix, stix_ooi_t nargs)
return 1;
}
static int prim_newinstsize (stix_t* stix, stix_ooi_t nargs)
static int pf_newinstsize (stix_t* stix, stix_ooi_t nargs)
{
stix_ooi_t newinstsize = STIX_SIZEOF(stdio_t) - STIX_SIZEOF(stix_obj_t);
STIX_STACK_SETRET (stix, nargs, STIX_SMOOI_TO_OOP(newinstsize));
@ -117,20 +117,25 @@ typedef struct fnctab_t fnctab_t;
struct fnctab_t
{
const stix_bch_t* name;
stix_prim_impl_t handler;
stix_pfimpl_t handler;
};
static fnctab_t fnctab[] =
{
{ "close", prim_close },
{ "newInstSize", prim_newinstsize },
{ "open", prim_open },
{ "puts", prim_puts }
{ "close", pf_close },
{ "newInstSize", pf_newinstsize },
{ "open", pf_open },
{ "puts", pf_puts }
};
/* ------------------------------------------------------------------------ */
static stix_prim_impl_t query (stix_t* stix, stix_mod_t* mod, const stix_ooch_t* name)
static int import (stix_t* stix, stix_mod_t* mod, stix_oop_t _class)
{
return 0;
}
static stix_pfimpl_t query (stix_t* stix, stix_mod_t* mod, const stix_ooch_t* name)
{
int left, right, mid, n;
@ -171,6 +176,7 @@ static void unload (stix_t* stix, stix_mod_t* mod)
int stix_mod_stdio (stix_t* stix, stix_mod_t* mod)
{
mod->import = import;
mod->query = query;
mod->unload = unload;
mod->ctx = STIX_NULL;
@ -183,11 +189,11 @@ int stix_mod_stdio (stix_t* stix, stix_mod_t* mod)
c = stix_findclass (stix, "Console");
if (!c) c = stix_makeclass (stix, "Console", "x y"); <- provides an API to create a simple class
stix_addmethod (stix, c, "open", prim_open);
stix_addmethod (stix, c, "close:", prim_close);
stix_addmethod (stix, c, "setCursorTo:", prim_setcursor);
stix_addmethod (stix, c, "clear", prim_clear );
stix_addmethod (stix, c, "write", prim_write );
stix_addmethod (stix, c, "open", pf_open);
stix_addmethod (stix, c, "close:", pf_close);
stix_addmethod (stix, c, "setCursorTo:", pf_setcursor);
stix_addmethod (stix, c, "clear", pf_clear );
stix_addmethod (stix, c, "write", pf_write );