pike.git / src / program.c

version» Context lines:

pike.git/src/program.c:125:    Tools.AutoDoc.PikeObjects       If new lfuns are added it might be beneficial to also add them to    that list.   */   const char *const lfun_names[] = {    "__INIT",    "create",    "\0_destruct\0destroy",    "_sprintf", +  "__create__",    0,       "`+",    "`-",    "`*",    "`/",    "`%",    "`&",    "`|",    "`^",
pike.git/src/program.c:218:   static struct mapping *lfun_ids;      /* mapping(string:type) */   static struct mapping *lfun_types;      static const char *const raw_lfun_types[] = {    tFunc(tNone, tVoid), /* "__INIT", */    tFuncV(tNone, tUnknown, tVoid), /* "create", */    tFunc(tInt03, tInt01), /* "_destruct", */    tFunc(tInt7bit tMap(tStr, tInt), tStr), /* "_sprintf", */ +  tFuncV(tNone, tUnknown, tVoid), /* "__create__", */    0,       tFunc(tUnknown, tMix), /* "`+", */    tFunc(tUnknown, tMix), /* "`-", */    tFuncV(tNone, tUnknown, tMix), /* "`*", */    tFuncV(tNone, tUnknown, tMix), /* "`/", */    tFuncV(tNone, tUnknown, tMix), /* "`%", */    tFuncV(tNone, tUnknown, tMix), /* "`&", */    tFuncV(tNone, tUnknown, tMix), /* "`|", */    tFuncV(tNone, tUnknown, tMix), /* "`^", */
pike.git/src/program.c:401:      /*! @decl void lfun::create(zero ... args)    *!    *! Object creation callback.    *!    *! This function is called right after @[lfun::__INIT()].    *!    *! @[args] are the arguments passed when the program was called.    *!    *! @note -  *! This function can be created implicitly -  *! by the compiler using the syntax: -  *! @code -  *! class Foo(int foo) { -  *! int bar; -  *! } -  *! @endcode -  *! In the above case an implicit @[lfun::create()] is created, and -  *! it's equivalent to: -  *! @code -  *! class Foo { -  *! int foo; -  *! int bar; -  *! protected void create(int foo) -  *! { -  *! this::foo = foo; -  *! } -  *! } -  *! @endcode +  *! If there exists an implicitly created @[lfun::__create__()] +  *! its arguments will be prepended to @[args] (affecting the +  *! prototype for @[lfun::create()]), and a call to it will be +  *! prepended to the code of @[lfun::create()].    *! -  +  *! @note +  *! In Pike 8.0 and earlier the code equivalent to +  *! @[lfun::__create__()] was inlined at the beginning +  *! of @[lfun::create()]. +  *! +  *! @note +  *! If this function does not exist, but @[lfun::__create__()] +  *! does, it will instead be called directly. +  *!    *! @seealso -  *! @[lfun::__INIT()], @[lfun::_destruct()] +  *! @[lfun::__create__()], @[lfun::__INIT()], @[lfun::_destruct()]    */      /*! @decl void lfun::_destruct (void|int reason)    *!    *! Object destruction callback.    *!    *! This function is called right before the object is destructed.    *! That can happen either through a call to @[predef::destruct()],    *! when there are no more references to the object, or when the    *! garbage collector discovers that it's part of a cyclic data
pike.git/src/program.c:537:    *! still intact. They are not freed if the @expr{_destruct@} function    *! adds external references to them. However, all objects with    *! @[lfun::_destruct] in the cycle are already scheduled for    *! destruction and will therefore be destroyed even if external    *! references are added to them.    *!    *! @seealso    *! @[lfun::create()], @[predef::destruct()]    */    + /*! @decl void lfun::__create__(__unknown__ ... args) +  *! +  *! Low-level object creation callback. +  *! +  *! This function is generated automatically by the compiler for +  *! inline classes that declare parameters. A call to it and its +  *! arguments are automatically added to user-supplied @[lfun::create()] +  *! +  *! @note +  *! This function is typically created implicitly +  *! by the compiler using the syntax: +  *! @code +  *! class Foo(int foo) { +  *! int bar; +  *! } +  *! @endcode +  *! In the above case an implicit @[lfun::__create__()] is created, and +  *! it's equivalent to: +  *! @code +  *! class Foo { +  *! int foo; +  *! int bar; +  *! local protected void __create__(int foo) +  *! { +  *! this::foo = foo; +  *! } +  *! } +  *! @endcode +  *! +  *! @note +  *! Note also that in case @[lfun::create()] does not exist, +  *! this function will be called instead. +  *! +  *! @note +  *! This function did not exist in Pike 8.0 and earlier (where it +  *! was instead automatically inlined in @[lfun::create()]. +  *! +  *! @seealso +  *! @[lfun::create()], @[lfun::__INIT()] +  */ +    /*! @decl mixed lfun::`+(zero arg)    *!    *! Left side addition/concatenation callback.    *!    *! This is used by @[predef::`+]. It's called with the argument    *! that follow this object in the argument list of the call to    *! @[predef::`+]. The returned value should be a new instance that    *! represents the addition/concatenation between this object and    *! the argument.    *!
pike.git/src/program.c:8156:    /* One of them is missing. */    return -1;    }    }    }    if (c && !(c->lex.pragmas & ID_NO_DEPRECATION_WARNINGS)) {    yywarning("Compat: Substituting %S() for %S().",    lfun_compat_name, lfun_name);    }    } +  } else if (lfun == LFUN_CREATE) { +  /* NB: In the first pass, we do not know yet if there'll +  * be an lfun::create() later, in which case the type +  * may differ from the type for lfun::__create__(). +  */ +  if (p->flags & PROGRAM_PASS_1_DONE) { +  /* No lfun::create(), but there might be an lfun::__create__(). */ +  return low_find_lfun(p, LFUN___CREATE__);    }    } -  +  }       if (i < 0 || !(p->flags & PROGRAM_FIXED)) {    return i;    }    id = ID_FROM_INT(p, i);   #if 0    if (IDENTIFIER_IS_PIKE_FUNCTION(id->identifier_flags) &&    (id->func.offset == -1)) {    /* Function prototype. */    return -1;