summaryrefslogtreecommitdiff
path: root/test cases/swift/11 mixed cpp
diff options
context:
space:
mode:
authorJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-08-01 15:33:41 +0300
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-08-01 16:52:03 +0300
commitbf9ff6e5eee7a5b7bfb2b50b0dc5bf948e87eaae (patch)
treed360be6801ff7b6315c724907c490979f8c7819e /test cases/swift/11 mixed cpp
parent550cf5ebcc395dfa78bfc31ee2abc1550a9ed349 (diff)
downloadmeson-bf9ff6e5eee7a5b7bfb2b50b0dc5bf948e87eaae.tar.gz
Condense test directory names for 1.9.
Diffstat (limited to 'test cases/swift/11 mixed cpp')
-rw-r--r--test cases/swift/11 mixed cpp/main.swift6
-rw-r--r--test cases/swift/11 mixed cpp/meson.build12
-rw-r--r--test cases/swift/11 mixed cpp/mylib.cpp22
-rw-r--r--test cases/swift/11 mixed cpp/mylib.h13
4 files changed, 53 insertions, 0 deletions
diff --git a/test cases/swift/11 mixed cpp/main.swift b/test cases/swift/11 mixed cpp/main.swift
new file mode 100644
index 000000000..c055dcdb7
--- /dev/null
+++ b/test cases/swift/11 mixed cpp/main.swift
@@ -0,0 +1,6 @@
+testCallFromSwift()
+testCallWithParam("Calling C++ function from Swift with param is working")
+
+var test = Test()
+var testtwo = Test(1)
+test.testCallFromClass()
diff --git a/test cases/swift/11 mixed cpp/meson.build b/test cases/swift/11 mixed cpp/meson.build
new file mode 100644
index 000000000..94b70f07b
--- /dev/null
+++ b/test cases/swift/11 mixed cpp/meson.build
@@ -0,0 +1,12 @@
+project('mixed cpp', 'cpp', 'swift')
+
+swiftc = meson.get_compiler('swift')
+
+# Testing C++ and Swift interoperability requires Swift 5.9
+if not swiftc.version().version_compare('>= 5.9')
+ error('MESON_SKIP_TEST Test requires Swift 5.9')
+endif
+
+lib = static_library('mylib', 'mylib.cpp')
+exe = executable('prog', 'main.swift', 'mylib.h', link_with: lib)
+test('cpp interface', exe)
diff --git a/test cases/swift/11 mixed cpp/mylib.cpp b/test cases/swift/11 mixed cpp/mylib.cpp
new file mode 100644
index 000000000..0c616814e
--- /dev/null
+++ b/test cases/swift/11 mixed cpp/mylib.cpp
@@ -0,0 +1,22 @@
+#include "mylib.h"
+#include <iostream>
+
+Test::Test() {
+ std::cout << "Test initialized" << std::endl;
+}
+
+Test::Test(int param) {
+ std::cout << "Test initialized with param " << param << std::endl;
+}
+
+void Test::testCallFromClass() {
+ std::cout << "Calling C++ class function from Swift is working" << std::endl;
+}
+
+void testCallFromSwift() {
+ std::cout << "Calling this C++ function from Swift is working" << std::endl;
+}
+
+void testCallWithParam(const std::string &param) {
+ std::cout << param << std::endl;
+}
diff --git a/test cases/swift/11 mixed cpp/mylib.h b/test cases/swift/11 mixed cpp/mylib.h
new file mode 100644
index 000000000..c465be44e
--- /dev/null
+++ b/test cases/swift/11 mixed cpp/mylib.h
@@ -0,0 +1,13 @@
+#pragma once
+#include <string>
+
+class Test {
+public:
+ Test();
+ Test(int param);
+
+ void testCallFromClass();
+};
+
+void testCallFromSwift();
+void testCallWithParam(const std::string &param);