functionalscript 0.0.442 → 0.0.444

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.
@@ -25,4 +25,4 @@ jobs:
25
25
  with:
26
26
  node-version: 19
27
27
  - run: npm ci
28
- - run: node ./com/test/build.cjs
28
+ - run: npm run comtest
@@ -1,11 +1,7 @@
1
- const _ = require('./module.f.cjs')
2
- const library = require('../types/testlib.f.cjs')
3
- const text = require('../../text/module.f.cjs')
4
- const { join } = require('../../types/module.f.cjs').string
1
+ const cpp = require('./testlib.f.cjs')
5
2
 
6
3
  const f = () =>
7
4
  {
8
- const r = join('\n')(text.flat(' ')(_.cpp('My')(library)))
9
5
  const e =
10
6
  '#pragma once\n' +
11
7
  '\n' +
@@ -34,11 +30,7 @@ const f = () =>
34
30
  ' virtual void COM_STDCALL SetManagedStruct(ManagedStruct a) = 0;\n' +
35
31
  ' };\n' +
36
32
  '}'
37
- if (r !== e) { throw r }
38
- return r
33
+ if (cpp !== e) { throw cpp }
39
34
  }
40
35
 
41
- module.exports = {
42
- /** @readonly */
43
- result: f()
44
- }
36
+ module.exports = f
@@ -0,0 +1,6 @@
1
+ const { join } = require("../../types/string/module.f.cjs");
2
+ const { flat } = require("../../text/module.f.cjs")
3
+ const library = require('../types/testlib.f.cjs')
4
+ const { cpp } = require('./module.f.cjs')
5
+
6
+ module.exports = join('\n')(flat(' ')(cpp('My')(library)))
package/com/cs/test.f.cjs CHANGED
@@ -1,11 +1,7 @@
1
- const _ = require('./module.f.cjs')
2
- const text = require('../../text/module.f.cjs')
3
- const library = require('../types/testlib.f.cjs')
4
- const { join } = require('../../types/string/module.f.cjs')
1
+ const cs = require('./testlib.f.cjs')
5
2
 
6
3
  const f = () =>
7
4
  {
8
- const cs = join('\n')(text.flat(' ')(_.cs('My')(library)))
9
5
  const e =
10
6
  'using System;\n' +
11
7
  'using System.Runtime.InteropServices;\n' +
@@ -44,12 +40,6 @@ const f = () =>
44
40
  ' }\n' +
45
41
  '}'
46
42
  if (cs !== e) { throw cs }
47
- return cs
48
43
  }
49
44
 
