1 module unit; 2 3 import kyle; 4 import std.file; 5 import std.stdio; 6 7 void hello(kyle_arguments Args, kyle_state S) { 8 writeln("Testing!"); 9 writeln(kyle_vararg!(int).kyle_convert_argument(0, Args) + kyle_vararg!(int).kyle_convert_argument(1, Args)); 10 } 11 12 void world(kyle_arguments a, kyle_state l) { 13 writeln(kyle_vararg!(string).kyle_convert_argument(0, a)); 14 } 15 16 void main() { 17 auto env = kyle_new(); 18 19 kyle_allow_module(env); 20 21 kyle_add_delegate( 22 env, 23 &hello, 24 "hello" 25 ); 26 27 kyle_add_delegate( 28 env, 29 &world, 30 "world" 31 ); 32 33 kyle_set_code(env, "#mod main;\n? Test Command\n#hello 1 1;\n#world \"hello owlr\";"); 34 35 kyle_execute(env); 36 37 auto env1 = kyle_new(); 38 kyle_allow_module(env1); 39 40 kyle_add_delegate( 41 env1, 42 &world, 43 "print" 44 ); 45 46 kyle_set_code(env1, cast(string)read("main.kyle")); 47 48 writeln("mod name: " ~ kyle_toplevel_module(env)); 49 50 kyle_execute(env1); 51 52 writeln("testing objects"); 53 54 auto env2 = kyle_new(); 55 56 kyle_object myObj = new kyle_object(); 57 58 kyle_setk(myObj, "1"); 59 60 kyle_set(env2, myObj, "obj"); 61 62 if (kyle_objects_has("obj", env2)) { 63 int one = kyle_convert!(int).object_to(kyle_get(env2, "obj")); 64 65 writeln(one + 1); 66 } 67 68 }