Skip to content
Snippets Groups Projects
Commit 84560929 authored by Fredrik Hübinette (Hubbe)'s avatar Fredrik Hübinette (Hubbe)
Browse files

more documentation added

Rev: doc/internal/array/aggregate_array:1.1
Rev: doc/internal/array/array_index:1.2
Rev: doc/internal/array/array_remove:1.1
Rev: doc/internal/array/array_search:1.1
Rev: doc/internal/array/array_set_index:1.1
Rev: doc/internal/array/copy_array:1.1
Rev: doc/internal/array/push_array_items:1.1
Rev: doc/internal/array/resize_array:1.1
Rev: doc/internal/array/slice_array:1.1
Rev: doc/internal/pike/types:1.1
Rev: doc/internal/program/add_function:1.1
Rev: doc/internal/program/add_storage:1.1
Rev: doc/internal/program/end_c_program:1.1
Rev: doc/internal/program/set_exit_callback:1.1
Rev: doc/internal/program/set_init_callback:1.1
Rev: doc/internal/program/start_new_program:1.1
parent 738d1e48
No related branches found
No related tags found
No related merge requests found
Showing
with 323 additions and 1 deletion
NAME
aggregate_array - build an array from the stack
SYNTAX
#include "array.h"
struct array *aggregate_array(INT32 num)
DESCRIPTION
This pops 'num' args off the stack an puts them in an array.
The 'top' of the stack will be the last element in the array.
KEYWORDS
array
SEE ALSO
check_stack, push_array_items
\ No newline at end of file
...@@ -21,5 +21,8 @@ NOTA BENE ...@@ -21,5 +21,8 @@ NOTA BENE
core. If Pike was compiled with DEBUG, a message will be written core. If Pike was compiled with DEBUG, a message will be written
first stating what the problem was. first stating what the problem was.
KEYWORDS
array
SEE ALSO SEE ALSO
assign_svalue assign_svalue
NAME
array_remove - remove an index from an array
SYNTAX
#include "array.h"
struct array *array_remove(struct array *a, INT32 ind);
DESCRIPTION
This function removes the index 'ind' from the array 'a' destructively.
The returned array should be used instead of 'a' and can be the same
as 'a'. Because this function is destructive and might free the
memory region for 'a' it may only be used on arrays which has not been
sent to any lpc functions yet.
KEYWORDS
array
SEE ALSO
array_insert
NAME
array_search - search an array
SYNTAX
#include "array.h"
INT32 array_search(struct array *a,
struct svalue *val,
INT32 start);
DESCRIPTION
This function loops over the array 'a' starting at 'start' until
it finds an index that is_eq to 'val'. When it finds such a value
the number for that index will be returned. If no such value is
found -1 is returned.
NOTA BENE
This function checks the type_field in the array, and also re-builds
the type-field if the value is not found.
KEYWORDS
array
SEE ALSO
is_eq
\ No newline at end of file
NAME
array_set_index - get an index from an array
SYNTAX
#include "array.h"
void array_set_index(struct array *a,
INT32 ind,
struct svalue *from);
DESCRIPTION
This function frees the contents of the index 'ind' in the array
'a' and replaces it with a copy of the contents from 'from'.
Basically, what it does is:
assign_svalue(a->item + n, from);
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.
KEYWORDS
array
SEE ALSO
assign_svalue
NAME
copy_array - copy an array
SYNTAX
#include "array.h"
struct array *copy_array(struct svalue *a);
DESCRIPTION
This function returns a copy of the array 'a'. It is not recursive,
arrays within 'a' will only get extra references.
KEYWORDS
array
NAME
push_array_items - push array contents on stack
SYNTAX
#include "array.h"
void push_array_items(struct array *a)
DESCRIPTION
This function is mainly used by the @ operator. It pushes all elements
in the array 'a' on the stack. It also frees one ref count on 'a', so
be sure to do a->refs++ first if you want to use the array after
calling this function. This function also calls check_stack properly.
KEYWORDS
array
SEE ALSO
aggregate_array, check_stack
NAME
resize_array - change the size of an array destructively
SYNTAX
#include "array.h"
struct array *resize_array(struct array *a, INT32 new_size);
DESCRIPTION
This function makes an array from 'a' with the size 'new_size'.
Note that the returned might or might not be the same as 'a'.
If 'a' is too small or too big for 'new_size', a copy of 'a' will
be made with enough room and then 'a' will be freed. This means
that you can only use this function on arrays which has not been
passed to any lpc functions yet.
KEYWORDS
array
SEE ALSO
array_insert, array_remove
NAME
slice_array - slice a pice of an array
SYNTAX
#include "array.h"
struct array *slice_array(struct array *a, INT32 start, INT32 end);
DESCRIPTION
This is the equivialent of the pike operation a[start..end]. A new
array will be returned with one reference.
KEYWORDS
array
NAME
types - how to describe types internally
DESCRIPTION
When describing types to add_function or add_efun you always write
it in a string. You write the type just as you would in Pike. The
internal types have a few extra features though. Here is a brief
explanation of the syntax:
type you write:
int "int"
float "float"
string "string"
mapping "mapping(mixed:mixed)" or "mapping"
array of int "array(int)" or "int *"
function(int:int) "function(int:int)"
varargs function "function(int ...:int)"
int or string "int|string"
Then there are a few tricks you can use, say you have a function which
returns an int except if you call it with a string in which case it
return a string:
"!function(string:mixed)&function(mixed:int)|function(string:string)"
The & and ! operators work as you might expect but are only useful
together.
KEYWORDS
internals
SEE ALSO
add_function, add_efun
\ No newline at end of file
NAME
add_function - add a function to the program
SYNTAX
#include "program.h"
void add_function(char *name,
void (*fun)(INT32),
char *type,
INT16 flags)
DESCRIPTION
This function adds a function to the program you are building.
The function will have the name 'name' and the type 'type'.
The function 'fun' will be called with an integer telling it how
many arguments are on the stack and is expected to remove those
elements from the stack and replace them with a return value.
The flags are zero or more of the following or:ed together:
ID_STATIC, ID_PRIVATE, ID_NOMASK, ID_PUBLIC, ID_PROTECTED and
ID_INLINE.
KEYWORDS
program
SEE ALSO
start_new_program, types
\ No newline at end of file
NAME
add_storage - allocate space for object-local data
SYNTAX
#include "program.h"
void add_storage(INT32 size);
DESCRIPTION
This function allocates 'size' bytes in every object cloned from the
program you are in the process of building. (Be sure to call
start_new_program first...) Whenever one of your methods are called
fp->current_storage will point to this area.
KEYWORDS
program
SEE ALSO
start_new_program, frame
NAME
end_c_program - finish building a 'struct program'
SYNTAX
#include "program.h"
struct program *end_c_program(char *name);
DESCRIPTION
This function finishes up the process of building a 'struct program'.
It initializes the struct program and calls
master()->add_precompiled_program with the program and the suggested
name. (As sent to end_c_program). It then returns the newly built
program. Note that the new program does NOT have an extra reference,
if you want to keep it around and use it you have to add that reference
yourself.
KEYWORDS
program
SEE ALSO
start_new_program, add_function
NAME
set_exit_callback - set function to call att destruct()
SYNTAX
#include "program.h"
void set_exit_callback(void (*exit)(struct object *) fun);
DESCRIPTION
This function sets what function will be called when an object
cloned from your program is destructed. This function is
mainly for de-initializing the fp->current_storage region.
The function will be called with the object about to be destructed
as argument.
KEYWORDS
program
SEE ALSO
start_new_program, set_init_callback
NAME
set_init_callback - set function to call att clone()
SYNTAX
#include "program.h"
void set_init_callback(void (*init)(struct object *) fun);
DESCRIPTION
This function sets what function will be called when someone
clones the struct program your are building. This function is
mainly for initializing the fp->current_storage region.
The initalizer function will be called with the newly cloned
object as argument.
KEYWORDS
program
SEE ALSO
start_new_program, set_exit_callback
NAME
start_new_program - start building a new 'struct program'
SYNTAX
#include "program.h"
void start_new_program(void);
DESCRIPTION
This function initalizes a new 'struct program' to be be fitted
with functions, variables, inherits etc. etc.
KEYWORDS
program
SEE ALSO
end_c_program, add_function, add_storage
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment