Branch: Tag:

2001-02-10

2001-02-10 14:58:48 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Converted AutoDoc mk II markup from Pike-style to C-style.
A few minor bugs fixed.

Rev: src/builtin.cmod:1.20

24:   #include "main.h"   #include "operators.h"    - //! Extract a column from a two-dimensional array. - //! - //! This function is exactly equivalent to: - //! @code{map(@[data], lambda(mixed x,mixed y) { return x[y]; }, @[index])@} - //! - //! Except of course it is a lot shorter and faster. - //! That is, it indices every index in the array data on the value of - //! the argument index and returns an array with the results. - //! - //! @seealso - //! @[rows()] - //! + /*! @decl array column(array data, mixed index) +  *! +  *! Extract a column from a two-dimensional array. +  *! +  *! This function is exactly equivalent to: +  *! @code{map(@[data], lambda(mixed x,mixed y) { return x[y]; }, @[index])@} +  *! +  *! Except of course it is a lot shorter and faster. +  *! That is, it indices every index in the array data on the value of +  *! the argument index and returns an array with the results. +  *! +  *! @seealso +  *! @[rows()] +  */   PIKEFUN array column(array data, mixed index)    efun;    optflags OPT_TRY_OPTIMIZE;
77:    RETURN a;   }    - //! This function creates a multiset from an array. - //! - //! @seealso - //! @[aggregate_multiset()] - //! + /*! @decl multiset mkmultiset(array a) +  *! +  *! This function creates a multiset from an array. +  *! +  *! @seealso +  *! @[aggregate_multiset()] +  *! +  */   PIKEFUN multiset(1) mkmultiset(array(1=mixed) a)    efun;    optflags OPT_TRY_OPTIMIZE|OPT_EXTERNAL_DEPEND;
89:    RETURN mkmultiset(a);   }    - //! This function changes the debug trace level. - //! - //! The old level is returned. - //! - //! Trace level 1 or higher means that calls to Pike functions are - //! printed to stderr, level 2 or higher means calls to builtin functions - //! are printed, 3 means every opcode interpreted is printed, 4 means - //! arguments to these opcodes are printed as well. - //! - //! See the @tt{-t@} command-line option for more information. - //! + /*! @decl int trace(int t) +  *! +  *! This function changes the debug trace level. +  *! +  *! The old level is returned. +  *! +  *! Trace level 1 or higher means that calls to Pike functions are +  *! printed to stderr, level 2 or higher means calls to builtin functions +  *! are printed, 3 means every opcode interpreted is printed, 4 means +  *! arguments to these opcodes are printed as well. +  *! +  *! See the @tt{-t@} command-line option for more information. +  */   PIKEFUN int trace(int t)    efun;    optflags OPT_SIDE_EFFECT;
109:    t_flag=t;   }    - //! Convert the output from a previous call to @[time()] into a readable - //! string containing the current year, month, day and time. - //! - //! @seealso - //! @[time()], @[localtime()], @[mktime()], @[gmtime()] - //! + /*! +  *! Convert the output from a previous call to @[time()] into a readable +  *! string containing the current year, month, day and time. +  *! +  *! @seealso +  *! @[time()], @[localtime()], @[mktime()], @[gmtime()] +  */   PIKEFUN string ctime(int timestamp)    efun;    optflags OPT_TRY_OPTIMIZE;
123:    RETURN make_shared_string(ctime(&i));   }    - //! Make a mapping from two arrays. - //! - //! Makes a mapping @[ind[x]]:@[val[x]], @tt{0 <= x < sizeof(ind)@}. - //! - //! @[ind] and @[val] must have the same size. - //! - //! This is the inverse operation of @[indices()] and @[values()]. - //! - //! @seealso - //! @[indices()], @[values()] - //! + /*! @decl mapping mkmapping(array ind, array val) +  *! +  *! Make a mapping from two arrays. +  *! +  *! Makes a mapping @[ind[x]]:@[val[x]], @tt{0 <= x < sizeof(ind)@}. +  *! +  *! @[ind] and @[val] must have the same size. +  *! +  *! This is the inverse operation of @[indices()] and @[values()]. +  *! +  *! @seealso +  *! @[indices()], @[values()] +  */   PIKEFUN mapping(1:2) mkmapping(array(1=mixed) ind, array(2=mixed) val)    efun;    optflags OPT_TRY_OPTIMIZE|OPT_EXTERNAL_DEPEND;
146:    RETURN mkmapping(ind, val);   }    - //! Count the number of non-overlapping times the string @[needle] occurrs - //! in the string @[haystack]. - //! - //! @seealso - //! @[search()], @[`/()] - //! + /*! @decl int string_count(string haystack, string needle) +  *! +  *! Count the number of non-overlapping times the string @[needle] occurrs +  *! in the string @[haystack]. +  *! +  *! @seealso +  *! @[search()], @[`/()] +  */   PIKEFUN int string_count(string haystack, string needle)    errname String.count;    optflags OPT_TRY_OPTIMIZE;
184:    RETURN DO_NOT_WARN((INT_TYPE)c);   }    - //! Returns 1 if @[prog] implements @[api]. - //! + /*! @decl int program_implements(program prog, program api) +  *! +  *! Returns 1 if @[prog] implements @[api]. +  */   PIKEFUN int program_implements(program prog, program api)    errname Program.implements;    optflags OPT_TRY_OPTIMIZE;
193:    RETURN implements(prog, api);   }    - //! Returns 1 if @[child] has inherited @[parent]. - //! + /*! @decl int program_inherits(program child, program parent) +  *! +  *! Returns 1 if @[child] has inherited @[parent]. +  */   PIKEFUN int program_inherits(program child, program parent)    errname Program.inherits;    optflags OPT_TRY_OPTIMIZE;
202:    RETURN !!low_get_storage(parent, child);   }    - //! Returns a string with filename and linenumber describing where - //! the program @[p] was defined. - //! - //! The returned string is of the format @tt{"@i{filename@}:@i{linenumber@}"@}. - //! - //! If it cannot be determined where the program was defined, @tt{0@} (zero) - //! will be returned. - //! + /*! @decl string program defined(program p) +  *! +  *! Returns a string with filename and linenumber describing where +  *! the program @[p] was defined. +  *! +  *! The returned string is of the format @tt{"@i{filename@}:@i{linenumber@}"@}. +  *! +  *! If it cannot be determined where the program was defined, @tt{0@} (zero) +  *! will be returned. +  */   PIKEFUN string program_defined(program p)    errname Program.defined;    optflags OPT_TRY_OPTIMIZE;
239:    push_int(0);   }    - //! Returns the width of a string. - //! - //! Three return values are possible: - //! @int - //! @value 8 - //! The string @[s] only contains characters <= 255. - //! @value 16 - //! The string @[s] only contains characters <= 65535. - //! @value 32 - //! The string @[s] contains characters >= 65536. - //! @endint - //! - PIKEFUN int string_width(string s) + /*! @decl int(8..8)|int(16..16)|int(32..32) string_width(string s) +  *! +  *! Returns the width of a string. +  *! +  *! Three return values are possible: +  *! @int +  *! @value 8 +  *! The string @[s] only contains characters <= 255. +  *! @value 16 +  *! The string @[s] only contains characters <= 65535. +  *! @value 32 +  *! The string @[s] contains characters >= 65536. +  *! @endint +  */ + PIKEFUN int(8..8)|int(16..16)|int(32..32) string_width(string s)    errname String.width;    optflags OPT_TRY_OPTIMIZE;   {    RETURN 8 * (1 << s->size_shift);   }    - //! Removes the entry with index @[index] from mapping @[map] destructively. - //! - //! If the mapping does not have an entry with index @[index], nothing is done. - //! - //! @returns - //! The value that was removed will be returned. - //! - //! @note - //! Note that @[m_delete()] changes @[map] destructively. - //! - //! @seealso - //! @[mappingp()] - //! + /*! @decl mixed m_delete(object|mapping map, mixed index) +  *! +  *! If @[map] is an object that implements @[lfun::_m_delete()], +  *! that function will be called with @[index] as the signle argument. +  *! +  *! Other wise if @[map] is a mapping the entry with index @[index] +  *! will be removed from @[map] destructively. +  *! +  *! If the mapping does not have an entry with index @[index], nothing is done. +  *! +  *! @returns +  *! The value that was removed will be returned. +  *! +  *! @note +  *! Note that @[m_delete()] changes @[map] destructively. +  *! +  *! @seealso +  *! @[mappingp()] +  */   PIKEFUN mixed m_delete(object|mapping map, mixed index)    efun;    optflags OPT_SIDE_EFFECT;
291:    }    else if (map->type == T_OBJECT)    { -  int id; -  if( !map->u.object->prog || !(map->u.object->prog->flags & PROGRAM_FIXED) ) -  SIMPLE_BAD_ARG_ERROR("m_delete", 1, "object|mapping"); +  int id = FIND_LFUN(map->u.object->prog, LFUN__M_DELETE);    -  id = map->u.object->prog->lfuns[ LFUN__M_DELETE ]; -  +     if( id == -1 )    SIMPLE_BAD_ARG_ERROR("m_delete", 1, "object with _m_delete");   
308:    }   }    - //! Returns 1 if the weak flag has been set for @[m]. - //! + /*! @decl int(0..1) get_weak_flag(array|mapping|multiset m) +  *! +  *! Returns 1 if the weak flag has been set for @[m]. +  */   PIKEFUN int(0 .. 1) get_weak_flag(array|mapping|multiset m)    efun;    optflags OPT_EXTERNAL_DEPEND;