changed to use moo_bch_t* in moo_pfinfo_t from moo_ooch_t[]
This commit is contained in:
parent
feb1825c41
commit
dde69fb64e
@ -8086,7 +8086,7 @@ static int resolve_primitive_method (moo_t* moo)
|
||||
return -1;
|
||||
}
|
||||
|
||||
pfbase = moo_getpfnum (moo, &cc->modname.ptr[savedlen], cc->modname.len - savedlen, &pfnum);
|
||||
pfbase = moo_getpfnum(moo, &cc->modname.ptr[savedlen], cc->modname.len - savedlen, &pfnum);
|
||||
if (!pfbase)
|
||||
{
|
||||
MOO_DEBUG2 (moo, "Cannot find intrinsic primitive function - %.*js\n",
|
||||
|
@ -1571,15 +1571,15 @@ int moo_fmt_object_ (moo_fmtout_t* fmtout, moo_oop_t oop)
|
||||
|
||||
/* TODO: better memory allocation management? */
|
||||
ns = ((moo_oop_nsdic_t)oop)->nsup;
|
||||
while (/*ns != moo->_system &&*/ ns != moo->_system->nsdic) /* exclude System from the output */
|
||||
while (/*ns != moo->_system &&*/ ns != (moo_oop_t)moo->_system->nsdic) /* exclude System from the output */
|
||||
{
|
||||
if (MOO_CLASSOF(moo, ns) == moo->_class)
|
||||
{
|
||||
ns = ((moo_oop_class_t)ns)->nsup;
|
||||
ns = (moo_oop_t)((moo_oop_class_t)ns)->nsup;
|
||||
}
|
||||
else if (MOO_CLASSOF(moo, ns) == moo->_interface)
|
||||
{
|
||||
ns = ((moo_oop_interface_t)ns)->nsup;
|
||||
ns = (moo_oop_t)((moo_oop_interface_t)ns)->nsup;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1622,16 +1622,16 @@ int moo_fmt_object_ (moo_fmtout_t* fmtout, moo_oop_t oop)
|
||||
int ok = 1;
|
||||
|
||||
/* TODO: collapse many duplicate code among namespace, class, interface name printing */
|
||||
ns = ((moo_oop_class_t)oop)->nsup;
|
||||
while (/*ns != moo->_system &&*/ ns != moo->_system->nsdic) /* exclude System from the output */
|
||||
ns = (moo_oop_t)((moo_oop_class_t)oop)->nsup;
|
||||
while (/*ns != moo->_system &&*/ ns != (moo_oop_t)moo->_system->nsdic) /* exclude System from the output */
|
||||
{
|
||||
if (MOO_CLASSOF(moo, ns) == moo->_class)
|
||||
{
|
||||
ns = ((moo_oop_class_t)ns)->nsup;
|
||||
ns = (moo_oop_t)((moo_oop_class_t)ns)->nsup;
|
||||
}
|
||||
else if (MOO_CLASSOF(moo, ns) == moo->_interface)
|
||||
{
|
||||
ns = ((moo_oop_interface_t)ns)->nsup;
|
||||
ns = (moo_oop_t)((moo_oop_interface_t)ns)->nsup;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1671,16 +1671,16 @@ int moo_fmt_object_ (moo_fmtout_t* fmtout, moo_oop_t oop)
|
||||
}* tmp, * top = MOO_NULL;
|
||||
int ok = 1;
|
||||
|
||||
ns = ((moo_oop_interface_t)oop)->nsup;
|
||||
while (/*ns != moo->_system &&*/ ns != moo->_system->nsdic) /* exclude System from the output */
|
||||
ns = (moo_oop_t)((moo_oop_interface_t)oop)->nsup;
|
||||
while (/*ns != moo->_system &&*/ ns != (moo_oop_t)moo->_system->nsdic) /* exclude System from the output */
|
||||
{
|
||||
if (MOO_CLASSOF(moo, ns) == moo->_class)
|
||||
{
|
||||
ns = ((moo_oop_class_t)ns)->nsup;
|
||||
ns = (moo_oop_t)((moo_oop_class_t)ns)->nsup;
|
||||
}
|
||||
else if (MOO_CLASSOF(moo, ns) == moo->_interface)
|
||||
{
|
||||
ns = ((moo_oop_interface_t)ns)->nsup;
|
||||
ns = (moo_oop_t)((moo_oop_interface_t)ns)->nsup;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -741,8 +741,8 @@ done2:
|
||||
moo_pfbase_t* moo_querymod (moo_t* moo, const moo_ooch_t* pfid, moo_oow_t pfidlen, moo_mod_t** mod)
|
||||
{
|
||||
/* primitive function identifier
|
||||
* _funcname
|
||||
* modname_funcname
|
||||
* modname.funcname
|
||||
* modname.modname2.funcname
|
||||
*/
|
||||
moo_rbt_pair_t* pair;
|
||||
moo_mod_data_t* mdp;
|
||||
@ -943,7 +943,7 @@ moo_pfbase_t* moo_findpfbase (moo_t* moo, moo_pfinfo_t* pfinfo, moo_oow_t pfcoun
|
||||
/*mid = (left + right) / 2;*/
|
||||
mid = left + ((right - left) / 2);
|
||||
|
||||
n = moo_comp_oochars_oocstr (name, namelen, pfinfo[mid].mthname);
|
||||
n = moo_comp_oochars_bcstr(name, namelen, pfinfo[mid].name);
|
||||
if (n < 0) right = mid - 1; /* this substraction can make right negative. so i can't use moo_oow_t for the variable */
|
||||
else if (n > 0) left = mid + 1;
|
||||
else return &pfinfo[mid].base;
|
||||
@ -955,7 +955,7 @@ moo_pfbase_t* moo_findpfbase (moo_t* moo, moo_pfinfo_t* pfinfo, moo_oow_t pfcoun
|
||||
for (base = 0, lim = pfcount; lim > 0; lim >>= 1)
|
||||
{
|
||||
mid = base + (lim >> 1);
|
||||
n = moo_comp_oochars_oocstr (name, namelen, pfinfo[mid].mthname);
|
||||
n = moo_comp_oochars_bcstr(name, namelen, pfinfo[mid].name);
|
||||
if (n == 0) return &pfinfo[mid].base;
|
||||
if (n > 0) { base = mid + 1; lim--; }
|
||||
}
|
||||
|
@ -1322,15 +1322,31 @@ struct moo_pfbase_t
|
||||
moo_oow_t maxargs;
|
||||
};
|
||||
|
||||
|
||||
typedef struct moo_pfinfo_t moo_pfinfo_t;
|
||||
struct moo_pfinfo_t
|
||||
{
|
||||
moo_method_type_t type;
|
||||
moo_ooch_t mthname[32];
|
||||
const moo_bch_t* name;
|
||||
int variadic;
|
||||
moo_pfbase_t base;
|
||||
};
|
||||
|
||||
/*
|
||||
typedef struct moo_pvbase_t moo_pvbase_t
|
||||
{
|
||||
void* ptr;
|
||||
moo_oow_t len;
|
||||
moo_oow_t type;
|
||||
};
|
||||
|
||||
typedef struct moo_pvinfo_t moo_pvinfo_t;
|
||||
struct moo_pvinfo_t
|
||||
{
|
||||
moo_ooch_t name[32];
|
||||
moo_pvbase_t base;
|
||||
};
|
||||
*/
|
||||
|
||||
/* receiver check failure leads to hard failure.
|
||||
* RATIONAL: the primitive handler should be used by relevant classes and
|
||||
|
@ -256,11 +256,11 @@ einval:
|
||||
|
||||
static moo_pfinfo_t pfinfos[] =
|
||||
{
|
||||
{ I, { 'c','l','e','a','r','\0' }, 0, { pf_clear, 0, 0 } },
|
||||
{ I, { 'c','l','o','s','e','\0' }, 0, { pf_close, 0, 0 } },
|
||||
{ I, { 'o','p','e','n','\0' }, 0, { pf_open, 0, 0 } },
|
||||
{ I, { 's','e','t','c','u','r','s','o','r','\0' }, 0, { pf_setcursor, 2, 2 } },
|
||||
{ I, { 'w','r','i','t','e','\0' }, 0, { pf_write, 1, 1 } }
|
||||
{ I, "clear", 0, { pf_clear, 0, 0 } },
|
||||
{ I, "close", 0, { pf_close, 0, 0 } },
|
||||
{ I, "open", 0, { pf_open, 0, 0 } },
|
||||
{ I, "setcursor", 0, { pf_setcursor, 2, 2 } },
|
||||
{ I, "write", 0, { pf_write, 1, 1 } }
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
@ -1198,10 +1198,10 @@ softfail:
|
||||
|
||||
static moo_pfinfo_t pfinfos[] =
|
||||
{
|
||||
{ I, { 'c','a','l','l','\0' }, 0, { pf_call, 3, 3 } },
|
||||
{ I, { 'c','l','o','s','e','\0' }, 0, { pf_close, 0, 0 } },
|
||||
{ I, { 'g','e','t','s','y','m','\0' }, 0, { pf_getsym, 1, 1 } },
|
||||
{ I, { 'o','p','e','n','\0' }, 0, { pf_open, 1, 1 } }
|
||||
{ I, "call", 0, { pf_call, 3, 3 } },
|
||||
{ I, "close", 0, { pf_close, 0, 0 } },
|
||||
{ I, "getsym", 0, { pf_getsym, 1, 1 } },
|
||||
{ I, "open", 0, { pf_open, 1, 1 } }
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
@ -118,8 +118,8 @@ oops:
|
||||
|
||||
static moo_pfinfo_t pfinfos[] =
|
||||
{
|
||||
{ I, { 'o','p','e','n',':','f','l','a','g','s',':','\0' }, 0, { pf_open_file, 2, 2 } },
|
||||
{ I, { 'o','p','e','n',':','f','l','a','g','s',':','m','o','d','e',':','\0' }, 0, { pf_open_file, 3, 3 } },
|
||||
{ I, "open:flags:", 0, { pf_open_file, 2, 2 } },
|
||||
{ I, "open:flags:mode:", 0, { pf_open_file, 3, 3 } },
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
@ -132,7 +132,7 @@ static int import (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class)
|
||||
|
||||
static moo_pfbase_t* query (moo_t* moo, moo_mod_t* mod, const moo_ooch_t* name, moo_oow_t namelen)
|
||||
{
|
||||
return moo_findpfbase (moo, pfinfos, MOO_COUNTOF(pfinfos), name, namelen);
|
||||
return moo_findpfbase(moo, pfinfos, MOO_COUNTOF(pfinfos), name, namelen);
|
||||
}
|
||||
|
||||
static void unload (moo_t* moo, moo_mod_t* mod)
|
||||
|
10
moo/mod/io.c
10
moo/mod/io.c
@ -219,11 +219,11 @@ static moo_pfrc_t pf_write_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
|
||||
|
||||
static moo_pfinfo_t pfinfos[] =
|
||||
{
|
||||
{ I, { 'c','l','o','s','e','\0' }, 0, { pf_close_io, 0, 0 } },
|
||||
{ I, { 'r','e','a','d','B','y','t','e','s','I','n','t','o',':','\0' }, 0, { pf_read_bytes, 1, 1 } },
|
||||
{ I, { 'r','e','a','d','B','y','t','e','s','I','n','t','o',':','s','t','a','r','t','i','n','g','A','t',':','f','o','r',':','\0' }, 0, { pf_read_bytes, 3, 3 } },
|
||||
{ I, { 'w','r','i','t','e','B','y','t','e','s','F','r','o','m',':','\0' }, 0, { pf_write_bytes, 1, 1 } },
|
||||
{ I, { 'w','r','i','t','e','B','y','t','e','s','F','r','o','m',':','s','t','a','r','t','i','n','g','A','t',':','f','o','r',':','\0' }, 0, { pf_write_bytes, 3, 3 } }
|
||||
{ I, "close", 0, { pf_close_io, 0, 0 } },
|
||||
{ I, "readBytesInto:", 0, { pf_read_bytes, 1, 1 } },
|
||||
{ I, "readBytesInto:startingAt:for:", 0, { pf_read_bytes, 3, 3 } },
|
||||
{ I, "writeBytesFrom:", 0, { pf_write_bytes, 1, 1 } },
|
||||
{ I, "writeBytesFrom:startingAt:for:", 0, { pf_write_bytes, 3, 3 } }
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
@ -494,8 +494,8 @@ static moo_pfrc_t pf_from_string (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
|
||||
|
||||
static moo_pfinfo_t pfinfos[] =
|
||||
{
|
||||
{ I, { 'f','a','m','i','l','y' }, 0, { pf_get_family, 0, 0 } },
|
||||
{ I, { 'f','r','o','m','S','t','r','i','n','g',':','\0' }, 0, { pf_from_string, 1, 1 } }
|
||||
{ I, "family", 0, { pf_get_family, 0, 0 } },
|
||||
{ I, "fromString:", 0, { pf_from_string, 1, 1 } }
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
@ -576,17 +576,17 @@ static moo_pfrc_t pf_write_socket (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
|
||||
|
||||
static moo_pfinfo_t pfinfos[] =
|
||||
{
|
||||
{ I, { 'a','c','c','e','p','t',':','\0' }, 0, { pf_accept_socket, 1, 1 } },
|
||||
{ I, { 'b','i','n','d',':','\0' }, 0, { pf_bind_socket, 1, 1 } },
|
||||
{ I, { 'c','l','o','s','e','\0' }, 0, { pf_close_socket, 0, 0 } },
|
||||
{ I, { 'c','o','n','n','e','c','t',':','\0' }, 0, { pf_connect_socket, 1, 1 } },
|
||||
{ I, { 'l','i','s','t','e','n',':','\0' }, 0, { pf_listen_socket, 1, 1 } },
|
||||
{ I, { 'o','p','e','n','\0' }, 0, { pf_open_socket, 1, 3 } },
|
||||
{ I, { 'r','e','a','d','B','y','t','e','s','I','n','t','o',':','\0' }, 0, { pf_read_socket, 1, 1 } },
|
||||
{ I, { 'r','e','a','d','B','y','t','e','s','I','n','t','o',':','s','t','a','r','t','i','n','g','A','t',':','f','o','r',':','\0' }, 0, { pf_read_socket, 3, 3 } },
|
||||
{ I, { 's','o','c','k','e','t','E','r','r','o','r','\0' }, 0, { pf_get_socket_error, 0, 0 } },
|
||||
{ I, { 'w','r','i','t','e','B','y','t','e','s','F','r','o','m',':','\0' }, 0, { pf_write_socket, 1, 1 } },
|
||||
{ I, { 'w','r','i','t','e','B','y','t','e','s','F','r','o','m',':','s','t','a','r','t','i','n','g','A','t',':','f','o','r',':','\0' }, 0, { pf_write_socket, 3, 3 } }
|
||||
{ I, "accept:", 0, { pf_accept_socket, 1, 1 } },
|
||||
{ I, "bind:", 0, { pf_bind_socket, 1, 1 } },
|
||||
{ I, "close", 0, { pf_close_socket, 0, 0 } },
|
||||
{ I, "connect:", 0, { pf_connect_socket, 1, 1 } },
|
||||
{ I, "listen:", 0, { pf_listen_socket, 1, 1 } },
|
||||
{ I, "open", 0, { pf_open_socket, 1, 3 } },
|
||||
{ I, "readBytesInto:", 0, { pf_read_socket, 1, 1 } },
|
||||
{ I, "readBytesInto:startingAt:for:", 0, { pf_read_socket, 3, 3 } },
|
||||
{ I, "socketError", 0, { pf_get_socket_error, 0, 0 } },
|
||||
{ I, "writeBytesFrom:", 0, { pf_write_socket, 1, 1 } },
|
||||
{ I, "writeBytesFrom:startingAt:for:", 0, { pf_write_socket, 3, 3 } }
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
@ -211,23 +211,23 @@ static moo_pfrc_t pf_puts (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
|
||||
|
||||
static moo_pfinfo_t pfinfos[] =
|
||||
{
|
||||
{ I, { 'c','l','o','s','e','\0' }, 0, { pf_close, 0, 0 } },
|
||||
{ I, { 'g','e','t','s','\0' }, 0, { pf_gets, 0, 0 } },
|
||||
{ I, { 'o','p','e','n','\0' }, 0, { pf_open, 2, 2 } },
|
||||
{ I, { 'p','u','t','c','\0' }, 1, { pf_putc, 0, MA } },
|
||||
{ I, { 'p','u','t','s','\0' }, 1, { pf_puts, 0, MA } }
|
||||
{ I, "close", 0, { pf_close, 0, 0 } },
|
||||
{ I, "gets", 0, { pf_gets, 0, 0 } },
|
||||
{ I, "open", 0, { pf_open, 2, 2 } },
|
||||
{ I, "putc", 1, { pf_putc, 0, MA } },
|
||||
{ I, "puts", 1, { pf_puts, 0, MA } }
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
static int import (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class)
|
||||
{
|
||||
if (moo_setclasstrsize (moo, _class, MOO_SIZEOF(stdio_t), MOO_NULL) <= -1) return -1;
|
||||
if (moo_setclasstrsize(moo, _class, MOO_SIZEOF(stdio_t), MOO_NULL) <= -1) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static moo_pfbase_t* query (moo_t* moo, moo_mod_t* mod, const moo_ooch_t* name, moo_oow_t namelen)
|
||||
{
|
||||
return moo_findpfbase (moo, pfinfos, MOO_COUNTOF(pfinfos), name, namelen);
|
||||
return moo_findpfbase(moo, pfinfos, MOO_COUNTOF(pfinfos), name, namelen);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -797,19 +797,19 @@ static moo_pfrc_t pf_draw_string (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
|
||||
|
||||
static moo_pfinfo_t x11_pfinfo[] =
|
||||
{
|
||||
{ MI, { 'a','p','p','l','y','_','g','c','\0' }, 0, { pf_apply_gc, 1, 1 } },
|
||||
{ MI, { 'c','l','o','s','e','_','d','i','s','p','l','a','y','\0' }, 0, { pf_close_display, 0, 0 } },
|
||||
{ MI, { 'c','r','e','a','t','e','_','g','c','\0' }, 0, { pf_create_gc, 1, 1 } },
|
||||
{ MI, { 'c','r','e','a','t','e','_','w','i','n','d','o','w','\0' }, 0, { pf_create_window, 7, 7 } },
|
||||
{ MI, { 'd','e','s','t','r','o','y','_','g','c','\0' }, 0, { pf_destroy_gc, 1, 1 } },
|
||||
{ MI, { 'd','e','s','t','r','o','y','_','w','i','n','d','o','w','\0' }, 0, { pf_destroy_window, 1, 1 } },
|
||||
{ MI, "apply_gc", 0, { pf_apply_gc, 1, 1 } },
|
||||
{ MI, "close_display", 0, { pf_close_display, 0, 0 } },
|
||||
{ MI, "create_gc", 0, { pf_create_gc, 1, 1 } },
|
||||
{ MI, "create_window", 0, { pf_create_window, 7, 7 } },
|
||||
{ MI, "destroy_gc", 0, { pf_destroy_gc, 1, 1 } },
|
||||
{ MI, "destroy_window", 0, { pf_destroy_window, 1, 1 } },
|
||||
|
||||
{ MI, { 'd','r','a','w','_','r','e','c','t','a','n','g','l','e','\0' }, 0, { pf_draw_rectangle, 6, 6 } },
|
||||
{ MI, { 'd','r','a','w','_','s','t','r','i','n','g','\0' }, 0, { pf_draw_string, 4, 4 } },
|
||||
{ MI, { 'f','i','l','l','_','r','e','c','t','a','n','g','l','e','\0' }, 0, { pf_fill_rectangle, 6, 6 } },
|
||||
{ MI, { 'g','e','t','_','f','d','\0' }, 0, { pf_get_fd, 0, 0 } },
|
||||
{ MI, { 'g','e','t','_','l','l','e','v','e','n','t','\0'}, 0, { pf_get_llevent, 1, 1 } },
|
||||
{ MI, { 'o','p','e','n','_','d','i','s','p','l','a','y','\0' }, 0, { pf_open_display, 0, 1 } }
|
||||
{ MI, "draw_rectangle", 0, { pf_draw_rectangle, 6, 6 } },
|
||||
{ MI, "draw_string", 0, { pf_draw_string, 4, 4 } },
|
||||
{ MI, "fill_rectangle", 0, { pf_fill_rectangle, 6, 6 } },
|
||||
{ MI, "get_fd", 0, { pf_get_fd, 0, 0 } },
|
||||
{ MI, "get_llevent", 0, { pf_get_llevent, 1, 1 } },
|
||||
{ MI, "open_display", 0, { pf_open_display, 0, 1 } }
|
||||
};
|
||||
|
||||
static int x11_import (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class)
|
||||
|
Loading…
Reference in New Issue
Block a user