ranger-compiler 3.0.4 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/dist/Lang.rgr +158 -9
- package/dist/lib/JSON.rgr +31 -4
- package/dist/lib/RangerProcess.rgr +273 -0
- package/dist/lib/stdlib.rgr +33 -3
- package/dist/package.json +1 -1
- package/dist/rgrc.js +1129 -37
- package/package.json +2 -2
- package/dist/lib/lib/ACEEditor.rgr +0 -5
- package/dist/lib/lib/Ajax.rgr +0 -196
- package/dist/lib/lib/CmdParams.rgr +0 -72
- package/dist/lib/lib/Crypto.rgr +0 -90
- package/dist/lib/lib/DOMLib.rgr +0 -307
- package/dist/lib/lib/Engine3D.rgr +0 -870
- package/dist/lib/lib/ImmutableVector.rgr +0 -364
- package/dist/lib/lib/IndexedDB.rgr +0 -32
- package/dist/lib/lib/JSON.rgr +0 -702
- package/dist/lib/lib/JinxProcess.rgr +0 -838
- package/dist/lib/lib/SQL.rgr +0 -44
- package/dist/lib/lib/ServiceLib.rgr +0 -9
- package/dist/lib/lib/Storage.rgr +0 -89
- package/dist/lib/lib/Time.rgr +0 -75
- package/dist/lib/lib/Timers.rgr +0 -176
- package/dist/lib/lib/TypedArrays.rgr +0 -14
- package/dist/lib/lib/ViewLib.rgr +0 -851
- package/dist/lib/lib/WebLib.rgr +0 -47
- package/dist/lib/lib/WebServerLib.rgr +0 -137
- package/dist/lib/lib/ranger-dir.rgr +0 -175
- package/dist/lib/lib/stdlib.rgr +0 -665
- package/dist/lib/lib/stdops.rgr +0 -168
package/dist/lib/lib/WebLib.rgr
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
systemclass View {
|
|
2
|
-
java7 View
|
|
3
|
-
es6 View
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
systemclass Button {
|
|
7
|
-
java7 Button
|
|
8
|
-
es6 HTMLElement
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
operators {
|
|
12
|
-
setTextNotUsed _:void (btn:Button txt:string) {
|
|
13
|
-
templates {
|
|
14
|
-
ranger ( "(setText " (e 1) " " (e 2) " )" )
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
operator type:void es6 {
|
|
22
|
-
|
|
23
|
-
fn findView:View (name:string) (
|
|
24
|
-
"view.querySelectorAll('[x-id=" (str 1) "]')[0]"
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
fn setText (btn:Button txt:string) ( (e 1) ".textContent = " (e 2) "; // ?? " )
|
|
28
|
-
|
|
29
|
-
; ev:(_:void (view:View))
|
|
30
|
-
fn onClick:void (view:View ev:block) (
|
|
31
|
-
(e 1) ".addEventListener('click', () => {" nl
|
|
32
|
-
I (block 2) nl i
|
|
33
|
-
"});" nl
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
fn loadFragment:void ( pageName:string into:string ) (
|
|
37
|
-
"() => {" nl
|
|
38
|
-
I "var replaced = view.querySelectorAll('[x-id=" (str 2) "]')[0];" nl
|
|
39
|
-
"var newChild = document.querySelectorAll('[x-id=" (str 1) "]')[0];" nl
|
|
40
|
-
"replaced.parentNode.replaceChild(newChild, replaced);" nl
|
|
41
|
-
i "}();" nl
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
operator type:void ranger {
|
|
46
|
-
fn setText (btn:Button txt:string) ( "(setText " (e 1) " " (e 2) " )" )
|
|
47
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
; Plan:
|
|
3
|
-
; to support: Go, PHP, Node.js
|
|
4
|
-
|
|
5
|
-
; maybe could be using Scalatra
|
|
6
|
-
; http://scalatra.org/guides/2.5/http/routes.html
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class DefinedHTTPServer {
|
|
10
|
-
def port:int 80
|
|
11
|
-
constructor ( p:int ) {
|
|
12
|
-
this.port = p
|
|
13
|
-
}
|
|
14
|
-
fn golangPortStr:string () {
|
|
15
|
-
return (":" + port)
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
systemclass WebServer {
|
|
20
|
-
es6 Object
|
|
21
|
-
go "*DefinedHTTPServer"
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
systemclass WebRequest {
|
|
25
|
-
es6 Object
|
|
26
|
-
go "*http.Request"
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
systemclass WebResponse {
|
|
30
|
-
es6 Object
|
|
31
|
-
go "http.ResponseWriter"
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
operators {
|
|
36
|
-
create_web_server _:WebServer ( port:int ) {
|
|
37
|
-
templates {
|
|
38
|
-
go ( "CreateNew_DefinedHTTPServer(" (e 1) ")"
|
|
39
|
-
(imp "net/http")
|
|
40
|
-
(imp "fmt")
|
|
41
|
-
)
|
|
42
|
-
ranger ("(create_web_server " (e 1) ")")
|
|
43
|
-
es6 ("(require('express'))()")
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
prepare_server _:void ( s:WebServer ) {
|
|
47
|
-
templates {
|
|
48
|
-
ranger ("(prepare_server " (e 1) ")")
|
|
49
|
-
es6 (
|
|
50
|
-
(e 1) ".use(function(req, res, next){" nl I
|
|
51
|
-
"var data = '';" nl
|
|
52
|
-
"req.on('data', function(chunk){ " nl I
|
|
53
|
-
"data += chunk;" nl i
|
|
54
|
-
"});" nl
|
|
55
|
-
"req.on('end', function(){"nl I
|
|
56
|
-
"req.rawBody = data;" nl
|
|
57
|
-
"next();" nl i
|
|
58
|
-
"})" nl i
|
|
59
|
-
"});" nl
|
|
60
|
-
|
|
61
|
-
)
|
|
62
|
-
go ()
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
operator class:WebRequest es6 {
|
|
69
|
-
fn get_post_data:string () ( (e 1) ".rawBody" )
|
|
70
|
-
fn getVar:string ( varName:string ) ( (e 1) ".query[" (e 2) "] ? " (e 1) ".query[" (e 2) "] : \"\" ")
|
|
71
|
-
}
|
|
72
|
-
operator class:WebResponse es6 {
|
|
73
|
-
fn contentType ( typeName:string) (
|
|
74
|
-
(e 1) ".writeHead(200, {'Content-Type': " (e 2) "});"
|
|
75
|
-
)
|
|
76
|
-
fn plaintext () ( (e 1) ".writeHead(200, {'Content-Type': 'text/plain'});")
|
|
77
|
-
fn send (value:string) ( (e 1) ".send(" (e 2) ")")
|
|
78
|
-
fn sendFile (value:string) ( (e 1) ".sendFile(" (e 2) ")")
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
operator class:WebServer es6 {
|
|
82
|
-
fn startServer ( post:int code:block) ( (e 1) ".listen(" (e 2) ", () => {" nl I (e 3) i nl "})" )
|
|
83
|
-
fn route ( path:string cb:(_:void (req:WebRequest res:WebResponse))) ( (e 1) ".get(" (e 2) ", " nl I (e 3) i nl ")" )
|
|
84
|
-
fn post_route ( path:string cb:(_:void (req:WebRequest res:WebResponse))) ( (e 1) ".post(" (e 2) ", " nl I (e 3) i nl ")" )
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
; http.HandleFunc("/", handler)
|
|
88
|
-
; body, err := ioutil.ReadAll(r.Body)
|
|
89
|
-
|
|
90
|
-
operators {
|
|
91
|
-
getVar _:string ( varName:string ) {
|
|
92
|
-
templates {
|
|
93
|
-
go ('req.URL.Query().Get(' (e 1) ')')
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
get_post_data _:string ( req:WebRequest) {
|
|
97
|
-
templates {
|
|
98
|
-
go ( "_req_to_string(" (e 1) ")"
|
|
99
|
-
(imp "io/ioutil")
|
|
100
|
-
(create_polyfill "
|
|
101
|
-
func _req_to_string (r *http.Request) string {
|
|
102
|
-
body, err := ioutil.ReadAll(r.Body)
|
|
103
|
-
if err != nil {
|
|
104
|
-
return \"\"
|
|
105
|
-
}
|
|
106
|
-
return string(body)
|
|
107
|
-
}
|
|
108
|
-
")
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
; class:WebRequest go {
|
|
113
|
-
; fn get_post_data:string ()
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
operator class:WebServer go {
|
|
117
|
-
fn startServer ( port:int code:block) ( "http.ListenAndServe( " (e 1) ".golangPortStr(), nil)" )
|
|
118
|
-
fn route ( path:string cb:(_:void ( res:WebResponse req:WebRequest))) ( "http.HandleFunc(" (e 2) ", " (e 3) ")" )
|
|
119
|
-
fn post_route ( path:string cb:(_:void ( res:WebResponse req:WebRequest))) ( "http.HandleFunc(" (e 2) ", " (e 3) ")" )
|
|
120
|
-
}
|
|
121
|
-
; http.ServeFile(w, r, "file")
|
|
122
|
-
operator class:WebResponse go {
|
|
123
|
-
fn contentType ( typeName:string) (
|
|
124
|
-
(e 1 ) ".Header().Add(\"Content-Type\", " (e 2) ")"
|
|
125
|
-
)
|
|
126
|
-
fn send (value:string) ( "fmt.Fprint( " (e 1) ", " (e 2) ")")
|
|
127
|
-
fn sendFile (value:string) ( "http.ServeFile(" (e 1) ", req, " (e 2) ")")
|
|
128
|
-
}
|
|
129
|
-
operator class:WebRequest go {
|
|
130
|
-
; fn get_post_data:string () ( (e 1) ".rawBody" )
|
|
131
|
-
fn getVar:string ( varName:string ) ( (e 1) ".URL.Query().Get(" (e 2) ")")
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
systemclass UIElement {
|
|
3
|
-
es6 DOMElement
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
systemclass SystemDate {
|
|
7
|
-
es6 Date
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
systemclass SystemUnixDate {
|
|
11
|
-
es6 Number
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
operators {
|
|
15
|
-
watch_has_file cmdFiles:boolean () {
|
|
16
|
-
templates {
|
|
17
|
-
es6 ( " typeof(_fileName) != 'undefined' " )
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
; statSync
|
|
21
|
-
|
|
22
|
-
to_date _:SystemDate ( timevalue:int ) {
|
|
23
|
-
templates {
|
|
24
|
-
es6 ( "(new Date(" (e 1) "))" )
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
remove_file _:void (path:string name:string) {
|
|
29
|
-
templates {
|
|
30
|
-
ranger ('(remove_file ' (e 1)' ' (e 2) ' )')
|
|
31
|
-
es6 ('(require("fs")).unlinkSync(' (e 1) ' + "/" + ' (e 2) ')')
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
utc_to_string _:string ( sd:int ) {
|
|
36
|
-
templates {
|
|
37
|
-
es6 ( "(new Date(" (e 1) ")).toString()" )
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
file_created _:int ( path:string) {
|
|
42
|
-
templates {
|
|
43
|
-
es6 ( "(new Date((require('fs')).statSync(" (e 1) ").birthtime)).getTime()" )
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
file_modtime _:int ( path:string) {
|
|
48
|
-
templates {
|
|
49
|
-
es6 ( "(new Date((require('fs')).statSync(" (e 1) ").mtime)).getTime()" )
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
file_modtime_str _:int ( path:string) {
|
|
54
|
-
templates {
|
|
55
|
-
es6 ( "(new Date((require('fs')).statSync(" (e 1) ").mtime)).toString()" )
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
watch_filename cmdFiles:string () {
|
|
60
|
-
templates {
|
|
61
|
-
es6 ( "_fileName" )
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
watch_dir cmdFiles:void (path:string code:block) {
|
|
65
|
-
templates {
|
|
66
|
-
es6 ( "require('fs').watch(" (e 1) ", (_eventType, _fileName) => { " nl I (block 2) i nl " })" )
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
cs_list_dir_files cmdFiles:[string] (path:string) {
|
|
71
|
-
templates {
|
|
72
|
-
csharp( "new List<String>(Directory.GetFiles(" (e 1) "))" (imp "System") (imp "System.IO") (imp "System.Collections.Generic"))
|
|
73
|
-
}¨
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
; Path.GetFileName
|
|
78
|
-
list_dir_files cmdFiles:[string] (path:string) {
|
|
79
|
-
templates {
|
|
80
|
-
ranger ( '(list_dir_files (' (e 1) '))')
|
|
81
|
-
go ( 'r_io_list_directory(' (e 1) ')'
|
|
82
|
-
|
|
83
|
-
(create_polyfill `
|
|
84
|
-
|
|
85
|
-
func r_io_list_directory( path string ) []string {
|
|
86
|
-
res := make([]string, 0)
|
|
87
|
-
files, err := ioutil.ReadDir("./")
|
|
88
|
-
if err != nil {
|
|
89
|
-
return res
|
|
90
|
-
}
|
|
91
|
-
for _, f := range files {
|
|
92
|
-
res = append(res, f.Name())
|
|
93
|
-
}
|
|
94
|
-
return res
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
`)
|
|
98
|
-
|
|
99
|
-
)
|
|
100
|
-
csharp ("DirListReader.getFiles(" (e 1) ")"
|
|
101
|
-
|
|
102
|
-
(create_polyfill
|
|
103
|
-
"
|
|
104
|
-
class DirListReader {
|
|
105
|
-
public static List<String> getFiles( String path ) {
|
|
106
|
-
string[] names = Directory.GetFiles(path);
|
|
107
|
-
string[] basenames = new string[names.Length];
|
|
108
|
-
for(int i=0; i<names.Length; i++) {
|
|
109
|
-
basenames[i] = Path.GetFileName(names[i]);
|
|
110
|
-
}
|
|
111
|
-
return (new List<String>(basenames));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
"
|
|
115
|
-
) )
|
|
116
|
-
es6 ( "require('fs').readdirSync(" (e 1) ")" )
|
|
117
|
-
cpp ( "__cpp_list_directory_files(" (e 1) ")"
|
|
118
|
-
(create_polyfill
|
|
119
|
-
"
|
|
120
|
-
|
|
121
|
-
#ifdef _MSC_VER
|
|
122
|
-
#include <windows.h>
|
|
123
|
-
#else
|
|
124
|
-
#endif
|
|
125
|
-
|
|
126
|
-
std::vector<std::string> __cpp_list_directory_files(std::string dirName) {
|
|
127
|
-
WIN32_FIND_DATA data;
|
|
128
|
-
std::vector<std::string> fileList;
|
|
129
|
-
std::string query = (dirName + \"\\\\*\");
|
|
130
|
-
HANDLE hFind = FindFirstFile(query.c_str(), &data); // DIRECTORY
|
|
131
|
-
|
|
132
|
-
if ( hFind != INVALID_HANDLE_VALUE ) {
|
|
133
|
-
do {
|
|
134
|
-
std::string name(data.cFileName);
|
|
135
|
-
fileList.push_back( name );
|
|
136
|
-
} while (FindNextFile(hFind, &data));
|
|
137
|
-
FindClose(hFind);
|
|
138
|
-
}
|
|
139
|
-
return fileList;
|
|
140
|
-
}
|
|
141
|
-
"
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
)
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
is_directory cmdFiles:boolean (path:string) {
|
|
148
|
-
templates {
|
|
149
|
-
es6 ( "require('fs').statSync(" (e 1) ").isDirectory()" )
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
is_file cmdFiles:boolean (path:string) {
|
|
153
|
-
templates {
|
|
154
|
-
es6 ( "require('fs').statSync(" (e 1) ").isFile()" )
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
class testFilesystem {
|
|
160
|
-
fn test_case:void () {
|
|
161
|
-
print "Directory testing ready"
|
|
162
|
-
def list:[string] (list_dir_files ".")
|
|
163
|
-
for list name:string i {
|
|
164
|
-
if( ( indexOf name ".js" ) > 0 ) {
|
|
165
|
-
print name
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
; watch interface...
|
|
169
|
-
watch_dir "." {
|
|
170
|
-
if( watch_has_file) {
|
|
171
|
-
print "... something changed with " + (watch_filename)
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|