2016-03-20 23:09:01 -04:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
2016-03-21 14:06:51 -04:00
|
|
|
## USAGE
|
|
|
|
#
|
|
|
|
# ./waf configure --luadoc ....
|
|
|
|
# ./waf
|
|
|
|
# ./gtk2_ardour/arluadoc > doc/luadoc.json
|
|
|
|
#
|
|
|
|
# php tools/fmt-luadoc.php > /tmp/luadoc.html
|
|
|
|
#
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
################################################################################
|
2016-03-20 23:09:01 -04:00
|
|
|
|
2016-03-21 14:06:51 -04:00
|
|
|
$json = file_get_contents (dirname (__FILE__).'/../doc/luadoc.json');
|
|
|
|
$doc = array ();
|
|
|
|
foreach (json_decode ($json, true) as $b) {
|
|
|
|
if (!isset ($b['type'])) { continue; }
|
2016-03-20 23:09:01 -04:00
|
|
|
$doc[] = $b;
|
|
|
|
}
|
|
|
|
|
2016-03-21 14:06:51 -04:00
|
|
|
if (count ($doc) == 0) {
|
|
|
|
fwrite (STDERR, "Failed to read luadoc.json\n");
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
## Global result variables
|
2016-03-20 23:09:01 -04:00
|
|
|
################################################################################
|
|
|
|
|
2016-03-21 14:06:51 -04:00
|
|
|
$classlist = array ();
|
|
|
|
$constlist = array ();
|
2016-03-20 23:09:01 -04:00
|
|
|
|
2016-03-21 14:06:51 -04:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
## Pre-process the data, collect functions, parse arguments, cross reference
|
2016-03-20 23:09:01 -04:00
|
|
|
################################################################################
|
|
|
|
|
2016-03-21 14:06:51 -04:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# some internal helper functions first
|
|
|
|
|
2016-03-21 16:15:26 -04:00
|
|
|
$funclist = array ();
|
2016-03-21 14:06:51 -04:00
|
|
|
$classes = array ();
|
|
|
|
$consts = array ();
|
|
|
|
|
2016-03-20 23:09:01 -04:00
|
|
|
function my_die ($msg) {
|
2016-03-21 14:06:51 -04:00
|
|
|
fwrite (STDERR, $msg."\n");
|
|
|
|
exit (1);
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
##function ptr_strip ($ctype) {
|
|
|
|
# # boost::shared_ptr<std::list<boost::shared_ptr<ARDOUR::Route>> > >
|
|
|
|
# # -> std::list<ARDOUR::Route>
|
|
|
|
# $ctype = preg_replace ('/boost::shared_ptr<([^>]*)[ ]*>/', '$1', $ctype);
|
|
|
|
# return preg_replace ('/boost::shared_ptr<([^>]*)[ ]*>/', '$1', $ctype);
|
|
|
|
#}
|
|
|
|
|
|
|
|
function arg2lua ($argtype) {
|
|
|
|
global $classes;
|
|
|
|
global $consts;
|
|
|
|
|
|
|
|
# LuaBridge abstracts C++ references
|
2016-03-21 14:06:51 -04:00
|
|
|
$flags = preg_match ('/&$/', $argtype);
|
2016-03-20 23:09:01 -04:00
|
|
|
$arg = preg_replace ('/&$/', '', $argtype);
|
|
|
|
|
|
|
|
# filter out basic types
|
|
|
|
$builtin = array ('float', 'double', 'bool', 'std::string', 'int', 'long', 'unsigned long', 'unsigned int', 'unsigned char', 'char', 'void', 'char*', 'unsigned char*', 'void*');
|
2016-03-21 14:06:51 -04:00
|
|
|
if (in_array ($arg, $builtin)) {
|
|
|
|
return array ($arg => $flags);
|
|
|
|
}
|
2016-03-20 23:09:01 -04:00
|
|
|
|
|
|
|
# check Class declarations first
|
|
|
|
foreach (array_merge ($classes, $consts) as $b) {
|
|
|
|
if ($b['decl'] == $arg) {
|
2016-03-21 14:06:51 -04:00
|
|
|
return array ($b['lua'] => $flags);
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# strip class pointers -- TODO Check C'tor for given class
|
|
|
|
$arg = preg_replace ('/[&*]*$/', '', $argtype);
|
|
|
|
foreach (array_merge ($classes, $consts) as $b) {
|
|
|
|
if ($b['decl'] == $arg) {
|
2016-03-21 14:06:51 -04:00
|
|
|
return array ($b['lua'] => $flags);
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
|
|
|
}
|
2016-03-21 14:06:51 -04:00
|
|
|
return array ('--MISSING (' . $argtype . ')--' => ($flags | 4));
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function stripclass ($classname, $name) {
|
|
|
|
$classname .= ':';
|
2016-03-21 14:06:51 -04:00
|
|
|
if (strpos ($name, $classname) !== 0) {
|
|
|
|
my_die ('invalid class prefix: ' .$classname. ' -- '. $name);
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
|
|
|
return substr ($name, strlen ($classname));
|
|
|
|
}
|
|
|
|
|
|
|
|
function datatype ($decl) {
|
|
|
|
# TODO handle spaces in type. Works because
|
|
|
|
# we don't yet have templated types (with_space <here >)
|
2016-03-21 14:06:51 -04:00
|
|
|
return substr ($decl, 0, strpos ($decl, ' '));
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function luafn2class ($lua) {
|
2016-03-21 14:06:51 -04:00
|
|
|
return substr ($lua, 0, strrpos ($lua, ':'));
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function checkclass ($b) {
|
|
|
|
global $classlist;
|
2016-03-21 14:06:51 -04:00
|
|
|
if (!isset ($classlist[luafn2class ($b['lua'])])) {
|
|
|
|
my_die ('MISSING CLASS FOR '. print_r ($b['lua'], true));
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# parse functions argument list to lua-names
|
|
|
|
function decl2args ($decl) {
|
|
|
|
$start = strrpos ($decl, '(');
|
|
|
|
$end = strrpos ($decl, ')');
|
|
|
|
$args = substr ($decl, $start + 1, $end - $start - 1);
|
|
|
|
$arglist = preg_split ('/, */', $args);
|
|
|
|
$rv = array ();
|
|
|
|
foreach ($arglist as $a) {
|
|
|
|
if (empty ($a)) { continue; }
|
2016-03-21 14:06:51 -04:00
|
|
|
$rv[] = arg2lua ($a);
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
|
|
|
return $rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# step 1: build class indices
|
|
|
|
|
|
|
|
foreach ($doc as $b) {
|
|
|
|
if (strpos ($b['type'], "[C] ") === 0) {
|
|
|
|
$classes[] = $b;
|
2016-03-21 14:06:51 -04:00
|
|
|
$classlist[$b['lua']] = $b;
|
|
|
|
if (strpos ($b['type'], 'Pointer Class') === false) {
|
|
|
|
$classdecl[$b['decl']] = $b;
|
|
|
|
}
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
|
|
|
}
|
2016-03-21 14:06:51 -04:00
|
|
|
|
2016-03-20 23:09:01 -04:00
|
|
|
foreach ($classes as $c) {
|
2016-03-21 14:06:51 -04:00
|
|
|
if (strpos ($c['type'], 'Pointer Class') !== false) { continue; }
|
2016-03-20 23:09:01 -04:00
|
|
|
if (isset ($c['parent'])) {
|
|
|
|
if (isset ($classdecl[$c['parent']])) {
|
2016-03-21 14:06:51 -04:00
|
|
|
$classlist[$c['lua']]['luaparent'][] = $classdecl[$c['parent']]['lua'];
|
2016-03-20 23:09:01 -04:00
|
|
|
} else {
|
2016-03-21 14:06:51 -04:00
|
|
|
my_die ('unknown parent class: ' . print_r ($c, true));
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# step 2: extract constants/enum
|
|
|
|
foreach ($doc as $b) {
|
|
|
|
switch ($b['type']) {
|
|
|
|
case "Constant/Enum":
|
|
|
|
case "Constant/Enum Member":
|
|
|
|
if (strpos ($b['decl'], '::') === false) {
|
|
|
|
# for extern c enums, use the Lua Namespace
|
2016-03-21 14:06:51 -04:00
|
|
|
$b['decl'] = str_replace (':', '::', luafn2class ($b['lua']));
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
2016-03-21 14:06:51 -04:00
|
|
|
$ns = str_replace ('::', ':', $b['decl']);
|
|
|
|
$constlist[$ns][] = $b;
|
|
|
|
# arg2lua lookup
|
2016-03-20 23:09:01 -04:00
|
|
|
$b['lua'] = $ns;
|
|
|
|
$consts[] = $b;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# step 3: process functions
|
|
|
|
foreach ($doc as $b) {
|
|
|
|
switch ($b['type']) {
|
|
|
|
case "Constructor":
|
|
|
|
case "Weak/Shared Pointer Constructor":
|
|
|
|
checkclass ($b);
|
2016-03-21 14:06:51 -04:00
|
|
|
$classlist[luafn2class ($b['lua'])]['ctor'][] = array (
|
|
|
|
'name' => luafn2class ($b['lua']),
|
2016-03-20 23:09:01 -04:00
|
|
|
'args' => decl2args ($b['decl']),
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case "Data Member":
|
|
|
|
checkclass ($b);
|
2016-03-21 14:06:51 -04:00
|
|
|
$classlist[luafn2class ($b['lua'])]['data'][] = array (
|
2016-03-20 23:09:01 -04:00
|
|
|
'name' => $b['lua'],
|
2016-03-21 14:06:51 -04:00
|
|
|
'ret' => arg2lua (datatype ($b['decl']))
|
2016-03-20 23:09:01 -04:00
|
|
|
);
|
|
|
|
break;
|
|
|
|
case "C Function":
|
|
|
|
# we required C functions to be in a class namespace
|
|
|
|
case "Ext C Function":
|
|
|
|
checkclass ($b);
|
2016-03-21 16:15:26 -04:00
|
|
|
$args = array (array ('--custom--' => 0));
|
|
|
|
$ret = array ('...' => 0);
|
|
|
|
$ns = luafn2class ($b['lua']);
|
|
|
|
$cls = $classlist[$ns];
|
|
|
|
## std::Vector std::List types
|
|
|
|
if (preg_match ('/.*<([^>]*)[ ]*>/', $cls['decl'], $templ)) {
|
|
|
|
// XXX -> move to C-source
|
|
|
|
switch (stripclass($ns, $b['lua'])) {
|
|
|
|
case 'add':
|
|
|
|
$args = array (array ('LuaTable {'.$templ[1].'}' => 0));
|
2016-03-21 19:50:14 -04:00
|
|
|
$ret = array ('LuaTable' => 0);
|
2016-03-21 16:15:26 -04:00
|
|
|
break;
|
|
|
|
case 'iter':
|
|
|
|
$args = array ();
|
|
|
|
$ret = array ('LuaIter' => 0);
|
|
|
|
break;
|
|
|
|
case 'table':
|
|
|
|
$args = array ();
|
|
|
|
$ret = array ('LuaTable' => 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (strpos ($cls['type'], ' Array') !== false) {
|
|
|
|
$templ = preg_replace ('/[&*]*$/', '', $cls['decl']);
|
|
|
|
switch (stripclass($ns, $b['lua'])) {
|
|
|
|
case 'array':
|
|
|
|
$args = array ();
|
|
|
|
$ret = array ('LuaMetaTable' => 0);
|
|
|
|
break;
|
|
|
|
case 'get_table':
|
|
|
|
$args = array ();
|
|
|
|
$ret = array ('LuaTable' => 0);
|
|
|
|
break;
|
|
|
|
case 'set_table':
|
|
|
|
$args = array (array ('LuaTable {'.$templ.'}' => 0));
|
|
|
|
$ret = array ('void' => 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-03-21 14:06:51 -04:00
|
|
|
$classlist[luafn2class ($b['lua'])]['func'][] = array (
|
2016-03-21 19:50:14 -04:00
|
|
|
'bind' => $b,
|
2016-03-20 23:09:01 -04:00
|
|
|
'name' => $b['lua'],
|
2016-03-21 16:15:26 -04:00
|
|
|
'args' => $args,
|
|
|
|
'ret' => $ret,
|
2016-03-21 14:06:51 -04:00
|
|
|
'ref' => true,
|
2016-03-20 23:09:01 -04:00
|
|
|
'ext' => true
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case "Free Function":
|
|
|
|
case "Free Function RefReturn":
|
2016-03-21 14:06:51 -04:00
|
|
|
$funclist[luafn2class ($b['lua'])][] = array (
|
2016-03-21 19:50:14 -04:00
|
|
|
'bind' => $b,
|
2016-03-20 23:09:01 -04:00
|
|
|
'name' => $b['lua'],
|
|
|
|
'args' => decl2args ($b['decl']),
|
|
|
|
'ret' => arg2lua ($b['ret']),
|
2016-03-21 14:06:51 -04:00
|
|
|
'ref' => (strpos ($b['type'], "RefReturn") !== false)
|
2016-03-20 23:09:01 -04:00
|
|
|
);
|
|
|
|
break;
|
|
|
|
case "Member Function":
|
2016-03-21 14:06:51 -04:00
|
|
|
case "Member Function RefReturn":
|
2016-03-20 23:09:01 -04:00
|
|
|
case "Member Pointer Function":
|
|
|
|
case "Weak/Shared Pointer Function":
|
|
|
|
case "Weak/Shared Pointer Function RefReturn":
|
|
|
|
case "Weak/Shared Null Check":
|
|
|
|
case "Weak/Shared Pointer Cast":
|
|
|
|
case "Static Member Function":
|
|
|
|
checkclass ($b);
|
2016-03-21 14:06:51 -04:00
|
|
|
$classlist[luafn2class ($b['lua'])]['func'][] = array (
|
2016-03-21 19:50:14 -04:00
|
|
|
'bind' => $b,
|
2016-03-20 23:09:01 -04:00
|
|
|
'name' => $b['lua'],
|
|
|
|
'args' => decl2args ($b['decl']),
|
|
|
|
'ret' => arg2lua ($b['ret']),
|
2016-03-21 14:06:51 -04:00
|
|
|
'ref' => (strpos ($b['type'], "RefReturn") !== false)
|
2016-03-20 23:09:01 -04:00
|
|
|
);
|
|
|
|
break;
|
|
|
|
case "Constant/Enum":
|
|
|
|
case "Constant/Enum Member":
|
|
|
|
# already handled -> $consts
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (strpos ($b['type'], "[C] ") !== 0) {
|
|
|
|
my_die ('unhandled type: ' . $b['type']);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-21 14:06:51 -04:00
|
|
|
# step 4: collect/group/sort
|
2016-03-20 23:09:01 -04:00
|
|
|
|
|
|
|
# step 4a: unify weak/shared Ptr classes
|
2016-03-21 14:06:51 -04:00
|
|
|
foreach ($classlist as $ns => $cl) {
|
|
|
|
if (strpos ($cl['type'], ' Array') !== false) {
|
|
|
|
$classlist[$ns]['arr'] = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
foreach ($classes as $c) {
|
|
|
|
if ($c['lua'] == $ns) {
|
|
|
|
if (strpos ($c['type'], 'Pointer Class') !== false) {
|
|
|
|
$classlist[$ns]['ptr'] = true;
|
|
|
|
$classlist[$ns]['decl'] = 'boost::shared_ptr< '.$c['decl']. ' >, boost::weak_ptr< '.$c['decl']. ' >';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# step4b: sanity check
|
|
|
|
foreach ($classlist as $ns => $cl) {
|
|
|
|
if (isset ($classes[$ns]['parent']) && !isset ($classlist[$ns]['luaparent'])) {
|
|
|
|
my_die ('missing parent class: ' . print_r ($cl, true));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# step 4c: merge free functions into classlist
|
|
|
|
foreach ($funclist as $ns => $fl) {
|
|
|
|
if (isset ($classlist[$ns])) {
|
|
|
|
my_die ('Free Funcion in existing namespace: '.$ns.' '. print_r ($ns, true));
|
|
|
|
}
|
|
|
|
$classlist[$ns]['func'] = $fl;
|
|
|
|
$classlist[$ns]['free'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
# step 4d: order to chaos
|
|
|
|
# no array_multisort() here, sub-types are sorted after merging parents
|
|
|
|
ksort ($classlist);
|
|
|
|
|
|
|
|
|
2016-03-21 16:15:26 -04:00
|
|
|
################################################################################
|
|
|
|
################################################################################
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
#### -- split here -- ####
|
|
|
|
|
|
|
|
# from here on, only $classlist and $constlist arrays are relevant.
|
|
|
|
|
|
|
|
# TODO: read function documentation from doxygen
|
|
|
|
# and/or reference source-code lines e.g from CSV list:
|
|
|
|
# ctags -o /tmp/tags.csv --fields=+afiKkmnsSzt libs/ardour/ardour/session.h
|
|
|
|
|
|
|
|
|
2016-03-21 14:06:51 -04:00
|
|
|
################################################################################
|
|
|
|
# OUTPUT
|
|
|
|
################################################################################
|
2016-03-20 23:09:01 -04:00
|
|
|
|
2016-03-21 14:06:51 -04:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Helper functions
|
2016-03-20 23:09:01 -04:00
|
|
|
define ('NL', "\n");
|
|
|
|
|
2016-03-21 14:06:51 -04:00
|
|
|
function ctorname ($name) {
|
|
|
|
return htmlentities (str_replace (':', '.', $name));
|
|
|
|
}
|
|
|
|
|
2016-03-21 16:15:26 -04:00
|
|
|
function shortname ($name) {
|
|
|
|
return htmlentities (substr ($name, strrpos ($name, ':') + 1));
|
|
|
|
}
|
|
|
|
|
2016-03-21 14:06:51 -04:00
|
|
|
function varname ($a) {
|
|
|
|
return array_keys ($a)[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
function name_sort_cb ($a, $b) {
|
|
|
|
return strcmp ($a['name'], $b['name']);
|
|
|
|
}
|
|
|
|
|
2016-03-21 16:15:26 -04:00
|
|
|
function traverse_parent ($ns, &$inherited) {
|
|
|
|
global $classlist;
|
|
|
|
$rv = '';
|
|
|
|
if (isset ($classlist[$ns]['luaparent'])) {
|
|
|
|
$parents = array_unique ($classlist[$ns]['luaparent']);
|
|
|
|
asort ($parents);
|
|
|
|
foreach ($parents as $p) {
|
|
|
|
if (!empty ($rv)) { $rv .= ', '; }
|
|
|
|
$rv .= typelink ($p);
|
|
|
|
$inherited[$p] = $classlist[$p];
|
|
|
|
traverse_parent ($p, $inherited);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
function typelink ($a, $short = false, $argcls = '', $linkcls = '', $suffix = '') {
|
2016-03-21 14:06:51 -04:00
|
|
|
global $classlist;
|
|
|
|
global $constlist;
|
2016-03-21 16:15:26 -04:00
|
|
|
# all cross-reference links are generated here.
|
|
|
|
# currently anchors on a single page.
|
2016-03-21 19:50:14 -04:00
|
|
|
if (isset($classlist[$a]['free'])) {
|
|
|
|
return '<a class="'.$linkcls.'" href="#'.htmlentities ($a).'">'.($short ? shortname($a) : ctorname($a)).$suffix.'</a>';
|
|
|
|
} else if (in_array ($a, array_keys ($classlist))) {
|
2016-03-21 16:15:26 -04:00
|
|
|
return '<a class="'.$linkcls.'" href="#'.htmlentities($a).'">'.($short ? shortname($a) : htmlentities($a)).$suffix.'</a>';
|
2016-03-21 14:06:51 -04:00
|
|
|
} else if (in_array ($a, array_keys ($constlist))) {
|
2016-03-21 16:15:26 -04:00
|
|
|
return '<a class="'.$linkcls.'" href="#'.ctorname ($a).'">'.($short ? shortname($a) : ctorname($a)).$suffix.'</a>';
|
2016-03-21 14:06:51 -04:00
|
|
|
} else {
|
2016-03-21 16:15:26 -04:00
|
|
|
return '<span class="'.$argcls.'">'.htmlentities($a).$suffix.'</span>';
|
2016-03-21 14:06:51 -04:00
|
|
|
}
|
|
|
|
}
|
2016-03-20 23:09:01 -04:00
|
|
|
|
|
|
|
function format_args ($args) {
|
2016-03-21 14:06:51 -04:00
|
|
|
$rv = '<span class="functionargs"> (';
|
2016-03-20 23:09:01 -04:00
|
|
|
$first = true;
|
|
|
|
foreach ($args as $a) {
|
2016-03-21 14:06:51 -04:00
|
|
|
if (!$first) { $rv .= ', '; }; $first = false;
|
|
|
|
$flags = $a[varname ($a)];
|
|
|
|
if ($flags & 1) {
|
2016-03-21 16:15:26 -04:00
|
|
|
$rv .= typelink (varname ($a), true, 'em', '', '&');
|
2016-03-21 14:06:51 -04:00
|
|
|
} else {
|
2016-03-21 16:15:26 -04:00
|
|
|
$rv .= typelink (varname ($a), true, 'em');
|
2016-03-21 14:06:51 -04:00
|
|
|
}
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
2016-03-21 14:06:51 -04:00
|
|
|
$rv .= ')</span>';
|
2016-03-20 23:09:01 -04:00
|
|
|
return $rv;
|
|
|
|
}
|
|
|
|
|
2016-03-21 14:06:51 -04:00
|
|
|
function format_class_members ($ns, $cl, &$dups) {
|
|
|
|
$rv = '';
|
2016-03-20 23:09:01 -04:00
|
|
|
if (isset ($cl['ctor'])) {
|
2016-03-21 14:06:51 -04:00
|
|
|
usort ($cl['ctor'], 'name_sort_cb');
|
|
|
|
$rv.= ' <tr><th colspan="3">Constructor</th></tr>'.NL;
|
2016-03-20 23:09:01 -04:00
|
|
|
foreach ($cl['ctor'] as $f) {
|
2016-03-21 14:06:51 -04:00
|
|
|
$rv.= ' <tr><td class="def">ℂ</td><td class="decl">';
|
|
|
|
$rv.= '<span class="functionname">'.ctorname ($f['name']).'</span>';
|
|
|
|
$rv.= format_args ($f['args']);
|
|
|
|
$rv.= '</td><td class="fill"></td></tr>'.NL;
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
|
|
|
}
|
2016-03-21 14:06:51 -04:00
|
|
|
$nondups = array ();
|
2016-03-20 23:09:01 -04:00
|
|
|
if (isset ($cl['func'])) {
|
|
|
|
foreach ($cl['func'] as $f) {
|
2016-03-21 14:06:51 -04:00
|
|
|
if (in_array (stripclass ($ns, $f['name']), $dups)) { continue; }
|
|
|
|
$nondups[] = $f;
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
2016-03-21 14:06:51 -04:00
|
|
|
}
|
|
|
|
if (count ($nondups) > 0) {
|
|
|
|
usort ($nondups, 'name_sort_cb');
|
|
|
|
$rv.= ' <tr><th colspan="3">Methods</th></tr>'.NL;
|
|
|
|
foreach ($nondups as $f) {
|
|
|
|
$dups[] = stripclass ($ns, $f['name']);
|
|
|
|
$rv.= ' <tr><td class="def">';
|
|
|
|
if ($f['ref'] && isset ($f['ext'])) {
|
|
|
|
# external C functions
|
2016-03-21 16:15:26 -04:00
|
|
|
$rv.= '<em>'.varname ($f['ret']).'</em>';
|
2016-03-21 14:06:51 -04:00
|
|
|
} elseif ($f['ref'] && varname ($f['ret']) == 'void') {
|
|
|
|
# functions with reference args return args
|
|
|
|
$rv.= '<em>LuaTable</em>(...)';
|
|
|
|
} elseif ($f['ref']) {
|
2016-03-21 16:15:26 -04:00
|
|
|
$rv.= '<em>LuaTable</em>('.typelink (varname ($f['ret'], false, 'em')).', ...)';
|
2016-03-21 14:06:51 -04:00
|
|
|
} else {
|
2016-03-21 16:15:26 -04:00
|
|
|
$rv.= typelink (varname ($f['ret']), true, 'em');
|
2016-03-21 14:06:51 -04:00
|
|
|
}
|
|
|
|
$rv.= '</td><td class="decl">';
|
2016-03-21 19:50:14 -04:00
|
|
|
$rv.= '<span class="functionname"><abbr title="'.htmlentities($f['bind']['decl']).'">'.stripclass ($ns, $f['name']).'</abbr></span>';
|
2016-03-21 14:06:51 -04:00
|
|
|
$rv.= format_args ($f['args']);
|
|
|
|
$rv.= '</td><td class="fill"></td></tr>'.NL;
|
2016-03-21 16:15:26 -04:00
|
|
|
}
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
|
|
|
if (isset ($cl['data'])) {
|
2016-03-21 14:06:51 -04:00
|
|
|
usort ($cl['data'], 'name_sort_cb');
|
|
|
|
$rv.= ' <tr><th colspan="3">Data Members</th></tr>'.NL;
|
2016-03-20 23:09:01 -04:00
|
|
|
foreach ($cl['data'] as $f) {
|
2016-03-21 16:15:26 -04:00
|
|
|
$rv.= ' <tr><td class="def">'.typelink (array_keys ($f['ret'])[0], false, 'em').'</td><td class="decl">';
|
2016-03-21 14:06:51 -04:00
|
|
|
$rv.= '<span class="functionname">'.stripclass ($ns, $f['name']).'</span>';
|
|
|
|
$rv.= '</td><td class="fill"></td></tr>'.NL;
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
|
|
|
}
|
2016-03-21 14:06:51 -04:00
|
|
|
return $rv;
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
|
|
|
|
2016-03-21 14:06:51 -04:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Start Output
|
2016-03-21 16:15:26 -04:00
|
|
|
|
2016-03-21 14:06:51 -04:00
|
|
|
?><!DOCTYPE html>
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
|
|
|
<head>
|
|
|
|
<title>Ardour Lua Bindings</title>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
|
|
<style type="text/css">
|
|
|
|
div.content { max-width:60em; margin: 1em auto; }
|
|
|
|
h1 { margin:2em 0 0 0; padding:0em; border-bottom: 1px solid black;}
|
|
|
|
h2.cls { margin:2em 0 0 0; padding-left:1em; border: 1px dashed #6666ee;}
|
|
|
|
h2.cls abbr { text-decoration:none; cursor:default;}
|
|
|
|
h3.cls { margin:1em 0 0 0;}
|
|
|
|
h2.class { background-color: #aaee66; }
|
|
|
|
h2.enum { background-color: #aaaaaa; }
|
|
|
|
h2.pointerclass { background-color: #eeaa66; }
|
|
|
|
h2.array { background-color: #66aaee; }
|
|
|
|
h2.opaque { background-color: #6666aa; }
|
|
|
|
p.cdecl { text-align: right; float:right; font-size:90%; margin:0; padding: 0 0 0 1em;}
|
2016-03-21 16:15:26 -04:00
|
|
|
ul.classindex { columns: 2; -webkit-columns: 2; -moz-columns: 2; }
|
2016-03-21 14:06:51 -04:00
|
|
|
div.clear { clear:both; }
|
|
|
|
table.classmembers { width: 100%; }
|
|
|
|
table.classmembers th { text-align:left; border-bottom:1px solid black; padding-top:1em; }
|
|
|
|
table.classmembers td.def { text-align:right; padding-right:.5em; white-space: nowrap;}
|
|
|
|
table.classmembers td.decl { text-align:left; padding-left:.5em; white-space: nowrap; }
|
|
|
|
table.classmembers td.fill { width: 99%;}
|
|
|
|
table.classmembers span.em { font-style: italic;}
|
2016-03-21 19:50:14 -04:00
|
|
|
span.functionname abbr { text-decoration:none; cursor:default;}
|
2016-03-21 14:06:51 -04:00
|
|
|
div.header {text-align:center;}
|
|
|
|
div.header h1 {margin:0;}
|
|
|
|
div.header p {margin:.25em;}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="header">
|
|
|
|
<h1>Ardour Lua Bindings</h1>
|
|
|
|
<p>
|
|
|
|
<a href="#h_classes">Class Documentation</a>
|
|
|
|
|
|
|
|
|
<a href="#h_enum">Enum/Constants</a>
|
|
|
|
|
|
|
|
|
<a href="#h_index">Index</a>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div class="content">
|
|
|
|
|
2016-03-21 16:15:26 -04:00
|
|
|
<h1 id="h_intro">Overview</h1>
|
|
|
|
<p>
|
|
|
|
The top-level entry point are <?=typelink('ARDOUR:Session')?> and <?=typelink('ARDOUR:Editor')?>.
|
|
|
|
Most other Classes are used indirectly starting with a Session function. e.g. Session:get_routes().
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
A few classes are dedicated to certain script types, e.g. Lua DSP processors have exclusive access to
|
|
|
|
<?=typelink('ARDOUR:DSP')?> and <?=typelink('ARDOUR:ChanMapping')?>. Action Hooks Scripts to
|
|
|
|
<?=typelink('LuaSignal:Set')?> etc.
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
Detailed documentation (parameter names, method description) is not yet available. Please stay tuned.
|
|
|
|
</p>
|
|
|
|
|
2016-03-21 14:06:51 -04:00
|
|
|
<?php
|
|
|
|
echo '<h1 id="h_classes">Class Documentation</h1>'.NL;
|
|
|
|
|
|
|
|
foreach ($classlist as $ns => $cl) {
|
|
|
|
$dups = array ();
|
|
|
|
$tbl = format_class_members ($ns, $cl, $dups);
|
|
|
|
|
2016-03-21 16:15:26 -04:00
|
|
|
# format class title
|
2016-03-21 14:06:51 -04:00
|
|
|
if (empty ($tbl)) {
|
2016-03-21 19:50:14 -04:00
|
|
|
echo '<h2 id="'.htmlentities ($ns).'" class="cls opaque"><abbr title="Opaque Object">∅</abbr> '.htmlentities ($ns).'</h2>'.NL;
|
2016-03-21 14:06:51 -04:00
|
|
|
}
|
|
|
|
else if (isset ($classlist[$ns]['free'])) {
|
2016-03-21 19:50:14 -04:00
|
|
|
echo '<h2 id="'.htmlentities ($ns).'" class="cls freeclass"><abbr title="Namespace">ℕ</abbr> '.ctorname($ns).'</h2>'.NL;
|
2016-03-21 14:06:51 -04:00
|
|
|
}
|
|
|
|
else if (isset ($classlist[$ns]['arr'])) {
|
2016-03-21 19:50:14 -04:00
|
|
|
echo '<h2 id="'.htmlentities ($ns).'" class="cls array"><abbr title="C Array">⋯</abbr> '.htmlentities ($ns).'</h2>'.NL;
|
2016-03-21 14:06:51 -04:00
|
|
|
}
|
|
|
|
else if (isset ($classlist[$ns]['ptr'])) {
|
2016-03-21 19:50:14 -04:00
|
|
|
echo '<h2 id="'.htmlentities ($ns).'" class="cls pointerclass"><abbr title="Pointer Class">↠</abbr> '. htmlentities ($ns).'</h2>'.NL;
|
2016-03-21 14:06:51 -04:00
|
|
|
} else {
|
|
|
|
echo '<h2 id="'.htmlentities ($ns).'" class="cls class"><abbr title="Class">∁</abbr> '.htmlentities ($ns).'</h2>'.NL;
|
|
|
|
}
|
|
|
|
if (isset ($cl['decl'])) {
|
|
|
|
echo '<p class="cdecl"><em>C‡</em>: '.htmlentities ($cl['decl']).'</p>'.NL;
|
|
|
|
}
|
|
|
|
|
2016-03-21 16:15:26 -04:00
|
|
|
# print class inheritance
|
2016-03-21 14:06:51 -04:00
|
|
|
$inherited = array ();
|
2016-03-21 16:15:26 -04:00
|
|
|
$isa = traverse_parent ($ns, $inherited);
|
|
|
|
if (!empty ($isa)) {
|
|
|
|
echo ' <p>is-a: '.$isa.'</p>'.NL;
|
2016-03-21 14:06:51 -04:00
|
|
|
}
|
|
|
|
echo '<div class="clear"></div>'.NL;
|
|
|
|
|
2016-03-21 16:15:26 -04:00
|
|
|
# member documentation
|
2016-03-21 14:06:51 -04:00
|
|
|
if (empty ($tbl)) {
|
|
|
|
echo '<p>This class object is only used indirectly as return-value and function-parameter.</p>'.NL;
|
|
|
|
} else {
|
|
|
|
echo '<table class="classmembers">'.NL;
|
|
|
|
echo $tbl;
|
|
|
|
echo ' </table>'.NL;
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
2016-03-21 14:06:51 -04:00
|
|
|
|
2016-03-21 16:15:26 -04:00
|
|
|
# traverse parent classes (inherited members)
|
2016-03-21 14:06:51 -04:00
|
|
|
foreach ($inherited as $pns => $pcl) {
|
|
|
|
$tbl = format_class_members ($pns, $pcl, $dups);
|
|
|
|
if (!empty ($tbl)) {
|
|
|
|
echo '<h3 class="cls">Inherited from '.$pns.'</h3>'.NL;
|
|
|
|
echo '<table class="classmembers">'.NL;
|
|
|
|
echo $tbl;
|
|
|
|
echo '</table>'.NL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '<h1 id="h_enum">Enum/Constants</h1>'.NL;
|
|
|
|
foreach ($constlist as $ns => $cs) {
|
|
|
|
echo '<h2 id="'.ctorname ($ns).'" class="cls enum"><abbr title="Enum">∈</abbr> '.ctorname ($ns).'</h2>'.NL;
|
|
|
|
echo '<ul class="enum">'.NL;
|
|
|
|
foreach ($cs as $c) {
|
|
|
|
echo '<li class="const">'.ctorname ($c['lua']).'</li>'.NL;
|
|
|
|
}
|
|
|
|
echo '</ul>'.NL;
|
2016-03-20 23:09:01 -04:00
|
|
|
}
|
|
|
|
|
2016-03-21 14:06:51 -04:00
|
|
|
echo '<h1 id="h_index" >Class Index</h1>'.NL;
|
2016-03-21 16:15:26 -04:00
|
|
|
echo '<ul class="classindex">'.NL;
|
2016-03-21 14:06:51 -04:00
|
|
|
foreach ($classlist as $ns => $cl) {
|
2016-03-21 16:15:26 -04:00
|
|
|
echo '<li>'.typelink($ns).'</li>'.NL;
|
2016-03-21 14:06:51 -04:00
|
|
|
}
|
|
|
|
echo '</ul>'.NL;
|
|
|
|
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|