SPL Module Documentation: Index
load "array";
Array Module
This module extends the built-in functionality of SPL for working with
arrays. Please also have a look at the Language Reference Manual for a
description of the built-in operators provided natively by SPL.
builtin
array_reindex(array);
builtin
array_switch(array, key1, key2);
function
array_sort_by_keys(array, order_function);
function
array_sort_by_values(array, order_function);
function
array_join(array, seperator);
load "bits";
Bits Module
This module adds built-in functions for bit manipulations.
builtin
bits_and(@values);
builtin
bits_or(@values);
builtin
bits_xor(@values);
builtin
bits_not(value);
builtin
bits_shl(value, bits);
builtin
bits_shr(value, bits);
load "builtins";
This module contains the SPL 'standard' builtin functions. It does not
need to be loaded explicitely, most SPL runtimes load it automatically
for you.
builtin
write(text, encoding);
builtin
read(prompt, encoding);
builtin
chr(number);
builtin
ord(text);
builtin
hex(text);
builtin
oct(text);
builtin
bin(text);
builtin
fmt(text, @args);
builtin
rand(max);
builtin
setlocale(category, locale);
builtin
bindtextdomain(domain, directory);
builtin
textdomain(domain);
builtin
gettext(message);
builtin
dgettext(domain, message);
builtin
_(message, domain, @args);
builtin
acos(x);
builtin
asin);
builtin
atan(x);
builtin
atan2(x, y);
builtin
cos(x);
builtin
sin(x);
builtin
tan(x);
builtin
sqrt(x);
builtin
round(x);
builtin
ceil(x);
builtin
floor(x);
load "cgi";
Module for writing CGIs
builtin
cgi_userfile_save(paramname, filename);
builtin
cgi_write(text);
namespace
cgi
{
var
param;
var
cookie;
var
config;
var
content_type = "text/html";
var
silent_debug = 0;
var
sid;
var
sid_vm;
var
sid_task;
var
sid_passed;
var
url;
var
agent;
var
peerip;
var
post_type;
var
post_data;
}
load "crypt";
A crypt() function (like in C).
builtin
crypt(key, salt);
load "curl";
cURL Module
This module adds an interface to the cURL library.
WARNING: This module is still under construction.
builtin
curl(url, %options);
load "encode_int";
Integer encoder
function
encode_int(text);
load "encode_js";
Javascript encoder
function
encode_js(text);
load "encode_regex";
Regex encoder
function
encode_regex(text);
load "encode_url";
URL encoder
function
encode_url(text);
load "encode_xml";
A simple XML encoding function
builtin
encode_xml(text);
load "environ";
A module for accessing environment variables
namespace
environ { }
load "file";
This module provides a simple API for reading and writing files
builtin
file_read(filename, encoding);
builtin
file_write(filename, content, encoding);
builtin
file_delete(filename);
builtin
file_list(dirname);
builtin
file_access(filename, mode);
object
FileEx
{
var
type;
var
filename;
var
errmsg;
var
description;
}
load "format_ini";
A simple INI file parser/dumper module
This module implements simple INI file parser and dumper functions.
function
format_ini_parse(inidata);
function
format_ini_dump(initree);
load "format_xml";
A simple XML parser/dumper module
This module implements simple XML parser and dumper functions.
builtin
format_xml_parse(xmldata);
builtin
format_xml_dump(xmltree);
object
FormatXmlEx
{
var
description;
}
load "kde";
A module for the KDE/Qt bindings
This module simply loads the qt module with additional support for the KDE
API. It mus be loaded before the "qt" module.
load "multimouse";
This module provides a simple way to access the Linux /dev/input/mouse*
devices. It has been written for multiplayer games where every player has
his own mouse.
builtin
multimouse_update();
namespace
multimouse { }
load "prime";
Example Module for hosted namespaces
namespace
prime { }
load "qt";
The SPL/Qt Module
This module provides a thin wrapper for the Qt toolkit.
It is using the SMOKE library from the kdebindings package.
manual
SPL_Qt;
builtin
qt_debug(mode);
builtin
qt_kde();
builtin
qt_ui(ui_file);
builtin
qt_child(parent, name, class, recursive);
builtin
qt_cast(object, type);
builtin
qt_destroy(object);
builtin
qt_delete(object);
builtin
qt_autodelete(object);
builtin
qt_as(type, value);
builtin
qt_connect(sender, signal, receiver, slot);
builtin
qt_disconnect(sender, signal, receiver, slot);
builtin
qt_event_callback(object, callback, @eventtypes);
builtin
qt_signal_callback(object, signalspec, callback);
builtin
qt_virtual_callback(object, method, callback);
builtin
qt_info();
function
qt_kdeinit(progname, desc, version);
namespace
qt { }
object
QtEx
{
var
description;
}
load "sdl";
A module for doing multimedia using the SDL library.
Note: Only one SDL window can be opened by one host program at a time.
This is a limitation from SDL.
builtin
sdl_init(width, height);
builtin
sdl_quit();
builtin
sdl_title(title, icon);
builtin
sdl_delay(ms);
builtin
sdl_flip();
builtin
sdl_update(x, y, w, h);
builtin
sdl_image_load(filename);
builtin
sdl_image_create(w, h);
builtin
sdl_blit(dstimg, srcimg, x, y);
builtin
sdl_blitrect(dstimg, srcimg, dest_x, dest_y, src_x, src_y, w, h);
builtin
sdl_copy(srcimg, x, y, w, h);
builtin
sdl_fill(dstimg, x, y, w, h, r, g, b, a);
builtin
sdl_fill_pattern(dstimg, x, y, w, h, patternimg);
builtin
sdl_keystat(keyname);
builtin
sdl_sprite_create();
builtin
sdl_sprite_redraw();
builtin
sdl_sprite_update();
object
SdlEx
{
var
description;
}
load "sql";
The base module for accessing SQL databases.
Additional database driver modules need to be loaded for the backend
databases.
builtin
encode_sql(text);
builtin
sql_connect(driver_name, driver_data);
builtin
sql(database_handler, query);
object
SqlEx
{
var
description;
}
load "sql_mysql";
This module implements the MySQL database driver.
Load this module (and the "sql" module) and pass "mysql" as backend
driver name to sql_connect();
The string describing the database connection (the 2nd argument to
sql_connect()) is a coma seperated list of the following tokens:
host={hostname}
user={username}
pass={password}
sock={socket_filename}
db={database_name}
port={tcp_port_number}
compress (set MySQL CLIENT_COMPRESS flag)
ignore_space (set MySQL CLIENT_IGNORE_SPACE flag)
multi_statements (set MySQL CLIENT_MULTI_STATEMENTS flag)
Whitespaces are not allowed. E.g.:
var db = sql_connect("mysql", "host=dbserver,user=dbuser");
var r = sql(db, "show databases");
foreach i (r)
debug pop r[i];
builtin
encode_mysql(text);
load "sql_postgres";
This module implements the POSTGRES database driver.
Load this module (and the "sql" module) and pass "postgres" as backend
driver name to sql_connect();
The string describing the database connection (the 2nd argument to
sql_connect()) is used as it is as PQconnectdb conninfo string.
A detailed description of the format of this string can be found at:
http://www.postgresql.org/docs/8.0/interactive/libpq.html#AEN22513
Example given:
var db = sql_connect("postgres", "host=dbserver user=postgres dbname=template1");
foreach[] tuple (sql(db, "show all"))
debug "${shift tuple} = ${shift tuple}";
load "sql_sqlite";
This module implements the SQLite database driver.
Load this module and the "sql" module and pass "sqlite" as backend
driver name to sql_connect();
load "sql_utils";
Additional SQL helper functions.
The "sql" module just provides a generic function for doing SQL queries,
namely sql(). This module declares some wrapper functions for
sql() which do implement common usage scenarios for sql().
function
sql_value(db, query);
function
sql_tuple(db, query);
function
sql_keyval(db, query);
function
sql_array(db, query);
load "system";
This module provides a simple API for calling shell commands
builtin
system(command, encoding);
load "task";
SPL Task Management Module
This module provides basic functions for handling SPL tasks. SPL tasks
may be used like threads, co-routines, or anything simmilar.
builtin
task_create(name, code, ctx);
builtin
task_pause(name);
builtin
task_continue(name);
builtin
task_system(name);
builtin
task_public(name);
builtin
task_getname();
builtin
task_check(name);
function
task_kill(name);
function
task_late_kill(name);
function
task_switch(name);
function
task_co_call(name);
function
task_co_return(retval);
function
task_co_setdefault(name, def);
function
task_eval(code, ctx);
load "termio";
Terminal IO module
This module provides simple functions for controlling ANSI terminals.
builtin
termio_setpos(x, y);
builtin
termio_clear();
builting
termio_sleep();
load "time";
A module for time and time manipulations
builtin
time();
builtin
time_local(time);
builtin
time_gm(time);
builtin
time_diff(time1, time0);
builtin
time_fmt(format, tm);
builtin
time_mk(tm);
builtin
time_mkgm(tm);
load "uuidgen";
This module provides a simple API for creating UUID strings
builtin
uuidgen();
load "w2t";
The SPL Web 2.0 Toolkit
This module is EXPERIMENTAL and not so well document yet.
Expect more to come..
var
w2t_core_scripts = <>;
object
W2t
{
static
scripts = [ w2t_core_scripts ];
static
styles = [ ];
static
w2t_ns = "http://www.spl-scripting.org/xml/w2t";
static
xmlns;
var
startup;
var
mime_type = "text/xml";
var
callbacks;
var
callbacks_oncleanup;
var
callbacks_rev = 0;
var
request;
var
response;
method
register_callback(id, handler, oncleanup);
method
response_add(xmltext);
method
dom_appendchild(id, xmltext);
method
dom_remove(id);
method
dom_replaceinner(id, xmltext);
method
dom_setattr(id, name, value);
method
execute(script);
method
getscripts();
method
getstyles();
method
getxmlnsdecls();
method
getid();
method
run();
method
init();
}
load "webdebug";
A module that implements an SPL debugger that can be used with a Web
Interface.
Only load that module when you are in a save test environment do not let
end-users access the debugger frontend!
function
webdebug() ;
load "wsf";
WebSPL Forms Library
This module provides a frame work for doing application development
with WebSPL. The basic idea is to split down the user interface into
so-called components. Each component provides a part of the DOM tree
which is displayed in the browser window. There is a seperate program
task for each component - so they can act as independent as the
programmer wants.
This module provides WsfComponent, the base object for WSF Components,
and WsfDocument, the object which manages the interaction with the
Browser.
Other Modules provide additional WSF Components. E.g.:
WsfDebug WsfDialog
WsfDisplay WsfEdit
WsfEditSql WsfGraph
WsfMenu WsfSwitch
If the browser has support for it, WsfDocument does only send those
parts of the DOM tree to the browser which have actually changed and replace
them 'in place' in the current page using a little JavaScript hack.
function
wsf_get_domupdate_status(@methods) ;
object
WsfComponent
{
static
id_counter = 0;
var
id;
var
sid;
var
dirty = 0;
var
children;
var
main_task;
method
add_action(url);
method
add_href(url);
method
add_javascript(url);
method
get_html_children();
method
get_html_cached();
method
get_html();
method
main();
method
child_set(name, obj);
method
child_remove(name);
method
destroy();
method
init();
}
object
WsfDocument
{
static
domupdate = wsf_get_domupdate_status();
static
showiframe = 0;
var
root;
var
title = "";
var
html_head = "";
var
body_attr = "";
var
callbacks;
method
callback_add(type, func);
method
callback_del(type, func);
method
callback_call(type, %options);
method
main();
}
load "wsf_action";
A module which implements a WSF Component with support for dynamically
registered callbacks (usually using closures) in the templates.
object
WsfAction WsfComponent
{
var
action_list;
var
template_function;
var
template_options;
var
data;
method
action_reset();
method
action(name, callback);
method
main();
method
get_html();
method
init(_template_function, %_template_options);
}
load "wsf_debug";
A module that implements an SPL debugger that can be used with a Web
Interface and integrates nicely in WSF applications.
object
WsfDebug WsfComponent
{
method
main() ;
method
get_html() ;
}
load "wsf_dialog";
A module which implements a "Qt Designer"-like component for creating WSF
dialogs in a web browser.
object
WsfDialog WsfComponent
{
var
xmltree;
var
values;
var
edit_mode = 0;
var
edit_current = "";
var
edit_show_xml = 0;
var
show_edit_button = 0;
method
set_edit_mode(newmode);
method
get_html();
method
save();
method
main();
method
reset_values();
method
import_xml(xmldata);
method
init(xmldata);
}
load "wsf_display";
A module which implements a simple WSF Component for displaying stuff.
object
WsfDisplay WsfComponent
{
var
tag = "div";
var
attributes;
var
html_text;
method
get_html();
method
set_html(t);
method
init(t);
}
load "wsf_edit";
A module which provides a generic WSF component for creating edit frontends
for any kind of data tuples. See "wsf_edit_sql" for an implementation.
object
WsfEdit WsfComponent
{
var
edit_data;
var
edit_fields;
var
edit_actions;
var
just_updated;
method
edit_reset();
method
edit_input(field, %opt);
method
edit_textarea(field, %opt);
method
edit_select(field, list, %opt);
method
edit_load();
method
edit_save();
method
main();
method
get_html();
method
init();
}
load "wsf_edit_sql";
A module which provides a generic component for editing records in SQL
databases, based on WsfEdit.
object
WsfEditSql WsfEdit
{
var
sql_id;
var
sql_db;
var
sql_table;
var
sql_key;
var
get_html_core;
method
edit_load();
method
edit_save();
method
get_html();
method
init(_sql_id, _sql_db, _sql_table, _sql_key, _get_html_core);
}
load "wsf_graph";
A module which implemnts a WSF Component for displaying and editing
graphs.
object
WsfGraph WsfComponent
{
var
get_list;
var
ibase;
var
raster;
var
iframe_header;
var
iframe_footer;
var
iframe_attributes;
var
scroll_x, scroll_y;
method
iframe_main();
method
get_html();
method
main();
method
destroy();
method
init(_get_list, _ibase);
}
interface
WsfGraphNode
{
method
get_xywh();
method
set_xy(x, y);
method
get_links();
method
set_link(trg);
method
get_color();
method
get_html();
}
load "wsf_menu";
A module which implements a WSF Component for DHTML menus.
object
WsfMenu WsfComponent
{
var
nojsmenu = 0;
var
size_x = 200;
var
size_y = 25;
method
main();
method
get_html();
method
init(menu_data, %options);
}
load "wsf_switch";
This module implements a WSF Component for switching between
components. Usually this is used for navigating between different
dialogs.
object
WsfSwitch WsfComponent
{
var
cases;
method
main() ;
method
switch_code(code);
method
switch_href(i) ;
method
switch_reset() ;
}
load "xml";
A module for accessing XML data
This module currently implements XML, XPath, XSLT (including some EXSLT
extensions), XML Namespaces and a simple interface for modifying XML data.
builtin
xml_parse(xml_text);
builtin
xml_dump(xmldoc);
builtin
xml_xslt_text(xmldoc, stylesheet, %params);
builtin
xml_xslt_xml(xmldoc, stylesheet, %params);
object
XmlEx
{
var
description;
}