<?xml version='1.0' encoding='utf-8'?> |
<autodoc> |
<namespace name='c'> |
<docgroup homogen-name='IS_ZERO' homogen-type='method'> |
<method name='IS_ZERO'/><doc placeholder='true'> |
<text> |
<p><tt>IS_ZERO</tt> - is this svalue considered 'false'</p> |
|
<tt><p>#include <simulate.h><br/> |
|
</p> |
<p>int IS_ZERO(struct svalue *<i>s</i>);<br/> |
</p> |
</tt> |
<p>IS_ZERO returns true if the svalue 's' is a zero. (or an object with |
`! operator that returned true..)</p> |
</text> |
|
<group><note/><text> |
<p>IS_ZERO is actually a macro</p> |
|
svalue</text></group> |
|
<group><seealso/><text> |
<p><ref resolved='c::is_eq' to='is_eq'>is_eq</ref>, <ref resolved='c::is_equal' to='is_equal'>is_equal</ref> and <ref resolved='c::is_lt' to='is_lt'>is_lt</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='add_shared_strings' homogen-type='method'> |
<method name='add_shared_strings'/><doc placeholder='true'> |
<text> |
<p><tt>add_shared_strings</tt> - add two pike strings</p> |
|
<tt><p>#include "stralloc.h"<br/> |
|
</p> |
<p>struct pike_string *add_shared_strings(struct pike_string *a,<br/> |
<dl><group><text>struct pike_string *b);<br/> |
</text></group></dl></p> |
</tt> |
<p>This function builds the string a+b, that is the string a with the |
string b appended to it. Note that the string returned will have |
an extra reference.</p> |
|
pike_string</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::begin_shared_string' to='begin_shared_string'>begin_shared_string</ref> and <ref resolved='c::make_shared_string' to='make_shared_string'>make_shared_string</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='allocate_array' homogen-type='method'> |
<method name='allocate_array'/><doc placeholder='true'> |
<text> |
<p><tt>allocate_array</tt> - allocate an array</p> |
|
<tt><p>#include "array.h"<br/> |
|
</p> |
<p>struct array *allocate_array(INT32 <i>size</i>);<br/> |
</p> |
</tt> |
<p>This function allocates an array of size 'size'. The returned |
array will have 'size' struct svalues in the member 'item'. |
The array can contain any svalue, and the type field will be |
initalized to -1.</p> |
</text> |
|
<group><note/><text> |
<p>When building arrays, it is recommended that you push the values |
on the stack and call aggregate_array or f_aggregate instead of |
allocating and filling in the values 'by hand'.</p> |
|
array</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='array' homogen-type='method'> |
<method name='array'/><doc placeholder='true'> |
<text> |
<p><tt>array</tt> - the internal representation of an array</p> |
|
<p>A Pike array is represented as a 'struct array' with all the |
needed svalues malloced in the same block. The relevant members |
are: |
</p> |
<p><matrix> |
<r><c> refs </c><c> reference count </c></r> |
<r><c> size </c><c> the number of svalues in the array </c></r> |
<r><c> malloced_size </c><c> the number of svalues that can fit in this block </c></r> |
<r><c> type_field </c><c> a bitfield indicating what types the array contains </c></r> |
<r><c> item </c><c> the array of svalues </c></r> |
</matrix> |
</p> |
</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::type_field' to='type_field'>type_field</ref></p> |
|
internals</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='array_index' homogen-type='method'> |
<method name='array_index'/><doc placeholder='true'> |
<text> |
<p><tt>array_index</tt> - get an index from an array</p> |
|
<tt><p>#include "array.h"<br/> |
|
</p> |
<p>void array_index(struct svalue *<i>to</i>, struct array *<i>a</i>, INT32 <i>n</i>);<br/> |
</p> |
</tt> |
<p>This function frees the contents of the svalue 'to' and replaces |
it with a copy of the contents from index 'n' in the array 'a'. |
Basically, what it does is: |
</p> |
<p><matrix> |
<r><c> </c><c> assign_svalue(to, a->item + n); </c></r> |
<r><c> </c></r> |
</matrix> |
|
</p> |
<p>The only differance is that it adds some debug and safety |
measures. Usually you don't really need to use this function.</p> |
</text> |
|
<group><note/><text> |
<p>If n is out of bounds (n < 0 or n >= a->size) Pike will dump |
core. If Pike was compiled with DEBUG, a message will be written |
first stating what the problem was.</p> |
</text></group> |
|
<group><seealso/><text> |
<p><ref resolved='c::assign_svalue' to='assign_svalue'>assign_svalue</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='assign_svalue' homogen-type='method'> |
<method name='assign_svalue'/><doc placeholder='true'> |
<text> |
<p><tt>assign_svalue</tt> - copy svalues from one place to another</p> |
|
<tt><p>#include <svalue.h><br/> |
|
</p> |
<p>void assign_svalue(struct svale *<i>to</i>, struct svalue *<i>from</i>);<br/> |
</p> |
</tt> |
<p>This function copies an svalue from one struct svalue to another. |
It frees the contents of 'to' first and updates the involved |
refcounts.</p> |
|
svalue</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::free_svalue' to='free_svalue'>free_svalue</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='begin_shared_string' homogen-type='method'> |
<method name='begin_shared_string'/><doc placeholder='true'> |
<text> |
<p><tt>begin_shared_string</tt> - allocate space for a shared string</p> |
|
<tt><p>#include "stralloc.h"<br/> |
|
</p> |
<p>struct pike_string *begin_shared_string(INT32 <i>len</i>);<br/> |
</p> |
</tt> |
<p>This function allocates space for a shared string of length 'len'. |
You should then MEMCPY 'len' bytes into the s->str. (s being the |
returned value) And then call end_shared_string.</p> |
|
pike_string</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::end_shared_string' to='end_shared_string'>end_shared_string</ref> and <ref resolved='c::make_shared_string' to='make_shared_string'>make_shared_string</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='binary_findstring' homogen-type='method'> |
<method name='binary_findstring'/><doc placeholder='true'> |
<text> |
<p><tt>binary_findstring</tt> - find a string</p> |
|
<tt><p>#include "stralloc.h"<br/> |
|
</p> |
<p>struct pike_string *binary_findstring(char *<i>str</i>, INT32 <i>length</i>);<br/> |
</p> |
</tt> |
<p>This function looks for the 'str' with length 'len' in the |
global hash table. It returns the shared string if found, otherwise |
zero. It does not increase/decrease the references to the string.</p> |
|
pike_string</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::findstring' to='findstring'>findstring</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='copy_mapping' homogen-type='method'> |
<method name='copy_mapping'/><doc placeholder='true'> |
<text> |
<p><tt>copy_mapping</tt> - copy a mapping</p> |
|
<tt><p>#include "mapping.h"<br/> |
|
</p> |
<p>struct mapping *copy_mapping(struct mapping *m)<br/> |
</p> |
</tt> |
<p>This function returns a copy of the mapping m. If you change the |
contents of the new mapping the contents of the mapping m will not |
change. Note that this function is not recursive.</p> |
|
mapping</text> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='end_shared_string' homogen-type='method'> |
<method name='end_shared_string'/><doc placeholder='true'> |
<text> |
<p><tt>end_shared_string</tt> - link a shared string into the hashtable</p> |
|
<tt><p>#include "stralloc.h"<br/> |
|
</p> |
<p>struct pike_string *end_shared_string(struct pike_string *<i>p</i>);<br/> |
</p> |
</tt> |
<p>This function the prepared output from a begin_shared_string and |
links the string into the hash table. If an identical string is |
already present in the hash table, p is freed and that string is |
returned instead. The returned string will have one extra reference |
added.</p> |
</text> |
|
<group><example/><text> |
<tt><p>#include "global.h"<br/> |
#include "stralloc.h"<br/> |
|
</p> |
<p>struct pike_string *mkcharstring(int ch)<br/> |
{<br/> |
<dl><group><text>struct pike_string *ret;<br/> |
ret=begin_shared_string(1);<br/> |
ret->str[0]=ch;<br/> |
return end_shared_string(ret);<br/> |
</text></group></dl>}<br/> |
</p> |
</tt> |
pike_string</text></group> |
|
<group><seealso/><text> |
<p><ref resolved='c::begin_shared_string' to='begin_shared_string'>begin_shared_string</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='error' homogen-type='method'> |
<method name='error'/><doc placeholder='true'> |
<text> |
<p><tt>error</tt> - throw an error</p> |
|
<tt><p>#include "error.h"<br/> |
|
</p> |
<p>void error(char *<i>format_string</i>, ...);<br/> |
</p> |
</tt> |
<p>This function takes the same kind of arguments as printf, puts it |
all together to a string and throws this as an error message |
togehter with a backtrace that tells the catcher where the error |
was. Note that this function does _not_ return. Instead it calls |
the C function lonjump and continues executing from the most |
resent active catch() call.</p> |
|
internals</text> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='fatal' homogen-type='method'> |
<method name='fatal'/><doc placeholder='true'> |
<text> |
<p><tt>fatal</tt> - print a message and dump core</p> |
|
<tt><p>#include "error.h"<br/> |
|
</p> |
<p>void fatal(char *<i>format_string</i>, ...);<br/> |
</p> |
</tt> |
<p>This function takes the same type of argument as 'printf', and |
prints these with any available debug information. (A trace of |
the 512 last executed instructions if you compiled with DEBUG.) |
Then it forces the driver to dump core so you can examine the |
bug with a debugger. Use with extreme caution, an error() might |
sometimes be a lot better...</p> |
|
internal</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::error' to='error'>error</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='findstring' homogen-type='method'> |
<method name='findstring'/><doc placeholder='true'> |
<text> |
<p><tt>findstring</tt> - find a string</p> |
|
<tt><p>#include "stralloc.h"<br/> |
|
</p> |
<p>struct pike_string *findstring(char *<i>str</i>);<br/> |
</p> |
</tt> |
<p>This function looks for the null terminated C string 'str' in the |
global hash table. It returns the shared string if found, otherwise |
zero. It does not increase/decrease the references to the string.</p> |
|
pike_string</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::make_shared_string' to='make_shared_string'>make_shared_string</ref> and <ref resolved='c::binary_findstring' to='binary_findstring'>binary_findstring</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='frame' homogen-type='method'> |
<method name='frame'/><doc placeholder='true'> |
<text> |
<p><tt>frame</tt> - the current frame of exectution</p> |
|
<p>The frame pointer is called 'fp' and is of type 'struct frame'. |
The frame pointer contains information about what function we |
are executing in, what is the current object, the current program, |
where the local variables are etc. It also contains a pointer to |
the previous frame in the call stack. The most important members |
of 'fp' are: |
</p> |
<p><matrix> |
<r><c> current_object </c><c> same as the Pike function this_object() </c></r> |
<r><c> context.program </c><c> the program in which this function resides </c></r> |
<r><c> current_storage </c><c> a 'char *' pointer into the data area for this </c></r> |
</matrix> |
<dl><group><text><matrix> |
<r><c> </c><c> object. This is the pointer to the area reserved </c></r> |
<r><c> </c></r> |
</matrix> |
<dl><group><text><matrix> |
<r><c> </c><c> for you if you have done add_storage() earlier. </c></r> |
<r><c> </c></r> |
</matrix> |
</text></group></dl></text></group></dl></p> |
|
internals</text> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='free_array' homogen-type='method'> |
<method name='free_array'/><doc placeholder='true'> |
<text> |
<p><tt>free_array</tt> - free one reference to a array</p> |
|
<tt><p>#include "array.h"<br/> |
|
</p> |
<p>void free_array(struct array *a)<br/> |
</p> |
</tt> |
<p>This function frees one reference to the array a. If the reference |
is the last reference to the array, it will free the memory used |
by the array a.</p> |
</text> |
|
<group><note/><text> |
<p>free_array is a macro</p> |
|
array</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='free_mapping' homogen-type='method'> |
<method name='free_mapping'/><doc placeholder='true'> |
<text> |
<p><tt>free_mapping</tt> - free one reference to a mapping</p> |
|
<tt><p>#include "mapping.h"<br/> |
|
</p> |
<p>void free_mapping(struct mapping *m)<br/> |
</p> |
</tt> |
<p>This function frees one reference to the mapping m. If the reference |
is the last reference to the mapping, it will free the memory used |
by the mapping m.</p> |
</text> |
|
<group><note/><text> |
<p>free_mapping is a macro</p> |
|
mapping</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='free_string' homogen-type='method'> |
<method name='free_string'/><doc placeholder='true'> |
<text> |
<p><tt>free_string</tt> - free a pike string</p> |
|
<tt><p>#include "stralloc.h"<br/> |
|
</p> |
<p>void free_string(struct pike_string *p)<br/> |
</p> |
</tt> |
<p>This function frees the string 'p'. What it actually does is that it |
decreases the reference count of 'p' and frees the memory reserved |
for it if the refereneces reach zero.</p> |
</text> |
|
<group><note/><text> |
<p>free_string is actually a macro</p> |
|
pike_string</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='free_svalue' homogen-type='method'> |
<method name='free_svalue'/><doc placeholder='true'> |
<text> |
<p><tt>free_svalue</tt> - free the contents of an svalue</p> |
|
<tt><p>#include <svalue.h><br/> |
|
</p> |
<p>void free_svalue(struct svalue *<i>s</i>);<br/> |
</p> |
</tt> |
<p>This function frees the contents of an svalue with respect to |
ref counts. It does not however free the storage for svalue itself. |
That is up to the caller to do.</p> |
|
svalue</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::assign_svalue' to='assign_svalue'>assign_svalue</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='is_eq' homogen-type='method'> |
<method name='is_eq'/><doc placeholder='true'> |
<text> |
<p><tt>is_eq</tt> - compare two svalues</p> |
|
<tt><p>#include <svalue.h><br/> |
|
</p> |
<p>int is_eq(struct svalue *<i>a</i>, struct svalue *<i>b</i>);<br/> |
</p> |
</tt> |
<p>This is the equivialent of the Pike operator `==. It compares two |
svalues and returns one if they are the same. Otherwise zero.</p> |
|
svalue</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::is_equal' to='is_equal'>is_equal</ref>, <ref resolved='c::is_lt' to='is_lt'>is_lt</ref> and <ref resolved='c::IS_ZERO' to='IS_ZERO'>IS_ZERO</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='is_equal' homogen-type='method'> |
<method name='is_equal'/><doc placeholder='true'> |
<text> |
<p><tt>is_equal</tt> - compare two svalues recursively</p> |
|
<tt><p>#include <svalue.h><br/> |
|
</p> |
<p>int is_equal(struct svalue *<i>a</i>, struct svalue *<i>b</i>);<br/> |
</p> |
</tt> |
<p>This is the equivialent of the Pike function equal(), it compares |
two svalues recursively and returns 1 if their contents are equal, |
zero otherwise.</p> |
|
svalue</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::is_eq' to='is_eq'>is_eq</ref>, <ref resolved='c::is_lt' to='is_lt'>is_lt</ref> and <ref resolved='c::IS_ZERO' to='IS_ZERO'>IS_ZERO</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='is_lt' homogen-type='method'> |
<method name='is_lt'/><doc placeholder='true'> |
<text> |
<p><tt>is_lt</tt> - compare two svalues</p> |
|
<tt><p>#include <svalue.h><br/> |
|
</p> |
<p>int is_lt(struct svalue *<i>a</i>, struct svalue *<i>b</i>);<br/> |
</p> |
</tt> |
<p>This is the equivialent of the Pike operator `<. It compares the |
contents of two svalues and returns true if the 'a' is lesser than |
'b'. It will give an error if the types are not comparable.</p> |
</text> |
|
<group><note/><text> |
<p>is_gt, is_ge and is_le are also available. They are all macros that |
call this function.</p> |
|
svalue</text></group> |
|
<group><seealso/><text> |
<p><ref resolved='c::is_eq' to='is_eq'>is_eq</ref> and <ref resolved='c::is_equal' to='is_equal'>is_equal</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='low_mapping_lookup' homogen-type='method'> |
<method name='low_mapping_lookup'/><doc placeholder='true'> |
<text> |
<p><tt>low_mapping_lookup</tt> - lookup a key in a mapping</p> |
|
<tt><p>#include "mapping.h"<br/> |
|
</p> |
<p>struct svalue *low_mapping_lookup(struct mapping *m,<br/> |
<dl><group><text>struct svalue *key);<br/> |
</text></group></dl></p> |
</tt> |
<p>This function looks up the key-index pair that has the key 'key' in |
the mapping 'm' and returns a pointer to the 'value'. If no such |
key-index pair is found, zero is returned.</p> |
</text> |
|
<group><note/><text> |
<p>Any call to an internal Pike function may re-allocate the mapping |
'm', which means that the pointer returned from this call is only |
valid until your next function call.</p> |
</text></group> |
|
<group><note/><text> |
<p>This function is intended for _reading_ mappings, it is forbidden |
to change the contents of the returned svalue.</p> |
|
mapping</text></group> |
|
<group><seealso/><text> |
<p><ref to='map_insert'>map_insert</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='m_sizeof' homogen-type='method'> |
<method name='m_sizeof'/><doc placeholder='true'> |
<text> |
<p><tt>m_sizeof</tt> - return the number of key-value pairs in a mapping</p> |
|
<tt><p>#include "mapping.h"<br/> |
|
</p> |
<p>int m_sizeof(struct mapping *m)<br/> |
</p> |
</tt> |
<p>This function returns the number of key-index pairs in the mapping, |
just like the function sizeof() in Pike.</p> |
</text> |
|
<group><note/><text> |
<p>m_sizeof is a macro</p> |
|
mapping</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='make_shared_binary_string' homogen-type='method'> |
<method name='make_shared_binary_string'/><doc placeholder='true'> |
<text> |
<p><tt>make_shared_binary_string</tt> - make a shared string</p> |
|
<tt><p>#include "stralloc.h"<br/> |
|
</p> |
<p>struct pike_string *make_shared_binary_string(const char *<i>str</i>, int <i>len</i>);<br/> |
</p> |
</tt> |
<p>This function makes a shared string from the memory area beginning |
at 'str' and ends at str+len. The returned string will have one |
extra reference.</p> |
|
pike_string</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::make_shared_string' to='make_shared_string'>make_shared_string</ref>, <ref resolved='c::begin_shared_string' to='begin_shared_string'>begin_shared_string</ref>, <ref resolved='c::push_string' to='push_string'>push_string</ref> and <ref resolved='c::free_string' to='free_string'>free_string</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='make_shared_string' homogen-type='method'> |
<method name='make_shared_string'/><doc placeholder='true'> |
<text> |
<p><tt>make_shared_string</tt> - make a shared string</p> |
|
<tt><p>#include "stralloc.h"<br/> |
|
</p> |
<p>struct pike_string *make_shared_string(const char *<i>str</i>);<br/> |
</p> |
</tt> |
<p>This function does the same thing as make_shared_binary_string, but |
expects a zero terminated string instead.</p> |
|
pike_string</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::make_shared_binary_string' to='make_shared_binary_string'>make_shared_binary_string</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='map_delete' homogen-type='method'> |
<method name='map_delete'/><doc placeholder='true'> |
<text> |
<p><tt>map_delete</tt> - delete an item from a mapping</p> |
|
<tt><p>#include "mapping.h"<br/> |
|
</p> |
<p>void map_delete(struct mapping *<i>m</i>, struct svalue *<i>key</i>);<br/> |
</p> |
</tt> |
<p>This function removes the key-index pair that has they key 'key' |
from the mapping. If there is no such key-index pair in the mapping |
nothing will be done.</p> |
|
mapping</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::mapping_insert' to='mapping_insert'>mapping_insert</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='mapping' homogen-type='method'> |
<method name='mapping'/><doc placeholder='true'> |
<text> |
<p><tt>mapping</tt> - internal pike mappings</p> |
|
<p>'struct mapping' is the C representation of a Pike mapping. The struct |
itself contains no user servicable parts except for the member 'refs' |
which has to be increased when putting a 'struct mapping *' into a |
svalue. Never _ever_ decrease the ref counter manually, use |
free_mapping instead. Also note that you should never ever allocate |
a mapping statically, you should always use the functions provided by |
pike to allocate mappings. |
</p> |
<p>A mapping is basically a hash table with a linked list of key-value |
pairs in each hash bin. The hash table and the key-index pairs are |
allocated together in one large block to minimize memory fragmentation. |
Also note that whenever you search for a specific key-value pair in |
the mapping that key-value pair is propagated to the top of the linked |
list in that hash bin, which makes the search time very very small for |
most cases.</p> |
|
internals</text> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='mapping_indices' homogen-type='method'> |
<method name='mapping_indices'/><doc placeholder='true'> |
<text> |
<p><tt>mapping_indices</tt> - return all the keys from a mapping</p> |
|
<tt><p>#include "mapping.h"<br/> |
|
</p> |
<p>struct array *mapping_indices(struct mapping *m)<br/> |
</p> |
</tt> |
<p>This function returns an array with all the keys from the mapping m. |
The keys in the array are ordered in the same order as the values |
when using mapping_values. But only if no other mapping operations |
are done in between.</p> |
|
mapping</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::mapping_values' to='mapping_values'>mapping_values</ref> and <ref resolved='c::mkmapping' to='mkmapping'>mkmapping</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='mapping_insert' homogen-type='method'> |
<method name='mapping_insert'/><doc placeholder='true'> |
<text> |
<p><tt>mapping_insert</tt> - insert a key-value pair into a mapping</p> |
|
<tt><p>#include "mapping.h"<br/> |
|
</p> |
<p>void mapping_insert(struct mapping *m,<br/> |
<dl><group><text>struct svalue *key,<br/> |
struct svalue *value)<br/> |
</text></group></dl></p> |
</tt> |
<p>This function inserts a new key-value pair into the mapping m. |
If there is a already key-value pair with the same key in the mapping |
it will be replaced with the new key-value pair. If there isn't |
such a key-value pair in the mapping the mapping will grow in size |
to accomodate the new key-value pair. This is identical to the |
Pike operation: m[key]=value</p> |
|
mapping</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::map_delete' to='map_delete'>map_delete</ref> and <ref resolved='c::low_mapping_lookup' to='low_mapping_lookup'>low_mapping_lookup</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='mapping_replace' homogen-type='method'> |
<method name='mapping_replace'/><doc placeholder='true'> |
<text> |
<p><tt>mapping_replace</tt> - replace values in a mapping</p> |
|
<tt><p>#include "mapping.h"<br/> |
|
</p> |
<p>void mapping_replace(struct mapping *m,<br/> |
<dl><group><text>struct svalue *from,<br/> |
struct svalue *to)<br/> |
</text></group></dl></p> |
</tt> |
<p>This function replaces all values of the value 'from' in the mapping |
'm' with 'to'. It is a part of the Pike function replace().</p> |
|
mapping</text> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='mapping_values' homogen-type='method'> |
<method name='mapping_values'/><doc placeholder='true'> |
<text> |
<p><tt>mapping_values</tt> - return all the values from a mapping</p> |
|
<tt><p>#include "mapping.h"<br/> |
|
</p> |
<p>struct array *mapping_values(struct mapping *m)<br/> |
</p> |
</tt> |
<p>This function returns an array with all the values from the mapping m. |
The values in the array are ordered in the same order as the keys |
when using mapping_indices, but only if no other mapping operations |
are done between the mapping_values and the mapping_indices.</p> |
</text> |
|
<group><example/><text> |
<tt><p>struct mapping *slow_copy_mapping(struct mapping *m)<br/> |
{<br/> |
<dl><group><text>struct array *indices, *values;<br/> |
indices=mapping_indices(m);<br/> |
values=mapping_indices(m);<br/> |
m=mkmapping(indices,values);<br/> |
free_array(indices);<br/> |
free_array(values);<br/> |
return m;<br/> |
</text></group></dl>}<br/> |
</p> |
</tt> |
mapping</text></group> |
|
<group><seealso/><text> |
<p><ref resolved='c::mapping_indices' to='mapping_indices'>mapping_indices</ref>, <ref resolved='c::copy_mapping' to='copy_mapping'>copy_mapping</ref> and <ref resolved='c::mkmapping' to='mkmapping'>mkmapping</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='mkmapping' homogen-type='method'> |
<method name='mkmapping'/><doc placeholder='true'> |
<text> |
<p><tt>mkmapping</tt> - make a mapping</p> |
|
<tt><p>#include <mapping.h><br/> |
|
</p> |
<p>struct mapping *mkmapping(struct array *keys, struct array *values)<br/> |
</p> |
</tt> |
<p>This function is the same as the Pike function mkmapping. It |
makes a mapping out of an array of keys and an array of values. |
Note that the returned mapping will have one extra reference.</p> |
|
mapping</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::mapping_indices' to='mapping_indices'>mapping_indices</ref> and <ref resolved='c::mapping_values' to='mapping_values'>mapping_values</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='my_strcmp' homogen-type='method'> |
<method name='my_strcmp'/><doc placeholder='true'> |
<text> |
<p><tt>my_strcmp</tt> - my own strcmp function</p> |
|
<tt><p>#include "stralloc.h"<br/> |
|
</p> |
<p>int my_strcmp(struct pike_string *a, struct pike_string *b)<br/> |
</p> |
</tt> |
<p>This function compares two pike strings and takes locales into |
account if the system supports locales. It returns zero if the |
strings are the same, a number greater than zero zero if 'a' |
is greater than 'b', and a number below zero otherwise.</p> |
|
pike_string</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::make_shared_string' to='make_shared_string'>make_shared_string</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='pike_string' homogen-type='method'> |
<method name='pike_string'/><doc placeholder='true'> |
<text> |
<p><tt>pike_string</tt> - internal pike shared strings</p> |
|
<p>This is the internal type for representing pike strings. They have |
ref counts and they are shared though a global hash table. The C |
type is a struct pike_string that has two public members: str and |
len. str is an array of char which contain the actual string. It |
is guaranteed that the string is null terminated, but the string |
can also contain zeroes before the end. len is of course the |
length of the string. Since strings are shared you may _never_ |
modify the contents of a string, except for adding/subtracting |
references when approperiate. The only exception to this is when |
creating a new shared string with begin_shared_string which has |
not yet been linked to the hash table with end_shared_string.</p> |
|
internals</text> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='program' homogen-type='method'> |
<method name='program'/><doc placeholder='true'> |
<text> |
<p><tt>program</tt> - internal representation of a program</p> |
|
<p>A 'struct program' is basically what C++ hackers call a 'class'. |
It contains the byte code, information about line numbers, |
global variables etc. etc. Mostly you won't have to bother with |
any of the contents of a 'struct program'. Usually you only need |
to create them with start_new_program()/end_c_program() or |
clone them with clone().</p> |
</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::frame' to='frame'>frame</ref></p> |
|
internal</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='push_string' homogen-type='method'> |
<method name='push_string'/><doc placeholder='true'> |
<text> |
<p><tt>push_string</tt> - push a string on the pike stack</p> |
|
<tt><p>#include "interpret.h"<br/> |
|
</p> |
<p>void push_string(struct pike_string *p)<br/> |
</p> |
</tt> |
<p><matrix> |
<r><c> This function pushes the string p on the pike stack. Note that this </c></r> |
<r><c> function does _not_ add any extra references to 'p'. Most functions </c></r> |
<r><c> that create shared strings give one extra reference to them though. </c></r> |
<r><c> If you get your string from a function that does not add extra </c><c> </c></r> |
<r><c> references you will have to add a reference manually. </c></r> |
</matrix> |
</p> |
</text> |
|
<group><note/><text> |
<p>push_string is actually a macro</p> |
|
pike_string</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='string_replace' homogen-type='method'> |
<method name='string_replace'/><doc placeholder='true'> |
<text> |
<p><tt>string_replace</tt> - do string replacements</p> |
|
<tt><p>#include "stralloc.h"<br/> |
|
</p> |
<p>struct pike_string *string_replace(struct pike_string *str,<br/> |
<dl><group><text>struct pike_string *from,<br/> |
struct pike_string *to);<br/> |
</text></group></dl></p> |
</tt> |
<p>This function builds a new string from 'str' with all occurances |
of 'from' replaced by 'to'. Note that the new string will have one |
extra reference.</p> |
|
pike_string</text> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='svalue' homogen-type='method'> |
<method name='svalue'/><doc placeholder='true'> |
<text> |
<p><tt>svalue</tt> - internal type for storing Pike values</p> |
|
<p>The 'struct svalue' contains one Pike 'value', variables, arrays |
and the evaluator are all svalues. An svalue consists of three |
elements: type, subtype and a union containing the actual value. |
The type is a short which tells you what type the svalue is. The |
value is one of the following: |
</p> |
<p><matrix> |
<r><c> T_ARRAY </c><c> When type is T_ARRAY, the array is stored in </c></r> |
<r><c> </c></r> |
</matrix> |
<dl><group><text><matrix> |
<r><c> </c><c> the 'array' member of the union. So if sval is </c></r> |
<r><c> </c></r> |
</matrix> |
<matrix> |
<r><c> </c><c> the pointer to the svalue, you would use sval->u.array </c></r> |
<r><c> </c></r> |
</matrix> |
<matrix> |
<r><c> </c><c> to access the actual array. </c></r> |
<r><c> </c></r> |
</matrix> |
</text></group></dl><matrix> |
<r><c> T_MAPPING </c><c> In this case, you use sval->u.mapping. </c></r> |
<r><c> T_MULTISET </c><c> sval->u.multiset </c></r> |
<r><c> T_OBJECT </c><c> sval->u.object </c></r> |
<r><c> T_FUNCTION </c><c> Functions are a bit more difficult, sval->u.object </c></r> |
</matrix> |
<dl><group><text><matrix> |
<r><c> </c><c> is the object the function is in, and sval->subtype </c></r> |
<r><c> </c></r> |
</matrix> |
<matrix> |
<r><c> </c><c> is the number of the function in that object. </c></r> |
<r><c> </c></r> |
</matrix> |
</text></group></dl><matrix> |
<r><c> T_PROGRAM </c><c> sval->u.program is the struct program you want. </c></r> |
<r><c> T_STRING </c><c> sval->u.string </c></r> |
<r><c> T_FLOAT </c><c> sval->u.float_number </c></r> |
<r><c> T_INT </c><c> sval->u.integer, a special case is that sval->subtype </c></r> |
</matrix> |
<dl><group><text><matrix> |
<r><c> </c><c> is used in some cases to represent the value </c></r> |
<r><c> </c><c> 'undefined'. This is what zero_type detects. </c></r> |
</matrix> |
</text></group></dl> |
</p> |
<p>There are lots of functions operating on svalues, so you shouldn't |
have to do all that much stuff with them yourself. However, for now |
you do need to check the type and extract the proper member of the |
union yourself when writing your own C functions for Pike.</p> |
|
internals</text> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='type_field' homogen-type='method'> |
<method name='type_field'/><doc placeholder='true'> |
<text> |
<p><tt>type_field</tt> - bit field used for optimizations</p> |
|
<p>Type fields are used by arrays, mappings and some svalue operations |
for optimization. The type field consists of OR:ed bits, one for |
each type. The bit for an array is 1<<T_ARRAY (same as BIT_ARRAY) |
The bit for a string is 1<<T_STRING (or BIT_STRING) etc. |
</p> |
<p>A bit field never has to be exact, it needs to have at least those |
bits that are present in the operation. It is never harmful to have |
too many bits though. It seldom pays off to calculate the bit field |
explicitly, so if you don't know what types are involved you should |
use -1 for the type field.</p> |
</text> |
|
<group><seealso/><text> |
<p><ref resolved='c::mapping' to='mapping'>mapping</ref>, <ref resolved='c::array' to='array'>array</ref> and <ref resolved='c::svalue' to='svalue'>svalue</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
</namespace> |
<namespace name='cpp'> |
<doc placeholder='true'> |
<text> |
<p><tt>preprocessor</tt> - textually process code before compiling</p> |
|
<p>Pike has a builtin C-style preprocessor. It works similar to old |
C preprocessors but has a few extra features. This file describes |
the different preprocessor directives.</p> |
|
<tt><p><dl><group><text>#!<br/> |
#define<br/> |
#elif<br/> |
#else<br/> |
#elseif<br/> |
#endif<br/> |
#error<br/> |
#if<br/> |
#ifdef<br/> |
#ifndef<br/> |
#include<br/> |
#line<br/> |
#pragma<br/> |
#undef<br/> |
</text></group></dl></p> |
</tt> |
pike</text> |
|
</doc> |
<docgroup homogen-name='#!' homogen-type='directive'> |
<directive name='#!'> |
</directive> |
<doc placeholder='true'> |
<text> |
|
<p>This directive is in effect a comment statement, since the |
preprocessor will ignore everything to the end of the line. |
This is used to write unix type scripts in Pike by starting |
the script with |
</p> |
<p>#!/usr/local/bin/pike |
</p> |
</text> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='#define' homogen-type='directive'> |
<directive name='#define'> |
</directive> |
<doc placeholder='true'> |
<text> |
|
<p>The simplest way to use define is to write |
</p> |
<p><dl><group><text>#define <identifier> <replacement string><br/> |
</text></group></dl> |
</p> |
<p>which will cause all subsequent occurances of 'identifier' to be |
replaced with the replacement string. |
</p> |
<p>Define also has the capability to use arguments, thus a line like |
</p> |
<p><dl><group><text>#define <identifier>(arg1, arg2) <replacement string><br/> |
</text></group></dl> |
</p> |
<p>would cause identifer to be a macro. All occurances of |
'identifier(something1,something2d)' would be replaced with |
the replacement string. And in the replacement string, arg1 and arg2 |
will be replaced with something1 and something2.</p> |
</text> |
|
<group><bugs/><text> |
<p>Note that it is not a good idea to do something like this: |
</p> |
<p>#define foo bar // a comment |
</p> |
<p>The comment will be included in the define, and thus inserted in the |
code. This will have the effect that the rest of the line will be |
ignored when the word foo is used. Not exactly what you might expect. |
</p> |
<p/> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-type='directive'> |
<directive name='#if'> |
</directive> |
<directive name='#elif'> |
</directive> |
<directive name='#elseif'> |
</directive> |
<directive name='#else'> |
</directive> |
<directive name='#endif'> |
</directive> |
<doc placeholder='true'> |
<text> |
|
<p>The #if directive causes conditional compiling of code depending on |
the expression after the #if directive. That is, if the expression |
is true, the code up to the next #else, #elif, #elseif or #endif is |
compiled. If the expression is false, that code will be skipped. |
If the skip leads up to a #else, the code after the else will be |
compiled. #elif and #elseif are equivialent and causes the code that |
follow them to be compiled if the previous #if or #elif evaluated |
false and the expression after the #elif evaluates true. |
</p> |
<p>Expressions given to #if, #elif or #endif are special, all identifiers |
evaluate to zero unless they are defined to something else. Integers, |
strings and floats are the only types that can be used, but all pike |
operators can be used on these types. |
</p> |
<p>Also, two special functions can be used, defined() and constant(). |
defined(<identifer>) expands to '1' if the identifier is defined, |
'0' otherwise. constant(<identifier>) expands to '1' if identifer is |
an predefined constant (with add_constant), '0' otherwise.</p> |
</text> |
|
<group><example/><text> |
<tt><p>#if 1<br/> |
<dl><group><text>write("foo");<br/> |
</text></group></dl>#else<br/> |
<dl><group><text>write("bar");<br/> |
</text></group></dl>#endif<br/> |
|
</p> |
<p>#if defined(FOO)<br/> |
<dl><group><text>write(FOO);<br/> |
</text></group></dl>#elif defined(BAR)<br/> |
<dl><group><text>write(BAR);<br/> |
</text></group></dl>#else<br/> |
<dl><group><text>write("default");<br/> |
</text></group></dl>#endif<br/> |
|
</p> |
<p>#if !constant(write_file)<br/> |
inherit "simulate.pike"<br/> |
#endif<br/> |
<br/> |
</p> |
</tt></text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='#error' homogen-type='directive'> |
<directive name='#error'> |
</directive> |
<doc placeholder='true'> |
<text> |
|
<p>This directive causes a compiler error, it can be used to notify |
the user that certain functions are missing and similar things.</p> |
</text> |
|
<group><example/><text> |
<tt><p>#if !constant(write_file)<br/> |
#error write_file efun is missing<br/> |
#endif<br/> |
<br/> |
</p> |
</tt></text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='#include' homogen-type='directive'> |
<directive name='#include'> |
</directive> |
<doc placeholder='true'> |
<text> |
|
<p>This directive should be given a file as argument, it will then be |
compiled as if all those lines were written at the #include line. |
The compiler then continues to compile this file.</p> |
</text> |
|
<group><example/><text> |
<tt><p>#include "foo.h"<br/> |
<br/> |
</p> |
</tt></text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='#line' homogen-type='directive'> |
<directive name='#line'> |
</directive> |
<doc placeholder='true'> |
<text> |
|
<p>This directive tells the compiler what line and file we are compiling. |
This is for instance used by the #include directive to tell the |
compiler that we are compiling another file. The directive takes |
the line number first, and optionally, the file afterwards. |
</p> |
<p>This can also be used when generating pike from something else, to |
tell teh compiler where the code originally originated from.</p> |
</text> |
|
<group><example/><text> |
<tt><p>#line 4 "foo.cf" /* The next line was generated from 4 in foo.cf */<br/> |
<br/> |
</p> |
</tt></text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='#pragma' homogen-type='directive'> |
<directive name='#pragma'> |
</directive> |
<doc placeholder='true'> |
<text> |
|
<p>This is a generic directive for flags to the compiler. Currently, the |
only flag available is 'all_inline' which is the same as adding the |
modifier 'inline' to all functions that follows. |
</p> |
</text> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='#undef' homogen-type='directive'> |
<directive name='#undef'> |
</directive> |
<doc placeholder='true'> |
<text> |
|
<p>This removes the effect of a #define, all subsequent occurances of |
the undefined identifier will not be replaced by anything. Note that |
when undefining a macro, you just give the identifer, not the |
arguments.</p> |
</text> |
|
<group><example/><text> |
<tt><p>#define foo bar<br/> |
#undef foo<br/> |
#define foo(bar) gazonk bar<br/> |
#undef foo<br/> |
<br/> |
</p> |
</tt></text></group> |
|
</doc> |
</docgroup> |
</namespace> |
<namespace name='predef'> |
<docgroup homogen-name='&&' homogen-type='method'>&& |
<method name='&&'/>&&<doc placeholder='true'> |
<text> |
<p><tt>&&</tt> - logical and</p> |
|
<tt><p>a && b<br/> |
</p> |
</tt> |
<p>This operator does logical 'and' between expressions. It first |
evaluates a and returns zero if a is zero. Otherwise it returns |
b. Note that b is not evaluated at all if a returns zero.</p> |
|
operators</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`&' to='`&'>&&`&</ref> and <ref resolved='predef::&&' to='||'>&&||</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='PI' homogen-type='constant'> |
<constant name='PI'/><doc placeholder='true'> |
<text> |
<p><tt>PI</tt> - pi</p> |
|
<tt><p>#include <simulate.h><br/> |
|
</p> |
<p>PI<br/> |
</p> |
</tt> |
<p>This is not a function, it is a constant added by simulate.pike.</p> |
|
float</text> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='_verify_internals' homogen-type='method'> |
<method name='_verify_internals'/><doc placeholder='true'> |
<text> |
<p><tt>_verify_internals</tt> - check Pike internals</p> |
|
<tt><p>void _verify_internals();<br/> |
</p> |
</tt> |
<p>This function goes through most of the internal Pike structures and |
generates a fatal error if one of them is found to be out of order. |
It is only used for debugging.</p> |
|
debugging</text> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`!' homogen-type='method'> |
<method name='`!'/><doc placeholder='true'> |
<text> |
<p><tt>`!</tt> - is not true</p> |
|
<tt><p>! a<br/> |
or<br/> |
int `!(mixed a)<br/> |
</p> |
</tt> |
<p>Returns 1 if a is zero, 0 otherwise.</p> |
|
operators</text> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`!=' homogen-type='method'> |
<method name='`!='/><doc placeholder='true'> |
<text> |
<p><tt>`!=</tt> - check if not equal</p> |
|
<tt><p>a != b<br/> |
or<br/> |
int `!=(mixed a, mixed b)<br/> |
</p> |
</tt> |
<p>This operator compares two values and returns 0 if they are the same, |
1 otherwise. Note that pointer equivialenec is required for arrays, |
objects, programs, mappings and multisets. (Thus it is not enough that |
two arrays LOOK alike, it must be the same array.)</p> |
|
operators</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`==' to='`=='>`==</ref>, <ref resolved='predef::`<' to='`<'><<`<</ref>, <ref resolved='predef::`>' to='`>'>>>`></ref>, <ref resolved='predef::`<=' to='`<='><<`<=</ref>, <ref resolved='predef::`>=' to='`>='>>>`>=</ref> and <ref to='efuns/equal'>efuns/equal</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`%' homogen-type='method'> |
<method name='`%'/><doc placeholder='true'> |
<text> |
<p><tt>`%</tt> - modulo</p> |
|
<tt><p>a % b<br/> |
or<br/> |
int `%(int a, int b)<br/> |
or<br/> |
float `%(int|float a,int|float b)<br/> |
</p> |
</tt> |
<p>This operator computes the rest of a division. For integers, this |
is the same as same as computing a-(a/b)*a. For floats, modulo is |
interpreted as a-floor(a/b)*a |
</p> |
</text> |
|
<group><example/><text> |
<tt><p><matrix> |
<r><c> 9%3 </c><c> returns 0 </c></r> |
<r><c> 10%3 </c><c> returns 1 </c></r> |
<r><c> 2%0.3 </c><c> returns 0.2 </c></r> |
</matrix> |
</p> |
</tt> |
operators</text></group> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`/' to='`/'>`/</ref> and <ref resolved='predef::`*' to='`*'>`*</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`&' homogen-type='method'>& |
<method name='`&'/>&<doc placeholder='true'> |
<text> |
<p><tt>`&</tt> - intersection</p> |
|
<tt><p>a & b<br/> |
or<br/> |
mixed `&(mixed ... args)<br/> |
</p> |
</tt> |
<p>This operator does logical intersections. For ints this means |
bitwise and. |
</p> |
<p>Arrays and multisets are treated as sets, so intersecting two arrays |
will result in an array with containing all values present in all |
arguments. |
</p> |
<p>For mappings, the intersection will be done on the indexes solely, |
however, the values will be taken from the rightmost mapping.</p> |
|
operators</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`|' to='`|'>`|</ref>, <ref resolved='predef::`^' to='`^'>`^</ref> and <ref resolved='predef::`&' to='&&'>&&&&&</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`*' homogen-type='method'> |
<method name='`*'/><doc placeholder='true'> |
<text> |
<p><tt>`*</tt> - multiplication</p> |
|
<tt><p>a * b<br/> |
or<br/> |
int `*(int ... args)<br/> |
or<br/> |
float `*(int|float ... args)<br/> |
or<br/> |
string `*(string *strings, string delimeter)<br/> |
</p> |
</tt> |
<p>For ints and floats, this operator simply multiplies its arguments. |
If the first argument is an array, and the second a string, all |
strings in the arrays will be concatenated, with the delimiter in |
between each string and the result will be returned.</p> |
</text> |
|
<group><example/><text> |
<tt><p><matrix> |
<r><c> 2*2 </c><c> returns 4 </c></r> |
<r><c> 2.0*2.0 </c><c> returns 4.0 </c></r> |
<r><c> 2.0*2 </c><c> returns 4.0 </c></r> |
<r><c> ({"f","",""})*"o") </c><c> Returns "foo" </c></r> |
<r><c> `*(2,2,2) </c><c> returns 8 </c></r> |
</matrix> |
</p> |
</tt> |
operators</text></group> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`/' to='`/'>`/</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`+' homogen-type='method'> |
<method name='`+'/><doc placeholder='true'> |
<text> |
<p><tt>`+</tt> - add things together</p> |
|
<tt><p>a + b<br/> |
or<br/> |
mixed `+(mixed ... args)<br/> |
</p> |
</tt> |
<p>For ints and floats this operator simply adds the two operators |
together. For strings and arrays, concatenation is done. For multisets |
and mapping this creates a new multiset/mapping with all indices and data as |
in a and b. Note that this can cause a multiset to contain |
several equal indices. Also, when adding a string to an int or float |
the number is converted to a printable string first.</p> |
</text> |
|
<group><example/><text> |
<tt><p><matrix> |
<r><c> "a"+10 </c><c> returns "a10" </c></r> |
<r><c> 10+20 </c><c> returns 30 </c></r> |
<r><c> ({1})+({2}) </c><c> returns ({1,2}) </c></r> |
<r><c> (<1>)+(<1>) </c><c> returns (<1,1>) </c></r> |
<r><c> `+(2,2,2) </c><c> returns 6 </c></r> |
</matrix> |
</p> |
</tt> |
operators</text></group> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`-' to='`-'>`-</ref> and <ref resolved='predef::`*' to='`*'>`*</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`-' homogen-type='method'> |
<method name='`-'/><doc placeholder='true'> |
<text> |
<p><tt>`-</tt> - subtract/negate</p> |
|
<tt><p>- a<br/> |
or<br/> |
`-(mixed <i>a</i>);<br/> |
or<br/> |
a - b<br/> |
or<br/> |
mixed `-(mixed a, mixed b)<br/> |
</p> |
</tt> |
<p>This is the negation and subtraction operator, for ints and floats |
the operation should be obvious. |
</p> |
<p>For arrays, an array containing all elements present in a and not in |
b is returne. The order of the remaining values from a will be kept. |
</p> |
<p>For multisets, the same operation is done as for arrays, except order is |
of course not considered. |
</p> |
<p><matrix> |
<r><c> For mappings, a mapping is returned with every key-index pair from </c></r> |
<r><c> a whos index is not present as an index in b. </c></r> |
<r><c> EXAMPLES </c></r> |
<r><c> 5-10 </c><c> returns -5 </c></r> |
<r><c> 10-2.0 </c><c> returns 8.0 </c></r> |
<r><c> ({1,2})-({2}) </c><c> returns ({1}) </c></r> |
<r><c> ([1:2,2:1])-([1:0]) </c><c> returns ([2:1]) </c></r> |
</matrix> |
</p> |
|
operators</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`+' to='`+'>`+</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`/' homogen-type='method'> |
<method name='`/'/><doc placeholder='true'> |
<text> |
<p><tt>`/</tt> - division</p> |
|
<tt><p>a / b<br/> |
or<br/> |
int `/(int a, int b)<br/> |
or<br/> |
float `/(int|float a,int|float b)<br/> |
or<br/> |
string* `/(string a,string b)<br/> |
</p> |
</tt> |
<p>For ints and floats, this operator simply divide its arguments. |
If the arguments are strings, the first string will be divided |
at every occurance of the second string. The resulting pieces |
are then returned in the form of an array.</p> |
</text> |
|
<group><example/><text> |
<tt><p><matrix> |
<r><c> 2/2 </c><c> returns 1 </c></r> |
<r><c> 3/2 </c><c> returns 1 </c></r> |
<r><c> 2.0/2.0 </c><c> returns 1.0 </c></r> |
<r><c> 2.0/2 </c><c> returns 1.0 </c></r> |
<r><c> "foo"/"o" </c><c> returns ({"f","",""}) </c></r> |
<r><c> `/(2,2) </c><c> returns 1 </c></r> |
</matrix> |
</p> |
</tt> |
operators</text></group> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`*' to='`*'>`*</ref> and <ref resolved='predef::`%' to='`%'>`%</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`<' homogen-type='method'>< |
<method name='`<'/><<doc placeholder='true'> |
<text> |
<p><tt>`<</tt> - is lesser than?</p> |
|
<tt><p>a < b<br/> |
or<br/> |
int `<(int|float|string a,int|float|string b)<br/> |
</p> |
</tt> |
<p>This operator compares two values and returns 1 if the first one |
is lesser than the second one.</p> |
|
operators</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`!=' to='`!='>`!=</ref>, <ref resolved='predef::`==' to='`=='>`==</ref>, <ref resolved='predef::`>' to='`>'>>>`></ref>, <ref resolved='predef::`<=' to='`<='><<`<=</ref> and <ref resolved='predef::`>=' to='`>='>>>`>=</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`<<' homogen-type='method'><< |
<method name='`<<'/><<<doc placeholder='true'> |
<text> |
<p><tt>`<<</tt> - shift left</p> |
|
<tt><p>a << b<br/> |
or<br/> |
int `<<(int a, int b)<br/> |
</p> |
</tt> |
<p>This operator shift the integer a b steps left. This is equal to |
multiplying a by 2 b times.</p> |
|
operators</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`>>' to='`>>'>>>>>`>></ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`<=' homogen-type='method'>< |
<method name='`<='/><<doc placeholder='true'> |
<text> |
<p><tt>`<=</tt> - is lesser or equal than?</p> |
|
<tt><p>a <= b<br/> |
or<br/> |
int `<=(int|float|string a,int|float|string b)<br/> |
</p> |
</tt> |
<p>This operator compares two values and returns 1 if the first one |
is lesser than or equal to the second one.</p> |
|
operators</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`!=' to='`!='>`!=</ref>, <ref resolved='predef::`==' to='`=='>`==</ref>, <ref resolved='predef::`>' to='`>'>>>`></ref>, <ref resolved='predef::`<' to='`<'><<`<</ref> and <ref resolved='predef::`>=' to='`>='>>>`>=</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`==' homogen-type='method'> |
<method name='`=='/><doc placeholder='true'> |
<text> |
<p><tt>`==</tt> - compare values</p> |
|
<tt><p>a == b<br/> |
or<br/> |
int `==(mixed a, mixed b)<br/> |
</p> |
</tt> |
<p>This operator compares two values and returns 1 if they are the same, |
0 otherwise. Note that pointer equivialenec is required for arrays, |
objects, programs, mappings and multisets. (Thus it is not enough that |
two arrays LOOK alike, it must be the same array.)</p> |
|
operators</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`!=' to='`!='>`!=</ref>, <ref resolved='predef::`<' to='`<'><<`<</ref>, <ref resolved='predef::`>' to='`>'>>>`></ref>, <ref resolved='predef::`<=' to='`<='><<`<=</ref>, <ref resolved='predef::`>=' to='`>='>>>`>=</ref> and <ref to='efuns/equal'>efuns/equal</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`>' homogen-type='method'>> |
<method name='`>'/>><doc placeholder='true'> |
<text> |
<p><tt>`></tt> - is lesser than?</p> |
|
<tt><p>a > b<br/> |
or<br/> |
int `>(int|float|string a,int|float|string b)<br/> |
</p> |
</tt> |
<p>This operator compares two values and returns 1 if the first one |
is greater than the second one.</p> |
|
operators</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`!=' to='`!='>`!=</ref>, <ref resolved='predef::`==' to='`=='>`==</ref>, <ref resolved='predef::`<' to='`<'><<`<</ref>, <ref resolved='predef::`<=' to='`<='><<`<=</ref> and <ref resolved='predef::`>=' to='`>='>>>`>=</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`>=' homogen-type='method'>> |
<method name='`>='/>><doc placeholder='true'> |
<text> |
<p><tt>`>=</tt> - is greater than or equal to?</p> |
|
<tt><p>a >= b<br/> |
or<br/> |
int `>=(int|float|string a,int|float|string b)<br/> |
</p> |
</tt> |
<p>This operator compares two values and returns 1 if the first one |
is greater than or equal to the second one.</p> |
|
operators</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`!=' to='`!='>`!=</ref>, <ref resolved='predef::`==' to='`=='>`==</ref>, <ref resolved='predef::`>' to='`>'>>>`></ref>, <ref resolved='predef::`<' to='`<'><<`<</ref> and <ref resolved='predef::`<=' to='`<='><<`<=</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`>>' homogen-type='method'>>> |
<method name='`>>'/>>><doc placeholder='true'> |
<text> |
<p><tt>`>></tt> - shift right</p> |
|
<tt><p>a >> b<br/> |
or<br/> |
int `>>(int a, int b)<br/> |
</p> |
</tt> |
<p>This operator shift the integer a b steps right. This is equal to |
dividing a by 2 b times.</p> |
|
operators</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`<<' to='`<<'><<<<`<<</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`^' homogen-type='method'> |
<method name='`^'/><doc placeholder='true'> |
<text> |
<p><tt>`^</tt> - exclusive or</p> |
|
<tt><p>a ^ b<br/> |
or<br/> |
mixed `^(mixed ... args)<br/> |
</p> |
</tt> |
<p>This operator does logical exclusive or operations For ints this means |
bitwise xor. |
</p> |
<p>Arrays and multisets are treated as sets, so xoring two arrays will |
result in an array with containing all values present in either but |
not both arrays. |
</p> |
<p>For mappings, the intersection will be done on the indexes solely, |
however, the values will be taken from the rightmost mapping.</p> |
|
operators</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`|' to='`|'>`|</ref> and <ref resolved='predef::`&' to='`&'>&&`&</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`|' homogen-type='method'> |
<method name='`|'/><doc placeholder='true'> |
<text> |
<p><tt>`|</tt> - union</p> |
|
<tt><p>a | b<br/> |
or<br/> |
mixed `|(mixed ... args)<br/> |
</p> |
</tt> |
<p>This operator does logical unions. For ints this means bitwise or. |
</p> |
<p>Arrays and multisets are treated as sets, so doing a union on two arrays |
will result in an array with containing all values present in either |
array. Although values present in both ararys will only be present |
once in the result. |
</p> |
<p>For mappings, the intersection will be done on the indexes solely, |
however, the values will be taken from the rightmost mapping.</p> |
|
operators</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`&' to='`&'>&&`&</ref>, <ref resolved='predef::`^' to='`^'>`^</ref> and <ref resolved='predef::`|' to='||'>||</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='`~' homogen-type='method'> |
<method name='`~'/><doc placeholder='true'> |
<text> |
<p><tt>`~</tt> - bitwise complement</p> |
|
<tt><p>~ a<br/> |
or<br/> |
int `~(int a)<br/> |
</p> |
</tt> |
<p>This operator inverses all bits in an integer and returns the |
new integer.</p> |
|
operators</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::`&' to='`&'>&&`&</ref>, <ref resolved='predef::`|' to='`|'>`|</ref> and <ref resolved='predef::`^' to='`^'>`^</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='acos' homogen-type='method'> |
<method name='acos'/><doc placeholder='true'> |
<text> |
<p><tt>acos</tt> - Trigonometrical inverse cosine</p> |
|
<tt><p>float acos(float <i>f</i>);<br/> |
</p> |
</tt> |
<p>Return the arcus cosinus value for f.</p> |
|
float</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::cos' to='predef::cos'>math/cos</ref> and <ref resolved='predef::asin' to='predef::asin'>math/asin</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='add_constant' homogen-type='method'> |
<method name='add_constant'/><doc placeholder='true'> |
<text> |
<p><tt>add_constant</tt> - add new predefined functions or constants</p> |
|
<tt><p>void add_constant(string <i>name</i>, mixed <i>value</i>);<br/> |
or<br/> |
void add_constant(string <i>name</i>);<br/> |
</p> |
</tt> |
<p>This function adds a new constant to Pike, it is often used to |
add builin functions (efuns). All programs compiled after add_constant |
function is called can access 'value' by the name given by 'name'. |
If there is a constant called 'name' already, it will be replaced by |
by the new definition. This will not affect already compiled programs. |
</p> |
<p>Calling add_constant without a value will remove that name from the list<br/> |
<dl><group><text><matrix> |
<r><c> </c><c> of of constant. As with replacing, this will not affect already compiled </c></r> |
<r><c> </c></r> |
</matrix> |
</text></group></dl>programs.<br/> |
</p> |
</text> |
|
<group><example/><text> |
<tt><p>add_constant("true",1);<br/> |
add_constant("false",0);<br/> |
add_constant("PI",4.0);<br/> |
add_constant("sqr",lambda(mixed x) { return x * x; });<br/> |
add_constant("add_constant");<br/> |
</p> |
</tt></text></group> |
|
<group><seealso/><text> |
<p><ref resolved='predef::all_constants' to='all_constants'>all_constants</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='add_efun' homogen-type='method'> |
<method name='add_efun'/><doc placeholder='true'> |
<text> |
<p><tt>add_efun</tt> - add an efun or constant</p> |
|
<tt><p>#include <simulate.h><br/> |
|
</p> |
<p>void add_efun(string func_name, mixed function)<br/> |
or<br/> |
void add_efun(string func_name)<br/> |
</p> |
</tt> |
<p>This function is the same as add_constant.</p> |
</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::add_constant' to='predef::add_constant'>builtin/add_constant</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='aggregage_list' homogen-type='method'> |
<method name='aggregage_list'/><doc placeholder='true'> |
<text> |
<p><tt>aggregage_list</tt> - aggregate a multiset</p> |
|
<tt><p>#include <simulate.h><br/> |
|
</p> |
<p>multiset aggregage_list(mixed ... <i>args</i>);<br/> |
</p> |
</tt> |
<p>This function is exactly the same as aggregate_multiset.</p> |
</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::aggregate_multiset' to='predef::aggregate_multiset'>builtin/aggregate_multiset</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='aggregate' homogen-type='method'> |
<method name='aggregate'/><doc placeholder='true'> |
<text> |
<p><tt>aggregate</tt> - construct an array</p> |
|
<tt><p>mixed *aggregate(mixed ... <i>elems</i>);<br/> |
or<br/> |
({ elem1, elem2, ... })<br/> |
</p> |
</tt> |
<p>Construct an array with the arguments as indices. This function |
could be written in Pike as: |
</p> |
<p>mixed *aggregate(mixed ... elems) { return elems; }</p> |
</text> |
|
<group><note/><text> |
<p>Arrays are dynamically allocated there is no need to declare them |
like int a[10]=allocate(10); (and it isn't possible either) like |
in C, just int *a=allocate(10); will do.</p> |
|
array</text></group> |
|
<group><seealso/><text> |
<p><ref resolved='predef::sizeof' to='sizeof'>sizeof</ref>, <ref resolved='predef::arrayp' to='arrayp'>arrayp</ref> and <ref resolved='predef::allocate' to='allocate'>allocate</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='aggregate_mapping' homogen-type='method'> |
<method name='aggregate_mapping'/><doc placeholder='true'> |
<text> |
<p><tt>aggregate_mapping</tt> - construct a mapping</p> |
|
<tt><p>mapping aggregate_mapping(mixed ... <i>elems</i>);<br/> |
or<br/> |
([ key1:val1, key2:val2, ... ])<br/> |
</p> |
</tt> |
<p>Groups the arguments together two and two to key-index pairs and |
creates a mapping of those pairs. The second syntax is always |
preferable.</p> |
|
mapping</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::sizeof' to='sizeof'>sizeof</ref>, <ref resolved='predef::mappingp' to='mappingp'>mappingp</ref> and <ref resolved='predef::mkmapping' to='mkmapping'>mkmapping</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='aggregate_multiset' homogen-type='method'> |
<method name='aggregate_multiset'/><doc placeholder='true'> |
<text> |
<p><tt>aggregate_multiset</tt> - construct a multiset</p> |
|
<tt><p>multiset aggregate_multiset(mixed ... <i>elems</i>);<br/> |
or<br/> |
(< elem1, elem2, ... >)<br/> |
</p> |
</tt> |
<p>Construct an multiset with the arguments as indexes. This function |
could be written in Pike as: |
</p> |
<p>multiset aggregate(mixed ... elems) { return mkmultiset(elems); } |
</p> |
<p>The only problem is that mkmultiset is implemented using |
aggregage_multiset...</p> |
|
multiset</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::sizeof' to='sizeof'>sizeof</ref>, <ref resolved='predef::multisetp' to='multisetp'>multisetp</ref> and <ref resolved='predef::mkmultiset' to='mkmultiset'>mkmultiset</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='alarm' homogen-type='method'> |
<method name='alarm'/><doc placeholder='true'> |
<text> |
<p><tt>alarm</tt> - set an alarm clock for delivery of a signal</p> |
|
<tt><p>int alarm(int <i>seconds</i>);<br/> |
</p> |
</tt> |
<p>alarm arranges for a SIGALRM signal to be delivered to the |
process in seconds seconds. |
</p> |
<p>If seconds is zero, no new alarm is scheduled. |
</p> |
<p>In any event any previously set alarm is cancelled.</p> |
</text> |
|
<group><returns/><text> |
<p>alarm returns the number of seconds remaining until any |
previously scheduled alarm was due to be delivered, or |
zero if there was no previously scheduled alarm.</p> |
</text></group> |
|
<group><seealso/><text> |
<p><ref resolved='predef::signal' to='signal'>signal</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='all_constants' homogen-type='method'> |
<method name='all_constants'/><doc placeholder='true'> |
<text> |
<p><tt>all_constants</tt> - return all predefined constants</p> |
|
<tt><p>mapping (string:mixed) <i>all_constant</i>();<br/> |
</p> |
</tt> |
<p>Return a mapping containing all constants, indexed on the names of the |
constant, and with the value of the efun as argument.</p> |
</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::add_constant' to='add_constant'>add_constant</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='all_efuns' homogen-type='method'> |
<method name='all_efuns'/><doc placeholder='true'> |
<text> |
<p><tt>all_efuns</tt> - return all 'efuns'</p> |
|
<tt><p>#include <simulate.h><br/> |
|
</p> |
<p>mapping all_efuns();<br/> |
</p> |
</tt> |
<p>This function is the same as all_constants.</p> |
</text> |
|
<group><seealso/><text> |
<p><ref resolved='predef::all_constants' to='all_constants'>all_constants</ref></p> |
</text></group> |
|
</doc> |
</docgroup> |
<docgroup homogen-name='allocate' homogen-type='method'> |
<me |