pike.git / src / operators.c

version» Context lines:

pike.git/src/operators.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   /**/   #include "global.h"   #include <math.h> - RCSID("$Id: operators.c,v 1.122 2001/02/08 18:21:11 grubba Exp $"); + RCSID("$Id: operators.c,v 1.123 2001/02/08 19:28:10 grubba Exp $");   #include "interpret.h"   #include "svalue.h"   #include "multiset.h"   #include "mapping.h"   #include "array.h"   #include "stralloc.h"   #include "opcodes.h"   #include "operators.h"   #include "language.h"   #include "pike_memory.h"
pike.git/src/operators.c:3174:    case 2:    if(sp[-1].type==T_STRING)    sp[-1].subtype=1;    o_index();    break;    default:    PIKE_ERROR("`->", "Too many arguments.\n", sp, args);    }   }    - /*! @decl mixed `[]=(mixed arg1, mixed arg2, mixed arg3) + /*! @decl mixed `[]=(object arg, mixed index, mixed val) +  *! @decl mixed `[]=(object arg, string index, mixed val) +  *! @decl mixed `[]=(array arg, int index, mixed val) +  *! @decl mixed `[]=(mapping arg, mixed index, mixed val) +  *! @decl int(0..1) `[]=(multiset arg, mixed index, int(0..1) val)    *!    *! Index assign operator. -  +  *! +  *! If @[arg] is an object that implements @[lfun::`[]=()], that function +  *! will be called with @[index] and @[val] as the arguments. +  *! +  *! @mixed @[arg] +  *! @type object +  *! The non-static (ie public) variable named @[index] will be looked up +  *! in @[arg], and assigned @[val]. +  *! @type array +  *! @type mapping +  *! Index @[index] in @[arg] will be assigned @[val]. +  *! @type multiset +  *! If @[val] is @tt{0@} (zero), one occurrance of @[index] in +  *! @[arg] will be removed. Otherwise @[index] will be added +  *! to @[arg] if it is not already there. +  *! @endmixed +  *! +  *! @returns +  *! @[val] will be returned. +  *! +  *! @seealso +  *! @[`->=()], @[lfun::`[]=()]    */   PMOD_EXPORT void f_index_assign(INT32 args)   {    switch (args) {    case 0:    case 1:    case 2:    PIKE_ERROR("`[]=", "Too few arguments.\n", sp, args);    break;    case 3:    if(sp[-2].type==T_STRING) sp[-2].subtype=0;    assign_lvalue (sp-3, sp-1);    assign_svalue (sp-3, sp-1);    pop_n_elems (args-1);    break;    default:    PIKE_ERROR("`[]=", "Too many arguments.\n", sp, args);    }   }    - /*! @decl mixed `->=(mixed arg1, mixed arg2, mixed arg3) + /*! @decl mixed `->=(object arg, string index, mixed val) +  *! @decl mixed `->=(mapping arg, string index, mixed val) +  *! @decl int(0..1) `->=(multiset arg, string index, int(0..1) val)    *!    *! Arrow assign operator. -  +  *! +  *! This function behaves much like @[`[]=()], just that the index is always +  *! a string. +  *! +  *! If @[arg] is an object that implements @[lfun::`->=()], that function +  *! will be called with @[index] and @[val] as the arguments. +  *! +  *! @mixed @[arg] +  *! @type object +  *! The non-static (ie public) variable named @[index] will be looked up +  *! in @[arg], and assigned @[val]. +  *! @type array +  *! @type mapping +  *! Index @[index] in @[arg] will be assigned @[val]. +  *! @type multiset +  *! If @[val] is @tt{0@} (zero), one occurrance of @[index] in +  *! @[arg] will be removed. Otherwise @[index] will be added +  *! to @[arg] if it is not already there. +  *! @endmixed +  *! +  *! @returns +  *! @[val] will be returned. +  *! +  *! @seealso +  *! @[`[]=()], @[lfun::`->=()]    */   PMOD_EXPORT void f_arrow_assign(INT32 args)   {    switch (args) {    case 0:    case 1:    case 2:    PIKE_ERROR("`->=", "Too few arguments.\n", sp, args);    break;    case 3:    if(sp[-2].type==T_STRING) sp[-2].subtype=1;    assign_lvalue (sp-3, sp-1);    assign_svalue (sp-3, sp-1);    pop_n_elems (args-1);    break;    default:    PIKE_ERROR("`->=", "Too many arguments.\n", sp, args);    }   }    - /*! @decl int sizeof(mixed arg) + /*! @decl int sizeof(string arg) +  *! @decl int sizeof(array arg) +  *! @decl int sizeof(mapping arg) +  *! @decl int sizeof(multiset arg) +  *! @decl int sizeof(object arg)    *!    *! Sizeof operator. -  +  *! +  *! The result will be as follows: +  *! @mixed @[arg] +  *! @type string +  *! The number of characters in @[arg] will be returned. +  *! @type array +  *! @type multiset +  *! The number of elements in @[arg] will be returned. +  *! @type mapping +  *! The number of key-value pairs in @[arg] will be returned. +  *! @type object +  *! If @[arg] implements @[lfun::_sizeof()], that function will +  *! be called. Otherwise the number of non-static (ie public) +  *! symbols in @[arg] will be returned. +  *! @endmixed +  *! +  *! @seealso +  *! @[lfun::_sizeof()]    */   PMOD_EXPORT void f_sizeof(INT32 args)   {    INT32 tmp;    if(args<1)    PIKE_ERROR("sizeof", "Too few arguments.\n", sp, args);       tmp=pike_sizeof(sp-args);       pop_n_elems(args);