nabaztag_hack_kit 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/.gitignore +7 -0
  2. data/.travis.yml +3 -0
  3. data/CHANGELOG.md +11 -0
  4. data/Gemfile +4 -0
  5. data/README.md +119 -0
  6. data/Rakefile +21 -0
  7. data/bin/mtl_comp +41 -0
  8. data/bin/mtl_merge +22 -0
  9. data/bin/mtl_simu +40 -0
  10. data/bytecode/lib/buffer.mtl +109 -0
  11. data/bytecode/lib/button.mtl +27 -0
  12. data/bytecode/lib/data_helper.mtl +88 -0
  13. data/bytecode/lib/ear.mtl +90 -0
  14. data/bytecode/lib/led.mtl +33 -0
  15. data/bytecode/lib/rfid.mtl +50 -0
  16. data/bytecode/main.mtl +129 -0
  17. data/config.ru +6 -0
  18. data/ext/bytecode/Commands.md +172 -0
  19. data/ext/bytecode/Docs.md +488 -0
  20. data/ext/bytecode/README.md +5 -0
  21. data/ext/bytecode/lib/arp.mtl +159 -0
  22. data/ext/bytecode/lib/cfg.mtl +74 -0
  23. data/ext/bytecode/lib/choreos.mtl +1487 -0
  24. data/ext/bytecode/lib/dhcp.mtl +152 -0
  25. data/ext/bytecode/lib/dns.mtl +89 -0
  26. data/ext/bytecode/lib/http.mtl +84 -0
  27. data/ext/bytecode/lib/tcp.mtl +340 -0
  28. data/ext/bytecode/lib/udp.mtl +49 -0
  29. data/ext/bytecode/lib/util.mtl +74 -0
  30. data/ext/bytecode/lib/var.mtl +15 -0
  31. data/ext/bytecode/lib/wifi.mtl +243 -0
  32. data/ext/bytecode/nominal-ping.mtl +5828 -0
  33. data/ext/mtl/Makefile +42 -0
  34. data/ext/mtl/README.md +13 -0
  35. data/ext/mtl/bc.cpp +1891 -0
  36. data/ext/mtl/conf.bin.sans_password +0 -0
  37. data/ext/mtl/config.txt +5 -0
  38. data/ext/mtl/dumpbc.c +2566 -0
  39. data/ext/mtl/extconf.rb +1 -0
  40. data/ext/mtl/linux_simu.c +271 -0
  41. data/ext/mtl/linux_simuaudio.c +16 -0
  42. data/ext/mtl/linux_simuaudio.h +18 -0
  43. data/ext/mtl/linux_simunet.c +620 -0
  44. data/ext/mtl/linux_simunet.h +7 -0
  45. data/ext/mtl/log.c +297 -0
  46. data/ext/mtl/log.h +20 -0
  47. data/ext/mtl/main_compiler.cpp +104 -0
  48. data/ext/mtl/main_simu.cpp +221 -0
  49. data/ext/mtl/mp3/GTKANAL.H +97 -0
  50. data/ext/mtl/mp3/LAYER3.C +2090 -0
  51. data/ext/mtl/mp3/TABINIT.C +82 -0
  52. data/ext/mtl/mp3/common.c +265 -0
  53. data/ext/mtl/mp3/dct64_i386.c +316 -0
  54. data/ext/mtl/mp3/decode_i386.c +155 -0
  55. data/ext/mtl/mp3/huffman.h +332 -0
  56. data/ext/mtl/mp3/interface.c +258 -0
  57. data/ext/mtl/mp3/mpg123.h +182 -0
  58. data/ext/mtl/mp3/mpglib.h +44 -0
  59. data/ext/mtl/properties.c +293 -0
  60. data/ext/mtl/properties.h +10 -0
  61. data/ext/mtl/simu.c +750 -0
  62. data/ext/mtl/simuaudio.c +662 -0
  63. data/ext/mtl/simuaudio.h +74 -0
  64. data/ext/mtl/simunet.c +400 -0
  65. data/ext/mtl/simunet.h +30 -0
  66. data/ext/mtl/utils/correct_const.sh +34 -0
  67. data/ext/mtl/vaudio.c +677 -0
  68. data/ext/mtl/vaudio.h +46 -0
  69. data/ext/mtl/vbc.h +160 -0
  70. data/ext/mtl/vbc_str.h +166 -0
  71. data/ext/mtl/vcomp/Makefile +29 -0
  72. data/ext/mtl/vcomp/bootstrap.cpp +89 -0
  73. data/ext/mtl/vcomp/compiler.cpp +470 -0
  74. data/ext/mtl/vcomp/compiler.h +200 -0
  75. data/ext/mtl/vcomp/compiler_file.cpp +929 -0
  76. data/ext/mtl/vcomp/compiler_prog.cpp +250 -0
  77. data/ext/mtl/vcomp/compiler_term.cpp +1053 -0
  78. data/ext/mtl/vcomp/compiler_type.cpp +872 -0
  79. data/ext/mtl/vcomp/compiler_var.cpp +289 -0
  80. data/ext/mtl/vcomp/file.cpp +79 -0
  81. data/ext/mtl/vcomp/file.h +39 -0
  82. data/ext/mtl/vcomp/filesystem.h +14 -0
  83. data/ext/mtl/vcomp/interpreter.cpp +85 -0
  84. data/ext/mtl/vcomp/interpreter.h +121 -0
  85. data/ext/mtl/vcomp/memory.cpp +241 -0
  86. data/ext/mtl/vcomp/memory.h +326 -0
  87. data/ext/mtl/vcomp/param.h +95 -0
  88. data/ext/mtl/vcomp/parser.cpp +427 -0
  89. data/ext/mtl/vcomp/parser.h +97 -0
  90. data/ext/mtl/vcomp/parser_xml.cpp +124 -0
  91. data/ext/mtl/vcomp/prodbuffer.cpp +125 -0
  92. data/ext/mtl/vcomp/prodbuffer.h +42 -0
  93. data/ext/mtl/vcomp/resource.h +17 -0
  94. data/ext/mtl/vcomp/stdlib_core.cpp +122 -0
  95. data/ext/mtl/vcomp/terminal.cpp +73 -0
  96. data/ext/mtl/vcomp/terminal.h +30 -0
  97. data/ext/mtl/vcomp/util.cpp +48 -0
  98. data/ext/mtl/vcomp/util.h +31 -0
  99. data/ext/mtl/vinterp.c +1349 -0
  100. data/ext/mtl/vinterp.h +11 -0
  101. data/ext/mtl/vloader.c +127 -0
  102. data/ext/mtl/vloader.h +31 -0
  103. data/ext/mtl/vlog.c +589 -0
  104. data/ext/mtl/vlog.h +69 -0
  105. data/ext/mtl/vmem.c +424 -0
  106. data/ext/mtl/vmem.h +107 -0
  107. data/ext/mtl/vnet.c +255 -0
  108. data/ext/mtl/vnet.h +19 -0
  109. data/lib/nabaztag_hack_kit/message/api.rb +39 -0
  110. data/lib/nabaztag_hack_kit/message/helper.rb +39 -0
  111. data/lib/nabaztag_hack_kit/message.rb +36 -0
  112. data/lib/nabaztag_hack_kit/server.rb +50 -0
  113. data/lib/nabaztag_hack_kit/version.rb +3 -0
  114. data/lib/nabaztag_hack_kit.rb +4 -0
  115. data/nabaztag_hack_kit.gemspec +29 -0
  116. data/public/bytecode.bin +0 -0
  117. data/test/bytecode/helper.mtl +60 -0
  118. data/test/bytecode/native.mtl +28 -0
  119. data/test/bytecode/test.mtl +221 -0
  120. data/test/spec_helper.rb +5 -0
  121. data/test/unit/message_spec.rb +56 -0
  122. metadata +209 -0
