functionalscript 0.0.470 → 0.0.471
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/com/cpp/module.f.cjs +49 -13
- package/com/cpp/test.f.cjs +5 -1
- package/com/cs/test.f.cjs +1 -1
- package/com/rust/test.f.cjs +6 -6
- package/com/test/cpp/main.cpp +1 -5
- package/com/test/cs/Program.cs +1 -1
- package/com/test/rust/src/lib.rs +1 -1
- package/com/types/testlib.f.cjs +1 -1
- package/package.json +1 -1
package/com/cpp/module.f.cjs
CHANGED
|
@@ -33,11 +33,33 @@ const resultVoid = types.result('void')
|
|
|
33
33
|
|
|
34
34
|
const namespace = text.curly('namespace')
|
|
35
35
|
|
|
36
|
+
/** @type {(id: string) => string} */
|
|
37
|
+
const comRef = id => `::com::ref<${id}>`
|
|
38
|
+
|
|
39
|
+
/** @type {(id: string) => string} */
|
|
40
|
+
const ptr = id => `${id} const*`
|
|
41
|
+
|
|
42
|
+
/** @type {(id: string) => string} */
|
|
43
|
+
const ref = id => `${id} const&`
|
|
44
|
+
|
|
45
|
+
/** @type {(p: types.Field) => string} */
|
|
46
|
+
const paramName = ([name]) => name
|
|
47
|
+
|
|
48
|
+
const mapParamName = map(paramName)
|
|
49
|
+
|
|
50
|
+
const joinComma = join(', ')
|
|
51
|
+
|
|
36
52
|
/** @type {(name: string) => (lib: types.Library) => text.Block} */
|
|
37
53
|
const cpp = name => lib => {
|
|
38
54
|
|
|
39
|
-
/** @type {(t: types.Type) =>
|
|
40
|
-
const
|
|
55
|
+
/** @type {(t: types.Type) => string|undefined} */
|
|
56
|
+
const interface_ = t => {
|
|
57
|
+
if (!(t instanceof Array) || t.length !== 1) {
|
|
58
|
+
return undefined
|
|
59
|
+
}
|
|
60
|
+
const [name] = t
|
|
61
|
+
return lib[name].interface !== undefined ? name : undefined
|
|
62
|
+
}
|
|
41
63
|
|
|
42
64
|
/** @type {(i: (t: string) => string) => (t: types.Type) => string} */
|
|
43
65
|
const objectType = i => t => {
|
|
@@ -48,9 +70,9 @@ const cpp = name => lib => {
|
|
|
48
70
|
return i(id)
|
|
49
71
|
}
|
|
50
72
|
|
|
51
|
-
const type = objectType(
|
|
73
|
+
const type = objectType(comRef)
|
|
52
74
|
|
|
53
|
-
const resultType = objectType(
|
|
75
|
+
const resultType = objectType(ptr)
|
|
54
76
|
|
|
55
77
|
/** @type {(s: types.Field) => text.Item} */
|
|
56
78
|
const field = ([name, t]) => `${type(t)} ${name};`
|
|
@@ -64,20 +86,34 @@ const cpp = name => lib => {
|
|
|
64
86
|
const cppResult = resultVoid(resultType)
|
|
65
87
|
|
|
66
88
|
/** @type {(p: types.Field) => string} */
|
|
67
|
-
const param = ([name, t]) => `${objectType(
|
|
89
|
+
const param = ([name, t]) => `${objectType(ref)(t)} ${name}`
|
|
68
90
|
|
|
69
91
|
const mapParam = map(param)
|
|
70
92
|
|
|
71
|
-
/** @type {(
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
93
|
+
/** @type {(result: string) => (paramArrayStr: string) => (name: string) => text.Item} */
|
|
94
|
+
const methodHeader = result => paramArrayStr => name =>
|
|
95
|
+
`virtual ${result} COM_STDCALL ${name}${paramArrayStr} const noexcept = 0;`
|
|
96
|
+
|
|
97
|
+
/** @type {(m: types.Method) => readonly text.Item[]} */
|
|
98
|
+
const method = ([name, paramArray]) => {
|
|
99
|
+
const result = cppResult(paramArray)
|
|
100
|
+
const paramL = paramList(paramArray)
|
|
101
|
+
const paramArrayStr = `(${joinComma(mapParam(paramL))})`
|
|
102
|
+
const m = methodHeader(result)(paramArrayStr)
|
|
103
|
+
const resultName = interface_(paramArray._)
|
|
104
|
+
if (resultName === undefined) {
|
|
105
|
+
return [m(name)]
|
|
106
|
+
}
|
|
107
|
+
return [
|
|
108
|
+
m(`${name}_`),
|
|
109
|
+
`${comRef(resultName)} ${name}${paramArrayStr} const noexcept`,
|
|
110
|
+
'{',
|
|
111
|
+
[`return ::com::move_to_ref(${name}_(${joinComma(mapParamName(paramL))}));`],
|
|
112
|
+
'}',
|
|
113
|
+
]
|
|
78
114
|
}
|
|
79
115
|
|
|
80
|
-
const mapMethod =
|
|
116
|
+
const mapMethod = flatMap(method)
|
|
81
117
|
|
|
82
118
|
/** @type {(i: types.Interface) => text.Block} */
|
|
83
119
|
const defInterface = ({ guid, interface: i }) => {
|
package/com/cpp/test.f.cjs
CHANGED
|
@@ -28,7 +28,11 @@ const f = () =>
|
|
|
28
28
|
' virtual bool const* COM_STDCALL GetUnsafe() const noexcept = 0;\n' +
|
|
29
29
|
' virtual void COM_STDCALL SetUnsafe(Slice const* p, uint32_t size) const noexcept = 0;\n' +
|
|
30
30
|
' virtual bool COM_STDCALL Some(IMy const& p) const noexcept = 0;\n' +
|
|
31
|
-
' virtual IMy const* COM_STDCALL GetIMy_() const noexcept = 0;\n' +
|
|
31
|
+
' virtual IMy const* COM_STDCALL GetIMy_(uint16_t a, int16_t b) const noexcept = 0;\n' +
|
|
32
|
+
' ::com::ref<IMy> GetIMy(uint16_t a, int16_t b) const noexcept\n' +
|
|
33
|
+
' {\n' +
|
|
34
|
+
' return ::com::move_to_ref(GetIMy_(a, b));\n' +
|
|
35
|
+
' }\n' +
|
|
32
36
|
' virtual void COM_STDCALL SetManagedStruct(ManagedStruct a) const noexcept = 0;\n' +
|
|
33
37
|
' };\n' +
|
|
34
38
|
'}'
|
package/com/cs/test.f.cjs
CHANGED
package/com/rust/test.f.cjs
CHANGED
|
@@ -23,7 +23,7 @@ module.exports = () => {
|
|
|
23
23
|
' pub GetUnsafe: unsafe extern "system" fn(this: &Object) -> *const bool,\n' +
|
|
24
24
|
' pub SetUnsafe: unsafe extern "system" fn(this: &Object, p: *const super::Slice, size: u32),\n' +
|
|
25
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' +
|
|
26
|
+
' pub GetIMy: unsafe extern "system" fn(this: &Object, a: u16, b: i16) -> super::IMy::Ref,\n' +
|
|
27
27
|
' pub SetManagedStruct: unsafe extern "system" fn(this: &Object, a: super::ManagedStruct),\n' +
|
|
28
28
|
' }\n' +
|
|
29
29
|
' impl nanocom::Interface for Interface {\n' +
|
|
@@ -35,7 +35,7 @@ module.exports = () => {
|
|
|
35
35
|
' fn GetUnsafe(&self) -> *const bool;\n' +
|
|
36
36
|
' fn SetUnsafe(&self, p: *const super::Slice, size: u32);\n' +
|
|
37
37
|
' fn Some(&self, p: &super::IMy::Object) -> bool;\n' +
|
|
38
|
-
' fn GetIMy(&self) -> super::IMy::Ref;\n' +
|
|
38
|
+
' fn GetIMy(&self, a: u16, b: i16) -> super::IMy::Ref;\n' +
|
|
39
39
|
' fn SetManagedStruct(&self, a: super::ManagedStruct);\n' +
|
|
40
40
|
' }\n' +
|
|
41
41
|
' impl Ex for Object {\n' +
|
|
@@ -54,8 +54,8 @@ module.exports = () => {
|
|
|
54
54
|
' fn Some(&self, p: &super::IMy::Object) -> bool {\n' +
|
|
55
55
|
' unsafe { (self.interface().Some)(self, p) }\n' +
|
|
56
56
|
' }\n' +
|
|
57
|
-
' fn GetIMy(&self) -> super::IMy::Ref {\n' +
|
|
58
|
-
' unsafe { (self.interface().GetIMy)(self) }\n' +
|
|
57
|
+
' fn GetIMy(&self, a: u16, b: i16) -> super::IMy::Ref {\n' +
|
|
58
|
+
' unsafe { (self.interface().GetIMy)(self, a, b) }\n' +
|
|
59
59
|
' }\n' +
|
|
60
60
|
' fn SetManagedStruct(&self, a: super::ManagedStruct) {\n' +
|
|
61
61
|
' unsafe { (self.interface().SetManagedStruct)(self, a) }\n' +
|
|
@@ -105,8 +105,8 @@ module.exports = () => {
|
|
|
105
105
|
' extern "system" fn Some(this: &Object, p: &super::IMy::Object) -> bool {\n' +
|
|
106
106
|
' unsafe { nanocom::CObject::from_object_unchecked(this) }.Some(p)\n' +
|
|
107
107
|
' }\n' +
|
|
108
|
-
' extern "system" fn GetIMy(this: &Object) -> super::IMy::Ref {\n' +
|
|
109
|
-
' unsafe { nanocom::CObject::from_object_unchecked(this) }.GetIMy()\n' +
|
|
108
|
+
' extern "system" fn GetIMy(this: &Object, a: u16, b: i16) -> super::IMy::Ref {\n' +
|
|
109
|
+
' unsafe { nanocom::CObject::from_object_unchecked(this) }.GetIMy(a, b)\n' +
|
|
110
110
|
' }\n' +
|
|
111
111
|
' extern "system" fn SetManagedStruct(this: &Object, a: super::ManagedStruct) {\n' +
|
|
112
112
|
' unsafe { nanocom::CObject::from_object_unchecked(this) }.SetManagedStruct(a)\n' +
|
package/com/test/cpp/main.cpp
CHANGED
|
@@ -37,14 +37,10 @@ public:
|
|
|
37
37
|
bool COM_STDCALL Some(My::IMy const &p) const noexcept override
|
|
38
38
|
{
|
|
39
39
|
}
|
|
40
|
-
My::IMy const *COM_STDCALL GetIMy_() const noexcept override
|
|
40
|
+
My::IMy const *COM_STDCALL GetIMy_(uint16_t a, int16_t b) const noexcept override
|
|
41
41
|
{
|
|
42
42
|
return ::com::to_ref(*this).copy_to_raw();
|
|
43
43
|
}
|
|
44
|
-
com::ref<My::IMy> GetIMy() const noexcept
|
|
45
|
-
{
|
|
46
|
-
return com::move_to_ref(GetIMy_());
|
|
47
|
-
}
|
|
48
44
|
void COM_STDCALL SetManagedStruct(My::ManagedStruct a) const noexcept override
|
|
49
45
|
{
|
|
50
46
|
}
|
package/com/test/cs/Program.cs
CHANGED
package/com/test/rust/src/lib.rs
CHANGED
package/com/types/testlib.f.cjs
CHANGED