functionalscript 0.0.472 → 0.0.473
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/README.md +80 -0
- package/com/cpp/nanocom.hpp +5 -0
- package/com/test/cpp/main.cpp +9 -0
- package/package.json +2 -2
- package/.vscode/launch.json +0 -17
- package/.vscode/tasks.json +0 -41
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# COM C++ library
|
|
2
|
+
|
|
3
|
+
## Example
|
|
4
|
+
|
|
5
|
+
### `nanocom` library
|
|
6
|
+
|
|
7
|
+
```cpp
|
|
8
|
+
class IUnknown
|
|
9
|
+
{
|
|
10
|
+
public:
|
|
11
|
+
virtual HRESULT QueryInterface(GUID const &riid, IUnknown const **ppvObject) const noexcept = 0;
|
|
12
|
+
virtual ULONG AddRef() const noexcept = 0;
|
|
13
|
+
virtual ULONG Release() const noexcept = 0;
|
|
14
|
+
protected:
|
|
15
|
+
IUnknown() {}
|
|
16
|
+
private:
|
|
17
|
+
IUnknown(IUnknown const&);
|
|
18
|
+
IUnknown& operator=(IUnknown const &);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
template<class I>
|
|
22
|
+
class base: public I
|
|
23
|
+
{
|
|
24
|
+
public:
|
|
25
|
+
HRESULT QueryInterface(GUID const &riid, IUnknown const **ppvObject) const noexcept override { ... }
|
|
26
|
+
ULONG AddRef() const noexcept override { ... }
|
|
27
|
+
ULONG Release() const noexcept override { ... }
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
template<class I, class T>
|
|
31
|
+
class impl;
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Generated
|
|
35
|
+
|
|
36
|
+
```cpp
|
|
37
|
+
class IAbc : public IUnknown
|
|
38
|
+
{
|
|
39
|
+
public:
|
|
40
|
+
constexpr static GUID const guid = GUID(...);
|
|
41
|
+
virtual IAbc* GetIAbc_() const noexcept = 0;
|
|
42
|
+
ref<IAbc> GetIAbc() const noexcept
|
|
43
|
+
{
|
|
44
|
+
return move_to_ref(GetIAbc_());
|
|
45
|
+
}
|
|
46
|
+
protected:
|
|
47
|
+
IAbc() {}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
template<class T>
|
|
51
|
+
class impl<IAbc, T> : public base<IAbc>
|
|
52
|
+
{
|
|
53
|
+
public:
|
|
54
|
+
T value;
|
|
55
|
+
IAbc* GetIAbc_() const noexcept override
|
|
56
|
+
{
|
|
57
|
+
return IAbc_GetIAbc(*this).copy_to_ref();
|
|
58
|
+
}
|
|
59
|
+
template <class... U>
|
|
60
|
+
static ref<T> create(U... u)
|
|
61
|
+
{
|
|
62
|
+
T const *const p = new implementation(u...);
|
|
63
|
+
return to_ref(*p);
|
|
64
|
+
}
|
|
65
|
+
private:
|
|
66
|
+
template <class... U>
|
|
67
|
+
explicit implementation(U... u) : value(u...) {}
|
|
68
|
+
};
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Manually Written Code
|
|
72
|
+
|
|
73
|
+
```cpp
|
|
74
|
+
struct Abc {};
|
|
75
|
+
|
|
76
|
+
ref<IAbc> IAbc_GetIAbc(impl<IAbc, Abc> const & self)
|
|
77
|
+
{
|
|
78
|
+
return to_ref(self);
|
|
79
|
+
}
|
|
80
|
+
```
|
package/com/cpp/nanocom.hpp
CHANGED
|
@@ -75,6 +75,11 @@ namespace nanocom
|
|
|
75
75
|
virtual HRESULT QueryInterface(GUID const &riid, IUnknown const **ppvObject) const noexcept = 0;
|
|
76
76
|
virtual ULONG AddRef() const noexcept = 0;
|
|
77
77
|
virtual ULONG Release() const noexcept = 0;
|
|
78
|
+
protected:
|
|
79
|
+
IUnknown() = default;
|
|
80
|
+
private:
|
|
81
|
+
IUnknown(IUnknown const&);
|
|
82
|
+
IUnknown& operator=(IUnknown const&);
|
|
78
83
|
};
|
|
79
84
|
|
|
80
85
|
template <class I>
|
package/com/test/cpp/main.cpp
CHANGED
|
@@ -53,6 +53,15 @@ public:
|
|
|
53
53
|
DLL_EXPORT
|
|
54
54
|
extern "C" My::IMy const *c_my_create()
|
|
55
55
|
{
|
|
56
|
+
{
|
|
57
|
+
auto const a = ::nanocom::implementation<Impl>::create().copy_to_raw();
|
|
58
|
+
// auto const c = *x; // no copy constructor
|
|
59
|
+
Impl *b;
|
|
60
|
+
b = const_cast<Impl*>(::nanocom::implementation<Impl>::create().copy_to_raw());
|
|
61
|
+
// *b = *a; // no assignment operator
|
|
62
|
+
b->Release();
|
|
63
|
+
a->Release();
|
|
64
|
+
}
|
|
56
65
|
{
|
|
57
66
|
auto const x = ::nanocom::implementation<Impl>::create().copy_to_raw();
|
|
58
67
|
x->Release();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functionalscript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.473",
|
|
4
4
|
"description": "FunctionalScript is a functional subset of JavaScript",
|
|
5
5
|
"main": "module.f.cjs",
|
|
6
6
|
"scripts": {
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"homepage": "https://github.com/functionalscript/functionalscript#readme",
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^18.11.9",
|
|
34
|
-
"typescript": "^4.
|
|
34
|
+
"typescript": "^4.9.3"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/.vscode/launch.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Use IntelliSense to learn about possible attributes.
|
|
3
|
-
// Hover to view descriptions of existing attributes.
|
|
4
|
-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
-
"version": "0.2.0",
|
|
6
|
-
"configurations": [
|
|
7
|
-
{
|
|
8
|
-
"type": "pwa-node",
|
|
9
|
-
"request": "launch",
|
|
10
|
-
"name": "Launch Program",
|
|
11
|
-
"skipFiles": [
|
|
12
|
-
"<node_internals>/**"
|
|
13
|
-
],
|
|
14
|
-
"program": "${workspaceFolder}\\test.js"
|
|
15
|
-
}
|
|
16
|
-
]
|
|
17
|
-
}
|
package/.vscode/tasks.json
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "2.0.0",
|
|
3
|
-
"tasks": [
|
|
4
|
-
{
|
|
5
|
-
"label": "build",
|
|
6
|
-
"command": "dotnet",
|
|
7
|
-
"type": "process",
|
|
8
|
-
"args": [
|
|
9
|
-
"build",
|
|
10
|
-
"${workspaceFolder}/com/cs/test/test.csproj",
|
|
11
|
-
"/property:GenerateFullPaths=true",
|
|
12
|
-
"/consoleloggerparameters:NoSummary"
|
|
13
|
-
],
|
|
14
|
-
"problemMatcher": "$msCompile"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"label": "publish",
|
|
18
|
-
"command": "dotnet",
|
|
19
|
-
"type": "process",
|
|
20
|
-
"args": [
|
|
21
|
-
"publish",
|
|
22
|
-
"${workspaceFolder}/com/cs/test/test.csproj",
|
|
23
|
-
"/property:GenerateFullPaths=true",
|
|
24
|
-
"/consoleloggerparameters:NoSummary"
|
|
25
|
-
],
|
|
26
|
-
"problemMatcher": "$msCompile"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"label": "watch",
|
|
30
|
-
"command": "dotnet",
|
|
31
|
-
"type": "process",
|
|
32
|
-
"args": [
|
|
33
|
-
"watch",
|
|
34
|
-
"run",
|
|
35
|
-
"--project",
|
|
36
|
-
"${workspaceFolder}/com/cs/test/test.csproj"
|
|
37
|
-
],
|
|
38
|
-
"problemMatcher": "$msCompile"
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
}
|