Branch: Tag:

2003-09-04

2003-09-04 15:02:02 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Added support for fake lfuns, and added lfun::_search().

Rev: src/program.c:1.523
Rev: src/program.h:1.186

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: program.c,v 1.522 2003/09/03 17:55:59 mast Exp $ + || $Id: program.c,v 1.523 2003/09/04 15:02:02 grubba Exp $   */      #include "global.h" - RCSID("$Id: program.c,v 1.522 2003/09/03 17:55:59 mast Exp $"); + RCSID("$Id: program.c,v 1.523 2003/09/04 15:02:02 grubba Exp $");   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"
150:    "_equal",    "_m_delete",    "_get_iterator", +  /* NOTE: After this point there are only fake lfuns. */ +  "_search",   };      struct pike_string *lfun_strings[NELEM(lfun_names)];
204:    tFuncV(tMix,tVoid,tInt), /* "_equal", */    tFuncV(tZero,tVoid,tMix), /* "_m_delete", */    tFuncV(tNone,tVoid,tObj), /* "_get_iterator", */ +  /* NOTE: After this point there are only fake lfuns. */ +  tFuncV(tZero tOr(tZero, tVoid), tVoid, tMix), /* "_search", */   };      /*! @namespace lfun::
258:    *! Overloading of other builtin functions.    *!    *! @[_is_type()], @[_sprintf()], @[_m_delete()], -  *! @[_get_iterator()] +  *! @[_get_iterator()], @[_search()]    *! @endul    *!    *! @note
841:    *! @[Iterator], @[get_iterator], @[predef::foreach()]    */    + /*! @decl mixed lfun::_search(mixed needle, mixed|void start) +  *! +  *! Search callback. +  *! +  *! @seealso +  *! @[predef::search()] +  */ +    /*! @endnamespace    */   
6641:       lfun_ids = allocate_mapping(NUM_LFUNS);    lfun_types = allocate_mapping(NUM_LFUNS); -  for (i=0; i < NUM_LFUNS; i++) { +  for (i=0; i < NELEM(lfun_names); i++) {    lfun_strings[i] = make_shared_string(lfun_names[i]);       id.type = T_INT;
6655:    mapping_insert(lfun_types, &key, &val);    free_type(val.u.type);    } +     start_new_program();    debug_malloc_touch(Pike_compiler->fake_object);    debug_malloc_touch(Pike_compiler->fake_object->storage);
6704:       free_mapping(lfun_types);    free_mapping(lfun_ids); -  for (e=0; e < NUM_LFUNS; e++) { +  for (e=0; e < NELEM(lfun_names); e++) {    free_string(lfun_strings[e]);    }   #ifdef FIND_FUNCTION_HASHSIZE