diff --git a/doc/internal/.bmmlrc b/doc/internal/.bmmlrc new file mode 100644 index 0000000000000000000000000000000000000000..ffd062627df1dd934e7c9151b0c18264f22674ab --- /dev/null +++ b/doc/internal/.bmmlrc @@ -0,0 +1 @@ +prefix internal diff --git a/doc/internal/array/allocate_array b/doc/internal/array/allocate_array new file mode 100644 index 0000000000000000000000000000000000000000..55f0dfca43321a08f562a90d0e7c48a9ca3a589e --- /dev/null +++ b/doc/internal/array/allocate_array @@ -0,0 +1,21 @@ +NAME + allocate_array - allocate an array + +SYNTAX + #include "array.h" + + struct array *allocate_array(INT32 size); + +DESCRIPTION + 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. + +NOTA BENE + 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'. + +KEYWORDS + array \ No newline at end of file diff --git a/doc/internal/array/array b/doc/internal/array/array new file mode 100644 index 0000000000000000000000000000000000000000..dee47e3d771800c6a58c2f889b9df4b36a6bffa5 --- /dev/null +++ b/doc/internal/array/array @@ -0,0 +1,20 @@ +NAME + array - the internal representation of an array + +DESCRIPTION + A Pike array is represented as a 'struct array' with all the + needed svalues malloced in the same block. The relevant members + are: + + refs reference count + size the number of svalues in the array + malloced_size the number of svalues that can fit in this block + type_field a bitfield indicating what types the array contains + item the array of svalues + + +SEE ALSO + type_field + +KEYWORDS + internals diff --git a/doc/internal/array/array_index b/doc/internal/array/array_index new file mode 100644 index 0000000000000000000000000000000000000000..bf9d37df8410829817f6529c60716ac1e597e994 --- /dev/null +++ b/doc/internal/array/array_index @@ -0,0 +1,25 @@ +NAME + array_index - get an index from an array + +SYNTAX + #include "array.h" + + void array_index(struct svalue *to, struct array *a, INT32 n); + +DESCRIPTION + 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: + + assign_svalue(to, a->item + n); + + The only differance is that it adds some debug and safety + measures. Usually you don't really need to use this function. + +NOTA BENE + 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. + +SEE ALSO + assign_svalue \ No newline at end of file diff --git a/doc/internal/array/free_array b/doc/internal/array/free_array new file mode 100644 index 0000000000000000000000000000000000000000..3240263494be27fad291c25d4512bf25d1e573b0 --- /dev/null +++ b/doc/internal/array/free_array @@ -0,0 +1,18 @@ +NAME + free_array - free one reference to a array + +SYNTAX + #include "array.h" + + void free_array(struct array *a) + +DESCRIPTION + 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. + +NOTA BENE + free_array is a macro + +KEYWORDS + array diff --git a/doc/internal/mappings/copy_mapping b/doc/internal/mappings/copy_mapping new file mode 100644 index 0000000000000000000000000000000000000000..e9ca05b7a9488ded7fb4689181f7d7ec91c338b2 --- /dev/null +++ b/doc/internal/mappings/copy_mapping @@ -0,0 +1,15 @@ +NAME + copy_mapping - copy a mapping + +SYNTAX + #include "mapping.h" + + struct mapping *copy_mapping(struct mapping *m) + +DESCRIPTION + 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. + +KEYWORDS + mapping diff --git a/doc/internal/mappings/free_mapping b/doc/internal/mappings/free_mapping new file mode 100644 index 0000000000000000000000000000000000000000..ead0598146f3cc3a8fb290f6003e353a576bd004 --- /dev/null +++ b/doc/internal/mappings/free_mapping @@ -0,0 +1,18 @@ +NAME + free_mapping - free one reference to a mapping + +SYNTAX + #include "mapping.h" + + void free_mapping(struct mapping *m) + +DESCRIPTION + 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. + +NOTA BENE + free_mapping is a macro + +KEYWORDS + mapping diff --git a/doc/internal/mappings/low_mapping_lookup b/doc/internal/mappings/low_mapping_lookup new file mode 100644 index 0000000000000000000000000000000000000000..07128a3a64929796488dc4dbc1a84bb84cdde6da --- /dev/null +++ b/doc/internal/mappings/low_mapping_lookup @@ -0,0 +1,28 @@ +NAME + low_mapping_lookup - lookup a key in a mapping + +SYNTAX + #include "mapping.h" + + struct svalue *low_mapping_lookup(struct mapping *m, + struct svalue *key); + +DESCRIPTION + 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. + +NOTA BENE + 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. + +NOTA BENE + This function is intended for _reading_ mappings, it is forbidden + to change the contents of the returned svalue. + +KEYWORDS + mapping + +SEE ALSO + map_insert \ No newline at end of file diff --git a/doc/internal/mappings/m_sizeof b/doc/internal/mappings/m_sizeof new file mode 100644 index 0000000000000000000000000000000000000000..7721c949d5405f454213ea886d7a2ce7e7ec515a --- /dev/null +++ b/doc/internal/mappings/m_sizeof @@ -0,0 +1,17 @@ +NAME + m_sizeof - return the number of key-value pairs in a mapping + +SYNTAX + #include "mapping.h" + + int m_sizeof(struct mapping *m) + +DESCRIPTION + This function returns the number of key-index pairs in the mapping, + just like the function sizeof() in Pike. + +NOTA BENE + m_sizeof is a macro + +KEYWORDS + mapping diff --git a/doc/internal/mappings/map_delete b/doc/internal/mappings/map_delete new file mode 100644 index 0000000000000000000000000000000000000000..c735593147ad7c01a3e0e3653e3a6f272505e8d4 --- /dev/null +++ b/doc/internal/mappings/map_delete @@ -0,0 +1,18 @@ +NAME + map_delete - delete an item from a mapping + +SYNTAX + #include "mapping.h" + + void map_delete(struct mapping *m, struct svalue *key); + +DESCRIPTION + 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. + +KEYWORDS + mapping + +SEE ALSO + mapping_insert diff --git a/doc/internal/mappings/mapping b/doc/internal/mappings/mapping new file mode 100644 index 0000000000000000000000000000000000000000..0e46d5cf647742c8a30547bfacd0139c1b1bd09d --- /dev/null +++ b/doc/internal/mappings/mapping @@ -0,0 +1,22 @@ +NAME + mapping - internal pike mappings + +DESCRIPTION + '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. + + 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. + +KEYWORDS + internals diff --git a/doc/internal/mappings/mapping_indices b/doc/internal/mappings/mapping_indices new file mode 100644 index 0000000000000000000000000000000000000000..dad43ab5fb3fdd177014d2936fd3386a6223e6a4 --- /dev/null +++ b/doc/internal/mappings/mapping_indices @@ -0,0 +1,19 @@ +NAME + mapping_indices - return all the keys from a mapping + +SYNTAX + #include "mapping.h" + + struct array *mapping_indices(struct mapping *m) + +DESCRIPTION + 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. + +KEYWORDS + mapping + +SEE ALSO + mapping_values, mkmapping diff --git a/doc/internal/mappings/mapping_insert b/doc/internal/mappings/mapping_insert new file mode 100644 index 0000000000000000000000000000000000000000..14f0c6c1044cec408d998b3cec9ba987ca6e9da6 --- /dev/null +++ b/doc/internal/mappings/mapping_insert @@ -0,0 +1,23 @@ +NAME + mapping_insert - insert a key-value pair into a mapping + +SYNTAX + #include "mapping.h" + + void mapping_insert(struct mapping *m, + struct svalue *key, + struct svalue *value) + +DESCRIPTION + 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 + +KEYWORDS + mapping + +SEE ALSO + map_delete, low_mapping_lookup diff --git a/doc/internal/mappings/mapping_replace b/doc/internal/mappings/mapping_replace new file mode 100644 index 0000000000000000000000000000000000000000..f14ad3da492d4f036f5e6708aa08d4dbacfb3904 --- /dev/null +++ b/doc/internal/mappings/mapping_replace @@ -0,0 +1,16 @@ +NAME + mapping_replace - replace values in a mapping + +SYNTAX + #include "mapping.h" + + void mapping_replace(struct mapping *m, + struct svalue *from, + struct svalue *to) + +DESCRIPTION + This function replaces all values of the value 'from' in the mapping + 'm' with 'to'. It is a part of the Pike function replace(). + +KEYWORDS + mapping diff --git a/doc/internal/mappings/mapping_values b/doc/internal/mappings/mapping_values new file mode 100644 index 0000000000000000000000000000000000000000..b0d491139dd0fcd783ef6a70be35301676f5b08b --- /dev/null +++ b/doc/internal/mappings/mapping_values @@ -0,0 +1,31 @@ +NAME + mapping_values - return all the values from a mapping + +SYNTAX + #include "mapping.h" + + struct array *mapping_values(struct mapping *m) + +DESCRIPTION + 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. + +EXAMPLE + struct mapping *slow_copy_mapping(struct mapping *m) + { + struct array *indices, *values; + indices=mapping_indices(m); + values=mapping_indices(m); + m=mkmapping(indices,values); + free_array(indices); + free_array(values); + return m; + } + +KEYWORDS + mapping + +SEE ALSO + mapping_indices, copy_mapping, mkmapping diff --git a/doc/internal/mappings/mkmapping b/doc/internal/mappings/mkmapping new file mode 100644 index 0000000000000000000000000000000000000000..de8ce63c2d7943e8443e6567f70892d5fef1b42f --- /dev/null +++ b/doc/internal/mappings/mkmapping @@ -0,0 +1,18 @@ +NAME + mkmapping - make a mapping + +SYNTAX + #include <mapping.h> + + struct mapping *mkmapping(struct array *keys, struct array *values) + +DESCRIPTION + 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. + +KEYWORDS + mapping + +SEE ALSO + mapping_indices, mapping_values \ No newline at end of file diff --git a/doc/internal/pike/error b/doc/internal/pike/error new file mode 100644 index 0000000000000000000000000000000000000000..158b687eddf0e069b9588b3d12a318a8dd9c1131 --- /dev/null +++ b/doc/internal/pike/error @@ -0,0 +1,18 @@ +NAME + error - throw an error + +SYNTAX + #include "error.h" + + void error(char *format_string, ...); + +DESCRIPTION + 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. + +KEYWORDS + internals diff --git a/doc/internal/pike/fatal b/doc/internal/pike/fatal new file mode 100644 index 0000000000000000000000000000000000000000..397feae1bee9163705a18d618a2298bfe43b113d --- /dev/null +++ b/doc/internal/pike/fatal @@ -0,0 +1,21 @@ +NAME + fatal - print a message and dump core + +SYNTAX + #include "error.h" + + void fatal(char *format_string, ...); + +DESCRIPTION + 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... + +KEYWORDS + internal + +SEE ALSO + error diff --git a/doc/internal/pike/frame b/doc/internal/pike/frame new file mode 100644 index 0000000000000000000000000000000000000000..7d9e6bccec95cc4cbbca78f6579775e90ffba08f --- /dev/null +++ b/doc/internal/pike/frame @@ -0,0 +1,19 @@ +NAME + frame - the current frame of exectution + +DESCRIPTION + 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: + + current_object same as the Pike function this_object() + context.program the program in which this function resides + current_storage a 'char *' pointer into the data area for this + object. This is the pointer to the area reserved + for you if you have done add_storage() earlier. + +KEYWORDS + internals diff --git a/doc/internal/pike/type_field b/doc/internal/pike/type_field new file mode 100644 index 0000000000000000000000000000000000000000..84bbbe69e2c08bfa2b051b9581363e4300e41fed --- /dev/null +++ b/doc/internal/pike/type_field @@ -0,0 +1,17 @@ +NAME + type_field - bit field used for optimizations + +DESCRIPTION + 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. + + 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. + +SEE ALSO + mapping, array, svalue diff --git a/doc/internal/program/program b/doc/internal/program/program new file mode 100644 index 0000000000000000000000000000000000000000..181b5c3e9a2b2af684adb13244174a8f10e9ba44 --- /dev/null +++ b/doc/internal/program/program @@ -0,0 +1,16 @@ +NAME + program - internal representation of a program + +DESCRIPTION + 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(). + +SEE ALSO + frame + +KEYWORDS + internal diff --git a/doc/internal/strings/free_string b/doc/internal/strings/free_string index 918c8811f2148ec51e589de936a9e22ea51959f4..91375ea1cc689dddcf4491f5c19d7777a9916f8a 100644 --- a/doc/internal/strings/free_string +++ b/doc/internal/strings/free_string @@ -6,7 +6,7 @@ SYNTAX void free_string(struct pike_string *p) -DESCRIPITON +DESCRIPTION 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. diff --git a/doc/internal/strings/make_shared_string b/doc/internal/strings/make_shared_string index 121459344b15afe17a2ee11c180d1b862ae80f60..4560313ab450c2ca6734156060f02843736f0cbd 100644 --- a/doc/internal/strings/make_shared_string +++ b/doc/internal/strings/make_shared_string @@ -1,5 +1,5 @@ NAME - make_shared_binary_string - make a shared string + make_shared_string - make a shared string SYNTAX #include "stralloc.h" diff --git a/doc/internal/strings/pike_string b/doc/internal/strings/pike_string index 1d095ef5708d5460e451f76b55b60b688d9184cf..638334dbca7a4270c731085217621675e01f7ad8 100644 --- a/doc/internal/strings/pike_string +++ b/doc/internal/strings/pike_string @@ -14,5 +14,5 @@ DESCRIPTION creating a new shared string with begin_shared_string which has not yet been linked to the hash table with end_shared_string. -KEYWORD +KEYWORDS internals