X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=tools%2Ffmt-luadoc.php;h=b13e38617caf77f2b7c31a75ca67ba958f20d006;hb=1dd4aab0b4d3e14ef93ddb3470d4c386f48cda6b;hp=bfb6b81ae57eb28bbc28624a6f01cbf1546c0186;hpb=c8db4fcfc642c6cc659757276a6796df0bc5f33f;p=ardour.git
diff --git a/tools/fmt-luadoc.php b/tools/fmt-luadoc.php
index bfb6b81ae5..b13e38617c 100755
--- a/tools/fmt-luadoc.php
+++ b/tools/fmt-luadoc.php
@@ -16,6 +16,13 @@
# php tools/fmt-luadoc.php > /tmp/luadoc.html
#
+$options = getopt("m");
+if (isset ($options['m'])) {
+ $HTMLOUTPUT = false; ## set to false to output ardour-manual
+} else {
+ $HTMLOUTPUT = true; ## set to false to output ardour-manual
+}
+
################################################################################
################################################################################
@@ -27,9 +34,18 @@ foreach (json_decode ($json, true) as $b) {
if (isset ($b['version'])) { $ardourversion = $b['version']; }
continue;
}
+ # reserved lua words
+ $b ['lua'] = preg_replace ('/:_end/', ':end', $b ['lua']);
+ $b ['lua'] = preg_replace ('/:_type/', ':type', $b ['lua']);
$b ['ldec'] = preg_replace ('/ const/', '', preg_replace ('/ const&/', '', $b['decl']));
+ $b ['ldec'] = preg_replace ('/_VampHost::/', '', $b['ldec']);
+ $b ['decl'] = preg_replace ('/_VampHost::/', '', $b['decl']);
if (isset ($b['ret'])) {
$b['ret'] = preg_replace ('/ const/', '', preg_replace ('/ const&/', '', $b['ret']));
+ $b['ret'] = preg_replace ('/_VampHost::/', '', $b['ret']);
+ }
+ if (isset ($b['parent'])) {
+ $b ['parent'] = preg_replace ('/_VampHost::/', '', $b['parent']);
}
$doc[] = $b;
}
@@ -81,11 +97,15 @@ function arg2lua ($argtype, $flags = 0) {
$arg = preg_replace ('/ $/', '', $arg);
# 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*');
+ $builtin = array ('float', 'double', 'bool', 'std::string', 'int', 'short', 'long', 'unsigned int', 'unsigned short', 'unsigned long', 'unsigned char', 'char', 'void', 'char*', 'unsigned char*', 'void*');
if (in_array ($arg, $builtin)) {
return array ($arg => $flags);
}
+ if ($arg == 'luabridge::LuaRef') {
+ return array ('Lua-Function' => $flags | 4);
+ }
+
# check Class declarations first
foreach (array_merge ($classes, $consts) as $b) {
if ($b['ldec'] == $arg) {
@@ -118,13 +138,22 @@ function stripclass ($classname, $name) {
function datatype ($decl) {
# TODO handle spaces in type. Works because
# we don't yet have templated types (with_space '.NL;
foreach ($cl['ctor'] as $f) {
- $rv.= ' Constructor ℂ ';
+ $rv.= ' ';
+ if ($f['nil']) {
+ $rv.= ' '.NL;
@@ -596,6 +708,34 @@ function format_class_members ($ns, $cl, &$dups) {
$rv.= format_doxydoc($f);
}
}
+ # print cast - if any
+ if (isset ($cl['cast'])) {
+ usort ($cl['cast'], 'name_sort_cb');
+ $rv.= ' ℵ ';
+ } else {
+ $rv.= 'ℂ ';
+ }
+ $rv.= '';
$rv.= ''.ctorname ($f['name']).'';
$rv.= format_args ($f['args']);
$rv.= ' '.NL;
+ foreach ($cl['cast'] as $f) {
+ $rv.= ' Cast '.NL;
+ # doxygen documentation (may be empty)
+ $rv.= format_doxydoc($f);
+ }
+ }
+
+ # print properties - if any
+ if (isset ($cl['props'])) {
+ usort ($cl['props'], 'name_sort_cb');
+ $rv.= ' ';
+ $rv.= typelink (varname ($f['ret']), true, 'em');
+ # function declaration and arguments
+ $rv.= ' ';
+ $rv.= ''.stripclass ($ns, $f['name']).'';
+ $rv.= format_args ($f['args']);
+ $rv.= ' '.NL;
+ foreach ($cl['props'] as $f) {
+ $rv.= ' Properties '.NL;
+ }
+ }
+
# print data members - if any
if (isset ($cl['data'])) {
usort ($cl['data'], 'name_sort_cb');
@@ -604,6 +744,8 @@ function format_class_members ($ns, $cl, &$dups) {
$rv.= ' '.typelink (array_keys ($f['ret'])[0], false, 'em').' ';
+ $rv.= ''.stripclass ($ns, $f['name']).'';
+ $rv.= ' '.NL;
+ $f['cand'] = str_replace (':', '::', $f['name']);
+ $rv.= format_doxydoc($f);
}
}
return $rv;
@@ -613,6 +755,8 @@ function format_class_members ($ns, $cl, &$dups) {
################################################################################
# Start Output
+if ($HTMLOUTPUT) {
+
?>
@@ -662,6 +806,7 @@ div.luafooter { text-align:center; font-size:80%; color: #888; margin: 2em
#luaref table.classmembers td.fill { width: 99%; }
#luaref table.classmembers span.em { font-style: italic; }
#luaref span.functionname abbr { text-decoration:none; cursor:default; }
+#luaref table.classmembers td.def abbr { text-decoration:none; cursor:default; }
@@ -676,7 +821,21 @@ div.luafooter { text-align:center; font-size:80%; color: #888; margin: 2em
'.typelink (array_keys ($f['ret'])[0], false, 'em').' ';
$rv.= ''.stripclass ($ns, $f['name']).'';
$rv.= '
+This documentation is far from complete may be inaccurate and subject to change. +
+ +obj = Session:route_by_name("Audio") obj:set_name("Guitar")
.
+Lua automatically follows C++ class inheritance. e.g one can directly call all SessionObject and Route methods on Track object. However lua does not automatically promote objects. A Route object which just happens to be a Track needs to be explicily cast to a Track. Methods for casts are provided with each class. Note that the cast may fail and return a nil reference. +
++Likewise multiple inheritance is a non-trivial issue in lua. To avoid performance penalties involved with lookups, explicit casts are required in this case. One example is =typelink('ARDOUR:SessionObject')?> which is-a StatefulDestructible which inhertis from both Stateful and Destructible. +
+Object lifetimes are managed by the Session. Most Objects cannot be directly created, but one asks the Session to create or destroy them. This is mainly due to realtime constrains: you cannot simply remove a track that is currently processing audio. There are various factory methods for object creation or removal.
@@ -827,8 +992,8 @@ foreach ($classlist as $ns => $cl) { } # show original C++ declaration - if (isset ($cl['decl'])) { - echo 'C‡: '.htmlentities ($cl['decl']).'
'.NL; + if (isset ($cl['cdecl'])) { + echo 'C‡: '.htmlentities ($cl['cdecl']).'
'.NL; } # print class inheritance (direct parent *name* only) @@ -890,12 +1055,15 @@ echo ''.NL; # see how far there is still to go... fwrite (STDERR, "Found $dox_found annotations. missing: $dox_miss\n"); +echo ''.NL; ?>