50
- const result = f()
51
-
52
- module.exports = {
53
- /** @readonly */
54
- result,
55
- }
45
+ module.exports = f
@@ -0,0 +1,6 @@
1
+ const { flat } = require('../../text/module.f.cjs');
2
+ const { join } = require('../../types/string/module.f.cjs');
3
+ const { cs } = require('./module.f.cjs');
4
+ const library = require('../types/testlib.f.cjs')
5
+
6
+ module.exports = join('\n')(flat(' ')(cs('My')(library)))
@@ -230,8 +230,12 @@ const rust = library => {
230
230
  traitImpl({
231
231
  pub: true,
232
232
  type: 'ClassEx',
233
- content: [`const INTERFACE: Interface = Interface {`,
234
- mapAssign(e),
233
+ content: ['const VMT: Vmt = Vmt {',
234
+ [ 'iunknown: Self::IUNKNOWN,',
235
+ 'interface: Interface {',
236
+ mapAssign(e),
237
+ '},',
238
+ ],
235
239
  '};'
236
240
  ]
237
241
  }),
@@ -36,9 +36,12 @@ mod library {
36
36
  where
37
37
  nanocom::CObject<Self>: Ex,
38
38
  {
39
- const INTERFACE: Interface = Interface {
40
- A: Self::A,
41
- B: Self::B,
39
+ const VMT: Vmt = Vmt {
40
+ iunknown: Self::IUNKNOWN,
41
+ interface: Interface {
42
+ A: Self::A,
43
+ B: Self::B,
44
+ }
42
45
  };
43
46
  }
44
47
 
@@ -73,10 +76,7 @@ mod number {
73
76
  impl nanocom::Class for X {
74
77
  type Interface = IMy::Interface;
75
78
  fn static_vmt() -> &'static Vmt<Self::Interface> {
76
- static V: IMy::Vmt = Vmt {
77
- iunknown: X::IUNKNOWN,
78
- interface: X::INTERFACE,
79
- };
79
+ static V: IMy::Vmt = X::VMT;
80
80
  &V
81
81
  }
82
82
  }
@@ -142,10 +142,7 @@ mod destructor {
142
142
  impl nanocom::Class for X {
143
143
  type Interface = IMy::Interface;
144
144
  fn static_vmt() -> &'static Vmt<Self::Interface> {
145
- static V: IMy::Vmt = Vmt {
146
- iunknown: X::IUNKNOWN,
147
- interface: X::INTERFACE,
148
- };
145
+ static V: IMy::Vmt = X::VMT;
149
146
  &V
150
147
  }
151
148
  }
@@ -1,127 +1,123 @@
1
- const { rust } = require('./module.f.cjs')
2
- const { flat } = require('../../text/module.f.cjs')
3
- const { join } = require('../../types/string/module.f.cjs')
4
- const library = require('../types/testlib.f.cjs')
1
+ const rust = require('./testlib.f.cjs')
5
2
 
6
- module.exports = {
7
- result: () => {
8
- const e =
9
- '#![allow(non_snake_case)]\n' +
10
- '#[repr(C)]\n' +
11
- 'pub struct Slice {\n' +
12
- ' pub Start: *const u8,\n' +
13
- ' pub Size: usize,\n' +
14
- '}\n' +
15
- '#[repr(C)]\n' +
16
- 'pub struct ManagedStruct {\n' +
17
- ' pub M: IMy::Ref,\n' +
18
- '}\n' +
19
- 'pub mod IMy {\n' +
20
- ' pub type Object = nanocom::Object<Interface>;\n' +
21
- ' pub type Ref = nanocom::Ref<Interface>;\n' +
22
- ' pub type Vmt = nanocom::Vmt<Interface>;\n' +
23
- ' #[repr(C)]\n' +
24
- ' pub struct Interface {\n' +
25
- ' pub GetSlice: unsafe extern "system" fn(this: &Object) -> super::Slice,\n' +
26
- ' pub SetSlice: unsafe extern "system" fn(this: &Object, slice: super::Slice),\n' +
27
- ' pub GetUnsafe: unsafe extern "system" fn(this: &Object) -> *const bool,\n' +
28
- ' pub SetUnsafe: unsafe extern "system" fn(this: &Object, p: *const super::Slice, size: u32),\n' +
29
- ' pub Some: unsafe extern "system" fn(this: &Object, p: &super::IMy::Object) -> bool,\n' +
30
- ' pub GetIMy: unsafe extern "system" fn(this: &Object) -> super::IMy::Ref,\n' +
31
- ' pub SetManagedStruct: unsafe extern "system" fn(this: &Object, a: super::ManagedStruct),\n' +
32
- ' }\n' +
33
- ' impl nanocom::Interface for Interface {\n' +
34
- ' const GUID: nanocom::GUID = 0xC66FB270_2D80_49AD_BB6E_88C1F90B805D;\n' +
35
- ' }\n' +
36
- ' pub trait Ex {\n' +
37
- ' fn GetSlice(&self) -> super::Slice;\n' +
38
- ' fn SetSlice(&self, slice: super::Slice);\n' +
39
- ' fn GetUnsafe(&self) -> *const bool;\n' +
40
- ' fn SetUnsafe(&self, p: *const super::Slice, size: u32);\n' +
41
- ' fn Some(&self, p: &super::IMy::Object) -> bool;\n' +
42
- ' fn GetIMy(&self) -> super::IMy::Ref;\n' +
43
- ' fn SetManagedStruct(&self, a: super::ManagedStruct);\n' +
44
- ' }\n' +
45
- ' impl Ex for Object {\n' +
46
- ' fn GetSlice(&self) -> super::Slice {\n' +
47
- ' unsafe { (self.interface().GetSlice)(self) }\n' +
48
- ' }\n' +
49
- ' fn SetSlice(&self, slice: super::Slice) {\n' +
50
- ' unsafe { (self.interface().SetSlice)(self, slice) }\n' +
51
- ' }\n' +
52
- ' fn GetUnsafe(&self) -> *const bool {\n' +
53
- ' unsafe { (self.interface().GetUnsafe)(self) }\n' +
54
- ' }\n' +
55
- ' fn SetUnsafe(&self, p: *const super::Slice, size: u32) {\n' +
56
- ' unsafe { (self.interface().SetUnsafe)(self, p, size) }\n' +
57
- ' }\n' +
58
- ' fn Some(&self, p: &super::IMy::Object) -> bool {\n' +
59
- ' unsafe { (self.interface().Some)(self, p) }\n' +
60
- ' }\n' +
61
- ' fn GetIMy(&self) -> super::IMy::Ref {\n' +
62
- ' unsafe { (self.interface().GetIMy)(self) }\n' +
63
- ' }\n' +
64
- ' fn SetManagedStruct(&self, a: super::ManagedStruct) {\n' +
65
- ' unsafe { (self.interface().SetManagedStruct)(self, a) }\n' +
66
- ' }\n' +
67
- ' }\n' +
68
- ' pub trait ClassEx\n' +
69
- ' where\n' +
70
- ' Self: nanocom::Class<Interface = Interface>,\n' +
71
- ' nanocom::CObject<Self>: Ex,\n' +
72
- ' {\n' +
73
- ' const INTERFACE: Interface = Interface {\n' +
74
- ' GetSlice: Self::GetSlice,\n' +
75
- ' SetSlice: Self::SetSlice,\n' +
76
- ' GetUnsafe: Self::GetUnsafe,\n' +
77
- ' SetUnsafe: Self::SetUnsafe,\n' +
78
- ' Some: Self::Some,\n' +
79
- ' GetIMy: Self::GetIMy,\n' +
80
- ' SetManagedStruct: Self::SetManagedStruct,\n' +
81
- ' };\n' +
82
- ' }\n' +
83
- ' impl<T> ClassEx for T\n' +
84
- ' where\n' +
85
- ' Self: nanocom::Class<Interface = Interface>,\n' +
86
- ' nanocom::CObject<Self>: Ex,\n' +
87
- ' {\n' +
88
- ' }\n' +
89
- ' trait PrivateClassEx\n' +
90
- ' where\n' +
91
- ' Self: nanocom::Class<Interface = Interface>,\n' +
92
- ' nanocom::CObject<Self>: Ex,\n' +
93
- ' {\n' +
94
- ' extern "system" fn GetSlice(this: &Object) -> super::Slice {\n' +
95
- ' unsafe { Self::to_cobject(this) }.GetSlice()\n' +
96
- ' }\n' +
97
- ' extern "system" fn SetSlice(this: &Object, slice: super::Slice) {\n' +
98
- ' unsafe { Self::to_cobject(this) }.SetSlice(slice)\n' +
99
- ' }\n' +
100
- ' extern "system" fn GetUnsafe(this: &Object) -> *const bool {\n' +
101
- ' unsafe { Self::to_cobject(this) }.GetUnsafe()\n' +
102
- ' }\n' +
103
- ' extern "system" fn SetUnsafe(this: &Object, p: *const super::Slice, size: u32) {\n' +
104
- ' unsafe { Self::to_cobject(this) }.SetUnsafe(p, size)\n' +
105
- ' }\n' +
106
- ' extern "system" fn Some(this: &Object, p: &super::IMy::Object) -> bool {\n' +
107
- ' unsafe { Self::to_cobject(this) }.Some(p)\n' +
108
- ' }\n' +
109
- ' extern "system" fn GetIMy(this: &Object) -> super::IMy::Ref {\n' +
110
- ' unsafe { Self::to_cobject(this) }.GetIMy()\n' +
111
- ' }\n' +
112
- ' extern "system" fn SetManagedStruct(this: &Object, a: super::ManagedStruct) {\n' +
113
- ' unsafe { Self::to_cobject(this) }.SetManagedStruct(a)\n' +
114
- ' }\n' +
115
- ' }\n' +
116
- ' impl<T> PrivateClassEx for T\n' +
117
- ' where\n' +
118
- ' Self: nanocom::Class<Interface = Interface>,\n' +
119
- ' nanocom::CObject<Self>: Ex,\n' +
120
- ' {\n' +
121
- ' }\n' +
122
- '}'
123
- const r = join('\n')(flat(' ')(rust(library)))
124
- if (r !== e) { throw r }
125
- return r
126
- }
127
- }
3
+ module.exports = () => {
4
+ const e =
5
+ '#![allow(non_snake_case)]\n' +
6
+ '#[repr(C)]\n' +
7
+ 'pub struct Slice {\n' +
8
+ ' pub Start: *const u8,\n' +
9
+ ' pub Size: usize,\n' +
10
+ '}\n' +
11
+ '#[repr(C)]\n' +
12
+ 'pub struct ManagedStruct {\n' +
13
+ ' pub M: IMy::Ref,\n' +
14
+ '}\n' +
15
+ 'pub mod IMy {\n' +
16
+ ' pub type Object = nanocom::Object<Interface>;\n' +
17
+ ' pub type Ref = nanocom::Ref<Interface>;\n' +
18
+ ' pub type Vmt = nanocom::Vmt<Interface>;\n' +
19
+ ' #[repr(C)]\n' +
20
+ ' pub struct Interface {\n' +
21
+ ' pub GetSlice: unsafe extern "system" fn(this: &Object) -> super::Slice,\n' +
22
+ ' pub SetSlice: unsafe extern "system" fn(this: &Object, slice: super::Slice),\n' +
23
+ ' pub GetUnsafe: unsafe extern "system" fn(this: &Object) -> *const bool,\n' +
24
+ ' pub SetUnsafe: unsafe extern "system" fn(this: &Object, p: *const super::Slice, size: u32),\n' +
25
+ ' pub Some: unsafe extern "system" fn(this: &Object, p: &super::IMy::Object) -> bool,\n' +
26
+ ' pub GetIMy: unsafe extern "system" fn(this: &Object) -> super::IMy::Ref,\n' +
27
+ ' pub SetManagedStruct: unsafe extern "system" fn(this: &Object, a: super::ManagedStruct),\n' +
28
+ ' }\n' +
29
+ ' impl nanocom::Interface for Interface {\n' +
30
+ ' const GUID: nanocom::GUID = 0xC66FB270_2D80_49AD_BB6E_88C1F90B805D;\n' +
31
+ ' }\n' +
32
+ ' pub trait Ex {\n' +
33
+ ' fn GetSlice(&self) -> super::Slice;\n' +
34
+ ' fn SetSlice(&self, slice: super::Slice);\n' +
35
+ ' fn GetUnsafe(&self) -> *const bool;\n' +
36
+ ' fn SetUnsafe(&self, p: *const super::Slice, size: u32);\n' +
37
+ ' fn Some(&self, p: &super::IMy::Object) -> bool;\n' +
38
+ ' fn GetIMy(&self) -> super::IMy::Ref;\n' +
39
+ ' fn SetManagedStruct(&self, a: super::ManagedStruct);\n' +
40
+ ' }\n' +
41
+ ' impl Ex for Object {\n' +
42
+ ' fn GetSlice(&self) -> super::Slice {\n' +
43
+ ' unsafe { (self.interface().GetSlice)(self) }\n' +
44
+ ' }\n' +
45
+ ' fn SetSlice(&self, slice: super::Slice) {\n' +
46
+ ' unsafe { (self.interface().SetSlice)(self, slice) }\n' +
47
+ ' }\n' +
48
+ ' fn GetUnsafe(&self) -> *const bool {\n' +
49
+ ' unsafe { (self.interface().GetUnsafe)(self) }\n' +
50
+ ' }\n' +
51
+ ' fn SetUnsafe(&self, p: *const super::Slice, size: u32) {\n' +
52
+ ' unsafe { (self.interface().SetUnsafe)(self, p, size) }\n' +
53
+ ' }\n' +
54
+ ' fn Some(&self, p: &super::IMy::Object) -> bool {\n' +
55
+ ' unsafe { (self.interface().Some)(self, p) }\n' +
56
+ ' }\n' +
57
+ ' fn GetIMy(&self) -> super::IMy::Ref {\n' +
58
+ ' unsafe { (self.interface().GetIMy)(self) }\n' +
59
+ ' }\n' +
60
+ ' fn SetManagedStruct(&self, a: super::ManagedStruct) {\n' +
61
+ ' unsafe { (self.interface().SetManagedStruct)(self, a) }\n' +
62
+ ' }\n' +
63
+ ' }\n' +
64
+ ' pub trait ClassEx\n' +
65
+ ' where\n' +
66
+ ' Self: nanocom::Class<Interface = Interface>,\n' +
67
+ ' nanocom::CObject<Self>: Ex,\n' +
68
+ ' {\n' +
69
+ ' const VMT: Vmt = Vmt {\n' +
70
+ ' iunknown: Self::IUNKNOWN,\n' +
71
+ ' interface: Interface {\n' +
72
+ ' GetSlice: Self::GetSlice,\n' +
73
+ ' SetSlice: Self::SetSlice,\n' +
74
+ ' GetUnsafe: Self::GetUnsafe,\n' +
75
+ ' SetUnsafe: Self::SetUnsafe,\n' +
76
+ ' Some: Self::Some,\n' +
77
+ ' GetIMy: Self::GetIMy,\n' +
78
+ ' SetManagedStruct: Self::SetManagedStruct,\n' +
79
+ ' },\n' +
80
+ ' };\n' +
81
+ ' }\n' +
82
+ ' impl<T> ClassEx for T\n' +
83
+ ' where\n' +
84
+ ' Self: nanocom::Class<Interface = Interface>,\n' +
85
+ ' nanocom::CObject<Self>: Ex,\n' +
86
+ ' {\n' +
87
+ ' }\n' +
88
+ ' trait PrivateClassEx\n' +
89
+ ' where\n' +
90
+ ' Self: nanocom::Class<Interface = Interface>,\n' +
91
+ ' nanocom::CObject<Self>: Ex,\n' +
92
+ ' {\n' +
93
+ ' extern "system" fn GetSlice(this: &Object) -> super::Slice {\n' +
94
+ ' unsafe { Self::to_cobject(this) }.GetSlice()\n' +
95
+ ' }\n' +
96
+ ' extern "system" fn SetSlice(this: &Object, slice: super::Slice) {\n' +
97
+ ' unsafe { Self::to_cobject(this) }.SetSlice(slice)\n' +
98
+ ' }\n' +
99
+ ' extern "system" fn GetUnsafe(this: &Object) -> *const bool {\n' +
100
+ ' unsafe { Self::to_cobject(this) }.GetUnsafe()\n' +
101
+ ' }\n' +
102
+ ' extern "system" fn SetUnsafe(this: &Object, p: *const super::Slice, size: u32) {\n' +
103
+ ' unsafe { Self::to_cobject(this) }.SetUnsafe(p, size)\n' +
104
+ ' }\n' +
105
+ ' extern "system" fn Some(this: &Object, p: &super::IMy::Object) -> bool {\n' +
106
+ ' unsafe { Self::to_cobject(this) }.Some(p)\n' +
107
+ ' }\n' +
108
+ ' extern "system" fn GetIMy(this: &Object) -> super::IMy::Ref {\n' +
109
+ ' unsafe { Self::to_cobject(this) }.GetIMy()\n' +
110
+ ' }\n' +
111
+ ' extern "system" fn SetManagedStruct(this: &Object, a: super::ManagedStruct) {\n' +
112
+ ' unsafe { Self::to_cobject(this) }.SetManagedStruct(a)\n' +
113
+ ' }\n' +
114
+ ' }\n' +
115
+ ' impl<T> PrivateClassEx for T\n' +
116
+ ' where\n' +
117
+ ' Self: nanocom::Class<Interface = Interface>,\n' +
118
+ ' nanocom::CObject<Self>: Ex,\n' +
119
+ ' {\n' +
120
+ ' }\n' +
121
+ '}'
122
+ if (rust !== e) { throw rust }
123
+ }
@@ -0,0 +1,6 @@
1
+ const { flat } = require('../../text/module.f.cjs');
2
+ const { join } = require('../../types/string/module.f.cjs');
3
+ const { rust } = require('./module.f.cjs');
4
+ const library = require('../types/testlib.f.cjs')
5
+
6
+ module.exports = join('\n')(flat(' ')(rust(library)))
@@ -1,9 +1,9 @@
1
1
  const list = require('../../types/list/module.f.cjs')
2
2
  const { flat } = list
3
3
 
4
- const cppContent = require('../cpp/test.f.cjs').result
5
- const csContent = require('../cs/test.f.cjs').result
6
- const rustContent = require("../rust/test.f.cjs").result();
4
+ const cppContent = require('../cpp/testlib.f.cjs')
5
+ const csContent = require('../cs/testlib.f.cjs')
6
+ const rustContent = require("../rust/testlib.f.cjs")
7
7
 
8
8
  /**
9
9
  * @typedef {|
@@ -5,5 +5,8 @@ edition = "2021"
5
5
 
6
6
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
7
 
8
+ [lib]
9
+ crate-type = ["cdylib"]
10
+
8
11
  [dependencies]
9
12
  nanocom = { path = "../../rust/nanocom" }
@@ -1 +1,43 @@
1
+ use crate::_result::IMy::ClassEx;
2
+
1
3
  mod _result;
4
+
5
+ struct My {}
6
+
7
+ impl nanocom::Class for My {
8
+ type Interface = _result::IMy::Interface;
9
+ fn static_vmt() -> &'static _result::IMy::Vmt {
10
+ static VMT: _result::IMy::Vmt = My::VMT;
11
+ &VMT
12
+ }
13
+ }
14
+
15
+ impl _result::IMy::Ex for nanocom::CObject<My> {
16
+ fn GetSlice(&self) -> _result::Slice {
17
+ todo!()
18
+ }
19
+
20
+ fn SetSlice(&self, slice: _result::Slice) {
21
+ todo!()
22
+ }
23
+
24
+ fn GetUnsafe(&self) -> *const bool {
25
+ todo!()
26
+ }
27
+
28
+ fn SetUnsafe(&self, p: *const _result::Slice, size: u32) {
29
+ todo!()
30
+ }
31
+
32
+ fn Some(&self, p: &_result::IMy::Object) -> bool {
33
+ todo!()
34
+ }
35
+
36
+ fn GetIMy(&self) -> _result::IMy::Ref {
37
+ todo!()
38
+ }
39
+
40
+ fn SetManagedStruct(&self, a: _result::ManagedStruct) {
41
+ todo!()
42
+ }
43
+ }
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.442",
3
+ "version": "0.0.444",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {
7
7
  "tsc": "tsc",
8
8
  "test": "tsc && npm run test-only",
9
9
  "version": "node ./nodejs/version/main.cjs",
10
- "test-only": "node --trace-uncaught ./dev/test.mjs"
10
+ "test-only": "node --trace-uncaught ./dev/test.mjs",
11
+ "comtest": "node ./com/test/build.cjs"
11
12
  },
12
13
  "repository": {
13
14
  "type": "git",