RPA Toolkit
used types cleaned up...
[rpatk.git] / tests / testrjs / rjs-simple.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <sys/types.h>
6 #include <fcntl.h>
7 #include <unistd.h>
8 #include <sys/mman.h>
9
10 #include "rlib/rstring.h"
11 #include "rjs/rjs.h"
12
13
14 int main(int argc, char *argv[])
15 {
16         rjs_engine_t *jse = rjs_engine_create();
17         char test_script1[] = "(2+3)*3;";
18         char test_script2[] = "function person(name, age, job) {this.name = name; this.age = age; this.job = job;} var me = new person('Martin', 25, 'Slacker');";
19
20 //      jse->debugexec = 1;
21         r_printf("script: %s result: %ld\n", test_script1, rvm_reg_signed(rjs_engine_exec_s(jse, test_script1)));
22         rjs_engine_exec_s(jse, test_script2);
23         r_printf("Name: %s\n", r_string_ansi(rvm_reg_string(rjs_engine_exec_s(jse, "me.name;"))));
24         r_printf("Job: %s\n", r_string_ansi(rvm_reg_string(rjs_engine_exec_s(jse, "me.job;"))));
25         r_printf("Description: %s\n", r_string_ansi(rvm_reg_string(rjs_engine_exec_s(jse, "'Name = ' + me.name + ', Job = ' + me.job;"))));
26         rjs_engine_destroy(jse);
27         return 0;
28 }