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.
- package/.github/workflows/com.yml +1 -1
- package/com/cpp/test.f.cjs +3 -11
- package/com/cpp/testlib.f.cjs +6 -0
- package/com/cs/test.f.cjs +2 -12
- package/com/cs/testlib.f.cjs +6 -0
- package/com/rust/module.f.cjs +6 -2
- package/com/rust/nanocom/tests/itmod.rs +8 -11
- package/com/rust/test.f.cjs +122 -126
- package/com/rust/testlib.f.cjs +6 -0
- package/com/test/build.f.cjs +3 -3
- package/com/test/rust/Cargo.toml +3 -0
- package/com/test/rust/src/lib.rs +42 -0
- package/package.json +3 -2
package/com/cpp/test.f.cjs
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
const
|
|
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 (
|
|
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
|
|
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
|
-
|
|
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)))
|
package/com/rust/module.f.cjs
CHANGED
|
@@ -230,8 +230,12 @@ const rust = library => {
|
|
|
230
230
|
traitImpl({
|
|
231
231
|
pub: true,
|
|
232
232
|
type: 'ClassEx',
|
|
233
|
-
content: [
|
|
234
|
-
|
|
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
|
|
40
|
-
|
|
41
|
-
|
|
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 =
|
|
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 =
|
|
146
|
-
iunknown: X::IUNKNOWN,
|
|
147
|
-
interface: X::INTERFACE,
|
|
148
|
-
};
|
|
145
|
+
static V: IMy::Vmt = X::VMT;
|
|
149
146
|
&V
|
|
150
147
|
}
|
|
151
148
|
}
|
package/com/rust/test.f.cjs
CHANGED
|
@@ -1,127 +1,123 @@
|
|
|
1
|
-
const
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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)))
|
package/com/test/build.f.cjs
CHANGED
|
@@ -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/
|
|
5
|
-
const csContent = require('../cs/
|
|
6
|
-
const rustContent = require("../rust/
|
|
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 {|
|
package/com/test/rust/Cargo.toml
CHANGED
package/com/test/rust/src/lib.rs
CHANGED
|
@@ -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.
|
|
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",
|