like this
PIKEFUN void create( int rows, int cols, int y, int x ) { THIS->m_window = newwin( rows, cols, y, x );
if( !THIS->m_window ) Pike_error( "Failed to create ncurses window\n" );
pop_n_elems( args ); }
PIKEFUN void create( object parent, int rows, int cols, int y, int x ) { Pike_error( "Not yet implemented. Sorry.\n" ); // verify parent to be of correct type.. // THIS->m_window = subwin(parent. check how to get the storage for object.., rows, cols, y, x );
pop_n_elems( args ); }
/* PIKEFUN void create() { // default window is the screen THIS->m_window = THIS_->m_screen; } */
if I uncomment the last create, it fails as below. simply initialising the best_method to -1 doesn't help (doesn't fail, but the function doesn't appear at all in the result either).
== precompile: kpike /home/kaos/pike/7.6.25/include/pike/precompile.pike ncurses.cmod MIN: 0 MAX: 5 Best method=0 Cannot index the NULL value with 0. /home/kaos/pike/7.6.25/include/pike/precompile.pike:1342:
/home/kaos/pike/7.6.25/include/pike/precompile()->generate_overload_func_for(({FuncData(f_Window_create_1_defined),FuncDat
a(f_Window_create_2_defined),FuncData(f_Window_create_3_defined)}),2,0,2147483647,"create",mapping[1]) /home/kaos/pike/7.6.25/include/pike/precompile.pike:2083:
/home/kaos/pike/7.6.25/include/pike/precompile()->ParseBlock()->create(({({"\n#undef var_m_wi"+[21],,,43}),({,,,3}),({,,,3 }),({,,,4}),({,,,4}),({,,,4}),({,,,4}),({,,,4}),({,,,15})}),"Window") /home/kaos/pike/7.6.25/include/pike/precompile.pike:167: /home/kaos/pike/7.6.25/include/pike/precompile()->ParseBlock() /home/kaos/pike/7.6.25/include/pike/precompile.pike:1414:
/home/kaos/pike/7.6.25/include/pike/precompile()->ParseBlock()->create(({({Parser.C.Token("/* $Id$ */",0,0),Parser.C.Token ("#include "global.h"\n","ncurses.cmod",3),,,55}),({Parser.C.Token("Window","ncurses.cmod",86),({Parser.C.Token("{","ncu rses.cmod",87),,,56}),,,7})}),"") /home/kaos/pike/7.6.25/include/pike/precompile.pike:167: /home/kaos/pike/7.6.25/include/pike/precompile()->ParseBlock() /home/kaos/pike/7.6.25/include/pike/precompile.pike:2205:
/home/kaos/pike/7.6.25/include/pike/precompile()->main(2,({"/home/kaos/pike/7.6.25/include/pike/precompile.pike","ncurses. cmod"})) Failed to run /home/kaos/pike/7.6.25/include/pike/precompile.pike. make: *** [ncurses.c] Error 1
Marcus Agehall (PacketFront) @ Pike (-) developers forum wrote:
How do you overload your methods? Those parts have been working before at least...
/ Marcus Agehall (PacketFront)
Previous text:
2004-10-15 12:30: Subject: Re: Bug in precompile.pike
Funny,
I was just having trouble with precompile.pike as well. It's the overloading code. Doesn't seem to handle overloading functions when one way to go takes no arguments.
Haven't figured out how all things are working togheter there yet... ;)
Marcus Agehall (PacketFront) @ Pike (-) developers forum wrote:
There seems to be a bug in precompile.pike in 7.7.
I checked out a fresh copy from CVS this morning and it failed to compile the SQLite module which Nilsson checked in last night.
I looked at the code and found that on line 145, it does
store = GET_RESOBJ_STORAGE(res);
which the C-compiler later complains about.
Some investigation shows that precompile.pike gives the following define for that macro:
#define GET_RESOBJ_STORAGE ((struct ResObj_struct *)(o->storage+ResObj_storage_offset)
which is almost the same as the OBJ2_RESOBJ macro, besides that OBJ2_RESOBJ takes a parameter (o) and has balanced parenthesis.
I do not understand the intended difference between these defines and thus I will leave it up to someone else to sort this out. For now, I'll change the code inte SQLite module to use the OBJ2_RESOBJ() macro.
/ Brevbäraren