summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-07-25 10:08:28 -0700
committerGitHub <noreply@github.com>2022-07-25 10:08:28 -0700
commit9566e8af25f87ad034a984db9d847942e454a180 (patch)
tree2f295bf2bf60c39fd35b6b634b903d574b4ca99e /tests
parent70147fc7ba6abe0b669363ed5adfd8d4d9545c3f (diff)
Allow `class` to implement COM interface, [DLLExport] (#2338)
* Allow `class` to implement COM interface, [DLLExport] * Fix [COM] usage in tests and examples with UUIDs. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/cpu-program/class-com.slang40
-rw-r--r--tests/cpu-program/class-com.slang.expected6
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/cpu-program/class-com.slang b/tests/cpu-program/class-com.slang
new file mode 100644
index 000000000..c8dfc7b14
--- /dev/null
+++ b/tests/cpu-program/class-com.slang
@@ -0,0 +1,40 @@
+//TEST:EXECUTABLE:
+__target_intrinsic(cpp, "printf(\"%s\\n\", ($0).getBuffer())")
+void writeln(String text);
+
+[COM("BE18F5D2-4522-4AB0-A6EE-1D157FA2B083")]
+interface IFoo
+{
+ int method();
+};
+
+class MyClass : IFoo
+{
+ int intMember;
+ __init()
+ {
+ intMember = 0;
+ }
+ int method()
+ {
+ writeln("method");
+ return intMember;
+ }
+};
+
+[DllExport]
+IFoo createFoo()
+{
+ IFoo result = new MyClass();
+ return result;
+}
+
+// Now we import the `createFoo` function from current module.
+[DllImport("", "createFoo")]
+IFoo createFooImported();
+
+public __extern_cpp int main()
+{
+ var obj = createFoo();
+ return obj.method();
+} \ No newline at end of file
diff --git a/tests/cpu-program/class-com.slang.expected b/tests/cpu-program/class-com.slang.expected
new file mode 100644
index 000000000..70274e060
--- /dev/null
+++ b/tests/cpu-program/class-com.slang.expected
@@ -0,0 +1,6 @@
+result code = 0
+standard error = {
+}
+standard output = {
+method
+}