From: fennecdjay Date: Fri, 5 Jul 2019 01:01:49 +0000 (+0200) Subject: :book: Update docs [skip ci] X-Git-Tag: nightly~2351 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=6156f1d204179b2c91147f92b651950f28b8f95f;p=gwion.git :book: Update docs [skip ci] --- diff --git a/docs/ControlFlow/ControlFlow.mdr b/docs/ControlFlow/ControlFlow.mdr deleted file mode 100644 index 2e9c1854..00000000 --- a/docs/ControlFlow/ControlFlow.mdr +++ /dev/null @@ -1,4 +0,0 @@ -# Control Flow - -## Repeats -let start simple ;-) diff --git a/docs/ControlFlow/Loops.mdr b/docs/ControlFlow/Loops.mdr deleted file mode 100644 index 4b787b4b..00000000 --- a/docs/ControlFlow/Loops.mdr +++ /dev/null @@ -1 +0,0 @@ -# Loops diff --git a/docs/ControlFlow/Repeat.mdr b/docs/ControlFlow/Repeat.mdr deleted file mode 100644 index bbfea851..00000000 --- a/docs/ControlFlow/Repeat.mdr +++ /dev/null @@ -1,21 +0,0 @@ -# the Repeat keyword -let start simple ;-) -The easiest way to do an action repeatidly in Gwion is, ... the **repeat** keyword! - -## Very basic example -@``` repeat.gw -repeat(3) - <<<"Hello, world!">>>; -@``` -@exec make -s CONTAINS="Hello" repeat.test - -## Block example -of course this also works with a block code. - -@``` repeat2.gw -repeat(3) { - maybe ? "You" : "Me" => string s; - <<<"Hello, ", s, "!">>>; -} -@``` -@exec make -s CONTAINS="Hello" repeat2.test diff --git a/docs/ControlFlow/forloop.mdr b/docs/ControlFlow/forloop.mdr deleted file mode 100644 index 5d01609f..00000000 --- a/docs/ControlFlow/forloop.mdr +++ /dev/null @@ -1,63 +0,0 @@ -# For Loops -**For** loops in Gwion is pretty similar to classic **C** syntax - -## basic loops -@``` forloop0.gw -for(int i; i < 3; ++i) - <<>>; -@``` -@exec make -s forloop0.test - -Of course, it also works with a block of code. - -@``` forloop2.gw -for(int i; i < 3; ++i) { - i/2 => float f1; - i/2. => float f2; - <<>>; -} -@``` -@exec make -s forloop2.test - -## Nested Loops -@``` forloop3.gw -int array[3][4]; - -for(int i; i < 3; ++i) { - for(int j; j < 4; ++j) { - <<>>; - } -} -@``` -@exec make -s forloop3.test - -### Auto Loops - -#### Simple auto loop -@``` forloop4.gw -int array[2][3]; -for(auto a: array) { - <<>>; - for(auto b: a) - <<>>; -} -@``` -@exec make -s forloop4.test - -### Auto Pointer loop -With the simple auto loop, you only get the value in the array. -If you want to change it, you need a pointer - -@``` forloop5.gw -int array[2][3]; -int i; -for(auto a: array) { - for(auto @b: a) - <<<++i => *b>>>; -} -for(auto a: array) { - for(auto @b: a) - <<<*b>>>; -} -@``` -@exec make -s forloop5.test diff --git a/docs/ControlFlow/whileuntil.mdr b/docs/ControlFlow/whileuntil.mdr deleted file mode 100644 index 798b0334..00000000 --- a/docs/ControlFlow/whileuntil.mdr +++ /dev/null @@ -1,23 +0,0 @@ -# Loops - -@``` while0.gw -while(true) { - if(maybe) - break; - <<<"running...">>>; -} -@``` -@exec make -s while0.test - -well this may output nothing... -lets try - -@``` while1.gw -<<>>; -do{ - if(maybe) - break; - <<<"running...">>>; -} while(true); -@``` -@exec make -s while1.test diff --git a/docs/Extending/WIP_Driver.mdr b/docs/Extending/WIP_Driver.mdr deleted file mode 100644 index 20478632..00000000 --- a/docs/Extending/WIP_Driver.mdr +++ /dev/null @@ -1,9 +0,0 @@ -# Giving gwion a new driver - -## basics - -> in order to use GWION_CTL ... - -# concept - -# upd driver diff --git a/docs/Extending/WIP_Plugins.mdr b/docs/Extending/WIP_Plugins.mdr deleted file mode 100644 index cd1822fd..00000000 --- a/docs/Extending/WIP_Plugins.mdr +++ /dev/null @@ -1,68 +0,0 @@ -# Writing a Gwion plugin - -> THIS IS OUTDATED. please look at the source code in src/lib/ instead - - * [getting started] - -## Getting started -use the script - -### headers -``` -#include "vm.h" -#include "instr.h" -#include "import.h -``` - - -### Class -Define the type: -``` -struct Type_ t_mytype = { "MyType", SZ_INT, &t_object}; -``` -> every type extending t_object should have SZ_INT - -### Handling Constructors and Destructors -#### CTOR -``` -CTOR(mytype_ctor) { - /* constructor code here */ -} -``` -#### DTOR -``` -DTOR(mytype_dtor) { - /* destructor code here */ -} -``` - -those macros provide two variables: - * `o`: the *M_Object* for the (con/des)tructor - * `shred`: the *VM_Shred* for the (con/des)tructor - -``` -CHECK_BB(import_class_begin(env, &t_mytpe, env->global_nspc, mytype_ctor, mytype_dtor)) -``` -#### variable -declare a `m_int`. coding convention require - * a leading *_o* - * a following *_type_* -```c -m_int o_mytype_myvaroffset; -``` -#### function -```c -/* declare a member function */ -MFUN(mytype_memberfunction) { - /* code here */ -} - -SFUN(mtype_staticfunction) { - /* code here */ -} -``` - -#### operator - -### Import function - diff --git a/docs/Functions/Lambdas.mdr b/docs/Functions/Lambdas.mdr deleted file mode 100644 index 132fbf32..00000000 --- a/docs/Functions/Lambdas.mdr +++ /dev/null @@ -1,37 +0,0 @@ -# Lambda - -## Overview - -Simply put, *lambda*s are anonymous functions. - -The syntax to create them is simple: -``` -\ variable0 variable1 ... { your code here } -``` -You can even use it to -### Call a function just once -@``` lambda_call0.gw -\ i { <<<"passed '", i, "'">>>; }(3); -@``` -@exec make -s CONTAINS="passed '3'" lambda_call0.test - - -## Use case - -### Passing to a function pointer -@``` lambda_fptr0.gw -typedef void fptr_t(int); -\ i { <<<"passed '", i, "'">>>; } @=> fptr_t fptr; -fptr(4); -@``` -@exec make -s CONTAINS="passed '4'" lambda_fptr0.test - -### As Argument to Functions -@``` lambda_args0.gw -typedef void fptr_t(int); -fun void test(fptr_t fptr) { - fptr(5); -} -test(\ i { <<<"passed '", i, "'">>>; }); -@``` -@exec make -s CONTAINS="passed '5'" lambda_args0.test diff --git a/docs/Functions/Variadic.mdr b/docs/Functions/Variadic.mdr deleted file mode 100644 index 23a75196..00000000 --- a/docs/Functions/Variadic.mdr +++ /dev/null @@ -1,18 +0,0 @@ -# Variadic functions - -> A function whoses arity is not fixed. - -Well, a function that takes a fixed number of arguments, and additionnal ones. - -## a simple example -@``` variadic.gw -fun void variadic_test(int i, ...) { - <<< "first argument is ", i >>>; - vararg.start; - <<< "\tadditionnal argument", vararg.i >>>; - vararg.end; -} -variadic_test(1); -variadic_test(1, 2); -variadic_test(1, 2, 3); -@``` diff --git a/docs/Functions/function.mdr b/docs/Functions/function.mdr deleted file mode 100644 index f92a174f..00000000 --- a/docs/Functions/function.mdr +++ /dev/null @@ -1,19 +0,0 @@ -# Functions - -## a simple (commented example) - -@``` function0.gw -// declare function 'test_function' -// with return type int -// taking an int as argument -fun int test_function(int arg) { - // return the argument + 2 - return arg + 2; -} - -// now call the function (and debug print the result) -<<>>; -// or use alternate syntax -<<<1 => test_function>>>; -@``` -@exec make -s function0.test diff --git a/docs/assets/benchmark/binary-trees.dat b/docs/assets/benchmark/binary-trees.dat index ce3d7278..bc78c854 100644 --- a/docs/assets/benchmark/binary-trees.dat +++ b/docs/assets/benchmark/binary-trees.dat @@ -1,3 +1,3 @@ -gwion 0.18500 0.63 -wren 0.228810 0.24 -lua 0.31364 1.10 +gwion 0.18650 0.58 +wren 0.23149 1.00 +lua 0.30273 1.31 diff --git a/docs/assets/benchmark/binary-trees.png b/docs/assets/benchmark/binary-trees.png index bafec935..a69a778d 100644 Binary files a/docs/assets/benchmark/binary-trees.png and b/docs/assets/benchmark/binary-trees.png differ diff --git a/docs/assets/benchmark/fib-recurs.dat b/docs/assets/benchmark/fib-recurs.dat index 7ea40956..68f31f11 100644 --- a/docs/assets/benchmark/fib-recurs.dat +++ b/docs/assets/benchmark/fib-recurs.dat @@ -1,3 +1,3 @@ -gwion 5.2990 0.37 -wren 13.4991 0.34 -lua 7.3146 0.29 +gwion 5.2823 0.38 +wren 13.4943 0.44 +lua 7.3512 0.89 diff --git a/docs/assets/benchmark/fib-recurs.png b/docs/assets/benchmark/fib-recurs.png index d3d56bec..12e95df9 100644 Binary files a/docs/assets/benchmark/fib-recurs.png and b/docs/assets/benchmark/fib-recurs.png differ diff --git a/docs/assets/benchmark/fib.dat b/docs/assets/benchmark/fib.dat index 693519bd..5ca617ec 100644 --- a/docs/assets/benchmark/fib.dat +++ b/docs/assets/benchmark/fib.dat @@ -1,3 +1,3 @@ -gwion 0.085201 0.50 -wren 0.210157 0.14 -lua 0.207941 0.43 +gwion 0.084083 0.72 +wren 0.210827 0.32 +lua 0.209405 0.47 diff --git a/docs/assets/benchmark/fib.png b/docs/assets/benchmark/fib.png index 63a8cd6a..039ee7d7 100644 Binary files a/docs/assets/benchmark/fib.png and b/docs/assets/benchmark/fib.png differ diff --git a/docs/assets/benchmark/method-call.dat b/docs/assets/benchmark/method-call.dat index 22636cce..21a3b323 100644 --- a/docs/assets/benchmark/method-call.dat +++ b/docs/assets/benchmark/method-call.dat @@ -1,3 +1,3 @@ -gwion 0.091161 0.26 -wren 0.107611 0.38 -lua 0.25866 1.21 +gwion 0.09491 1.85 +wren 0.11345 5.40 +lua 0.25868 1.48 diff --git a/docs/assets/benchmark/method-call.png b/docs/assets/benchmark/method-call.png index ed8d5acc..da5d03be 100644 Binary files a/docs/assets/benchmark/method-call.png and b/docs/assets/benchmark/method-call.png differ