data/ext/mtl/vbc.h ADDED
@@ -0,0 +1,160 @@
1
+ // VLISP Virtual Machine - 2006 - by Sylvain Huet
2
+ // Lowcost IS Powerfull
3
+
4
+ #ifndef VBC_H_
5
+ # define VBC_H_
6
+
7
+ #define OPexec 0
8
+ #define OPret 1
9
+ #define OPintb 2
10
+ #define OPint 3
11
+ #define OPnil 4
12
+ #define OPdrop 5
13
+ #define OPdup 6
14
+ #define OPgetlocalb 7
15
+ #define OPgetlocal 8
16
+ #define OPadd 9
17
+ #define OPsub 10
18
+ #define OPmul 11
19
+ #define OPdiv 12
20
+ #define OPmod 13
21
+ #define OPand 14
22
+ #define OPor 15
23
+ #define OPeor 16
24
+ #define OPshl 17
25
+ #define OPshr 18
26
+ #define OPneg 19
27
+ #define OPnot 20
28
+ #define OPnon 21
29
+ #define OPeq 22
30
+ #define OPne 23
31
+ #define OPlt 24
32
+ #define OPgt 25
33
+ #define OPle 26
34
+ #define OPge 27
35
+ #define OPgoto 28
36
+ #define OPelse 29
37
+ #define OPmktabb 30
38
+ #define OPmktab 31
39
+ #define OPdeftabb 32
40
+ #define OPdeftab 33
41
+ #define OPfetchb 34
42
+ #define OPfetch 35
43
+ #define OPgetglobalb 36
44
+ #define OPgetglobal 37
45
+ #define OPSecho 38
46
+ #define OPIecho 39
47
+ #define OPsetlocalb 40
48
+ #define OPsetlocal 41
49
+ #define OPsetglobal 42
50
+ #define OPsetstructb 43
51
+ #define OPsetstruct 44
52
+ #define OPhd 45
53
+ #define OPtl 46
54
+ #define OPsetlocal2 47
55
+ #define OPstore 48
56
+ #define OPcall 49
57
+ #define OPcallrb 50
58
+ #define OPcallr 51
59
+ #define OPfirst 52
60
+ #define OPtime_ms 53
61
+ #define OPtabnew 54
62
+ #define OPfixarg 55
63
+ #define OPabs 56
64
+ #define OPmax 57
65
+ #define OPmin 58
66
+ #define OPrand 59
67
+ #define OPsrand 60
68
+ #define OPtime 61
69
+ #define OPstrnew 62
70
+ #define OPstrset 63
71
+ #define OPstrcpy 64
72
+ #define OPvstrcmp 65
73
+ #define OPstrfind 66
74
+ #define OPstrfindrev 67
75
+ #define OPstrlen 68
76
+ #define OPstrget 69
77
+ #define OPstrsub 70
78
+ #define OPstrcat 71
79
+ #define OPtablen 72
80
+ #define OPstrcatlist 73
81
+ #define OPled 74
82
+ #define OPmotorset 75
83
+ #define OPmotorget 76
84
+ #define OPbutton2 77
85
+ #define OPbutton3 78
86
+ #define OPplayStart 79
87
+ #define OPplayFeed 80
88
+ #define OPplayStop 81
89
+ #define OPload 82
90
+ #define OPudpStart 83
91
+ #define OPudpCb 84
92
+ #define OPudpStop 85
93
+ #define OPudpSend 86
94
+ #define OPgc 87
95
+ #define OPtcpOpen 88
96
+ #define OPtcpClose 89
97
+ #define OPtcpSend 90
98
+ #define OPtcpCb 91
99
+ #define OPsave 92
100
+ #define OPbytecode 93
101
+ #define OPloopcb 94
102
+ #define OPIecholn 95
103
+ #define OPSecholn 96
104
+ #define OPtcpListen 97
105
+ #define OPenvget 98
106
+ #define OPenvset 99
107
+ #define OPsndVol 100
108
+ #define OPrfidGet 101
109
+ #define OPplayTime 102
110
+ #define OPnetCb 103
111
+ #define OPnetSend 104
112
+ #define OPnetState 105
113
+ #define OPnetMac 106
114
+ #define OPnetChk 107
115
+ #define OPnetSetmode 108
116
+ #define OPnetScan 109
117
+ #define OPnetAuth 110
118
+ #define OPrecStart 111
119
+ #define OPrecStop 112
120
+ #define OPrecVol 113
121
+ #define OPnetSeqAdd 114
122
+ #define OPstrgetword 115
123
+ #define OPstrputword 116
124
+ #define OPatoi 117
125
+ #define OPhtoi 118
126
+ #define OPitoa 119
127
+ #define OPctoa 120
128
+ #define OPitoh 121
129
+ #define OPctoh 122
130
+ #define OPitobin2 123
131
+ #define OPlistswitch 124
132
+ #define OPlistswitchstr 125
133
+ #define OPsndRefresh 126
134
+ #define OPsndWrite 127
135
+ #define OPsndRead 128
136
+ #define OPsndFeed 129
137
+ #define OPsndAmpli 130
138
+ #define OPcorePP 131
139
+ #define OPcorePush 132
140
+ #define OPcorePull 133
141
+ #define OPcoreBit0 134
142
+ #define OPtcpEnable 135
143
+ #define OPreboot 136
144
+ #define OPstrcmp 137
145
+ #define OPadp2wav 138
146
+ #define OPwav2adp 139
147
+ #define OPalaw2wav 140
148
+ #define OPwav2alaw 141
149
+ #define OPnetPmk 142
150
+ #define OPflashFirmware 143
151
+ #define OPcrypt 144
152
+ #define OPuncrypt 145
153
+ #define OPnetRssi 146
154
+ #define OPrfidGetList 147
155
+ #define OPrfidRead 148
156
+ #define OPrfidWrite 149
157
+ #define OPi2cRead 150
158
+ #define OPi2cWrite 151
159
+
160
+ #endif // ! VBC_H_
data/ext/mtl/vbc_str.h ADDED
@@ -0,0 +1,166 @@
1
+ // VLISP Virtual Machine - 2006 - by Sylvain Huet
2
+ // Lowcost IS Powerfull
3
+
4
+ #ifndef VBC_STR_H_
5
+ # define VBC_STR_H_
6
+
7
+ // cette table ne sert qu'� l'affichage du bytecode dans la console
8
+ #define MaxOpcode 152
9
+ const char* strbytecod[MaxOpcode]=
10
+ {
11
+ "exec",
12
+ "ret",
13
+ "intb",
14
+ "int",
15
+ "nil",
16
+ "drop",
17
+ "dup",
18
+ "getlocalb",
19
+ "getlocal",
20
+ "add",
21
+ "sub",
22
+ "mul",
23
+ "div",
24
+ "mod",
25
+ "and",
26
+ "or",
27
+ "eor",
28
+ "shl",
29
+ "shr",
30
+ "neg",
31
+ "not",
32
+ "non",
33
+ "eq",
34
+ "ne",
35
+ "lt",
36
+ "gt",
37
+ "le",
38
+ "ge",
39
+ "goto",
40
+ "else",
41
+ "mktabb",
42
+ "mktab",
43
+ "deftabb",
44
+ "deftab",
45
+ "fetchb",
46
+ "fetch",
47
+ "getglobalb",
48
+ "getglobal",
49
+ "Secho",
50
+ "Iecho",
51
+ "setlocalb",
52
+ "setlocal",
53
+ "setglobal",
54
+ "setstructb",
55
+ "setstruct",
56
+ "hd",
57
+ "tl",
58
+ "setlocal2",
59
+ "store",
60
+ "call",
61
+ "callrb",
62
+ "callr",
63
+ "first",
64
+ "time_ms",
65
+ "tabnew",
66
+ "fixarg",
67
+ "abs",
68
+ "max",
69
+ "min",
70
+ "rand",
71
+ "srand",
72
+ "time",
73
+ "strnew",
74
+ "strset",
75
+ "strcpy",
76
+ "vstrcmp",
77
+ "strfind",
78
+ "strfindrev",
79
+ "strlen",
80
+ "strget",
81
+ "strsub",
82
+ "strcat",
83
+ "tablen",
84
+ "strcatlist",
85
+ "led",
86
+ "motorset",
87
+ "motorget",
88
+ "button2",
89
+ "button3",
90
+ "playStart",
91
+ "playFeed",
92
+ "playStop",
93
+ "load",
94
+ "udpStart",
95
+ "udpCb",
96
+ "udpStop",
97
+ "udpSend",
98
+ "gc",
99
+ "tcpOpen",
100
+ "tcpClose",
101
+ "tcpSend",
102
+ "tcpCb",
103
+ "save",
104
+ "bytecode",
105
+ "loopcb",
106
+ "Iecholn",
107
+ "Secholn",
108
+ "tcpListen",
109
+ "envget",
110
+ "envset",
111
+ "sndVol",
112
+ "rfidGet",
113
+ "playTime",
114
+ "netCb",
115
+ "netSend",
116
+ "netState",
117
+ "netMac",
118
+ "netChk",
119
+ "netSetmode",
120
+ "netScan",
121
+ "netAuth",
122
+ "recStart",
123
+ "recStop",
124
+ "recVol",
125
+ "netSeqAdd",
126
+ "strgetword",
127
+ "strputword",
128
+ "atoi",
129
+ "htoi",
130
+ "itoa",
131
+ "ctoa",
132
+ "itoh",
133
+ "ctoh",
134
+ "itobin2",
135
+ "listswitch",
136
+ "listswitchstr",
137
+ "sndRefresh",
138
+ "sndWrite",
139
+ "sndRead",
140
+ "sndFeed",
141
+ "sndAmpli",
142
+ "corePP",
143
+ "corePush",
144
+ "corePull",
145
+ "coreBit0",
146
+ "tcpEnable",
147
+ "reboot",
148
+ "strcmp",
149
+ "adp2wav",
150
+ "wav2adp",
151
+ "alaw2wav",
152
+ "wav2alaw",
153
+ "netPmk",
154
+ "flashFirmware",
155
+ "crypt",
156
+ "uncrypt",
157
+ "netRssi",
158
+ "rfidGetList",
159
+ "rfidRead",
160
+ "rfidWrite",
161
+ "i2cRead",
162
+ "i2cWrite"
163
+ };
164
+
165
+ #endif // ! VBC_STR_H_
166
+
@@ -0,0 +1,29 @@
1
+ OBJS = \
2
+ bootstrap.o \
3
+ compiler_file.o \
4
+ compiler.o \
5
+ compiler_prog.o \
6
+ compiler_term.o \
7
+ compiler_type.o \
8
+ compiler_var.o \
9
+ file.o \
10
+ interpreter.o \
11
+ memory.o \
12
+ parser.o \
13
+ parser_xml.o \
14
+ prodbuffer.o \
15
+ stdlib_core.o \
16
+ terminal.o \
17
+ util.o
18
+
19
+ libvcomp.a : $(OBJS)
20
+ ar rcs $@ $(OBJS)
21
+ ranlib $@
22
+
23
+ # %.o : %.cpp
24
+ # g++ -c $^ -o $@
25
+
26
+ CPPFLAGS=-fpermissive
27
+
28
+ clean :
29
+ rm -f $(OBJS)
@@ -0,0 +1,89 @@
1
+ //-------------------
2
+ // MV
3
+ // version WIN32 et POCKETPC
4
+ // Sylvain Huet
5
+ // Derniere mise a jour : 07/01/2003
6
+ //
7
+
8
+
9
+ //#include <windows.h>
10
+ //#include <windowsx.h>
11
+ //#include <wingdi.h>
12
+ //#include <commctrl.h>
13
+ //#include <commdlg.h>
14
+ //#include <string.h>
15
+ #include "param.h"
16
+
17
+ #include <stdio.h>
18
+
19
+ #include "param.h"
20
+ #include "prodbuffer.h"
21
+ #include "filesystem.h"
22
+ #include "file.h"
23
+ #include "terminal.h"
24
+
25
+ #include "memory.h"
26
+ #include "util.h"
27
+ #include "parser.h"
28
+ #include "compiler.h"
29
+ #include "interpreter.h"
30
+
31
+
32
+
33
+ void AbortMetal(Memory* m,int donotstop)
34
+ {
35
+ if (m->abort) return;
36
+ PRINTF(m)(LOG_RUNTIME,"\n---------- end of execution\n");
37
+ m->stop();
38
+ }
39
+
40
+
41
+
42
+ int StartMetal(const char *starter, const char* output, bool inSign)
43
+ {
44
+ int k;
45
+
46
+ // passe dans le r�pertoire de l'executable, en retenant le r�pertoire courant
47
+
48
+ Terminal* t=new Terminal();
49
+ Memory* m=new Memory(32*1024,t,NULL);
50
+ t->m=m;
51
+
52
+ if (k=m->start())
53
+ {
54
+ t->printf(LOG_RUNTIME,"Launcher : erreur d'initialisation Memory\n");
55
+ return -1;
56
+ }
57
+ STRPUSH(m, (char*) starter);
58
+ if (!(k=m->util->compiler->gocompile(COMPILE_FROMFILE)))
59
+ {
60
+ t->printf(LOG_RUNTIME,"\nCompiler : done !\n");
61
+ File* f=new File(NULL);
62
+ f->openwrite(output);
63
+ if (inSign) {
64
+ f->write("amber", 5);
65
+ char sizeStr[9];
66
+ sprintf(sizeStr, "%.8x", m->util->compiler->brelease->getsize());
67
+ f->write(sizeStr, 8);
68
+ }
69
+ f->write(m->util->compiler->brelease->getstart(),m->util->compiler->brelease->getsize());
70
+ if (inSign) {
71
+ f->write("Mind", 4);
72
+ }
73
+ f->close();
74
+ return 0;
75
+ }
76
+ else
77
+ {
78
+ t->printf(LOG_RUNTIME,"Launcher : %s\n\n",m->errorname(k));
79
+ return -1;
80
+ }
81
+ }
82
+
83
+
84
+ int vcompDoit(char *starter)
85
+ {
86
+ int k=StartMetal(starter, "foo.bin", false);
87
+ getchar();
88
+ return k;
89
+ }