From b38b5218d7792162488f08f7cf7f917201f9d4ca Mon Sep 17 00:00:00 2001 From: a4z Date: Mon, 29 Sep 2025 14:15:33 +0200 Subject: [PATCH 01/22] Update cmake minimum version --- CMakeLists.txt | 2 +- test-suite/CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f6691c9..5558835 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.6.0) +cmake_minimum_required(VERSION 3.10.0) if(DJINNI_WITH_OBJC) set(PROJECT_LANGUAGES OBJC OBJCXX) diff --git a/test-suite/CMakeLists.txt b/test-suite/CMakeLists.txt index 92c4709..5282b7a 100644 --- a/test-suite/CMakeLists.txt +++ b/test-suite/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.6.0) +cmake_minimum_required(VERSION 3.10.0) set(CMAKE_CXX_STANDARD 17) @@ -241,7 +241,7 @@ if(DJINNI_WITH_PYTHON) "${CMAKE_CURRENT_BINARY_DIR}/generated-src/python" $ENV{PYTHONPATH}) endif() - + # Compile Python extension module (CFFI) set(C_WRAPPER_GENERATED_HEADERS ${C_WRAPPER_GENERATED_SRCS}) list(FILTER C_WRAPPER_GENERATED_HEADERS INCLUDE REGEX "\\.h$") From 1d9e40055fd72b5d1858068b87d41122899adabe Mon Sep 17 00:00:00 2001 From: a4z Date: Mon, 29 Sep 2025 14:44:20 +0200 Subject: [PATCH 02/22] Cleanup build files --- test-suite/CMakeLists.txt | 21 -------------- test-suite/Djinni.cmake | 59 --------------------------------------- 2 files changed, 80 deletions(-) diff --git a/test-suite/CMakeLists.txt b/test-suite/CMakeLists.txt index 5282b7a..5fa2a04 100644 --- a/test-suite/CMakeLists.txt +++ b/test-suite/CMakeLists.txt @@ -32,9 +32,6 @@ add_djinni_target(DjinniAllTests OBJC_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/objc" OBJC_TYPE_PREFIX "DB" OBJCPP_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/objc" - CPPCLI_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/cppcli" - CPPCLI_NAMESPACE "Djinni::TestSuite" - CPPCLI_INCLUDE_CPP_PREFIX "cpp/" YAML_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/yaml" YAML_PREFIX "test_" @@ -69,9 +66,6 @@ add_djinni_target(DjinniWCharTests OBJC_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/objc" OBJC_TYPE_PREFIX "DB" OBJCPP_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/objc" - CPPCLI_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/cppcli" - CPPCLI_NAMESPACE "Djinni::TestSuite" - CPPCLI_INCLUDE_CPP_PREFIX "cpp/" YAML_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/yaml" YAML_PREFIX "test_" @@ -84,21 +78,6 @@ add_djinni_target(DjinniWCharTests YAML_OUT_FILE WCHAR_YAML_GENERATED_SRCS ) -add_djinni_target(DjinniPyTests - IDL "djinni/py_all.djinni" - PY_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/python" - PYCFFI_PACKAGE_NAME "PyCFFIlib" - PYCFFI_DYNAMIC_LIB_LIST "mylib" - PYCFFI_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/cffi" - C_WRAPPER_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/cwrapper" - CPP_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/pycpp" - CPP_NAMESPACE "testsuite" - IDENT_CPP_ENUM_TYPE "foo_bar" - PY_OUT_FILES PYTHON_GENERATED_SRCS - PYCFFI_OUT_FILES PYCFFI_GENERATED_SRCS - C_WRAPPER_OUT_FILES C_WRAPPER_GENERATED_SRCS - CPP_OUT_FILES PYCPP_GENERATED_SRCS -) file(GLOB_RECURSE CPP_HANDWRITTEN_SRCS "handwritten-src/cpp/*") file(GLOB_RECURSE JAVA_TEST_SRCS "handwritten-src/java/*") diff --git a/test-suite/Djinni.cmake b/test-suite/Djinni.cmake index 19a188f..5ba85af 100644 --- a/test-suite/Djinni.cmake +++ b/test-suite/Djinni.cmake @@ -255,21 +255,6 @@ function(add_djinni_target) append_if_defined(DJINNI_GENERATION_COMMAND "--objc-extended-record-include-prefix" ${DJINNI_OBJC_EXTENDED_RECORD_INCLUDE_PREFIX}) append_if_defined(DJINNI_GENERATION_COMMAND "--objcpp-namespace" ${DJINNI_OBJCPP_NAMESPACE}) - append_if_defined(DJINNI_GENERATION_COMMAND "--py-import-prefix" ${DJINNI_PY_IMPORT_PREFIX}) - append_if_defined(DJINNI_GENERATION_COMMAND "--pycffi-package-name" ${DJINNI_PYCFFI_PACKAGE_NAME}) - append_if_defined(DJINNI_GENERATION_COMMAND "--pycffi-dynamic-lib-list" ${DJINNI_PYCFFI_DYNAMIC_LIB_LIST}) - append_if_defined(DJINNI_GENERATION_COMMAND "--ident-py-type" ${DJINNI_IDENT_PY_TYPE}) - append_if_defined(DJINNI_GENERATION_COMMAND "--ident-py-class-name" ${DJINNI_IDENT_PY_CLASS_NAME}) - append_if_defined(DJINNI_GENERATION_COMMAND "--ident-py-type-param" ${DJINNI_IDENT_PY_TYPE_PARAM}) - append_if_defined(DJINNI_GENERATION_COMMAND "--ident-py-method" ${DJINNI_IDENT_PY_METHOD}) - append_if_defined(DJINNI_GENERATION_COMMAND "--ident-py-field" ${DJINNI_IDENT_PY_FIELD}) - append_if_defined(DJINNI_GENERATION_COMMAND "--ident-py-local" ${DJINNI_IDENT_PY_LOCAL}) - append_if_defined(DJINNI_GENERATION_COMMAND "--ident-py-enum" ${DJINNI_IDENT_PY_ENUM}) - append_if_defined(DJINNI_GENERATION_COMMAND "--ident-py-const" ${DJINNI_IDENT_PY_CONST}) - - append_if_defined(DJINNI_GENERATION_COMMAND "--cppcli-namespace" ${DJINNI_CPPCLI_NAMESPACE}) - append_if_defined(DJINNI_GENERATION_COMMAND "--cppcli-include-cpp-prefix" ${DJINNI_CPPCLI_INCLUDE_CPP_PREFIX}) - if(DEFINED DJINNI_CPP_OUT_FILES) set(DJINNI_CPP_GENERATION_COMMAND ${DJINNI_GENERATION_COMMAND}) append_if_defined(DJINNI_CPP_GENERATION_COMMAND "--cpp-out" ${DJINNI_CPP_OUT}) @@ -354,37 +339,9 @@ function(add_djinni_target) set(${DJINNI_OBJCPP_OUT_FILES} ${OBJCPP_OUT_FILES} PARENT_SCOPE) endif() - if(DEFINED DJINNI_PY_OUT_FILES) - set(DJINNI_PY_GENERATION_COMMAND ${DJINNI_GENERATION_COMMAND}) - append_if_defined(DJINNI_PY_GENERATION_COMMAND "--py-out" ${DJINNI_PY_OUT}) - resolve_djinni_outputs(COMMAND "${DJINNI_PY_GENERATION_COMMAND}" RESULT PY_OUT_FILES) - add_custom_command( - OUTPUT ${PY_OUT_FILES} - DEPENDS ${DJINNI_INPUTS} - COMMAND ${DJINNI_PY_GENERATION_COMMAND} - COMMENT "Generating Djinni Python bindings from ${DJINNI_IDL}" - VERBATIM - ) - set(${DJINNI_PY_OUT_FILES} ${PY_OUT_FILES} PARENT_SCOPE) - endif() - if(DEFINED DJINNI_PYCFFI_OUT_FILES) - set(DJINNI_PYCFFI_GENERATION_COMMAND ${DJINNI_GENERATION_COMMAND}) - append_if_defined(DJINNI_PYCFFI_GENERATION_COMMAND "--pycffi-out" ${DJINNI_PYCFFI_OUT}) - - resolve_djinni_outputs(COMMAND "${DJINNI_PYCFFI_GENERATION_COMMAND}" RESULT PYCFFI_OUT_FILES) - - add_custom_command( - OUTPUT ${PYCFFI_OUT_FILES} - DEPENDS ${DJINNI_INPUTS} - COMMAND ${DJINNI_PYCFFI_GENERATION_COMMAND} - COMMENT "Generating Djinni CFFI bindings from ${DJINNI_IDL}" - VERBATIM - ) - set(${DJINNI_PYCFFI_OUT_FILES} ${PYCFFI_OUT_FILES} PARENT_SCOPE) - endif() if(DEFINED DJINNI_C_WRAPPER_OUT_FILES) set(DJINNI_C_WRAPPER_GENERATION_COMMAND ${DJINNI_GENERATION_COMMAND}) @@ -402,21 +359,5 @@ function(add_djinni_target) set(${DJINNI_C_WRAPPER_OUT_FILES} ${C_WRAPPER_OUT_FILES} PARENT_SCOPE) endif() - if(DEFINED DJINNI_CPPCLI_OUT_FILES) - set(DJINNI_CPPCLI_GENERATION_COMMAND ${DJINNI_GENERATION_COMMAND}) - append_if_defined(DJINNI_CPPCLI_GENERATION_COMMAND "--cppcli-out" ${DJINNI_CPPCLI_OUT}) - - resolve_djinni_outputs(COMMAND "${DJINNI_CPPCLI_GENERATION_COMMAND}" RESULT CPPCLI_OUT_FILES) - - add_custom_command( - OUTPUT ${CPPCLI_OUT_FILES} - DEPENDS ${DJINNI_INPUTS} - COMMAND ${DJINNI_CPPCLI_GENERATION_COMMAND} - COMMENT "Generating Djinni C++/CLI bindings from ${DJINNI_IDL}" - VERBATIM - ) - set(${DJINNI_CPPCLI_OUT_FILES} ${CPPCLI_OUT_FILES} PARENT_SCOPE) - endif() - endfunction() From f384c2caf145d83dff8dd1ecf5b8b9c115699cce Mon Sep 17 00:00:00 2001 From: a4z Date: Mon, 29 Sep 2025 14:46:25 +0200 Subject: [PATCH 03/22] Backup agent instructions --- AGENT.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 AGENT.md diff --git a/AGENT.md b/AGENT.md new file mode 100644 index 0000000..80c4dc7 --- /dev/null +++ b/AGENT.md @@ -0,0 +1,50 @@ +# Djinni support lib refactoring instructions + +This is the support lib for + +Over time, language support has been added, and now they are a maintainance burden. +We want to go back to basic, that means, focus on Objective-C and Java (JNI) support. + +There is a python interaface and a C# interface. +We can keep the plain c wrapper, called cwrapper, if is is C specific and does not have dependencies other than C/C++. + +- [x] Clean up the build system and remove everything does does not belong to Objective-C and Java (JNI) or C support. +- [ ] Remove all code that does not belong to Objective-C and Java (JNI) or C support. +- [ ] Remove all tests that does not belong to Objective-C and Java (JNI) or C support. +- [ ] Clean up the documentation remove everything that does not belong to Objective-C and Java (JNI) or C support. + +The project builds with cmake, every step we shall be able to run cmake and do the tests. +To make that happen, I need 2 generator versions. + +Implementation shall happen step by step and interative. +No agent mode to go crazy, follow the plan. + +## Clean up build system (step 1) + +I have encapsulated the old and new CMake calls in 2 scripts in the working directory + +- Old generator with support for c# and python (sh zconf-old.sh) +- New generator where support for c# and python was removed (sh zconf-new.sh) + +Review the scripts, zconf-old.sh and zconf-new.sh to understand them, but do not change them + +### Definition of done + +To succeed, sh zconf-new.sh shall run without error, and a build of it must work! + +In the new generator, the C wrapper has been disabled, maybe we bring the back. +If there are problems due to the C wrapper, we will disable them in this project for now. + +## General build instrucktions + +### New version + + sh zconf-new.sh + cmake --build build/new --config Debug + (cd build/new && ctest -C Debug) + +### Old version + + sh zconf-old.sh + cmake --build build/old --config Debug + (cd build/old && ctest -C Debug) From 8eccb8694648415649a917d328349b2203eb668b Mon Sep 17 00:00:00 2001 From: a4z Date: Mon, 29 Sep 2025 14:55:22 +0200 Subject: [PATCH 04/22] Update instructions --- AGENT.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/AGENT.md b/AGENT.md index 80c4dc7..6be2b9b 100644 --- a/AGENT.md +++ b/AGENT.md @@ -19,16 +19,22 @@ To make that happen, I need 2 generator versions. Implementation shall happen step by step and interative. No agent mode to go crazy, follow the plan. -## Clean up build system (step 1) +## step 1 -I have encapsulated the old and new CMake calls in 2 scripts in the working directory +Clean up CMake build system -- Old generator with support for c# and python (sh zconf-old.sh) -- New generator where support for c# and python was removed (sh zconf-new.sh) +### Definition of done 1 -Review the scripts, zconf-old.sh and zconf-new.sh to understand them, but do not change them +To succeed, sh zconf-new.sh shall run without error, and a build of it must work! + +In the new generator, the C wrapper has been disabled, maybe we bring the back. +If there are problems due to the C wrapper, we will disable them in this project for now. + +## Step 2 + +Remove all code that does not belong to Objective-C and Java (JNI) or C support. -### Definition of done +### Definition of done 2 To succeed, sh zconf-new.sh shall run without error, and a build of it must work! From 97e7c19d4813c21d40f3fe7d334f981db779ac65 Mon Sep 17 00:00:00 2001 From: a4z Date: Mon, 29 Sep 2025 14:55:34 +0200 Subject: [PATCH 05/22] Remove removed language files --- test-suite/djinni/py_all.djinni | 13 -- .../handwritten-src/cpp/Duration-cs.hpp | 37 --- .../handwritten-src/cs/ClientInterfaceImpl.cs | 32 --- .../handwritten-src/cs/ClientInterfaceTest.cs | 44 ---- .../handwritten-src/cs/CppExceptionTest.cs | 23 -- test-suite/handwritten-src/cs/DurationTest.cs | 41 ---- test-suite/handwritten-src/cs/EnumTest.cs | 63 ----- .../handwritten-src/cs/MapRecordTest.cs | 69 ------ .../handwritten-src/cs/MockRecordTest.cs | 25 -- .../cs/NestedCollectionTest.cs | 35 --- .../handwritten-src/cs/PrimitiveListTest.cs | 38 ---- .../handwritten-src/cs/PrimitivesTest.cs | 17 -- .../cs/RecordWithDerivingsTest.cs | 74 ------ .../handwritten-src/cs/SetRecordTest.cs | 27 --- test-suite/handwritten-src/cs/TokenTest.cs | 53 ----- test-suite/handwritten-src/cs/WcharTest.cs | 21 -- .../python/foo_extensible_record.py | 9 - .../python/foo_listener_impl.py | 31 --- .../handwritten-src/python/test_callbacks.py | 215 ------------------ .../python/test_client_interface.py | 125 ---------- .../handwritten-src/python/test_constants.py | 36 --- .../python/test_containers_interface.py | 212 ----------------- .../python/test_enum_interface.py | 55 ----- .../python/test_foo_interface.py | 134 ----------- .../python/test_foo_primitives.py | 168 -------------- .../handwritten-src/python/test_foo_static.py | 31 --- .../python/test_multiple_inheritance.py | 44 ---- .../handwritten-src/python/test_proxying.py | 123 ---------- .../python/test_record_with_derivings.py | 63 ----- 29 files changed, 1858 deletions(-) delete mode 100644 test-suite/djinni/py_all.djinni delete mode 100644 test-suite/handwritten-src/cpp/Duration-cs.hpp delete mode 100644 test-suite/handwritten-src/cs/ClientInterfaceImpl.cs delete mode 100644 test-suite/handwritten-src/cs/ClientInterfaceTest.cs delete mode 100644 test-suite/handwritten-src/cs/CppExceptionTest.cs delete mode 100644 test-suite/handwritten-src/cs/DurationTest.cs delete mode 100644 test-suite/handwritten-src/cs/EnumTest.cs delete mode 100644 test-suite/handwritten-src/cs/MapRecordTest.cs delete mode 100644 test-suite/handwritten-src/cs/MockRecordTest.cs delete mode 100644 test-suite/handwritten-src/cs/NestedCollectionTest.cs delete mode 100644 test-suite/handwritten-src/cs/PrimitiveListTest.cs delete mode 100644 test-suite/handwritten-src/cs/PrimitivesTest.cs delete mode 100644 test-suite/handwritten-src/cs/RecordWithDerivingsTest.cs delete mode 100644 test-suite/handwritten-src/cs/SetRecordTest.cs delete mode 100644 test-suite/handwritten-src/cs/TokenTest.cs delete mode 100644 test-suite/handwritten-src/cs/WcharTest.cs delete mode 100644 test-suite/handwritten-src/python/foo_extensible_record.py delete mode 100644 test-suite/handwritten-src/python/foo_listener_impl.py delete mode 100644 test-suite/handwritten-src/python/test_callbacks.py delete mode 100644 test-suite/handwritten-src/python/test_client_interface.py delete mode 100644 test-suite/handwritten-src/python/test_constants.py delete mode 100644 test-suite/handwritten-src/python/test_containers_interface.py delete mode 100644 test-suite/handwritten-src/python/test_enum_interface.py delete mode 100644 test-suite/handwritten-src/python/test_foo_interface.py delete mode 100644 test-suite/handwritten-src/python/test_foo_primitives.py delete mode 100644 test-suite/handwritten-src/python/test_foo_static.py delete mode 100644 test-suite/handwritten-src/python/test_multiple_inheritance.py delete mode 100644 test-suite/handwritten-src/python/test_proxying.py delete mode 100644 test-suite/handwritten-src/python/test_record_with_derivings.py diff --git a/test-suite/djinni/py_all.djinni b/test-suite/djinni/py_all.djinni deleted file mode 100644 index 511f66d..0000000 --- a/test-suite/djinni/py_all.djinni +++ /dev/null @@ -1,13 +0,0 @@ -@import "common.djinni" - -@import "foo_interface.djinni" -@import "foo_primitives.djinni" -@import "foo_static.djinni" -@import "foo_listener.djinni" -@import "foo_receiver.djinni" -@import "foo_listener_bf.djinni" -@import "foo_client_interface.djinni" -@import "foo_containers.djinni" -@import "foo_constants.djinni" -@import "foo_enum_interface.djinni" -@import "foo_duplicate_file_creation.djinni" diff --git a/test-suite/handwritten-src/cpp/Duration-cs.hpp b/test-suite/handwritten-src/cpp/Duration-cs.hpp deleted file mode 100644 index 41aacea..0000000 --- a/test-suite/handwritten-src/cpp/Duration-cs.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include - -namespace djinni { - -// This is only a helper, trying to use it as member/param will fail -template -struct DurationPeriod; - -using Duration_h = DurationPeriod>; -using Duration_min = DurationPeriod>; -using Duration_s = DurationPeriod>; -using Duration_ms = DurationPeriod; -using Duration_us = DurationPeriod; -using Duration_ns = DurationPeriod; - -template -struct Duration; - -template -struct Duration> { - using CppType = std::chrono::duration; - using CsType = System::TimeSpan; - - using Ticks = std::chrono::duration>; - - static CppType ToCpp(CsType dt) { - return std::chrono::duration_cast(Ticks(dt.Ticks)); - } - static CsType FromCpp(CppType dt) { - auto ms = std::chrono::duration_cast(dt).count(); - return System::TimeSpan::FromTicks(ms); - } -}; - -} \ No newline at end of file diff --git a/test-suite/handwritten-src/cs/ClientInterfaceImpl.cs b/test-suite/handwritten-src/cs/ClientInterfaceImpl.cs deleted file mode 100644 index 52e6b1b..0000000 --- a/test-suite/handwritten-src/cs/ClientInterfaceImpl.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Djinni.TestSuite; - -namespace Djinni.Testing.Unit -{ - public class ClientInterfaceImpl : ClientInterface - { - public override ClientReturnedRecord GetRecord(long recordId, string utf8String, string misc) - { - return new ClientReturnedRecord(recordId, utf8String, misc); - } - - public override double IdentifierCheck(byte[] data, int r, long jret) - { - throw new System.NotImplementedException(); - } - - public override string ReturnStr() - { - return "test"; - } - - public override string MethTakingInterface(ClientInterface i) - { - return i != null ? i.ReturnStr() : ""; - } - - public override string MethTakingOptionalInterface(ClientInterface i) - { - return i != null ? i.ReturnStr() : ""; - } - } -} \ No newline at end of file diff --git a/test-suite/handwritten-src/cs/ClientInterfaceTest.cs b/test-suite/handwritten-src/cs/ClientInterfaceTest.cs deleted file mode 100644 index 603552c..0000000 --- a/test-suite/handwritten-src/cs/ClientInterfaceTest.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Djinni.TestSuite; -using NUnit.Framework; - -namespace Djinni.Testing.Unit -{ - [TestFixture] - public class ClientInterfaceTest - { - private ClientInterface _csClientInterface; - - [SetUp] - public void SetUp() - { - _csClientInterface = new ClientInterfaceImpl(); - } - - [Test] - public void TestClientReturn() - { - Assert.That(() => TestHelpers.CheckClientInterfaceAscii(_csClientInterface), Throws.Nothing); - } - - [Test] - public void TestClientReturnUtf8() - { - Assert.That(() => TestHelpers.CheckClientInterfaceNonascii(_csClientInterface), Throws.Nothing); - } - - [Test] - public void TestClientInterfaceArgs() - { - Assert.That(() => TestHelpers.CheckClientInterfaceArgs(_csClientInterface), Throws.Nothing); - } - - [Test] - public void TestReverseClientInterfaceArgs() - { - var i = ReverseClientInterface.Create(); - - Assert.That(() => i.MethTakingInterface(i), Is.EqualTo("test")); - Assert.That(() => i.MethTakingOptionalInterface(i), Is.EqualTo("test")); - } - } -} \ No newline at end of file diff --git a/test-suite/handwritten-src/cs/CppExceptionTest.cs b/test-suite/handwritten-src/cs/CppExceptionTest.cs deleted file mode 100644 index 08df53f..0000000 --- a/test-suite/handwritten-src/cs/CppExceptionTest.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Djinni.TestSuite; -using NUnit.Framework; - -namespace Djinni.Testing.Unit -{ - [TestFixture] - public class CppExceptionTest - { - private CppException _cppInterface; - - [SetUp] - public void SetUp() - { - _cppInterface = CppException.Get(); - } - - [Test] - public void TestCppException() - { - Assert.That(() => _cppInterface.ThrowAnException(), Throws.Exception.Message.EqualTo("Exception Thrown")); - } - } -} \ No newline at end of file diff --git a/test-suite/handwritten-src/cs/DurationTest.cs b/test-suite/handwritten-src/cs/DurationTest.cs deleted file mode 100644 index fb07bf8..0000000 --- a/test-suite/handwritten-src/cs/DurationTest.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using Djinni.TestSuite; -using NUnit.Framework; - -namespace Djinni.Testing.Unit -{ - [TestFixture] - public class DurationTest - { - [Test] - public void Test() - { - Assert.That(() => TestDuration.HoursString(TimeSpan.FromHours(1)), Is.EqualTo("1")); - Assert.That(() => TestDuration.MinutesString(TimeSpan.FromMinutes(1)), Is.EqualTo("1")); - Assert.That(() => TestDuration.SecondsString(TimeSpan.FromSeconds(1)), Is.EqualTo("1")); - Assert.That(() => TestDuration.MillisString(TimeSpan.FromMilliseconds(1)), Is.EqualTo("1")); - Assert.That(() => TestDuration.MicrosString(TimeSpan.FromTicks(10)), Is.EqualTo("1")); // 1 tick = 100 nanoseconds - Assert.That(() => TestDuration.NanosString(TimeSpan.FromTicks(1)), Is.EqualTo("100")); // 1 tick = 100 nanoseconds - - Assert.That(() => TestDuration.Hours(1).Hours, Is.EqualTo(1)); - Assert.That(() => TestDuration.Minutes(1).Minutes, Is.EqualTo(1)); - Assert.That(() => TestDuration.Seconds(1).Seconds, Is.EqualTo(1)); - Assert.That(() => TestDuration.Millis(1).Milliseconds, Is.EqualTo(1)); - Assert.That(() => TestDuration.Micros(1).Ticks, Is.EqualTo(10)); // 1 tick = 100 nanoseconds - Assert.That(() => TestDuration.Nanos(100).Ticks, Is.EqualTo(1)); // 1 tick = 100 nanoseconds - - Assert.That(() => TestDuration.Hoursf(1.5).TotalMinutes, Is.EqualTo(90)); - Assert.That(() => TestDuration.Minutesf(1.5).TotalSeconds, Is.EqualTo(90)); - Assert.That(() => TestDuration.Secondsf(1.5).TotalMilliseconds, Is.EqualTo(1500)); - Assert.That(() => TestDuration.Millisf(1.5).Ticks, Is.EqualTo(1500 * 10)); - Assert.That(() => TestDuration.Microsf(1.5).Ticks, Is.EqualTo(15)); // 1 tick = 100 nanoseconds - Assert.That(() => TestDuration.Nanosf(100.5).Ticks, Is.EqualTo(1)); // 1 tick = 100 nanoseconds - - Assert.That(() => TestDuration.Box(1)?.Seconds, Is.EqualTo(1)); - Assert.That(() => TestDuration.Box(-1), Is.Null); - - Assert.That(() => TestDuration.Unbox(TimeSpan.FromSeconds(1)), Is.EqualTo(1)); - Assert.That(() => TestDuration.Unbox(null), Is.EqualTo(-1)); - } - } -} \ No newline at end of file diff --git a/test-suite/handwritten-src/cs/EnumTest.cs b/test-suite/handwritten-src/cs/EnumTest.cs deleted file mode 100644 index c1ab059..0000000 --- a/test-suite/handwritten-src/cs/EnumTest.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.Collections.Generic; -using Djinni.TestSuite; -using NUnit.Framework; - -namespace Djinni.Testing.Unit -{ - [TestFixture] - public class EnumTest - { - [Test] - public void TestEnumKey() - { - var m = new Dictionary - { - {Color.Red, "red"}, - {Color.Orange, "orange"}, - {Color.Yellow, "yellow"}, - {Color.Green, "green"}, - {Color.Blue, "blue"}, - {Color.Indigo, "indigo"}, - {Color.Violet, "violet"} - }; - Assert.That(() => TestHelpers.CheckEnumMap(m), Throws.Nothing); - } - - [Test] - public void TestAccessFlagRoundtrip() - { - AccessFlags[] flags = - { - AccessFlags.Nobody, - AccessFlags.Everybody, - AccessFlags.OwnerRead, - AccessFlags.OwnerRead | AccessFlags.OwnerWrite, - AccessFlags.OwnerRead | AccessFlags.OwnerWrite | AccessFlags.OwnerExecute - }; - - foreach (var flag in flags) - { - Assert.That(FlagRoundtrip.RoundtripAccess(flag), Is.EqualTo(flag)); - Assert.That(FlagRoundtrip.RoundtripAccessBoxed(flag), Is.EqualTo(flag)); - } - Assert.That(FlagRoundtrip.RoundtripAccessBoxed(null), Is.Null); - } - - [Test] - public void TestEmptyFlagRoundtrip() - { - EmptyFlags[] flags = - { - EmptyFlags.None, - EmptyFlags.All - }; - - foreach (var flag in flags) - { - Assert.That(FlagRoundtrip.RoundtripEmpty(flag), Is.EqualTo(flag)); - Assert.That(FlagRoundtrip.RoundtripEmptyBoxed(flag), Is.EqualTo(flag)); - } - Assert.That(FlagRoundtrip.RoundtripEmptyBoxed(null), Is.Null); - } - } -} \ No newline at end of file diff --git a/test-suite/handwritten-src/cs/MapRecordTest.cs b/test-suite/handwritten-src/cs/MapRecordTest.cs deleted file mode 100644 index 9f1d52a..0000000 --- a/test-suite/handwritten-src/cs/MapRecordTest.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Djinni.TestSuite; -using NUnit.Framework; - -namespace Djinni.Testing.Unit -{ - [TestFixture] - public class MapRecordTest - { - [Test] - public void TestCppMapToCsMap() - { - CheckCsMap(TestHelpers.GetMap()); - } - - [Test] - public void TestEmptyCppMapToCsMap() - { - Assert.That(TestHelpers.GetEmptyMap, Is.Empty); - } - - [Test] - public void TestCppMapListToCsMapList() - { - var mapListRecord = TestHelpers.GetMapListRecord(); - var mapList = mapListRecord.MapList; - Assert.That(() => mapList, Has.Count.EqualTo(1)); - CheckCsMap(mapList.First()); - } - - [Test] - public void TestCsMapToCppMap() - { - Assert.That(() => TestHelpers.CheckMap(CsMap), Is.True); - } - - [Test] - public void TestEmptyCsMapToCppMap() - { - Assert.That(() => TestHelpers.CheckEmptyMap(new Dictionary()), Is.True); - } - - [Test] - public void TestCsMapListToCppMapList() - { - var mapList = new List>{ CsMap }; - Assert.That(() => TestHelpers.CheckMapListRecord(new MapListRecord(mapList)), Is.True); - } - - private static Dictionary CsMap => new Dictionary - { - {"String1", 1}, - {"String2", 2}, - {"String3", 3} - }; - - private void CheckCsMap(Dictionary map) - { - var expectedMap = new Dictionary - { - {"String1", 1}, - {"String2", 2}, - {"String3", 3} - }; - Assert.That(() => map, Is.EquivalentTo(expectedMap)); - } - } -} \ No newline at end of file diff --git a/test-suite/handwritten-src/cs/MockRecordTest.cs b/test-suite/handwritten-src/cs/MockRecordTest.cs deleted file mode 100644 index 529cce2..0000000 --- a/test-suite/handwritten-src/cs/MockRecordTest.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Runtime.InteropServices; -using Djinni.TestSuite; -using NUnit.Framework; - -namespace Djinni.Testing.Unit -{ - [TestFixture] - public class MockRecordTest - { - [Test] - public void TestMockConstants() - { - Constants mock = new MockConstants(); - Assert.That(() => mock.ToString(), Is.EqualTo("MockConstants{}"), "The ToString() method should be overridden."); - } - } - - public class MockConstants : Constants - { - public override string ToString() - { - return "MockConstants{}"; - } - } -} \ No newline at end of file diff --git a/test-suite/handwritten-src/cs/NestedCollectionTest.cs b/test-suite/handwritten-src/cs/NestedCollectionTest.cs deleted file mode 100644 index 7819a1c..0000000 --- a/test-suite/handwritten-src/cs/NestedCollectionTest.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections.Generic; -using Djinni.TestSuite; -using NUnit.Framework; - -namespace Djinni.Testing.Unit -{ - [TestFixture] - public class NestedCollectionTest - { - private NestedCollection _nestedCollection; - - [SetUp] - public void SetUp() - { - _nestedCollection = new NestedCollection(new List> - { - new HashSet { "String1", "String2" }, - new HashSet { "StringA", "StringB" } - }); - } - - [Test] - public void TestCppNestedRecordToCsNestedCollection() - { - var converted = TestHelpers.GetNestedCollection(); - Assert.That(() => converted.SetList, Is.EquivalentTo(_nestedCollection.SetList)); - } - - [Test] - public void TestCsNestedRecordToCppNestedCollection() - { - Assert.That(() => TestHelpers.CheckNestedCollection(_nestedCollection), Is.True); - } - } -} \ No newline at end of file diff --git a/test-suite/handwritten-src/cs/PrimitiveListTest.cs b/test-suite/handwritten-src/cs/PrimitiveListTest.cs deleted file mode 100644 index 20330bc..0000000 --- a/test-suite/handwritten-src/cs/PrimitiveListTest.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Collections.Generic; -using Djinni.TestSuite; -using NUnit.Framework; - -namespace Djinni.Testing.Unit -{ - [TestFixture] - public class PrimitiveListTest - { - [SetUp] - public void SetUp() - { - _primitiveList = new PrimitiveList(new List {1, 2, 3}); - } - - private PrimitiveList _primitiveList; - - [Test] - public void TestCsPrimitiveListToCpp() - { - Assert.That(() => TestHelpers.CheckPrimitiveList(_primitiveList), Is.True); - } - - [Test] - public void TestCppPrimitiveListToCs() - { - var converted = TestHelpers.GetPrimitiveList(); - Assert.That(() => converted.List, Is.EquivalentTo(_primitiveList.List)); - } - - [Test] - public void TestBinary() - { - byte[] b = {1, 2, 3}; - Assert.That(() => TestHelpers.IdBinary(b), Is.EqualTo(b)); - } - } -} \ No newline at end of file diff --git a/test-suite/handwritten-src/cs/PrimitivesTest.cs b/test-suite/handwritten-src/cs/PrimitivesTest.cs deleted file mode 100644 index 941ee08..0000000 --- a/test-suite/handwritten-src/cs/PrimitivesTest.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Djinni.TestSuite; -using NUnit.Framework; - -namespace Djinni.Testing.Unit -{ - [TestFixture] - public class PrimitivesTest - { - [Test] - public void TestPrimitives() - { - var p = new AssortedPrimitives(true, 123, 20000, 1000000000, 1234567890123456789L, 1.23f, 1.23d, - true, 123, 20000, 1000000000, 1234567890123456789L, 1.23f, 1.23d); - Assert.That(() => TestHelpers.AssortedPrimitivesId(p), Is.EqualTo(p)); - } - } -} \ No newline at end of file diff --git a/test-suite/handwritten-src/cs/RecordWithDerivingsTest.cs b/test-suite/handwritten-src/cs/RecordWithDerivingsTest.cs deleted file mode 100644 index 847590a..0000000 --- a/test-suite/handwritten-src/cs/RecordWithDerivingsTest.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using Djinni.TestSuite; -using NUnit.Framework; - -namespace Djinni.Testing.Unit -{ - [TestFixture] - public class RecordWithDerivingsTest - { - [SetUp] - public void SetUp() - { - _record1 = new RecordWithDerivings(1, 2, 3, 4, 5.0f, 6.0, new DateTime(1970, 1, 1), "String8"); - _record1A = new RecordWithDerivings(1, 2, 3, 4, 5.0f, 6.0, new DateTime(1970, 1, 1), "String8"); - _record2 = new RecordWithDerivings(1, 2, 3, 4, 5.0f, 6.0, new DateTime(1970, 1, 1), "String888"); - _record3 = new RecordWithDerivings(111, 2, 3, 4, 5.0f, 6.0, new DateTime(1970, 1, 1), "String8"); - - _nestedRecord1 = new RecordWithNestedDerivings(1, _record1); - _nestedRecord1A = new RecordWithNestedDerivings(1, _record1A); - _nestedRecord2 = new RecordWithNestedDerivings(1, _record2); - } - - private RecordWithDerivings _record1; - private RecordWithDerivings _record1A; - private RecordWithDerivings _record2; - private RecordWithDerivings _record3; - - private RecordWithNestedDerivings _nestedRecord1; - private RecordWithNestedDerivings _nestedRecord1A; - private RecordWithNestedDerivings _nestedRecord2; - - [Test] - public void TestNestedRecordEq() - { - Assert.That(() => _nestedRecord1, Is.EqualTo(_nestedRecord1A)); - Assert.That(() => _nestedRecord1, Is.Not.EqualTo(_nestedRecord2)); - Assert.That(() => _nestedRecord2, Is.Not.EqualTo(_nestedRecord1)); - } - - [Test] - public void TestNestedRecordOrd() - { - Assert.That(() => _nestedRecord1.CompareTo(_nestedRecord1A), Is.Zero); - Assert.That(() => _nestedRecord1.CompareTo(_nestedRecord2), Is.LessThan(0)); - Assert.That(() => _nestedRecord2.CompareTo(_nestedRecord1), Is.GreaterThan(0)); - } - - [Test] - public void TestRecordEq() - { - Assert.That(() => _record1, Is.EqualTo(_record1A)); - Assert.That(() => _record1A, Is.EqualTo(_record1)); - Assert.That(() => _record1, Is.Not.EqualTo(_record2)); - Assert.That(() => _record2, Is.Not.EqualTo(_record1)); - Assert.That(() => _record1, Is.Not.EqualTo(_record3)); - Assert.That(() => _record3, Is.Not.EqualTo(_record1)); - Assert.That(() => _record2, Is.Not.EqualTo(_record3)); - Assert.That(() => _record3, Is.Not.EqualTo(_record2)); - } - - [Test] - public void TestRecordOrd() - { - Assert.That(() => _record1.CompareTo(_record1A), Is.Zero); - Assert.That(() => _record1A.CompareTo(_record1), Is.Zero); - Assert.That(() => _record1.CompareTo(_record2), Is.LessThan(0)); - Assert.That(() => _record2.CompareTo(_record1), Is.GreaterThan(0)); - Assert.That(() => _record1.CompareTo(_record3), Is.LessThan(0)); - Assert.That(() => _record3.CompareTo(_record1), Is.GreaterThan(0)); - Assert.That(() => _record2.CompareTo(_record3), Is.LessThan(0)); - Assert.That(() => _record3.CompareTo(_record2), Is.GreaterThan(0)); - } - } -} \ No newline at end of file diff --git a/test-suite/handwritten-src/cs/SetRecordTest.cs b/test-suite/handwritten-src/cs/SetRecordTest.cs deleted file mode 100644 index 020deb3..0000000 --- a/test-suite/handwritten-src/cs/SetRecordTest.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using Djinni.TestSuite; -using NUnit.Framework; - -namespace Djinni.Testing.Unit -{ - [TestFixture] - public class SetRecordTest - { - [Test] - public void TestCppSetToCsSet() - { - var setRecord = TestHelpers.GetSetRecord(); - var set = setRecord.Set; - Assert.That(() => set, Is.EquivalentTo(new HashSet {"StringA", "StringB", "StringC"})); - } - - [Test] - public void TestCsSetToCppSet() - { - var sSet = new HashSet {"StringA", "StringB", "StringC"}; - var iSet = new HashSet(); - var setRecord = new SetRecord(sSet, iSet); - Assert.That(() => TestHelpers.CheckSetRecord(setRecord), Is.True); - } - } -} \ No newline at end of file diff --git a/test-suite/handwritten-src/cs/TokenTest.cs b/test-suite/handwritten-src/cs/TokenTest.cs deleted file mode 100644 index 7286551..0000000 --- a/test-suite/handwritten-src/cs/TokenTest.cs +++ /dev/null @@ -1,53 +0,0 @@ -using Djinni.TestSuite; -using NUnit.Framework; - -namespace Djinni.Testing.Unit -{ - [TestFixture] - public class TokenTest - { - private class CsToken : UserToken - { - public override string Whoami() - { - return "C#"; - } - } - - [Test] - public void TestTokens() - { - UserToken token = new CsToken(); - Assert.That(TestHelpers.TokenId(token), Is.SameAs(token)); - } - - [Test] - public void TestNullToken() - { - Assert.That(TestHelpers.TokenId(null), Is.EqualTo(null)); - } - - [Test] - public void TestCppToken() - { - var token = TestHelpers.CreateCppToken(); - Assert.That(TestHelpers.TokenId(token), Is.SameAs(token)); - Assert.That(() => TestHelpers.CheckCppToken(token), Throws.Nothing); - } - - [Test] - public void TestTokenType() - { - Assert.That(() => TestHelpers.CheckTokenType(new CsToken(), "C#"), Throws.Nothing); - Assert.That(() => TestHelpers.CheckTokenType(TestHelpers.CreateCppToken(), "C++"), Throws.Nothing); - Assert.That(() => TestHelpers.CheckTokenType(new CsToken(), "foo"), Throws.Exception); - Assert.That(() => TestHelpers.CheckTokenType(TestHelpers.CreateCppToken(), "foo"), Throws.Exception); - } - - [Test] - public void TestNotCppToken() - { - Assert.That(() => TestHelpers.CheckCppToken(new CsToken()), Throws.Exception); - } -} -} \ No newline at end of file diff --git a/test-suite/handwritten-src/cs/WcharTest.cs b/test-suite/handwritten-src/cs/WcharTest.cs deleted file mode 100644 index bdd884a..0000000 --- a/test-suite/handwritten-src/cs/WcharTest.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Djinni.TestSuite; -using NUnit.Framework; - -namespace Djinni.Testing.Unit -{ - [TestFixture] - public class WcharTest - { - private const string Str1 = "some string with unicode \u0000, \u263A, \uD83D\uDCA9 symbols"; - private const string Str2 = "another string with unicode \u263B, \uD83D\uDCA8 symbols"; - - [Test] - public void Test() - { - Assert.That(WcharTestHelpers.GetRecord().S, Is.EqualTo(Str1)); - Assert.That(WcharTestHelpers.GetString(), Is.EqualTo(Str2)); - Assert.That(WcharTestHelpers.CheckString(Str2), Is.True); - Assert.That(WcharTestHelpers.CheckRecord(new WcharTestRec(Str1)), Is.True); - } - } -} \ No newline at end of file diff --git a/test-suite/handwritten-src/python/foo_extensible_record.py b/test-suite/handwritten-src/python/foo_extensible_record.py deleted file mode 100644 index 2a76c88..0000000 --- a/test-suite/handwritten-src/python/foo_extensible_record.py +++ /dev/null @@ -1,9 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -from foo_extensible_record_base import FooExtensibleRecordBase - -class FooExtensibleRecord(FooExtensibleRecordBase): - def ret5(self): # simple extension to a record - return 5 - diff --git a/test-suite/handwritten-src/python/foo_listener_impl.py b/test-suite/handwritten-src/python/foo_listener_impl.py deleted file mode 100644 index bdc36ba..0000000 --- a/test-suite/handwritten-src/python/foo_listener_impl.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -class FooListenerImpl: - def on_string_change(self, prs): - print ("FooListenerImpl.py: on_string_change prs", prs) - self._prs = prs - return self._prs - def get_private_int(self): - return self._pri - def on_changes_string_returned(self, i, f, s, binar, b, d): - print ("Not to be used") - def on_changes_string_optional_returned(self, i, f, s, binar, b, d): - print ("Not to be used") - def on_changes_date_returned(self, i, f, s, binar, b, d): - print ("Not to be used") - def on_changes_binary_returned(self, i, f, s, binar, b, d): - print ("Not to be used") - def on_changes_int_returned(self, i, f, s, binar, b, d): - print ("Not to be used") - def on_changes_int_optional_returned(self, i, f, s, binar, b, d): - print ("Not to be used") - def delete_fl_in_fl(self): - print ("Not to be used") - def cause_py_exception(self, s): - print ("Not to be used") - def cause_zero_division_error(self): - print ("Not to be used") - def on_changes_record_returned(self, n1, n2): - print ("Not to be used") - diff --git a/test-suite/handwritten-src/python/test_callbacks.py b/test-suite/handwritten-src/python/test_callbacks.py deleted file mode 100644 index a6dcd0e..0000000 --- a/test-suite/handwritten-src/python/test_callbacks.py +++ /dev/null @@ -1,215 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals -import pytest -import datetime -import sys -import gc -from djinni.exception import DjinniException - -from foo_listener_impl import FooListenerImpl -from foo_receiver import FooReceiver -from foo_listener import FooListenerHelper -from foo_some_other_record import FooSomeOtherRecord - -# add foo listener impl here with variable set inside -class FooListenerImpl_SimpleTest: - def __init__(self): - self._local_false = True - self._local_true = False - def on_string_change(self, prs): - self._prs = prs - self._local_false = False - self._local_true = True - return self._prs - def get_private_int(self): - return self._pri - def get_private_int_optional(self): - return self._pri - def on_changes_string_returned(self, i, f, s, binar, b, d): - print ("Not to be used") - def on_changes_string_optional_returned(self, i, f, s, binar, b, d): - print ("Not to be used") - def on_changes_date_returned(self, i, f, s, binar, b, d): - print ("Not to be used") - def on_changes_binary_returned(self, i, f, s, binar, b, d): - print ("Not to be used") - def on_changes_int_returned(self, i, f, s, binar, b, d): - print ("Not to be used") - def on_changes_int_optional_returned(self, i, f, s, binar, b, d): - print ("Not to be used") - def on_changes_record_returned(self, n1, n2): - print ("Not to be used") - def cause_py_exception(self, s): - print ("Not to be used") - def cause_zero_division_error(self): - print ("Not to be used") - -class FooListenerImpl_FullTest: - def on_string_change(self, pri, prs): - print ("Not to be used") - def get_private_int(self): - print ("Not to be used") - def get_private_int_optional(self): - print ("Not to be used") - def cause_py_exception(self, s): - print ("raising exception in cause_py_exception") - raise Exception(s) - def cause_zero_division_error(self): - raise ZeroDivisionError - def on_changes_string_returned(self, i, f, s, binar, b, d): - self._local_pri = i - self._local_prf = f - self._local_prs = s - self._local_prbin = binar - self._local_prbool = b - self._local_prdate = d - return self._local_prs - def on_changes_string_optional_returned(self, i, f, s, binar, b, d): - self._local_pri = i - self._local_prf = f - self._local_prs = s - self._local_prbin = binar - self._local_prbool = b - self._local_prdate = d - return self._local_prs - def on_changes_date_returned(self, i, f, s, binar, b, d): - self._local_pri = i - self._local_prf = f - self._local_prs = s - self._local_prbin = binar - self._local_prbool = b - self._local_prdate = d - return self._local_prdate - def on_changes_binary_returned(self, i, f, s, binar, b, d): - self._local_pri = i - self._local_prf = f - self._local_prs = s - self._local_prbin = binar - self._local_prbool = b - self._local_prdate = d - return self._local_prbin - def on_changes_int_returned(self, i, f, s, binar, b, d): - self._local_pri = i - self._local_prf = f - self._local_prs = s - self._local_prbin = binar - self._local_prbool = b - self._local_prdate = d - return self._local_pri - def on_changes_int_optional_returned(self, i, f, s, binar, b, d): - self._local_pri = i - self._local_prf = f - self._local_prs = s - self._local_prbin = binar - self._local_prbool = b - self._local_prdate = d - return self._local_pri - def on_changes_record_returned(self, n1, n2): - return FooSomeOtherRecord(n1,n2) - -def test_simple_callback_indirect(): - fr = FooReceiver.create() - fl = FooListenerImpl() - fr.add_listener(fl) - - # indirect check via returned value from receiver - s = "Hello world!" - assert fr.set_private_string(s) == s, "test_simple_callback_indirect failed" - fl = None - fr = None - gc.collect() - -def test_simple_callback_direct(): - fr = FooReceiver.create() - fl = FooListenerImpl_SimpleTest() - fr.add_listener(fl) - - s = "" - assert fr.set_private_string(s) == s - - # direct check via peek inside listener - assert fl._local_true == True and fl._local_false == False, "test_simple_callback_direct failed" - fl = None - fr = None - gc.collect() - -def fr_fl(fr, fl): - i32 = 32 # could use limit number, and add other integer - f32 = 32.0 - s = "string" - binar = b'binary' - b = True - d = datetime.datetime(2007,4,17,1,2,3) - - assert fr.cause_changes_string_returned(i32, f32, s, binar, b, d) == s, "test_full_callback failed" - assert fr.cause_changes_binary_returned(i32, f32, s, binar, b, d) == binar, "test_full_callback failed" - assert fr.cause_changes_date_returned(i32, f32, s, binar, b, d) == d, "test_full_callback failed" - assert fr.cause_changes_int_returned(i32, f32, s, binar, b, d) == i32, "test_full_callback failed" - - # non none optional - assert fr.cause_changes_string_optional_returned(i32, f32, s, binar, b, d) == s, "test_full_callback failed" - assert fr.cause_changes_int_optional_returned(i32, f32, s, binar, b, d) == i32, "test_full_callback failed" - - # direct check via peek inside listener - assert fl._local_pri == i32 and \ - fl._local_prf == f32 and \ - fl._local_prs == s and \ - fl._local_prbin == binar and \ - fl._local_prbool == b and \ - fl._local_prdate == d, "test_full_callback failed" - - # none optionals - assert fr.cause_changes_string_optional_returned(i32, f32, None, binar, b, d) is None, "test_full_callback failed" - assert fr.cause_changes_string_optional_returned(None, f32, None, binar, b, d) is None, "test_full_callback failed" - assert fr.cause_changes_int_optional_returned(None, f32, s, binar, b, d) is None, "test_full_callback failed" - assert fr.cause_changes_int_optional_returned(None, f32, None, binar, b, d) is None, "test_full_callback failed" - -def test_full_callback(): - fr = FooReceiver.create() - fl = FooListenerImpl_FullTest() - fl_opt = FooListenerImpl_FullTest() - fr.add_listener(fl) - fr_fl(fr,fl) - - fr.add_optional_listener(fl_opt) - fr_fl(fr,fl_opt) - - fr.add_optional_listener(None) - assert fr.get_optional_listener() is None, "test_full_callback failed" - - fl = None - gc.collect() - fr = None - gc.collect() - assert 0 == len(FooListenerHelper.c_data_set), "test_full_callback failed" - -def test_exceptions(): - fr = FooReceiver.create() - exception_arg = "cpp_impl_error!" - - # pytest.raises(RuntimeError(exception_arg), fr.cause_cpp_exception, exception_arg) # tried to simplify like this, did not work yet - - # CAUSE CUSTOM EXCEPTION in CPP IMPLEMENTATION - try: - fr.cause_cpp_exception(exception_arg) - except DjinniException as e: - # Note: fully checking exception equality requires type check as well; not sure if needed for our purposes - assert e.args == DjinniException(exception_arg).args - - fl = FooListenerImpl_FullTest() - fr.add_listener(fl) - - # CAUSE CUSTOM EXCEPTION in PY IMPLEMENTATION - exception_arg = "py_impl_error!" - try: - fr.cause_py_exception(exception_arg) - except Exception as e: - # Note: fully checking exception equality requires type check as well; not sure if needed for our purposes - assert e.args == Exception(exception_arg).args - - # CAUSE REGULAR PY EXCEPTION IN PY - pytest.raises(ZeroDivisionError, fr.cause_zero_division_error) - - from djinni.exception import ExceptionHelper - assert len(ExceptionHelper.c_data_set) == 0 - diff --git a/test-suite/handwritten-src/python/test_client_interface.py b/test-suite/handwritten-src/python/test_client_interface.py deleted file mode 100644 index b76815c..0000000 --- a/test-suite/handwritten-src/python/test_client_interface.py +++ /dev/null @@ -1,125 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals -import pytest -import gc -import sys -sys.path.append("/Users/iuliatamas/djinni/test-suite/generated-src/python") -# print (sys.path) - -from foo_client_interface import FooClientInterface -from foo_client_returned_record import FooClientReturnedRecord -from foo_some_other_record import FooSomeOtherRecord -from foo_extensible_record import FooExtensibleRecord - -# TODO rename this test to something more suggestive - -def test_client_returned_record(): - ci = FooClientInterface.create() - - number1 = 10 - number2 = -10 - some_record = FooSomeOtherRecord(number1, number2) - - record_id = 28 - content = "Hello World" - set_rec = FooClientReturnedRecord(record_id, content, some_record) - - ci.set_record(set_rec) - get_rec = ci.get_record() - - assert set_rec.record_id == record_id and \ - set_rec.content == content and \ - set_rec.some_record.__dict__ == some_record.__dict__ - - print ("Forcing garbage collection in test_client_interface_py") - set_rec = None - get_rec = None - some_record = None - gc.collect() - - FooClientReturnedRecord.check_c_data_set_empty() - FooSomeOtherRecord.check_c_data_set_empty() - -def eq_neq(rec_1a, rec_1b, rec_1c, rec_less_1, rec_greater_1): - assert rec_1a == rec_1b and rec_1b == rec_1c and \ - rec_1a != rec_less_1 and rec_less_1 != rec_1a and \ - rec_1a != rec_greater_1 and rec_greater_1 != rec_1a, "test_client_returned_record_derivings failed" - -def lt_gt(rec_less_1, rec_1a): - assert rec_less_1.__lt__(rec_1a) and \ - rec_1a.__gt__(rec_less_1), "test_client_returned_record_derivings failed" - -def test_client_returned_record_derivings(): - number1 = 10 - number2 = 20 - some_record_1a = FooSomeOtherRecord(number1, number2) - some_record_1b = FooSomeOtherRecord(number1, number2) - some_record_1c = some_record_1a - - some_record_less_1 = FooSomeOtherRecord(number1 -2, number2) - some_record_less_2 = FooSomeOtherRecord(number1 , number2 -2) - some_record_greater_1 = FooSomeOtherRecord(number1 +2, number2) - some_record_greater_2 = FooSomeOtherRecord(number1 +2, number2 -2) - - eq_neq(some_record_1a, some_record_1b, some_record_1c, some_record_less_1, some_record_greater_1) - lt_gt(some_record_less_1, some_record_1a) - lt_gt(some_record_less_2, some_record_1a) - - pytest.raises(AssertionError, lt_gt, some_record_greater_2, some_record_1a) - - record_id = 28 - content = "Hello World" - rec_1a = FooClientReturnedRecord(record_id, content, some_record_1a) - rec_1b = FooClientReturnedRecord(record_id, content, some_record_1b) - rec_1c = rec_1a - - rec_less_1 = FooClientReturnedRecord(record_id - 2, content, some_record_1a) - rec_less_2 = FooClientReturnedRecord(record_id, "A " + content, some_record_1a) - rec_less_3 = FooClientReturnedRecord(record_id, content, some_record_less_1) - rec_greater_1 = FooClientReturnedRecord(record_id + 2, content, some_record_1b) - - eq_neq(rec_1a, rec_1b, rec_1c, rec_less_1, rec_greater_1) - lt_gt(rec_less_1, rec_1a) - lt_gt(rec_less_2, rec_1a) - lt_gt(rec_less_3, rec_1a) - -def test_extensible_record(): - ci = FooClientInterface.create() - - number1 = 10 - number2 = 1 - string1 = "hello" - string2 = "does not matter" - set_rec = FooExtensibleRecord(number1, string1) - set_rec.number2 = number2 # to confirm it does not matter we are sending extended rather than base record - set_rec.string2 = string2 # to confirm it does not matter we are sending extended rather than base record - - ci.set_extensible_record(set_rec) - got_rec = ci.get_extensible_record() - - assert ci.get_extensible_record_number2() == number1 * 2, "test_extensible_record failed" - assert ci.get_extensible_record_string2() == string1 + string1, "test_extensible_record failed" - - assert set_rec.number1 == got_rec.number1 and\ - set_rec.string1 == got_rec.string1 and\ - set_rec.number2 == number2 and \ - set_rec.string2 == string2, "test_extensible_record failed" - - # Check that we can call method specific to extended record - assert isinstance(set_rec, FooExtensibleRecord) - assert isinstance(got_rec, FooExtensibleRecord) - assert set_rec.ret5() == 5, "test_extensible_record failed" - assert got_rec.ret5() == 5, "test_extensible_record failed" - - -''' - # more things I could potentially test - - some_record_greater_2 = FooSomeOtherRecord(number1, number2 +2) - rec_greater_2 = FooClientReturnedRecord(record_id, "z " + content, some_record_1b) - rec_greater_3 = FooClientReturnedRecord(record_id, content, some_record_greater_1) - - # get_record_with_fields(record_id: i64, utf8string: string): foo_client_returned_record; - # return_str(): string; - -''' diff --git a/test-suite/handwritten-src/python/test_constants.py b/test-suite/handwritten-src/python/test_constants.py deleted file mode 100644 index be642b2..0000000 --- a/test-suite/handwritten-src/python/test_constants.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -from foo_constants import FooConstants -from foo_constants_interface import FooConstantsInterface - -def test_record_consts(): - assert FooConstants.BOOL_CONSTANT == True - assert FooConstants.I8_CONSTANT == 1 - assert FooConstants.I16_CONSTANT == 2 - assert FooConstants.I32_CONSTANT == 3 - assert FooConstants.I64_CONSTANT == 4 - assert FooConstants.F32_CONSTANT == 5.0 - assert FooConstants.F64_CONSTANT == 6.0 - assert FooConstants.STRING_CONSTANT == "string-constant" - assert FooConstants.OPTIONAL_INTEGER_CONSTANT == 1 - - assert FooConstants.OBJECT_CONSTANT.some_integer == FooConstants.I32_CONSTANT - assert FooConstants.OBJECT_CONSTANT.some_string == FooConstants.STRING_CONSTANT - - assert FooConstants.SOME_RECORD.number1 == 28 - assert FooConstants.SOME_RECORD.number2 == FooConstants.I16_CONSTANT - -def test_interface_consts(): - assert FooConstantsInterface.BOOL_CONSTANT == True - assert FooConstantsInterface.I8_CONSTANT == 1 - assert FooConstantsInterface.I16_CONSTANT == 2 - assert FooConstantsInterface.I32_CONSTANT == 3 - assert FooConstantsInterface.I64_CONSTANT == 4 - assert FooConstantsInterface.F32_CONSTANT == 5.0 - assert FooConstantsInterface.F64_CONSTANT == 6.0 - assert FooConstantsInterface.STRING_CONSTANT == "another-string-constant" - assert FooConstantsInterface.OPTIONAL_INTEGER_CONSTANT == 1 - - assert FooConstantsInterface.OBJECT_CONSTANT.some_integer == FooConstantsInterface.I32_CONSTANT - assert FooConstantsInterface.OBJECT_CONSTANT.some_string == FooConstantsInterface.STRING_CONSTANT diff --git a/test-suite/handwritten-src/python/test_containers_interface.py b/test-suite/handwritten-src/python/test_containers_interface.py deleted file mode 100644 index e9af2f4..0000000 --- a/test-suite/handwritten-src/python/test_containers_interface.py +++ /dev/null @@ -1,212 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals -import datetime -import gc -import pytest -import sys -sys.path.append("/Users/iuliatamas/djinni/test-suite/generated-src/python") -# print (sys.path) - -from foo_containers_interface import FooContainersInterface -from foo_containers_record import FooContainersRecord -from foo_some_other_record import FooSomeOtherRecord - -def set_get(ci, optional_list_int, list_int, list_binary, list_optional_binary, list_list_string, - list_record, optional_map_string_int, map_string_int, map_string_string, map_optional_string_optional_string, map_int_list_date, - optional_set_string, set_string, set_optional_string, map_int_set_string, map_optional_int_set_string): - - set_rec = FooContainersRecord(optional_list_int, list_int, list_binary, list_binary, list_list_string, \ - list_record, optional_map_string_int, map_string_int, map_string_string, map_string_string, map_int_list_date, \ - optional_set_string, set_string, set_string, map_int_set_string, map_optional_int_set_string) - - ci.set_containers_record(set_rec) - get_rec = ci.get_containers_record() - eq(set_rec, get_rec) - -def set_get_optional(ci, optional_list_int, list_int, list_binary, list_optional_binary, list_list_string, - list_record, optional_map_string_int, map_string_int, map_string_string, map_optional_string_optional_string, map_int_list_date, - optional_set_string, set_string, set_optional_string, map_int_set_string, map_optional_int_set_string): - - set_rec = FooContainersRecord(optional_list_int, list_int, list_binary, list_binary, list_list_string, \ - list_record, optional_map_string_int, map_string_int, map_string_string, map_string_string, map_int_list_date, \ - optional_set_string, set_string, set_string, map_int_set_string, map_optional_int_set_string) - - ci.set_optional_containers_record(set_rec) - get_rec = ci.get_optional_containers_record() - eq(set_rec, get_rec) - -# TODO: add some informative messafe to assert fail -def eq(set_rec, get_rec): - if set_rec.optional_list_int is None: - assert get_rec.optional_list_int is None - else: - assert set_rec.optional_list_int == get_rec.optional_list_int - - if set_rec.optional_map_string_int is None: - assert get_rec.optional_map_string_int is None - else: - assert set_rec.optional_map_string_int == get_rec.optional_map_string_int - - if set_rec.optional_set_string is None: - assert get_rec.optional_set_string is None - else: - assert set_rec.optional_set_string == get_rec.optional_set_string - - assert set_rec.list_int == get_rec.list_int and \ - set_rec.list_binary == get_rec.list_binary and \ - set_rec.map_optional_string_optional_string == get_rec.map_optional_string_optional_string and \ - set_rec.list_list_string == get_rec.list_list_string and \ - set_rec.map_string_int == get_rec.map_string_int and \ - set_rec.map_string_string == get_rec.map_string_string and \ - set_rec.map_int_list_date == get_rec.map_int_list_date and \ - set_rec.set_string == get_rec.set_string and \ - set_rec.set_optional_string == get_rec.set_optional_string and \ - set_rec.map_int_set_string == get_rec.map_int_set_string and \ - set_rec.map_optional_int_set_string == get_rec.map_optional_int_set_string and \ - set_rec.list_optional_binary == get_rec.list_optional_binary #and \ - # set_rec.set_record == get_rec.set_record - - for i, s_r in enumerate(set_rec.list_record): - assert s_r.__dict__ == get_rec.list_record[i].__dict__ - -def test_set_get_record(): - ci = FooContainersInterface.create() - - optional_list_int = None - list_int = list([5,6,7,8,9]) - list_int_2 = list_int # possible to use same list as argument twice, as we use multiset - list_binary = list([b'some_binary', b'some_other_binary']) - list_string1 = list(['hi', '', 'bye']) - list_string2 = list(['hi2', '', 'bye2']) - list_list_string = list([list_string1, list_string2]) - number1 = 10 - number2 = -10 - some_record_1 = FooSomeOtherRecord(number1, number2) - some_record_2 = FooSomeOtherRecord(number1 * 2, number2 * 2) - list_record = list([some_record_1, some_record_2]) - set_record = set([some_record_1, some_record_1]) - optional_map_string_int = None - map_string_int = dict([('josh', 4139), ('anna', 4127), ('jack', 4098)]) - map_string_string = dict([('josh', 'val1'), ('anna', 'val2'), ('jack', 'val3')]) - list_date1 = list([datetime.datetime(2007,4,17,1,2,3)]) - list_date2 = list([datetime.datetime(2007,4,17,1,2,4)]) - map_int_list_date = dict([(18, list_date1), (5, list_date2)]) - optional_set_string = None - set_string = set(['hi', 'bye']) - map_int_set_string = dict([(18, set_string)]) - map_optional_int_set_string = dict([(18, set_string), (None, set_string)]) - list_optional_binary = list([b'some_binary', None]) - map_optional_string_optional_string = dict([('anna', None), (None, None)]) - set_optional_string = set(['hi', None]) - # set_record = set(list[some_record_1, some_record_2]) - - # Passing optional list as argument - ci.set_optional_list_int(list_int) - assert ci.get_optional_list_int() == list_int - ci.set_optional_list_int(None) - assert ci.get_optional_list_int() is None - - # Passing optional map as argument - ci.set_optional_map_string_int(map_string_int) - assert ci.get_optional_map_string_int() == map_string_int - ci.set_optional_map_string_int(None) - assert ci.get_optional_map_string_int() is None - - # Passing non-Nones for the optional arguments - set_get(ci, list_int_2, list_int, list_binary, list_binary, list_list_string, \ - list_record, map_string_int, map_string_int, map_string_string, map_string_string, map_int_list_date, \ - set_string, set_string, set_string, map_int_set_string, map_optional_int_set_string) - - set_get(ci, list(), list(), list(), list(), list(list()), list(), dict(), dict(), dict(), dict(), dict(), set(), set(), set(), dict(), dict()) - - # Passing Nones for the optional arguments - set_get(ci, optional_list_int, list_int, list_binary, list_optional_binary, list_list_string, \ - list_record, optional_map_string_int, map_string_int, map_string_string, map_optional_string_optional_string, map_int_list_date, \ - optional_set_string, set_string, set_optional_string, map_int_set_string, map_optional_int_set_string) - - # Passing non-None for optional record argument - set_get_optional(ci, list(), list(), list(), list(), list(list()), list(), dict(), dict(), dict(), dict(), dict(), set(), set(), set(), dict(), dict()) - set_get_optional(ci, optional_list_int, list_int, list_binary, list_optional_binary, list_list_string, \ - list_record, optional_map_string_int, map_string_int, map_string_string, map_optional_string_optional_string, map_int_list_date, \ - optional_set_string, set_string, set_optional_string, map_int_set_string, map_optional_int_set_string) - - # Passing None for optional record argument - ci.set_optional_containers_record(None) - get_rec = ci.get_optional_containers_record() - assert get_rec is None - - print ("Forcing garbage collection") - set_rec = None - get_rec = None - some_record_2 = None - some_record_1 = None - list_record = None - # set_record = None - list_string1 = None - list_string2 = None - list_list_string = None - - list_date1 = None - list_date2 = None - map_int_list_date = None - gc.collect() - - FooContainersRecord.check_c_data_set_empty() - FooSomeOtherRecord.check_c_data_set_empty() - - # print ("GOT MAP ", get_rec._map_string_int) - # TODO: more tests: ex: map_binary_list_record - - # print ("got ", get_rec) - # print ("_list_list_string", get_rec._list_list_string) - # print ("_list_optional_binary", get_rec._list_optional_binary) - # print ("_map_opt_str_opt_str", set_rec._map_optional_string_optional_string, get_rec._map_optional_string_optional_string, map_optional_string_optional_string) - # print ("_list_record", get_rec._list_record) - -def test_set_get_list(): - ci = FooContainersInterface.create() - - list_binary = list([b'binary_test', b'']) - - ci.set_list_binary(list_binary) - assert ci.get_list_binary() == list_binary - # print ("_list_binary", ci.get_list_binary()) - -''' -def test_set_get_list(): - # TODO: good closer to complete test, for when time allows - ci = FooContainersInterface.create() - - list_int = list([5,6,7,8,9]) - list_binary = list([b'some_binary', b'some_other_binary']) - - list_string1 = list(['hi', '', 'bye']) - list_string2 = list(['hi2', '', 'bye2']) - list_list_string = list([list_string1, list_string2]) - - number1 = 10 - number2 = -10 - some_record_1 = FooSomeOtherRecord(number1, number2) - some_record_2 = FooSomeOtherRecord(number1 * 2, number2 * 2) - list_record = list([some_record_1, some_record_2]) - - ci.set_list_int(list_int) - assert ci.get_list_int == list_int - - ci.set_list_binary(list_binary) - assert ci.get_list_binary == list_binary - - ci.set_list_string(list_string) - assert ci.get_list_string == list_string - - ci.set_list_record(list_record) - get_list_record = ci.get_list_record - for i, s_r in enumerate(list_record): - assert s_r.__dict__ == get_list_record[i].__dict__ - -''' - -''' - set_list_int(lb: list); - get_list_int(): list; -''' diff --git a/test-suite/handwritten-src/python/test_enum_interface.py b/test-suite/handwritten-src/python/test_enum_interface.py deleted file mode 100644 index 9f9b298..0000000 --- a/test-suite/handwritten-src/python/test_enum_interface.py +++ /dev/null @@ -1,55 +0,0 @@ -# Example code written by a python developer to access cpp implementation of Foo -# This file should be hand-written by a python developer -from foo_enum_interface import FooEnumInterface -from color import Color - -def get_set(foo, colorInt, colorString): - color_enum = Color(colorInt) - assert color_enum == colorInt and color_enum.value == colorInt and isinstance(color_enum.value, int) and \ - color_enum.name == colorString and isinstance(color_enum.name, str), "test_color failed construction" - - foo.set_enum(color_enum) - got_enum = foo.get_enum() - assert got_enum == color_enum and got_enum == colorInt and isinstance(got_enum, Color) and\ - isinstance(color_enum, Color), "test_color get/set failed" - - # It should work for ints too, to allow duck typing - foo.set_enum(colorInt) - got_enum = foo.get_enum() - assert got_enum == color_enum and got_enum == colorInt and isinstance(got_enum, Color) and \ - isinstance(color_enum, Color), "test_color get/set int failed" - -def get_set_optional(foo, colorInt, colorString): - color_enum = Color(colorInt) - assert color_enum.value == colorInt and \ - color_enum.name == colorString - - foo.set_optional_enum(color_enum) - assert foo.get_optional_enum() == color_enum - -def test_color(): - Red, Orange, Yellow, Green, Blue, Indigo, Violet = range(7) - foo = FooEnumInterface.create() - - get_set(foo, Red, "Red") - get_set(foo, Green, "Green") - get_set(foo, Violet, "Violet") - - # Test default enum __hash__ function works as expected - color_set = set() - - color_green_1 = Color(Green) - color_green_2 = Color(Green) - color_set.add(color_green_1) - color_set.add(color_green_2) - assert len(color_set) == 1, "test_color failed" - - color_set.add(Color(Red)) - assert len(color_set) == 2, "test_color failed" - get_set_optional(foo, Red, "Red") - get_set_optional(foo, Green, "Green") - get_set_optional(foo, Violet, "Violet") - - foo.set_optional_enum(None) - assert foo.get_optional_enum() is None - diff --git a/test-suite/handwritten-src/python/test_foo_interface.py b/test-suite/handwritten-src/python/test_foo_interface.py deleted file mode 100644 index 285fac9..0000000 --- a/test-suite/handwritten-src/python/test_foo_interface.py +++ /dev/null @@ -1,134 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -# Example code written by a python developer to access cpp implementation of Foo -# This file should be hand-written by a python developer - - -from foo_interface import FooInterface -from djinni.support import decoded_utf_8 -import sys -PYTHON3 = sys.version_info[0] >= 3 - -def test_ints(): - foo = FooInterface.create() - iSet = 8 - foo.set_private_int32(iSet) - assert iSet == foo.get_private_int32(), "TestInts failed" - - iSet = 18 - foo.set_private_int32(foo.int32_inverse(iSet)) - assert -iSet == foo.get_private_int32(), "TestInts failed" - - #foo.__del__() - #assert 0 == 1 - print ("TestInts succeeded") - -def test_interface_as_return_value(): - foo = FooInterface.create() - foo_primitives = foo.get_foo_primitives() - - # Test a foo_primitives specific feature (impl of bools) works - b = True - foo_primitives.set_bool(b) - assert b == foo_primitives.get_bool(), "test_bool failed" - - b = False - foo_primitives.set_bool(b) - assert b == foo_primitives.get_bool(), "test_bool failed" - - -# Can set: unicode strings (python 2 and 3), bytes utf-8 encoded (python 3) -# Will get: utf-8 encoded strings, and utf-8 encoded bytes respectively -DECODEUtf8 = 1 -def test_strings(): - foo = FooInterface.create() - strs = dict([ - # PYTHON 2 and 3 unicode strings - (u"", not DECODEUtf8), - (u"my\0text", not DECODEUtf8), - (u"the best text", not DECODEUtf8), - (u"my \b friend", not DECODEUtf8), - #"Non-ASCII / 非 ASCII 字符" - (u"Non-ASCII / \xe9\x9d\x9e ASCII \xe5\xad\x97\xe7\xac\xa6", not DECODEUtf8), - (u"Non-ASCII / \u975e ASCII \u5b57\u7b26", not DECODEUtf8) - ]) - if PYTHON3: - strs.update({ - chr(40960) + u'abcd' + chr(1972) + u"\0\bhi": not DECODEUtf8, #unicode string - bytes(chr(40960) + u'abcd' + chr(1972) + u"\0\bhi", 'utf-8'): DECODEUtf8 # bytes utf-8 encoded - }) - else: - strs.update({ - unichr(40960) + u'abcd' + unichr(1972) + u"\0\bhi": not DECODEUtf8, #unicode string for python 2 - }) - - for sSet, decode in strs.items(): - foo.set_private_string(sSet) - - sSetUnicode = sSet - if decode: - sSetUnicode = decoded_utf_8(sSet) - sGetUnicode = foo.get_private_string() - - # print ("client SetPrs=", sSetUnicode, ".", len(sSetUnicode), List(sSetUnicode) ) - # print ("client GetPrs=", sGetUnicode, ".", len(sGetUnicode), List(sGetUnicode)) - assert sSetUnicode == sGetUnicode - - print ("TestStrings succeeded") - -def test_abc_direct_instantiate(): - try: - f = FooInterface() - assert False, "Instantiated abstract base class" - except: - pass - -def test_abc_subclass_instantiate(): - class FooInterfaceSub(FooInterface): - pass - try: - dummy = FooInterfaceSub() - assert False, "Instantiated abstract base class" - except TypeError: - pass - -def test_abc_missing_method_instantiate(): - class FooInterfaceSub(FooInterface): - def int32_inverse(self, x): - pass - def set_private_int32(self, private_int): - pass - def get_private_int32(self): - pass - def set_private_string(self, private_string): - pass - #def get_private_string(self): - # pass - def get_set_strings(self, ps1, ps2): - pass - def get_foo_primitives(self): - pass - try: - dummy = FooInterfaceSub() - assert False, "Instantiated abstract base class" - except TypeError: - pass - -def test_abc_successful_instantiate(): - class FooInterfaceSub(FooInterface): - def int32_inverse(self, x): - pass - def set_private_int32(self, private_int): - pass - def get_private_int32(self): - pass - def set_private_string(self, private_string): - pass - def get_private_string(self): - pass - def get_set_strings(self, ps1, ps2): - pass - def get_foo_primitives(self): - pass - dummy = FooInterfaceSub() diff --git a/test-suite/handwritten-src/python/test_foo_primitives.py b/test-suite/handwritten-src/python/test_foo_primitives.py deleted file mode 100644 index cbb118f..0000000 --- a/test-suite/handwritten-src/python/test_foo_primitives.py +++ /dev/null @@ -1,168 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals -import pytest -# Example code written by a python developer to access cpp implementation of Foo -# This file should be hand-written by a python developer - -from foo_primitives import FooPrimitives -from djinni.support import decoded_utf_8 -import datetime -import sys -PYTHON3 = sys.version_info[0] >= 3 - -from PyCFFIlib_cffi import lib - -# testing climits: http://www.cplusplus.com/reference/climits/ -def test_int8(): - foo = FooPrimitives.create() - - min_i8 = -128 - foo.set_int8(min_i8) - assert min_i8 == foo.get_int8(), "test_ints failed" - max_i8 = 127 - foo.set_int8(max_i8) - assert max_i8 == foo.get_int8(), "test_ints failed" - - pytest.raises(OverflowError, foo.set_int8, min_i8 - 1) - pytest.raises(OverflowError, foo.set_int8, max_i8 + 1) - -# testing climits: http://www.cplusplus.com/reference/climits/ -def test_int16(): - foo = FooPrimitives.create() - - min_i16 = -32768 - foo.set_int16(min_i16) - assert min_i16 == foo.get_int16(), "test_ints failed" - max_i16 = 32767 - foo.set_int16(max_i16) - assert max_i16 == foo.get_int16(), "test_ints failed" - - pytest.raises(OverflowError, foo.set_int16, min_i16 - 1) - pytest.raises(OverflowError, foo.set_int16, max_i16 + 1) - -def test_int32(): - foo = FooPrimitives.create() - - min_i32 = -2147483648 - foo.set_int32(min_i32) - assert min_i32 == foo.get_int32(), "test_ints failed" - max_i32 = 2147483647 - foo.set_int32(max_i32) - assert max_i32 == foo.get_int32(), "test_ints failed" - - pytest.raises(OverflowError, foo.set_int32, min_i32 - 1) - pytest.raises(OverflowError, foo.set_int32, max_i32 + 1) - -def test_int64(): - foo = FooPrimitives.create() - - min_i64 = -9223372036854775808 - foo.set_int64(min_i64) - assert min_i64 == foo.get_int64(), "test_ints failed" - max_i64 = 9223372036854775807 - foo.set_int64(max_i64) - assert max_i64 == foo.get_int64(), "test_ints failed" - - pytest.raises(OverflowError, foo.set_int64, min_i64 - 1) - pytest.raises(OverflowError, foo.set_int64, max_i64 + 1) - -def test_float(): - foo = FooPrimitives.create() - - min_f32 = lib.min_f32_t() - foo.set_float(min_f32) - assert min_f32 == foo.get_float(), "test_float failed" - max_f32 = lib.max_f32_t() - foo.set_float(max_f32) - assert max_f32 == foo.get_float(), "test_float failed" - - -def test_double(): - foo = FooPrimitives.create() - - min_f64 = lib.min_f64_t() - foo.set_double(min_f64) - assert min_f64 == foo.get_double(), "test_double failed" - max_f64 = lib.max_f64_t() - foo.set_double(max_f64) - assert max_f64 == foo.get_double(), "test_double failed" - - -def test_binary(): - foo = FooPrimitives.create() - b = b'' - foo.set_binary(b) - bGet = foo.get_binary() - assert b == bGet, "test_binary failed" - assert type(bGet) is bytes - - b = b'123g' - foo.set_binary(b) - bGet = foo.get_binary() - assert b == bGet, "test_binary failed" - assert type(bGet) is bytes - -def test_bool(): - foo = FooPrimitives.create() - b = True - foo.set_bool(b) - assert b == foo.get_bool(), "test_bool failed" - - b = False - foo.set_bool(b) - assert b == foo.get_bool(), "test_bool failed" - -def test_date(): - epoch = datetime.datetime.utcfromtimestamp(0) - - foo = FooPrimitives.create() - d = datetime.datetime(2007,4,17,1,2,3) - foo.set_date(d) - assert d == foo.get_date(), "test_date failed" - - for i in range(100): # more reliable - d = datetime.datetime.now() - d = d.replace(microsecond = (d.microsecond // 1000) * 1000) # our precision is millisecond level - - foo.set_date(d) - assert d == foo.get_date(), "test_date failed" - - -# Can set: unicode strings (python 2 and 3), bytes utf-8 encoded (python 3) -# Will get: utf-8 encoded strings, and utf-8 encoded bytes respectively -DECODEUtf8 = 1 -def test_strings(): - foo = FooPrimitives.create() - strs = dict([ - # PYTHON 2 and 3 unicode strings - (u"", not DECODEUtf8), - (u"my\0text", not DECODEUtf8), - (u"the best text", not DECODEUtf8), - (u"my \b friend", not DECODEUtf8), - #"Non-ASCII /\0 非 ASCII 字符" - (u"Non-ASCII /\0 \xe9\x9d\x9e ASCII \xe5\xad\x97\xe7\xac\xa6", not DECODEUtf8), - (u"Non-ASCII /\0 \u975e ASCII \u5b57\u7b26", not DECODEUtf8) - ]) - if PYTHON3: - strs.update({ - chr(40960) + u'abcd' + chr(1972) + u"\0\bhi": not DECODEUtf8, #unicode string - bytes(chr(40960) + u'abcd' + chr(1972) + u"\0\bhi", 'utf-8'): DECODEUtf8 # bytes utf-8 encoded - }) - else: - strs.update({ - unichr(40960) + u'abcd' + unichr(1972) + u"\0\bhi": not DECODEUtf8, #unicode string for python 2 - }) - - for sSet, decode in strs.items(): - foo.set_string(sSet) - - sSetUnicode = sSet - if decode: - sSetUnicode = decoded_utf_8(sSet) - sGetUnicode = foo.get_string() - - # print ("client SetPrs=", sSetUnicode, ".", len(sSetUnicode), List(sSetUnicode) ) - # print ("client GetPrs=", sGetUnicode, ".", len(sGetUnicode), List(sGetUnicode)) - assert sSetUnicode == sGetUnicode - - diff --git a/test-suite/handwritten-src/python/test_foo_static.py b/test-suite/handwritten-src/python/test_foo_static.py deleted file mode 100644 index b5916a6..0000000 --- a/test-suite/handwritten-src/python/test_foo_static.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -from foo_static import FooStatic - -import datetime - -def test_static_counter(): - FooStatic.update_static_counter_to(100) # 100 - FooStatic.update_static_counter_by(1) # 101 - FooStatic.update_static_counter_by(2) # 103 - FooStatic.update_static_counter_by(3) # 106 - assert FooStatic.update_static_counter_by(4) == 110, "test_static_counter failed" - assert FooStatic.get_static_counter() == 110, "test_static_counter failed" - -def test_static_message(): - assert FooStatic.update_static_messg_to("hello world") == "hello world", "test_static_message failed" - assert FooStatic.get_static_messg() == "hello world", "test_static_message failed" - - assert FooStatic.update_static_messg_to("") == "", "test_static_message failed" - assert FooStatic.get_static_messg() == "", "test_static_message failed" - -def test_static_date(): - val = datetime.datetime(2015, 9, 12) - assert val == FooStatic.date_id(val), "test_static_date failed" - -def test_static_opt_date(): - val = datetime.datetime(2015, 9, 12) - assert val == FooStatic.opt_date_id(val), "test_static_opt_date failed" - - #assert FooStatic.opt_date_id(None) is None, "test_static_opt_date failed" diff --git a/test-suite/handwritten-src/python/test_multiple_inheritance.py b/test-suite/handwritten-src/python/test_multiple_inheritance.py deleted file mode 100644 index f1c453d..0000000 --- a/test-suite/handwritten-src/python/test_multiple_inheritance.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -from listener_caller import ListenerCaller -from first_listener import FirstListener -from second_listener import SecondListener - -from return_one import ReturnOne -from return_two import ReturnTwo - -class MultiListenerImpl(FirstListener, SecondListener): - def __init__(self): - self.first_called = False - self.second_called = False - - def first(self): - self.first_called = True - - def second(self): - self.second_called = True - -def test_multiple_inheritance_in_python(): - listener = MultiListenerImpl() - caller = ListenerCaller.init(listener, listener) - - assert not listener.first_called - assert not listener.second_called - - caller.callFirst() - - assert listener.first_called - assert not listener.second_called - - caller.callSecond() - - assert listener.first_called - assert listener.second_called - -def test_multiple_inheritance_in_cpp(): - return_one = ReturnOne.get_instance() - assert return_one.return_one() == 1 - - return_two = ReturnTwo.get_instance() - assert return_two.return_two() == 2 diff --git a/test-suite/handwritten-src/python/test_proxying.py b/test-suite/handwritten-src/python/test_proxying.py deleted file mode 100644 index 20dd7c7..0000000 --- a/test-suite/handwritten-src/python/test_proxying.py +++ /dev/null @@ -1,123 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -from foo_receiver import FooReceiver -from foo_listener_bf import FooListenerBfHelper -from PyCFFIlib_cffi import ffi, lib -import gc - -class FooListenerBfImpl: - def delete_fl_in_fl(self): - print ("Not to be used") - def on_string_change(self, prs): - print ("FooListenerImpl.py: on_string_change prs", prs) - self._prs = prs - return self._prs - def get_string(self): - return self._prs - def set_listener_bf(self,fl): - self._fl = fl - def get_listener_bf(self): - return self._fl - def set_binary(self,b): - print ("setting Binary in FooListenerBfImpl ", b) - self._b = b - def get_binary(self): - return self._b - def send_return(self,fl): - return fl - -def fr_set_get(fr, fl, s): - fr.add_listener_bf(fl) - assert fr.set_private_bf_string(s) == s, "test_interface_back_forth failed" - # assert fl._prs == s, "test_interface_back_forth failed" - assert fr.get_listener_bf_string() == s, "test_interface_back_forth failed" - -# back and forth via regular calls from python to cpp -def test_interface_back_forth(): - print ("start test len ", len(FooListenerBfHelper.c_data_set)) - fr = FooReceiver.create() - fl = FooListenerBfImpl() # python implementation of listener - fl_cpp = fr.get_foo_listener_bf() # cpp implementation of listener - - # both direct and indirect test for python impl of FooListenerBf - fr_set_get(fr, fl, "Hello world!") - - # both direct and indirect test for cpp impl of FooListenerBf - fr_set_get(fr, fl_cpp, "Goodbye world!") - fr_set_get(fr, fl_cpp, "Goodbye world!") - # send python implementation back and forth and see that it can still be used, and that no wrapper was added - fl_1 = fr.send_return(fl) - fl_2 = fr.send_return(fl_1) - fr_set_get(fr, fl_2, "Hello") - assert fl == fl_1 and fl_1 == fl_2, "test_interface_back_forth failed" - - # send cpp implementation back and forth and see that is can still be used, and handles hold same implementation - fl_cpp_1 = fr.send_return(fl_cpp) - fl_cpp_2 = fr.send_return(fl_cpp_1) - fr_set_get(fr, fl_cpp_2, "Goodbye") - assert lib.equal_handles_cw__foo_listener_bf(fl_cpp._cpp_impl, fl_cpp_1._cpp_impl) and \ - lib.equal_handles_cw__foo_listener_bf(fl_cpp_1._cpp_impl, fl_cpp_2._cpp_impl) - - fl = fl_1 = fl_2 = fl_cpp = fl_cpp_1 = fl_cpp_2 = None - gc.collect() - fr = None - gc.collect() - assert 0 == len(FooListenerBfHelper.c_data_set) - -def fr_fl_set_get(fr, fl_in_fl, b): - fr.set_listener_bf_in_listener_bf(fl_in_fl) - fr.set_binary_in_listener_bf_in_listener_bf(b) - assert b == fr.get_binary_in_listener_bf_in_listener_bf(), "test_interface_back_forth failed" - -# back and forth via callbacks cpp to python -def test_interface_callback_back_forth(): - fr = FooReceiver.create() - fl = FooListenerBfImpl() - fr.add_listener_bf(fl) - - fl_in_fl = FooListenerBfImpl() - b = b'Some Binary 11' - fr_fl_set_get(fr, fl_in_fl, b) # listener 1 in python, listener 2 in python - fl_in_fl_1 = fr.in_listener_bf_send_return(fl_in_fl) - fl_in_fl_2 = fr.in_listener_bf_send_return(fl_in_fl_1) - assert fl_in_fl == fl_in_fl_1 and fl_in_fl_1 == fl_in_fl_2, "test_interface_back_forth failed" - fr_fl_set_get(fr, fl_in_fl_2, b) # listener 1 in python, listener 2 in python after back&forth - - fl_in_fl = fr.get_foo_listener_bf() - b = b'Some Other Binary 12' - fr_fl_set_get(fr, fl_in_fl, b) # listener 1 in python, listener 2 in cpp - fl_in_fl_1 = fr.in_listener_bf_send_return(fl_in_fl) - fl_in_fl_2 = fr.in_listener_bf_send_return(fl_in_fl_1) - assert lib.equal_handles_cw__foo_listener_bf(fl_in_fl._cpp_impl, fl_in_fl_1._cpp_impl) and \ - lib.equal_handles_cw__foo_listener_bf(fl_in_fl_1._cpp_impl, fl_in_fl_2._cpp_impl) - fr_fl_set_get(fr, fl_in_fl_2, b) # listener 1 in python, listener 2 in cpp after back&forth - - - fl = fr.get_foo_listener_bf() - fr.add_listener_bf(fl) - - fl_in_fl = FooListenerBfImpl() - b = b'Some Binary 21' - fr_fl_set_get(fr, fl_in_fl, b) # listener 1 in cpp, listener 2 in python - fl_in_fl_1 = fr.in_listener_bf_send_return(fl_in_fl) - fl_in_fl_2 = fr.in_listener_bf_send_return(fl_in_fl_1) - assert fl_in_fl == fl_in_fl_1 and fl_in_fl_1 == fl_in_fl_2, "test_interface_back_forth failed" - fr_fl_set_get(fr, fl_in_fl_2, b) # listener 1 in cpp, listener 2 in python after back&forth - - - fl_in_fl = fr.get_foo_listener_bf() - b = b'Some Other Binary 22' - fr_fl_set_get(fr, fl_in_fl, b) # listener 1 in cpp, listener 2 in cpp - fl_in_fl_1 = fr.in_listener_bf_send_return(fl_in_fl) - fl_in_fl_2 = fr.in_listener_bf_send_return(fl_in_fl_1) - assert lib.equal_handles_cw__foo_listener_bf(fl_in_fl._cpp_impl, fl_in_fl_1._cpp_impl) and \ - lib.equal_handles_cw__foo_listener_bf(fl_in_fl_1._cpp_impl, fl_in_fl_2._cpp_impl) - fr_fl_set_get(fr, fl_in_fl_2, b) # listener 1 in cpp, listener 2 in cpp after back&forth - - fl = fl_in_fl = fl_in_fl_1 = fl_in_fl_2 = None - gc.collect() - fr = None - gc.collect() - assert 0 == len(FooListenerBfHelper.c_data_set) - diff --git a/test-suite/handwritten-src/python/test_record_with_derivings.py b/test-suite/handwritten-src/python/test_record_with_derivings.py deleted file mode 100644 index 8ebe201..0000000 --- a/test-suite/handwritten-src/python/test_record_with_derivings.py +++ /dev/null @@ -1,63 +0,0 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -from record_with_derivings import RecordWithDerivings -from record_with_nested_derivings import RecordWithNestedDerivings - -from datetime import datetime - -record1 = RecordWithDerivings(1, 2, 3, 4, 5.0, 6.0, datetime.fromtimestamp(7), "String8") -record1A = RecordWithDerivings(1, 2, 3, 4, 5.0, 6.0, datetime.fromtimestamp(7), "String8") -record2 = RecordWithDerivings(1, 2, 3, 4, 5.0, 6.0, datetime.fromtimestamp(7), "String888") -record3 = RecordWithDerivings(111, 2, 3, 4, 5.0, 6.0, datetime.fromtimestamp(7), "String8") - -def test_record_ord(): - assert not record1 < record1A - assert not record1A < record1 - assert not record1 > record1A - assert not record1A > record1 - - assert record1 < record2 - assert record2 > record1 - assert record1 < record3 - assert record3 > record1 - assert record2 < record3 - assert record3 > record2 - - assert not record1 > record2 - assert not record2 < record1 - assert not record1 > record3 - assert not record3 < record1 - assert not record2 > record3 - assert not record3 < record2 - -def test_record_eq(): - assert record1 == record1A - assert record1A == record1 - assert not record1 == record2 - assert not record2 == record1 - assert not record1 == record3 - assert not record3 == record1 - assert not record2 == record3 - assert not record3 == record2 - - assert record1.__hash__() == record1A.__hash__() - assert record1.__hash__() != record2.__hash__() - assert record1.__hash__() != record3.__hash__() - assert record2.__hash__() != record3.__hash__() - -nested_record1 = RecordWithNestedDerivings(1, record1) -nested_record1A = RecordWithNestedDerivings(1, record1A) -nested_record2 = RecordWithNestedDerivings(1, record2) - -def test_nested_record_ord(): - assert not nested_record1 > nested_record1A - assert not nested_record1 < nested_record1A - assert not nested_record1A > nested_record1 - assert not nested_record1A < nested_record1 - assert nested_record1 < nested_record2 - assert nested_record2 > nested_record1 - -def test_nested_record_eq(): - assert nested_record1 == nested_record1A - assert nested_record1 != nested_record2 - assert nested_record2 != nested_record1 From 5d3fedddcb7694b8c64ee24a49672277e0f7165d Mon Sep 17 00:00:00 2001 From: a4z Date: Mon, 29 Sep 2025 14:56:34 +0200 Subject: [PATCH 06/22] Update instructions --- AGENT.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/AGENT.md b/AGENT.md index 6be2b9b..2ff9051 100644 --- a/AGENT.md +++ b/AGENT.md @@ -41,6 +41,17 @@ To succeed, sh zconf-new.sh shall run without error, and a build of it must work In the new generator, the C wrapper has been disabled, maybe we bring the back. If there are problems due to the C wrapper, we will disable them in this project for now. +## Step 3 + +Remove all code that does not belong to Objective-C and Java (JNI) or C support. + +### Definition of done 3 + +To succeed, sh zconf-new.sh shall run without error, and a build of it must work! + +In the new generator, the C wrapper has been disabled, maybe we bring the back. +If there are problems due to the C wrapper, we will disable them in this project for now. + ## General build instrucktions ### New version From 8fbd072334acf26eaaf2384c3712aa9802bdad7f Mon Sep 17 00:00:00 2001 From: a4z Date: Wed, 1 Oct 2025 16:14:05 +0200 Subject: [PATCH 07/22] Remove removed builds --- .github/workflows/build.yml | 198 +++++++++++------------------------- 1 file changed, 60 insertions(+), 138 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 195b0db..0a30e85 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,153 +4,75 @@ jobs: build-on-osx-for-objectiveC: runs-on: macos-11 steps: - - uses: actions/checkout@v2 - - uses: asdf-vm/actions/install@v1 - - name: Report cmake version - run: cmake --version - - name: Configure cmake - run: cmake -S . -B build -DDJINNI_WITH_OBJC=ON -G Xcode - - name: Build release - run: cmake --build build --parallel $(sysctl -n hw.ncpu) --config Release - - name: Run tests - working-directory: build/test-suite - run: ctest -C Release -V - - name: Install files - run: cmake --build build --parallel $(sysctl -n hw.ncpu) --config Release --target install -- DESTDIR=check_install_root - - name: List installed files - working-directory: build/check_install_root - run: du -a | tail -r | awk -F ' ' '{print $2}' - - name: Test if expected files have been installed - working-directory: build/check_install_root - run: diff -u ../../test/objc_list.txt <(du -a | tail -r | awk -F ' ' '{print $2}') - - build-on-osx-for-python: - runs-on: macos-11 - strategy: - matrix: - python-version: ["3.7.12", "3.10.4"] # oldest and newest, rest assumed to work - steps: - - uses: actions/checkout@v2 - - uses: asdf-vm/actions/install@v1 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install Python dependencies - uses: py-actions/py-dependency-install@v3 - with: - path: "requirements.txt" - - name: Report cmake version - run: cmake --version - - name: Configure cmake - run: cmake -S . -B build -DDJINNI_WITH_PYTHON=ON - - name: Build release - run: cmake --build build --parallel $(sysctl -n hw.ncpu) --config Release - - name: Run tests - working-directory: build/test-suite - run: ctest -C Release -V + - uses: actions/checkout@v2 + - uses: asdf-vm/actions/install@v1 + - name: Report cmake version + run: cmake --version + - name: Configure cmake + run: cmake -S . -B build -DDJINNI_WITH_OBJC=ON -G Xcode + - name: Build release + run: cmake --build build --parallel $(sysctl -n hw.ncpu) --config Release + - name: Run tests + working-directory: build/test-suite + run: ctest -C Release -V + - name: Install files + run: cmake --build build --parallel $(sysctl -n hw.ncpu) --config Release --target install -- DESTDIR=check_install_root + - name: List installed files + working-directory: build/check_install_root + run: du -a | tail -r | awk -F ' ' '{print $2}' + - name: Test if expected files have been installed + working-directory: build/check_install_root + run: diff -u ../../test/objc_list.txt <(du -a | tail -r | awk -F ' ' '{print $2}') build-on-ubuntu-for-jni: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: asdf-vm/actions/install@v1 - - name: Report cmake version - run: cmake --version - - name: Configure cmake - run: cmake -S . -B build -DDJINNI_WITH_JNI=ON - - name: Build release - run: cmake --build build --parallel $(nproc) --config Release - - name: Run tests - working-directory: build/test-suite - run: ctest -C Release -V - - name: Install files - run: cmake --build build --parallel $(nproc) --config Release --target install -- DESTDIR=check_install_root - - name: List installed files - working-directory: build/check_install_root - run: du -a | tac | awk -F ' ' '{print $2}' | sort - - name: Test if expected files have been installed - working-directory: build/check_install_root - run: diff -u ../../test/jni_list.txt <(du -a | tac | awk -F ' ' '{print $2}' | sort) + - uses: actions/checkout@v2 + - uses: asdf-vm/actions/install@v1 + - name: Report cmake version + run: cmake --version + - name: Configure cmake + run: cmake -S . -B build -DDJINNI_WITH_JNI=ON + - name: Build release + run: cmake --build build --parallel $(nproc) --config Release + - name: Run tests + working-directory: build/test-suite + run: ctest -C Release -V + - name: Install files + run: cmake --build build --parallel $(nproc) --config Release --target install -- DESTDIR=check_install_root + - name: List installed files + working-directory: build/check_install_root + run: du -a | tac | awk -F ' ' '{print $2}' | sort + - name: Test if expected files have been installed + working-directory: build/check_install_root + run: diff -u ../../test/jni_list.txt <(du -a | tac | awk -F ' ' '{print $2}' | sort) build-on-ubuntu-for-jni-with-thread-attach: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: asdf-vm/actions/install@v1 - - name: Report cmake version - run: cmake --version - - name: Configure cmake - run: cmake -S . -B build -DDJINNI_WITH_JNI=ON -DJNI_CPP_THREAD_ATTACH=ON -DCMAKE_BUILD_TYPE=Release - - name: Build release - run: cmake --build build --parallel $(nproc) - - name: Run tests - working-directory: build/test-suite - run: ctest -C Release -V - + - uses: actions/checkout@v2 + - uses: asdf-vm/actions/install@v1 + - name: Report cmake version + run: cmake --version + - name: Configure cmake + run: cmake -S . -B build -DDJINNI_WITH_JNI=ON -DJNI_CPP_THREAD_ATTACH=ON -DCMAKE_BUILD_TYPE=Release + - name: Build release + run: cmake --build build --parallel $(nproc) + - name: Run tests + working-directory: build/test-suite + run: ctest -C Release -V build-on-ubuntu-for-android_arm32-with-thread-attach: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: asdf-vm/actions/install@v1 - - uses: ashutoshvarma/setup-ninja@master - with: - version: 1.10.2 - - name: Report cmake version - run: cmake --version - - name: Configure cmake - run: cmake -S . -B build -DDJINNI_WITH_JNI=ON -DJNI_CPP_THREAD_ATTACH=ON -DCMAKE_BUILD_TYPE=Release -DJINNI_BUILD_TESTING=OFF -DCMAKE_TOOLCHAIN_FILE=${ANDROID_SDK_ROOT}/ndk/$(ls ${ANDROID_SDK_ROOT}/ndk -C1 | sort -r | head -1)/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-26 -DANDROID_NATIVE_API_LEVEL=26 -DANDROID_ABI=armeabi-v7a -G Ninja - - name: Build release - run: cmake --build build --parallel $(nproc) - - build-on-ubuntu-for-python: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: asdf-vm/actions/install@v1 - - name: Install dependencies - uses: py-actions/py-dependency-install@v3 - with: - path: "requirements.txt" - - name: Report cmake version - run: cmake --version - - name: Configure cmake - run: cmake -S . -B build -DDJINNI_WITH_PYTHON=ON - - name: Build release - run: cmake --build build --parallel $(nproc) --config Release - - name: Run tests - working-directory: build/test-suite - run: ctest -C Release -V - - - build-on-windows-for-cppcli: - runs-on: windows-latest - steps: - - uses: actions/checkout@v2 - - name: install djinni - run: | - $VERSION = 'v' + [regex]::Match((Get-Content .tool-versions), '^djinni (\d+.\d+.\d+)').captures.groups[1].value - $URL = 'https://github.com/cross-language-cpp/djinni-generator/releases/download/' + $VERSION + '/djinni.bat' - Invoke-WebRequest -Uri $URL -OutFile djinni.bat - - name: Report cmake version - run: cmake --version - - name: Configure cmake - run: cmake -S . -B build -DDJINNI_WITH_CPPCLI=ON -DCMAKE_INSTALL_PREFIX=build/check_install_root -DDJINNI_EXECUTABLE="$(((Get-Location).Path) -replace "\\","/")/djinni.bat" -G "Visual Studio 17 2022" - - name: Install nuget dependencies - working-directory: build/test-suite - run: dotnet restore DjinniCppCliTest.csproj --runtime win-x64 - - name: Build release - run: cmake --build build --config Release - - name: Run tests - working-directory: build/test-suite - run: dotnet test Release/DjinniCppCliTest.dll - - name: Install files - run: cmake --build build --config Release --target install - - name: List installed files - working-directory: build/check_install_root - run: Resolve-Path -Path (Get-ChildItem -Recurse).FullName -Relative - - name: Test if expected files have been installed - working-directory: build/check_install_root - run: if((Compare-Object (Get-Content ..\..\test\cppcli_list.txt) (Resolve-Path -Path (Get-ChildItem -Recurse).FullName -Relative))) { Write-Error "file list not equal" } - + - uses: actions/checkout@v2 + - uses: asdf-vm/actions/install@v1 + - uses: ashutoshvarma/setup-ninja@master + with: + version: 1.10.2 + - name: Report cmake version + run: cmake --version + - name: Configure cmake + run: cmake -S . -B build -DDJINNI_WITH_JNI=ON -DJNI_CPP_THREAD_ATTACH=ON -DCMAKE_BUILD_TYPE=Release -DJINNI_BUILD_TESTING=OFF -DCMAKE_TOOLCHAIN_FILE=${ANDROID_SDK_ROOT}/ndk/$(ls ${ANDROID_SDK_ROOT}/ndk -C1 | sort -r | head -1)/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-26 -DANDROID_NATIVE_API_LEVEL=26 -DANDROID_ABI=armeabi-v7a -G Ninja + - name: Build release + run: cmake --build build --parallel $(nproc) From 8e7bb9786f9bd1e0369a7db6c7dc1fca0bffd4fb Mon Sep 17 00:00:00 2001 From: a4z Date: Wed, 1 Oct 2025 18:02:31 +0200 Subject: [PATCH 08/22] Update wanted Mac version --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0a30e85..ca05065 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: build-all-configs on: [push, pull_request] jobs: build-on-osx-for-objectiveC: - runs-on: macos-11 + runs-on: macos-lastest steps: - uses: actions/checkout@v2 - uses: asdf-vm/actions/install@v1 From 808751c359c4e059b4457008688041e271741977 Mon Sep 17 00:00:00 2001 From: a4z Date: Wed, 1 Oct 2025 18:37:53 +0200 Subject: [PATCH 09/22] Type runner name --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ca05065..7aacb08 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: build-all-configs on: [push, pull_request] jobs: build-on-osx-for-objectiveC: - runs-on: macos-lastest + runs-on: macos-latest steps: - uses: actions/checkout@v2 - uses: asdf-vm/actions/install@v1 From 59bcd5d6fc450cc00906898d0edc4c54f5a21a1d Mon Sep 17 00:00:00 2001 From: a4z Date: Wed, 1 Oct 2025 18:40:49 +0200 Subject: [PATCH 10/22] Update asdf version --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7aacb08..58f122c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,7 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v2 - - uses: asdf-vm/actions/install@v1 + - uses: asdf-vm/actions/install@v4 - name: Report cmake version run: cmake --version - name: Configure cmake From 3d3deb164fef9688e4826c83d35b778f4025b48c Mon Sep 17 00:00:00 2001 From: a4z Date: Wed, 1 Oct 2025 18:45:47 +0200 Subject: [PATCH 11/22] Update Java version --- .tool-versions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.tool-versions b/.tool-versions index 769966f..7847554 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -djinni 1.3.1 -java zulu-11.41.23 +djinni latest +java openjdk-25 From b44d3babac8c1d4d0c67bb9bbcaa2378556535cc Mon Sep 17 00:00:00 2001 From: a4z Date: Wed, 1 Oct 2025 18:48:27 +0200 Subject: [PATCH 12/22] Update asdf djinni --- .tool-versions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tool-versions b/.tool-versions index 7847554..aa99359 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -djinni latest +djinni 1.4.1 java openjdk-25 From 9978170d311b95b81d9005d080cde1151d9d1260 Mon Sep 17 00:00:00 2001 From: a4z Date: Wed, 1 Oct 2025 18:49:52 +0200 Subject: [PATCH 13/22] Use latest asdf plugin everywhere --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 58f122c..8976097 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: asdf-vm/actions/install@v1 + - uses: asdf-vm/actions/install@v4 - name: Report cmake version run: cmake --version - name: Configure cmake @@ -51,7 +51,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: asdf-vm/actions/install@v1 + - uses: asdf-vm/actions/install@v4 - name: Report cmake version run: cmake --version - name: Configure cmake @@ -66,7 +66,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: asdf-vm/actions/install@v1 + - uses: asdf-vm/actions/install@v4 - uses: ashutoshvarma/setup-ninja@master with: version: 1.10.2 From 5c2e7633de93f5cb497f84ba1b4f712c8685933d Mon Sep 17 00:00:00 2001 From: a4z Date: Wed, 1 Oct 2025 18:58:11 +0200 Subject: [PATCH 14/22] Fix modern xcode build --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8976097..25aea58 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ jobs: - name: Report cmake version run: cmake --version - name: Configure cmake - run: cmake -S . -B build -DDJINNI_WITH_OBJC=ON -G Xcode + run: cmake -S . -B build -DDJINNI_WITH_OBJC=ON -DCMAKE_OSX_SYSROOT=$(xcodebuild -version -sdk macosx Path) -G Xcode - name: Build release run: cmake --build build --parallel $(sysctl -n hw.ncpu) --config Release - name: Run tests From 281bb692b9e10337f6261a0d15d5ea175c63d94d Mon Sep 17 00:00:00 2001 From: a4z Date: Wed, 1 Oct 2025 19:13:53 +0200 Subject: [PATCH 15/22] Cleanup tests --- AGENT.md | 4 +- .../cwrapper/limits_helper.cpp | 17 -- .../handwritten-src/cwrapper/limits_helper.h | 9 - .../cwrapper/limits_helper.hpp | 10 -- .../pycpp/foo_client_interface_impl.cpp | 38 ----- .../pycpp/foo_client_interface_impl.hpp | 32 ---- .../pycpp/foo_containers_interface_impl.cpp | 79 --------- .../pycpp/foo_containers_interface_impl.hpp | 57 ------- .../pycpp/foo_enum_interface_impl.cpp | 25 --- .../pycpp/foo_enum_interface_impl.hpp | 25 --- .../pycpp/foo_extensible_record.hpp | 17 -- .../pycpp/foo_interface_impl.cpp | 45 ----- .../pycpp/foo_interface_impl.hpp | 34 ---- .../pycpp/foo_listener_bf_impl.cpp | 43 ----- .../pycpp/foo_listener_bf_impl.hpp | 32 ---- .../pycpp/foo_primitives_impl.cpp | 91 ---------- .../pycpp/foo_primitives_impl.hpp | 62 ------- .../pycpp/foo_receiver_impl.cpp | 155 ------------------ .../pycpp/foo_receiver_impl.hpp | 79 --------- .../handwritten-src/pycpp/foo_static_impl.cpp | 81 --------- .../handwritten-src/pycpp/foo_static_impl.hpp | 34 ---- test/cppcli_list.txt | 13 -- 22 files changed, 2 insertions(+), 980 deletions(-) delete mode 100644 test-suite/handwritten-src/cwrapper/limits_helper.cpp delete mode 100644 test-suite/handwritten-src/cwrapper/limits_helper.h delete mode 100644 test-suite/handwritten-src/cwrapper/limits_helper.hpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_client_interface_impl.cpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_client_interface_impl.hpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_containers_interface_impl.cpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_containers_interface_impl.hpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_enum_interface_impl.cpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_enum_interface_impl.hpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_extensible_record.hpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_interface_impl.cpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_interface_impl.hpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_listener_bf_impl.cpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_listener_bf_impl.hpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_primitives_impl.cpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_primitives_impl.hpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_receiver_impl.cpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_receiver_impl.hpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_static_impl.cpp delete mode 100644 test-suite/handwritten-src/pycpp/foo_static_impl.hpp delete mode 100644 test/cppcli_list.txt diff --git a/AGENT.md b/AGENT.md index 2ff9051..b11799e 100644 --- a/AGENT.md +++ b/AGENT.md @@ -9,7 +9,7 @@ There is a python interaface and a C# interface. We can keep the plain c wrapper, called cwrapper, if is is C specific and does not have dependencies other than C/C++. - [x] Clean up the build system and remove everything does does not belong to Objective-C and Java (JNI) or C support. -- [ ] Remove all code that does not belong to Objective-C and Java (JNI) or C support. +- [x] Remove all code that does not belong to Objective-C and Java (JNI) or C support. - [ ] Remove all tests that does not belong to Objective-C and Java (JNI) or C support. - [ ] Clean up the documentation remove everything that does not belong to Objective-C and Java (JNI) or C support. @@ -43,7 +43,7 @@ If there are problems due to the C wrapper, we will disable them in this project ## Step 3 -Remove all code that does not belong to Objective-C and Java (JNI) or C support. +Remove all test code that does not belong to Objective-C and Java (JNI) or C support. ### Definition of done 3 diff --git a/test-suite/handwritten-src/cwrapper/limits_helper.cpp b/test-suite/handwritten-src/cwrapper/limits_helper.cpp deleted file mode 100644 index c4908b0..0000000 --- a/test-suite/handwritten-src/cwrapper/limits_helper.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Useful for testing limits of primitive types from Python -#include "limits_helper.hpp" - -float min_f32_t() { - return FLT_MIN; -} -float max_f32_t() { - return FLT_MAX; -} - -double min_f64_t() { - return DBL_MIN; -} -double max_f64_t() { - return DBL_MAX; -} - diff --git a/test-suite/handwritten-src/cwrapper/limits_helper.h b/test-suite/handwritten-src/cwrapper/limits_helper.h deleted file mode 100644 index f929d46..0000000 --- a/test-suite/handwritten-src/cwrapper/limits_helper.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once // python_cdef_ignore - -#include // python_cdef_ignore - -float min_f32_t(void); -float max_f32_t(void); - -double min_f64_t(void); -double max_f64_t(void); diff --git a/test-suite/handwritten-src/cwrapper/limits_helper.hpp b/test-suite/handwritten-src/cwrapper/limits_helper.hpp deleted file mode 100644 index 0dcc511..0000000 --- a/test-suite/handwritten-src/cwrapper/limits_helper.hpp +++ /dev/null @@ -1,10 +0,0 @@ - -#ifdef __cplusplus // python_cdef_ignore -extern "C" { // python_cdef_ignore -#endif // python_cdef_ignore - -#include "limits_helper.h" - -#ifdef __cplusplus // python_cdef_ignore -} // python_cdef_ignore -#endif // python_cdef_ignore diff --git a/test-suite/handwritten-src/pycpp/foo_client_interface_impl.cpp b/test-suite/handwritten-src/pycpp/foo_client_interface_impl.cpp deleted file mode 100644 index 8108cd3..0000000 --- a/test-suite/handwritten-src/pycpp/foo_client_interface_impl.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -#include -#include "foo_client_interface_impl.hpp" - -namespace testsuite { - -std::shared_ptr FooClientInterface::create() { - return std::make_shared(); -} - -void FooClientInterfaceImpl::set_record(const FooClientReturnedRecord & rec) { - m_record = rec; -} - -FooClientReturnedRecord FooClientInterfaceImpl::get_record() { - return m_record; -} - -void FooClientInterfaceImpl::set_extensible_record(const FooExtensibleRecord & rec) { - m_ext_record = rec; -} - -FooExtensibleRecord FooClientInterfaceImpl::get_extensible_record() { - return m_ext_record; -} - -int32_t FooClientInterfaceImpl::get_extensible_record_number2() { - return m_ext_record.number2; -} - -std::string FooClientInterfaceImpl::get_extensible_record_string2() { - return m_ext_record.string2; -} - -FooClientInterfaceImpl::FooClientInterfaceImpl(): m_record(FooClientReturnedRecord(5,"hi", FooSomeOtherRecord(1,2))), - m_ext_record(6, "bye"){}; - -} // namespace testsuite diff --git a/test-suite/handwritten-src/pycpp/foo_client_interface_impl.hpp b/test-suite/handwritten-src/pycpp/foo_client_interface_impl.hpp deleted file mode 100644 index 9647059..0000000 --- a/test-suite/handwritten-src/pycpp/foo_client_interface_impl.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include "foo_client_interface.hpp" -#include "foo_client_returned_record.hpp" -#include "foo_extensible_record.hpp" - -namespace testsuite { - -class FooClientInterfaceImpl final: public FooClientInterface { -public: - FooClientInterfaceImpl(); - - virtual void set_record(const FooClientReturnedRecord & rec) override; - - virtual FooClientReturnedRecord get_record() override; - - virtual void set_extensible_record(const FooExtensibleRecord & rec) override; - - virtual FooExtensibleRecord get_extensible_record() override; - - virtual int32_t get_extensible_record_number2() override; - - virtual std::string get_extensible_record_string2() override; - - static std::shared_ptr create(); - -private: - FooClientReturnedRecord m_record; - FooExtensibleRecord m_ext_record; -}; - -} // namespace testsuite diff --git a/test-suite/handwritten-src/pycpp/foo_containers_interface_impl.cpp b/test-suite/handwritten-src/pycpp/foo_containers_interface_impl.cpp deleted file mode 100644 index 34263fb..0000000 --- a/test-suite/handwritten-src/pycpp/foo_containers_interface_impl.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include -#include "foo_containers_interface_impl.hpp" -#include "foo_some_other_record.hpp" -#include - -namespace testsuite { - -std::shared_ptr FooContainersInterface::create() { - return std::make_shared(); -} - -void FooContainersInterfaceImpl::set_containers_record(const FooContainersRecord & rec) { - m_record = rec; -} - -FooContainersRecord FooContainersInterfaceImpl::get_containers_record() { - return m_record; -} - -void FooContainersInterfaceImpl::set_optional_containers_record(const std::optional & rec) { - if (!rec) { - m_optional_record = std::nullopt; - } - else { - m_optional_record = *rec; - } -} - -std::optional FooContainersInterfaceImpl::get_optional_containers_record() { - return m_optional_record; -} - -void FooContainersInterfaceImpl::set_optional_map_string_int(const std::optional> & m) { - m_optional_map_string_int = m; -} - -std::optional> FooContainersInterfaceImpl::get_optional_map_string_int() { - return m_optional_map_string_int; -} - - -void FooContainersInterfaceImpl::set_optional_list_int(const std::optional> & li) { - m_optional_list_int = li; -} - -std::optional> FooContainersInterfaceImpl::get_optional_list_int() { - return m_optional_list_int; -} - -void FooContainersInterfaceImpl::set_list_record(const std::vector & lr) { - m_list_record = lr; -} - -void FooContainersInterfaceImpl::set_list_binary(const std::vector> & lb) { - m_list_binary = lb; -} - -std::vector> FooContainersInterfaceImpl::get_list_binary() { - return m_list_binary; -} - -// void FooContainersInterfaceImpl::set_set_record(const std::unordered_set & sr) { -// m_set_record = sr; -// } - -// std::unordered_set FooContainersInterfaceImpl::get_set_record() { -// return m_set_record; -// } - -FooContainersInterfaceImpl::FooContainersInterfaceImpl(): - m_record(FooContainersRecord(m_optional_list_int, m_list_int, m_list_binary, m_list_optional_binary, - m_list_list_string, m_list_record, m_optional_map_string_int, m_map_string_int, m_map_string_string, m_map_optional_string_optional_string, m_map_int_list_date, - m_optional_set_string, m_set_string, m_set_optional_string, m_map_int_set_string, m_map_optional_int_set_string)), - m_optional_record(FooContainersRecord(m_optional_list_int, m_list_int, m_list_binary, m_list_optional_binary, - m_list_list_string, m_list_record, m_optional_map_string_int, m_map_string_int, m_map_string_string, m_map_optional_string_optional_string, m_map_int_list_date, - m_optional_set_string, m_set_string, m_set_optional_string, m_map_int_set_string, m_map_optional_int_set_string)) - {}; - -} // namespace testsuite diff --git a/test-suite/handwritten-src/pycpp/foo_containers_interface_impl.hpp b/test-suite/handwritten-src/pycpp/foo_containers_interface_impl.hpp deleted file mode 100644 index 1344600..0000000 --- a/test-suite/handwritten-src/pycpp/foo_containers_interface_impl.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once - -#include "foo_containers_record.hpp" -#include "foo_containers_interface.hpp" -#include "foo_some_other_record.hpp" -#include - -namespace testsuite { - -class FooContainersInterfaceImpl final: public FooContainersInterface { -public: - FooContainersInterfaceImpl(); - - virtual void set_containers_record(const FooContainersRecord & rec) override; - virtual FooContainersRecord get_containers_record() override; - - virtual void set_optional_containers_record(const std::optional & rec) override; - virtual std::optional get_optional_containers_record() override; - - virtual void set_optional_map_string_int(const std::optional> & m) override; - virtual std::optional> get_optional_map_string_int() override; - - virtual void set_optional_list_int(const std::optional> & li) override; - virtual std::optional> get_optional_list_int() override; - - virtual void set_list_record(const std::vector & lr) override; - virtual void set_list_binary(const std::vector> & lb) override; - virtual std::vector> get_list_binary() override; - // virtual void set_set_record(const std::unordered_set & sr) override; - // virtual std::unordered_set get_set_record() override; - static std::shared_ptr create(); -private: - std::optional> m_optional_list_int; - std::vector m_list_int; - std::vector> m_list_binary; - std::vector>> m_list_optional_binary; - std::vector> m_list_list_string; - std::vector m_list_record; - std::optional> m_optional_map_string_int; - std::unordered_map m_map_string_int; - std::unordered_map m_map_string_string; - std::unordered_map, std::optional> m_map_optional_string_optional_string; - std::unordered_map> m_map_int_list_date; - - std::unordered_map> m_map_int_set_string; - std::unordered_map, std::unordered_set> m_map_optional_int_set_string; - std::optional> m_optional_set_string; - std::unordered_set m_set_string; - std::unordered_set> m_set_optional_string; - FooContainersRecord m_record; - - // std::unordered_set m_set_record; - - std::optional m_optional_record; -}; - -} // namespace testsuite diff --git a/test-suite/handwritten-src/pycpp/foo_enum_interface_impl.cpp b/test-suite/handwritten-src/pycpp/foo_enum_interface_impl.cpp deleted file mode 100644 index 6aac3c6..0000000 --- a/test-suite/handwritten-src/pycpp/foo_enum_interface_impl.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "foo_enum_interface_impl.hpp" - -namespace testsuite { - -std::shared_ptr FooEnumInterface::create() { - return std::make_shared(); -} - -void FooEnumInterfaceImpl::set_enum(color some_color) { - m_color = some_color; -} - -color FooEnumInterfaceImpl::get_enum() { - return m_color; -} - -void FooEnumInterfaceImpl::set_optional_enum(std::optional some_color) { - m_optional_color = some_color; -} - -std::optional FooEnumInterfaceImpl::get_optional_enum() { - return m_optional_color; -} - -} // namespace testsuite diff --git a/test-suite/handwritten-src/pycpp/foo_enum_interface_impl.hpp b/test-suite/handwritten-src/pycpp/foo_enum_interface_impl.hpp deleted file mode 100644 index 02ee60a..0000000 --- a/test-suite/handwritten-src/pycpp/foo_enum_interface_impl.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "foo_enum_interface.hpp" -#include "color.hpp" -#include -#include - -namespace testsuite { - -class FooEnumInterfaceImpl final: public FooEnumInterface { -public: - - virtual void set_enum(color some_color) override; - virtual color get_enum() override; - - virtual void set_optional_enum(std::optional some_color) override; - virtual std::optional get_optional_enum() override; - - static std::shared_ptr create(); -private: - color m_color; - std::optional m_optional_color; -}; - -} // namespace testsuite diff --git a/test-suite/handwritten-src/pycpp/foo_extensible_record.hpp b/test-suite/handwritten-src/pycpp/foo_extensible_record.hpp deleted file mode 100644 index 60b728d..0000000 --- a/test-suite/handwritten-src/pycpp/foo_extensible_record.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include - -#include "foo_extensible_record_base.hpp" - -namespace testsuite { - -class FooExtensibleRecord final: public FooExtensibleRecordBase { -public: - FooExtensibleRecord(int number1, std::string string1): FooExtensibleRecordBase(number1, std::move(string1)), - number2(number1 * 2), string2(this->string1 + this->string1) {}; - int number2; - std::string string2; -}; - -} // namespace testsuite diff --git a/test-suite/handwritten-src/pycpp/foo_interface_impl.cpp b/test-suite/handwritten-src/pycpp/foo_interface_impl.cpp deleted file mode 100644 index 483d538..0000000 --- a/test-suite/handwritten-src/pycpp/foo_interface_impl.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// Example cpp implementation of foo.hpp -// This file should be hand-written by a cpp developer - -#include -#include "foo_interface_impl.hpp" - -namespace testsuite { - -std::shared_ptr FooInterface::create() { - return std::make_shared(); -} - -int32_t FooInterfaceImpl::int32_inverse(int32_t x) { - return -x; -} - -void FooInterfaceImpl::set_private_int32(int32_t pri) { - m_pri = pri; -} - -int32_t FooInterfaceImpl::get_private_int32() { - return m_pri; -} - -void FooInterfaceImpl::set_private_string(const std::string& prs) { - m_prs = prs; -} - -std::string FooInterfaceImpl::get_private_string() { - return m_prs; -} - -std::string FooInterfaceImpl::get_set_strings(const std::string& ps1, const std::string & ps2) { - m_prs = ps2; - return m_prs; -} - -std::shared_ptr FooInterfaceImpl::get_foo_primitives() { - if (!m_foo_primitives) { - m_foo_primitives = FooPrimitives::create(); - } - return m_foo_primitives; -} - -} // namespace testsuite diff --git a/test-suite/handwritten-src/pycpp/foo_interface_impl.hpp b/test-suite/handwritten-src/pycpp/foo_interface_impl.hpp deleted file mode 100644 index b38df5e..0000000 --- a/test-suite/handwritten-src/pycpp/foo_interface_impl.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Example cpp implementation of foo.hpp -// This file should be hand-written by a cpp developer - -#pragma once - -#include -#include "foo_interface.hpp" -#include "foo_primitives.hpp" - -namespace testsuite { - -class FooInterfaceImpl final: public FooInterface { -public: - virtual int32_t int32_inverse(int32_t x) override; - - virtual void set_private_int32(int32_t pri) override; - virtual int32_t get_private_int32() override; - - virtual void set_private_string(const std::string& prs) override; - virtual std::string get_private_string() override; - - virtual std::string get_set_strings(const std::string& ps1, const std::string & ps2) override; - - virtual std::shared_ptr get_foo_primitives() override; - - static std::shared_ptr create(); -private: - int32_t m_pri = 0; - std::string m_prs; - - std::shared_ptr m_foo_primitives; -}; - -} // namespace testsuite diff --git a/test-suite/handwritten-src/pycpp/foo_listener_bf_impl.cpp b/test-suite/handwritten-src/pycpp/foo_listener_bf_impl.cpp deleted file mode 100644 index 5d5ca05..0000000 --- a/test-suite/handwritten-src/pycpp/foo_listener_bf_impl.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include - -#include "foo_listener_bf_impl.hpp" - -namespace testsuite { - -std::string FooListenerBfImpl::on_string_change(const std::string & private_string) { - m_string = private_string; - return m_string; -} - -std::string FooListenerBfImpl::get_string() { - return m_string; -} - - -void FooListenerBfImpl::set_listener_bf(const std::shared_ptr & listener) { - m_foo_listener_bf = listener; -} - -std::shared_ptr FooListenerBfImpl::get_listener_bf() { - return m_foo_listener_bf; -} - -void FooListenerBfImpl::set_binary(const std::vector & b) { - m_prbin = b; -} - -std::vector FooListenerBfImpl::get_binary() { - return m_prbin; -} - -std::shared_ptr FooListenerBfImpl::send_return(const std::shared_ptr & fl_bf) { - return fl_bf; -} - -void FooListenerBfImpl::delete_fl_in_fl() { - // std::cout<< "In delete_fl_in_fl " << m_foo_listener_bf.use_count() << std::endl; - m_foo_listener_bf = nullptr; -} - -} // namespace testsuite diff --git a/test-suite/handwritten-src/pycpp/foo_listener_bf_impl.hpp b/test-suite/handwritten-src/pycpp/foo_listener_bf_impl.hpp deleted file mode 100644 index 120b3e6..0000000 --- a/test-suite/handwritten-src/pycpp/foo_listener_bf_impl.hpp +++ /dev/null @@ -1,32 +0,0 @@ - -#include "foo_listener_bf.hpp" - -namespace testsuite { - -class FooListenerBfImpl final: public FooListenerBf { -public: - ~FooListenerBfImpl() { - // std::cout<< "In Destructor of FooListenerBfImpl, internal shared_ptr (fl_in_fl) " << m_foo_listener_bf.use_count() << std::endl; - } - - virtual void delete_fl_in_fl() override; - - - virtual std::string on_string_change(const std::string & private_string) override; - virtual std::string get_string() override; - - virtual void set_listener_bf(const std::shared_ptr & listener) override; - virtual std::shared_ptr get_listener_bf() override; - virtual void set_binary(const std::vector & b) override; - virtual std::vector get_binary() override; - virtual std::shared_ptr send_return(const std::shared_ptr & fl_bf) override; - - static std::shared_ptr create(); -private: - std::string m_string; - std::vector m_prbin; - - std::shared_ptr m_foo_listener_bf; -}; - -} // namespace testsuite diff --git a/test-suite/handwritten-src/pycpp/foo_primitives_impl.cpp b/test-suite/handwritten-src/pycpp/foo_primitives_impl.cpp deleted file mode 100644 index a8ddede..0000000 --- a/test-suite/handwritten-src/pycpp/foo_primitives_impl.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include // for debugging -#include -#include "foo_primitives_impl.hpp" - -namespace testsuite { - -std::shared_ptr FooPrimitives::create() { - return std::make_shared(); -} - -void FooPrimitivesImpl::set_int8(int8_t private_int) { - m_pri8 = private_int; -} - -int8_t FooPrimitivesImpl::get_int8() { - return m_pri8; -} - -void FooPrimitivesImpl::set_int16(int16_t private_int) { - m_pri16 = private_int; -} - -int16_t FooPrimitivesImpl::get_int16() { - return m_pri16; -} - -void FooPrimitivesImpl::set_int32(int32_t private_int) { - m_pri32 = private_int; -} - -int32_t FooPrimitivesImpl::get_int32() { - return m_pri32; -} - -void FooPrimitivesImpl::set_int64(int64_t private_int) { - m_pri64 = private_int; -} - -int64_t FooPrimitivesImpl::get_int64() { - return m_pri64; -} - -void FooPrimitivesImpl::set_float(float private_float) { - m_prf = private_float; -} - -float FooPrimitivesImpl::get_float() { - return m_prf; -} - -void FooPrimitivesImpl::set_double(double private_double) { - m_prd = private_double; -} - -double FooPrimitivesImpl::get_double() { - return m_prd; -} - -void FooPrimitivesImpl::set_bool(bool private_bool) { - m_prb = private_bool; -} - -bool FooPrimitivesImpl::get_bool() { - return m_prb; -} - -void FooPrimitivesImpl::set_string(const std::string & private_string) { - m_prs = private_string; -} - -std::string FooPrimitivesImpl::get_string() { - return m_prs; -} - -void FooPrimitivesImpl::set_binary(const std::vector & private_binary) { - m_prbin = private_binary; -} - -std::vector FooPrimitivesImpl::get_binary() { - return m_prbin; -} - -void FooPrimitivesImpl::set_date(const std::chrono::system_clock::time_point & private_date) { - m_prdate = private_date; -} - -std::chrono::system_clock::time_point FooPrimitivesImpl::get_date() { - return m_prdate; -} - -} // namespace testsuite diff --git a/test-suite/handwritten-src/pycpp/foo_primitives_impl.hpp b/test-suite/handwritten-src/pycpp/foo_primitives_impl.hpp deleted file mode 100644 index 585058d..0000000 --- a/test-suite/handwritten-src/pycpp/foo_primitives_impl.hpp +++ /dev/null @@ -1,62 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include "foo_primitives.hpp" - -namespace testsuite { - -class FooPrimitivesImpl final: public FooPrimitives { -public: - virtual void set_int8(int8_t private_int) override; - virtual int8_t get_int8() override; - - virtual void set_int16(int16_t private_int) override; - virtual int16_t get_int16() override; - - virtual void set_int32(int32_t private_int) override; - virtual int32_t get_int32() override; - - virtual void set_int64(int64_t private_int) override; - virtual int64_t get_int64() override; - - virtual void set_bool(bool private_bool) override; - virtual bool get_bool() override; - - virtual void set_float(float private_float) override; - virtual float get_float() override; - - virtual void set_double(double private_double) override; - virtual double get_double() override; - - virtual void set_string(const std::string & private_string) override; - virtual std::string get_string() override; - - virtual void set_binary(const std::vector & private_binary) override; - virtual std::vector get_binary() override; - - virtual void set_date(const std::chrono::system_clock::time_point & private_date) override; - virtual std::chrono::system_clock::time_point get_date() override; - - static std::shared_ptr create(); - -private: - int8_t m_pri8 = 0; - int16_t m_pri16 = 0; - int32_t m_pri32 = 0; - int64_t m_pri64 = 0; - - bool m_prb = false; - - float m_prf = 0.0; - double m_prd = 0.0; - - std::string m_prs; - - std::vector m_prbin; - std::chrono::system_clock::time_point m_prdate; -}; - -} // namespace testsuite diff --git a/test-suite/handwritten-src/pycpp/foo_receiver_impl.cpp b/test-suite/handwritten-src/pycpp/foo_receiver_impl.cpp deleted file mode 100644 index ed5dbfd..0000000 --- a/test-suite/handwritten-src/pycpp/foo_receiver_impl.cpp +++ /dev/null @@ -1,155 +0,0 @@ -// Example cpp implementation of foo.hpp -// This file should be hand-written by a cpp developer - -#include -#include -#include "djinni/cwrapper/wrapper_marshal.hpp" -#include "foo_listener_bf_impl.hpp" -#include "foo_receiver_impl.hpp" -#include "foo_some_other_record.hpp" - -namespace testsuite { - -std::shared_ptr FooReceiver::create() { - return std::make_shared(); -} - -std::string FooReceiverImpl::set_private_string(const std::string & private_string) { - m_prs = private_string; - return m_listener->on_string_change(m_prs); -} - -std::string FooReceiverImpl::cause_changes_string_returned(int32_t i, float f, const std::string & s, const std::vector & binar, - bool b, const std::chrono::system_clock::time_point & d) { - return m_listener->on_changes_string_returned(i,f,s,binar,b,d); -} - -std::vector FooReceiverImpl::cause_changes_binary_returned(int32_t i, float f, const std::string & s, const std::vector & binar, - bool b, const std::chrono::system_clock::time_point & d) { - return m_listener->on_changes_binary_returned(i,f,s,binar,b,d); -} - -std::chrono::system_clock::time_point FooReceiverImpl::cause_changes_date_returned(int32_t i, float f, const std::string & s, const std::vector & binar, - bool b, const std::chrono::system_clock::time_point & d) { - return m_listener->on_changes_date_returned(i,f,s,binar,b,d); -} - -int32_t FooReceiverImpl::cause_changes_int_returned(int32_t i, float f, const std::string & s, const std::vector & binar, - bool b, const std::chrono::system_clock::time_point & d) { - return m_listener->on_changes_int_returned(i,f,s,binar,b,d); -} - -std::string FooReceiverImpl::get_private_string() { - return m_prs; -} - -void FooReceiverImpl::add_listener(const std::shared_ptr & listener) { - m_listener = listener; -} - -void FooReceiverImpl::add_optional_listener(const std::shared_ptr & listener) { - m_listener = listener; -} - -std::shared_ptr FooReceiverImpl::get_optional_listener() { - return m_listener; -} - -std::optional FooReceiverImpl::cause_changes_int_optional_returned( - std::optional i, - float f, - const std::optional & s , - const std::vector & binar, - bool b, const std::chrono::system_clock::time_point & d) { - - return m_listener->on_changes_int_optional_returned(i,f,s,binar,b,d); -} - -std::optional FooReceiverImpl::cause_changes_string_optional_returned( - std::optional i, - float f, - const std::optional & s , - const std::vector & binar, - bool b, const std::chrono::system_clock::time_point & d) { - - return m_listener->on_changes_string_optional_returned(i,f,s,binar,b,d); -} - -FooSomeOtherRecord FooReceiverImpl::cause_changes_record_returned(int32_t n1, int32_t n2) { - return m_listener->on_changes_record_returned(n1, n2); -} - -void FooReceiverImpl::cause_cpp_exception(const std::string & s) { - throw std::runtime_error(std::move(s)); -} - -void FooReceiverImpl::cause_py_exception(const std::string & s) { - try { - m_listener->cause_py_exception(std::move(s)); - } catch (djinni::front_end_exception & e) { - throw std::move(e); - } -} - -void FooReceiverImpl::cause_zero_division_error() { - try { - m_listener->cause_zero_division_error(); - } catch (djinni::front_end_exception & e) { - throw std::move(e); - } -} - -// Receiver functions where the listener we are calling methods on has been -// Passed back and forth as an argument and return value of other methods -std::string FooReceiverImpl::set_private_bf_string(const std::string & private_string) { - m_prs = private_string; - return m_listener_bf->on_string_change(m_prs); -} - -void FooReceiverImpl::add_listener_bf(const std::shared_ptr & listener) { - m_listener_bf = listener; -} - -std::string FooReceiverImpl::get_listener_bf_string() { - return m_listener_bf->get_string(); -} - -std::shared_ptr FooReceiverImpl::get_foo_listener_bf() { - if (!m_cpp_listener) { - m_cpp_listener = std::make_shared(); - } - return m_cpp_listener; -} - -std::shared_ptr FooReceiverImpl::send_return(const std::shared_ptr & fl_bf) { - return fl_bf; -} - -void FooReceiverImpl::set_listener_bf_in_listener_bf(const std::shared_ptr & listener) { - m_listener_bf->set_listener_bf(listener); -} - -std::shared_ptr FooReceiverImpl::get_listener_bf_in_listener_bf() { - return m_listener_bf->get_listener_bf(); -} - -void FooReceiverImpl::set_binary_in_listener_bf_in_listener_bf(const std::vector & b) { - m_listener_bf->set_binary(b); -} - -std::vector FooReceiverImpl::get_binary_in_listener_bf_in_listener_bf() { - return m_listener_bf->get_binary(); -} - -std::shared_ptr FooReceiverImpl::in_listener_bf_send_return(const std::shared_ptr & fl_bf) { - return m_listener_bf->send_return(fl_bf); -} - -FooReceiverImpl::~FooReceiverImpl() { - // Needed for when we have a foo_listner in a foo_listener, because in our test we use the same foo_listener - if (m_cpp_listener) { - m_cpp_listener->delete_fl_in_fl(); - } -} - -} // namespace testsuite diff --git a/test-suite/handwritten-src/pycpp/foo_receiver_impl.hpp b/test-suite/handwritten-src/pycpp/foo_receiver_impl.hpp deleted file mode 100644 index 55bb12e..0000000 --- a/test-suite/handwritten-src/pycpp/foo_receiver_impl.hpp +++ /dev/null @@ -1,79 +0,0 @@ - -#pragma once - -#include -#include - -#include "foo_receiver.hpp" -#include "foo_listener.hpp" -#include "foo_listener_bf.hpp" - -namespace testsuite { - -class FooListener; - -class FooReceiverImpl final: public FooReceiver { -public: - - ~FooReceiverImpl(); - - virtual std::string set_private_string(const std::string & private_string) override; - virtual std::string get_private_string() override; - - virtual std::string cause_changes_string_returned(int32_t i, float f, const std::string & s, const std::vector & binar, - bool b, const std::chrono::system_clock::time_point & d) override; - virtual std::vector cause_changes_binary_returned(int32_t i, float f, const std::string & s, const std::vector & binar, - bool b, const std::chrono::system_clock::time_point & d) override; - virtual std::chrono::system_clock::time_point cause_changes_date_returned(int32_t i, float f, const std::string & s, const std::vector & binar, - bool b, const std::chrono::system_clock::time_point & d) override; - virtual int cause_changes_int_returned(int32_t i, float f, const std::string & s, const std::vector & binar, - bool b, const std::chrono::system_clock::time_point & d) override; - virtual FooSomeOtherRecord cause_changes_record_returned(int32_t n1, int32_t n2) override; - - virtual std::optional cause_changes_int_optional_returned( - std::optional, - float, - const std::optional &, - const std::vector &, - bool, const std::chrono::system_clock::time_point &) override; - - virtual std::optional cause_changes_string_optional_returned( - std::optional, - float, - const std::optional &, - const std::vector &, - bool, const std::chrono::system_clock::time_point &) override; - - virtual void cause_cpp_exception(const std::string & s) override; - virtual void cause_py_exception(const std::string & s) override; - virtual void cause_zero_division_error() override; - - virtual void add_listener(const std::shared_ptr & listener) override; - virtual void add_optional_listener(const std::shared_ptr & listener) override; - virtual std::shared_ptr get_optional_listener() override; - - // former receiver bf functions - virtual std::string set_private_bf_string(const std::string & private_string) override; - - virtual void add_listener_bf(const std::shared_ptr & listener) override; - virtual std::shared_ptr get_foo_listener_bf() override; - virtual std::string get_listener_bf_string() override; - - virtual std::shared_ptr send_return(const std::shared_ptr & fl_bf) override; - - virtual void set_listener_bf_in_listener_bf(const std::shared_ptr & listener) override; - virtual std::shared_ptr get_listener_bf_in_listener_bf() override; - virtual void set_binary_in_listener_bf_in_listener_bf(const std::vector & s) override; - virtual std::vector get_binary_in_listener_bf_in_listener_bf() override; - virtual std::shared_ptr in_listener_bf_send_return(const std::shared_ptr & fl_bf) override; - -private: - std::shared_ptr m_listener; - std::shared_ptr m_listener_bf; // python or cpp impl - std::shared_ptr m_cpp_listener; // access to cpp implementation of listener - - int32_t m_pri = 0; - std::string m_prs; -}; - -} // namespace testsuite diff --git a/test-suite/handwritten-src/pycpp/foo_static_impl.cpp b/test-suite/handwritten-src/pycpp/foo_static_impl.cpp deleted file mode 100644 index b77da1f..0000000 --- a/test-suite/handwritten-src/pycpp/foo_static_impl.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include // for debugging -#include -#include "foo_static_impl.hpp" - -namespace testsuite { - -std::string FooStaticImpl::s_messg; -int FooStaticImpl::s_counter; - -// STATIC methods FooStatic - -std::string FooStatic::update_static_messg_to(const std::string & static_string) { - return FooStaticImpl::update_static_messg_to(static_string); -} - -std::string FooStatic::get_static_messg() { - return FooStaticImpl::get_static_messg(); -} - -int32_t FooStatic::update_static_counter_by(int32_t plus) { - return FooStaticImpl::update_static_counter_by(plus); -} - -int32_t FooStatic::update_static_counter_to(int32_t init) { - return FooStaticImpl::update_static_counter_to(init); -} - -int32_t FooStatic::get_static_counter() { - return FooStaticImpl::get_static_counter(); -} - -std::chrono::system_clock::time_point FooStatic::date_id(const std::chrono::system_clock::time_point & d) { - return FooStaticImpl::date_id(d); -} - -std::optional FooStatic::opt_date_id(const std::optional & od) { - return FooStaticImpl::opt_date_id(od); -} - -std::optional FooStatic::opt_i64_id(std::optional oi) { - return FooStaticImpl::opt_i64_id(oi); -} - -// STATIC methods FooStaticImpl - -std::string FooStaticImpl::update_static_messg_to(const std::string & static_string) { - FooStaticImpl::s_messg = static_string; - return FooStaticImpl::s_messg; -} - -std::string FooStaticImpl::get_static_messg() { - return FooStaticImpl::s_messg; -} - -int32_t FooStaticImpl::update_static_counter_by(int32_t plus) { - FooStaticImpl::s_counter += plus; - return FooStaticImpl::s_counter; -} - -int32_t FooStaticImpl::update_static_counter_to(int32_t init) { - FooStaticImpl::s_counter = init; - return FooStaticImpl::s_counter; -} - -int32_t FooStaticImpl::get_static_counter() { - return FooStaticImpl::s_counter; -} - -std::chrono::system_clock::time_point FooStaticImpl::date_id(const std::chrono::system_clock::time_point & d) { - return d; -} - -std::optional FooStaticImpl::opt_date_id(const std::optional & od) { - return od; -} - -std::optional FooStaticImpl::opt_i64_id(std::optional oi) { - return oi; -} - -} // namespace testsuite diff --git a/test-suite/handwritten-src/pycpp/foo_static_impl.hpp b/test-suite/handwritten-src/pycpp/foo_static_impl.hpp deleted file mode 100644 index cd21ab7..0000000 --- a/test-suite/handwritten-src/pycpp/foo_static_impl.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include -#include -#include -#include "foo_static.hpp" - -namespace testsuite { - -class FooStaticImpl final: public FooStatic { -public: - static std::string update_static_messg_to(const std::string & static_string); - - static std::string get_static_messg(); - - static int32_t update_static_counter_by(int32_t plus); - - static int32_t update_static_counter_to(int32_t init); - - static int32_t get_static_counter(); - - static std::chrono::system_clock::time_point date_id(const std::chrono::system_clock::time_point & d); - - static std::optional opt_date_id(const std::optional & od); - - static std::optional opt_i64_id(std::optional oi); - -private: - static std::string s_messg; - static int s_counter; -}; - -} // namespace testsuite - diff --git a/test/cppcli_list.txt b/test/cppcli_list.txt deleted file mode 100644 index f3323fe..0000000 --- a/test/cppcli_list.txt +++ /dev/null @@ -1,13 +0,0 @@ -.\include -.\lib -.\include\djinni -.\include\djinni\cppcli -.\include\djinni\proxy_cache_interface.hpp -.\include\djinni\proxy_cache_impl.hpp -.\include\djinni\djinni_common.hpp -.\include\djinni\cppcli\Marshal.hpp -.\include\djinni\cppcli\AutoPtr.hpp -.\include\djinni\cppcli\Error.hpp -.\include\djinni\cppcli\Assert.hpp -.\include\djinni\cppcli\WrapperCache.hpp -.\lib\djinni_support_lib.lib From f5573596337998c19502365186a5a6662683f69d Mon Sep 17 00:00:00 2001 From: a4z Date: Wed, 1 Oct 2025 19:26:43 +0200 Subject: [PATCH 16/22] Clean docs --- docs/developer-guide.md | 5 ++-- docs/install.md | 8 ++---- docs/python-support.md | 58 ----------------------------------------- 3 files changed, 5 insertions(+), 66 deletions(-) delete mode 100644 docs/python-support.md diff --git a/docs/developer-guide.md b/docs/developer-guide.md index 176ab03..bbbeaf6 100644 --- a/docs/developer-guide.md +++ b/docs/developer-guide.md @@ -42,9 +42,11 @@ ctest #### C++/CLI 1. Generate Visual Studio Solution with `-G "Visual Studio 16 2019"`: + ```sh cmake -S . -B build -DDJINNI_WITH_CPPCLI=ON -DDJINNI_STATIC_LIB=ON -G "Visual Studio 16 2019" ``` + 2. Open the solution `djinni_support_lib.sln` in Visual Studio. 3. Build `DjinniCppCliTest`. 4. Run the tests: Test > Run All Tests. @@ -59,7 +61,7 @@ You can preview how the docs will look like: # install required dependencies pip install -r mkdocs-requirements.txt # render a live preview of the docs under http://127.0.0.1:8000 -mkdocs serve +mkdocs serve ``` ## Release process @@ -68,4 +70,3 @@ To release a new version of the support-lib, the following steps must be followe 1. Create a [new release](https://github.com/cross-language-cpp/djinni-support-lib/releases/new) on Github like [described here](https://docs.github.com/en/github/administering-a-repository/managing-releases-in-a-repository). Set a tag version following [semantic versioning](https://semver.org/) rules (`v..`) and describe what has changed in the new version. -3. Create a PR to the [conan-center-index](https://github.com/conan-io/conan-center-index/tree/master/recipes/djinni-support-lib) to publish the new version to [Conan Center](https://conan.io/center/djinni-support-lib). diff --git a/docs/install.md b/docs/install.md index fbb7464..4121a0a 100644 --- a/docs/install.md +++ b/docs/install.md @@ -19,8 +19,6 @@ if(ANDROID) set(DJINNI_WITH_JNI ON CACHE INTERNAL "") elseif(CMAKE_SYSTEM_NAME IN_LIST "Darwin;iOS") set(DJINNI_WITH_OBJC ON CACHE INTERNAL "") -elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") - set(DJINNI_WITH_CPPCLI ON CACHE INTERNAL "") endif() add_subdirectory(thirdparty/djinni-support-lib) @@ -47,8 +45,6 @@ if(ANDROID) set(DJINNI_WITH_JNI ON CACHE INTERNAL "") elseif(CMAKE_SYSTEM_NAME IN_LIST "Darwin;iOS") set(DJINNI_WITH_OBJC ON CACHE INTERNAL "") -elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") - set(DJINNI_WITH_CPPCLI ON CACHE INTERNAL "") endif() FetchContent_MakeAvailable(djinni-support-lib) @@ -61,6 +57,8 @@ target_link_libraries(foo PRIVATE djinni-support-lib::djinni-support-lib) ### Conan +(deprecated) + The library is available at [conan-center](https://conan.io/center/djinni-support-lib): ```text @@ -77,6 +75,4 @@ djinni-support-lib/1.2.1 | `target` | `deprecated` | *Do not use the target option anymore! It exists just to stay compatible to old versions of the recipe and will be removed.* | | `with_jni` | `True`, `False`, `auto` | Default: `auto`. Wether to build JNI bindings or not. `auto` means `True` for Android builds, `False` for other platforms. | | `with_objc` | `True`, `False`, `auto` | Default: `auto`. Wether to build Objective-C bindings or not. `auto` means `True` for any Darwin platform (iOS, macOS, ...), `False` false other platforms. | -| `with_python` | `True`, `False`, `auto` | Default: `auto`. Wether to build Python bindings or not. `auto` means `False`. | -| `with_cppcli` | `True`, `False`, `auto` | Default: `auto`. Wether to build C++/CLI bindings or not. `auto` means `True` on Windows, `False` otherwise. | | `system_java` | `True`, `False` | Wether `zulu-openjdk/11.0.8` should be installed from conan center if `target=jni`. Set to `True` to use the system JDK. (Default: `False`, Android: `True`) | diff --git a/docs/python-support.md b/docs/python-support.md deleted file mode 100644 index 21c9b33..0000000 --- a/docs/python-support.md +++ /dev/null @@ -1,58 +0,0 @@ -# Python Support - -Python support in Djinni is experimental, but ready to try out. It can generate code for bridging -C++ with Python 3. - -For more information, you can check out the talk from CppCon 2015. -[Slides](https://bit.ly/djinnitalk2) and [video](https://bit.ly/djinnivideo2) are avilable online. - -## Pre-requisites - -Djinni generates code which should work with Python 3. Python support has only been tested on macOS -with the clang compiler. ~~It's been designed to work on any platform, and the known issues are in -the build scripts rather than the generated code itself.~~ _(We're now using CMake to build all -bindings but it still requires testing in platforms other than macOS.)_ - -The Python support generated by Djinni makes use of a few non-default Python extensions, as does the -test suite. You can install them as follows: - -``` - sudo pip3 install cffi - sudo pip3 install future - sudo pip3 install pytest -``` - -## Test Suite - -Because of the known limitations described below, the Python test suite does not use all of the same -inputs as the other languages. As a result, you'll see a separate `pycpp` directory in -generated-src. This contains output of the standard C++ generator, but for the specific input files -used by the Python test suite. - -## Known limitations - -* Proxy caching is not yet implemented. In addition to some inefficiency, this means that the same -object passed across the language boundary twice is not guaranteed to appear as a single object on -the other side. -* The support library code makes direct reference to types rather than respecting the -command-line choice of a different optional library. - - -## Python support on Windows not complete yet - -If you want help development of that feature, please download the current generator for Windows and place it in the root folder. - -Generate the cmake project: - -``` -cmake -S . -B build/py -DDJINNI_WITH_PYTHON=ON -DDJINNI_EXECUTABLE="$(((Get-Location).Path) -replace "\\","/")/djinni.bat" -G "Visual Studio 16 2019" -``` - - -Run the build - -``` -cmake --build build/py -``` - -Explore the error. Help will be welcome! From 24cd19299fe3cc287f4f31c3eb66469a47a18b23 Mon Sep 17 00:00:00 2001 From: a4z Date: Wed, 1 Oct 2025 19:38:35 +0200 Subject: [PATCH 17/22] Remove temporary file --- AGENT.md | 67 -------------------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 AGENT.md diff --git a/AGENT.md b/AGENT.md deleted file mode 100644 index b11799e..0000000 --- a/AGENT.md +++ /dev/null @@ -1,67 +0,0 @@ -# Djinni support lib refactoring instructions - -This is the support lib for - -Over time, language support has been added, and now they are a maintainance burden. -We want to go back to basic, that means, focus on Objective-C and Java (JNI) support. - -There is a python interaface and a C# interface. -We can keep the plain c wrapper, called cwrapper, if is is C specific and does not have dependencies other than C/C++. - -- [x] Clean up the build system and remove everything does does not belong to Objective-C and Java (JNI) or C support. -- [x] Remove all code that does not belong to Objective-C and Java (JNI) or C support. -- [ ] Remove all tests that does not belong to Objective-C and Java (JNI) or C support. -- [ ] Clean up the documentation remove everything that does not belong to Objective-C and Java (JNI) or C support. - -The project builds with cmake, every step we shall be able to run cmake and do the tests. -To make that happen, I need 2 generator versions. - -Implementation shall happen step by step and interative. -No agent mode to go crazy, follow the plan. - -## step 1 - -Clean up CMake build system - -### Definition of done 1 - -To succeed, sh zconf-new.sh shall run without error, and a build of it must work! - -In the new generator, the C wrapper has been disabled, maybe we bring the back. -If there are problems due to the C wrapper, we will disable them in this project for now. - -## Step 2 - -Remove all code that does not belong to Objective-C and Java (JNI) or C support. - -### Definition of done 2 - -To succeed, sh zconf-new.sh shall run without error, and a build of it must work! - -In the new generator, the C wrapper has been disabled, maybe we bring the back. -If there are problems due to the C wrapper, we will disable them in this project for now. - -## Step 3 - -Remove all test code that does not belong to Objective-C and Java (JNI) or C support. - -### Definition of done 3 - -To succeed, sh zconf-new.sh shall run without error, and a build of it must work! - -In the new generator, the C wrapper has been disabled, maybe we bring the back. -If there are problems due to the C wrapper, we will disable them in this project for now. - -## General build instrucktions - -### New version - - sh zconf-new.sh - cmake --build build/new --config Debug - (cd build/new && ctest -C Debug) - -### Old version - - sh zconf-old.sh - cmake --build build/old --config Debug - (cd build/old && ctest -C Debug) From 6d6a79f90eeeeb48257dc64b877000b879edc8a1 Mon Sep 17 00:00:00 2001 From: a4z Date: Tue, 7 Oct 2025 08:25:55 +0200 Subject: [PATCH 18/22] Add conf scripts --- zconf-new.sh | 4 ++++ zconf-old.sh | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 zconf-new.sh create mode 100644 zconf-old.sh diff --git a/zconf-new.sh b/zconf-new.sh new file mode 100644 index 0000000..3f74645 --- /dev/null +++ b/zconf-new.sh @@ -0,0 +1,4 @@ +cmake -G "Ninja Multi-Config" -B build/new -S . --fresh \ + -DDJINNI_WITH_OBJC=ON -DDJINNI_WITH_JNI=ON -DDJINNI_WITH_CPPCLI=OFF \ + -DDJINNI_EXECUTABLE=$(pwd)/../djinni-generator/target/bin/djinni \ + -DCMAKE_OSX_SYSROOT=/Applications/Xcode-16.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk diff --git a/zconf-old.sh b/zconf-old.sh new file mode 100644 index 0000000..4447c2a --- /dev/null +++ b/zconf-old.sh @@ -0,0 +1,5 @@ +cmake -G "Ninja Multi-Config" -B build/old -S . --fresh \ + -DDJINNI_WITH_OBJC=ON -DDJINNI_WITH_JNI=ON -DDJINNI_WITH_CPPCLI=OFF \ + -DDJINNI_EXECUTABLE=$(pwd)/ztmp/old/djinni \ + -DCMAKE_OSX_SYSROOT=$(xcodebuild -version -sdk macosx Path) + From d9df4c8f774436c75a7e84201176fc7f475799e3 Mon Sep 17 00:00:00 2001 From: a4z Date: Tue, 7 Oct 2025 11:43:06 +0200 Subject: [PATCH 19/22] Continue removal of py anc c# --- .bazelrc | 71 +++++ CMakeLists.txt | 69 +---- djinni/cppcli/Assert.hpp | 23 -- djinni/cppcli/AutoPtr.hpp | 70 ----- djinni/cppcli/Error.cpp | 33 --- djinni/cppcli/Error.hpp | 38 --- djinni/cppcli/Marshal.hpp | 286 ------------------ djinni/cppcli/WrapperCache.cpp | 41 --- djinni/cppcli/WrapperCache.hpp | 139 --------- djinni/cwrapper/wrapper_marshal.cpp | 333 --------------------- djinni/cwrapper/wrapper_marshal.h | 92 ------ djinni/cwrapper/wrapper_marshal.hpp | 220 -------------- djinni/py/djinni/__init__.py | 2 - djinni/py/djinni/exception.py | 51 ---- djinni/py/djinni/pycffi_marshal.py | 443 ---------------------------- djinni/py/djinni/support.py | 75 ----- docs/developer-guide.md | 12 - docs/install.md | 2 +- requirements.txt | 3 - test-suite/CMakeLists.txt | 105 ------- zconf-new.sh | 4 +- 21 files changed, 76 insertions(+), 2036 deletions(-) create mode 100644 .bazelrc delete mode 100644 djinni/cppcli/Assert.hpp delete mode 100644 djinni/cppcli/AutoPtr.hpp delete mode 100644 djinni/cppcli/Error.cpp delete mode 100644 djinni/cppcli/Error.hpp delete mode 100644 djinni/cppcli/Marshal.hpp delete mode 100644 djinni/cppcli/WrapperCache.cpp delete mode 100644 djinni/cppcli/WrapperCache.hpp delete mode 100644 djinni/cwrapper/wrapper_marshal.cpp delete mode 100644 djinni/cwrapper/wrapper_marshal.h delete mode 100644 djinni/cwrapper/wrapper_marshal.hpp delete mode 100644 djinni/py/djinni/__init__.py delete mode 100644 djinni/py/djinni/exception.py delete mode 100644 djinni/py/djinni/pycffi_marshal.py delete mode 100644 djinni/py/djinni/support.py delete mode 100644 requirements.txt diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000..940dee9 --- /dev/null +++ b/.bazelrc @@ -0,0 +1,71 @@ +# Bazel configuration for djinni-support-lib + +# Import common configs +import %workspace%/.bazelrc.common + +# Build optimizations +build --compilation_mode=opt +build --copt=-O2 +build --copt=-DNDEBUG + +# C++ Configuration +build --cxxopt=-std=c++17 +build --host_cxxopt=-std=c++17 +build --copt=-Wall +build --copt=-Wextra +build --copt=-Werror + +# Platform-specific configurations +build:linux --copt=-fPIC +build:linux --linkopt=-ldl + +build:macos --copt=-fPIC +build:macos --linkopt=-framework Foundation +build:macos --apple_platform_type=macos + +build:ios --apple_platform_type=ios +build:ios --copt=-fobjc-arc +build:ios --linkopt=-framework Foundation + +build:windows --copt=/std:c++17 +build:windows --host_copt=/std:c++17 + +# JNI Configuration +build --define=with_jni=true + +# Objective-C Configuration (when building on macOS/iOS) +build:objc --copt=-fobjc-arc +build:objc --copt=-x +build:objc --copt=objective-c++ + +# Python Configuration +build:python --define=with_python=true + +# C++/CLI Configuration (Windows only) +build:cppcli --define=with_cppcli=true +build:cppcli --copt=/clr + +# Test Configuration +test --test_output=errors +test --test_summary=detailed +test --test_verbose_timeout_warnings + +# Coverage +coverage --combined_report=lcov +coverage --coverage_report_generator=@bazel_tools//tools/test:coverage_report_generator + +# Debug Configuration +build:debug --compilation_mode=dbg +build:debug --copt=-g +build:debug --strip=never +build:debug --linkopt=-g + +# Fast build (for development) +build:fastbuild --compilation_mode=fastbuild + +# Remote execution (if using remote build execution) +build:remote --remote_executor=... +build:remote --remote_cache=... + +# Try to import user-specific .bazelrc.user file if it exists +try-import %workspace%/.bazelrc.user diff --git a/CMakeLists.txt b/CMakeLists.txt index 5558835..e5fd94d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.10.0) if(DJINNI_WITH_OBJC) set(PROJECT_LANGUAGES OBJC OBJCXX) -elseif(DJINNI_WITH_CPPCLI) - set(PROJECT_LANGUAGES CSharp) endif() project(djinni_support_lib CXX ${PROJECT_LANGUAGES}) @@ -32,22 +30,6 @@ set(SRC_OBJC "djinni/objc/DJIProxyCaches.mm" ) -set(SRC_C_WRAPPER - "djinni/cwrapper/wrapper_marshal.cpp" - "djinni/cwrapper/wrapper_marshal.h" - "djinni/cwrapper/wrapper_marshal.hpp" -) - -set(SRC_CPPCLI - "djinni/cppcli/Assert.hpp" - "djinni/cppcli/AutoPtr.hpp" - "djinni/cppcli/Error.hpp" - "djinni/cppcli/Error.cpp" - "djinni/cppcli/Marshal.hpp" - "djinni/cppcli/WrapperCache.hpp" - "djinni/cppcli/WrapperCache.cpp" -) - # set `DJINNI_LIBRARY_TYPE` to `STATIC` or `SHARED` to define the type of library. # If undefined, the type will be determined based on `BUILD_SHARED_LIBS` add_library(djinni_support_lib ${DJINNI_LIBRARY_TYPE} ${SRC_SHARED}) @@ -133,55 +115,8 @@ if(DJINNI_WITH_JNI) endif() endif() -# Python support -option(DJINNI_WITH_PYTHON "Include the Python support code in Djinni support library." OFF) -if(DJINNI_WITH_PYTHON) - set_target_properties(djinni_support_lib PROPERTIES - POSITION_INDEPENDENT_CODE ON) - target_sources(djinni_support_lib PRIVATE ${SRC_C_WRAPPER}) - source_group("cwrapper" FILES ${SRC_C_WRAPPER}) - # these files might be delivered in future per default - install( - FILES - "djinni/cwrapper/wrapper_marshal.h" - "djinni/cwrapper/wrapper_marshal.hpp" - DESTINATION - ${CMAKE_INSTALL_INCLUDEDIR}/djinni/cwrapper - ) -endif() - -option(DJINNI_WITH_CPPCLI "Include the C++/CLI support code in Djinni support library." OFF) -if(DJINNI_WITH_CPPCLI) - - if(NOT MSVC) - message(FATAL_ERROR "Enabling DJINNI_WITH_CPPCLI without MSVC is not supported") - endif() - - if(DJINNI_WITH_OBJC OR DJINNI_WITH_JNI OR DJINNI_WITH_PYTHON) - message(FATAL_ERROR "DJINNI_WITH_CPPCLI can not be used with other bindings enabled.") - endif() - - target_sources(djinni_support_lib PRIVATE ${SRC_CPPCLI}) - source_group("cppcli" FILES ${SRC_CPPCLI}) - set_target_properties(djinni_support_lib PROPERTIES - VS_DOTNET_REFERENCES "System;System.Core" - COMMON_LANGUAGE_RUNTIME "" - ) - - install( - FILES - "djinni/cppcli/Assert.hpp" - "djinni/cppcli/AutoPtr.hpp" - "djinni/cppcli/Error.hpp" - "djinni/cppcli/Marshal.hpp" - "djinni/cppcli/WrapperCache.hpp" - DESTINATION - ${CMAKE_INSTALL_INCLUDEDIR}/djinni/cppcli - ) -endif() - -if(NOT (DJINNI_WITH_OBJC OR DJINNI_WITH_JNI OR DJINNI_WITH_PYTHON OR DJINNI_WITH_CPPCLI)) - message(FATAL_ERROR "At least one of DJINNI_WITH_OBJC or DJINNI_WITH_JNI or DJINNI_WITH_PYTHON or DJINNI_WITH_CPPCLI must be enabled.") +if(NOT (DJINNI_WITH_OBJC OR DJINNI_WITH_JNI)) + message(FATAL_ERROR "At least one of DJINNI_WITH_OBJC or DJINNI_WITH_JNI must be enabled.") endif() option(DJINNI_BUILD_TESTING "Build tests" ON) diff --git a/djinni/cppcli/Assert.hpp b/djinni/cppcli/Assert.hpp deleted file mode 100644 index eeb7a8c..0000000 --- a/djinni/cppcli/Assert.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// -// Copyright 2021 cross-language-cpp -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#pragma once - -#ifdef _DEBUG -#define ASSERT(condition, ...) ::System::Diagnostics::Debug::Assert(condition, ##__VA_ARGS__) -#else -#define ASSERT(condition, ...) // This macro will completely evaporate in Release. -#endif diff --git a/djinni/cppcli/AutoPtr.hpp b/djinni/cppcli/AutoPtr.hpp deleted file mode 100644 index 0766773..0000000 --- a/djinni/cppcli/AutoPtr.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// -// Copyright 2021 cross-language-cpp -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#pragma once - -#include "Assert.hpp" - -template -ref struct AutoPtr { - AutoPtr() : _ptr(0) {} - AutoPtr(T* ptr) : _ptr(ptr) {} - AutoPtr(AutoPtr% right) : _ptr(right.Release()) {} - - ~AutoPtr() { - delete _ptr; - _ptr = 0; - } - !AutoPtr() { - //ASSERT(0 == _ptr); - delete _ptr; - } - T* operator->() { - if (0 == _ptr) { - throw gcnew System::ObjectDisposedException(System::String::Empty); - } - - return _ptr; - } - - T* GetPointer() { - return _ptr; - } - T& GetRef() { - if (0 == _ptr) { - throw gcnew System::ObjectDisposedException(System::String::Empty); - } - - return *_ptr; - } - T* Release() { - T* released = _ptr; - _ptr = 0; - return released; - } - void Reset() { - Reset(0); - } - void Reset(T* ptr) { - if (ptr != _ptr) { - delete _ptr; - _ptr = ptr; - } - } - -private: - T* _ptr; -}; diff --git a/djinni/cppcli/Error.cpp b/djinni/cppcli/Error.cpp deleted file mode 100644 index 423cd0d..0000000 --- a/djinni/cppcli/Error.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// -// Copyright 2021 cross-language-cpp -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include "Error.hpp" - -namespace djinni { - -void ThrowUnimplemented(const char *, const char * msg) { - throw gcnew System::NotImplementedException(msclr::interop::marshal_as(msg)); -} - -void ThrowNativeExceptionFromCurrent(const char *) { - try { - throw; - } catch (const std::exception & e) { - throw gcnew System::Exception(msclr::interop::marshal_as(e.what())); - } -} - -} diff --git a/djinni/cppcli/Error.hpp b/djinni/cppcli/Error.hpp deleted file mode 100644 index 0d3ad27..0000000 --- a/djinni/cppcli/Error.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// -// Copyright 2021 cross-language-cpp -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#pragma once - -#include - -namespace djinni { - -// Throws an exception for an unimplemented method call. -void ThrowUnimplemented(const char * ctx, const char * msg); - -// Helper function for exception translation. Do not call directly! -void ThrowNativeExceptionFromCurrent(const char * ctx); - -} - -#define DJINNI_UNIMPLEMENTED(msg) \ - ::djinni::ThrowUnimplemented(__FUNCTION__, msg); \ - return nullptr; // Silence warning C4715: not all control paths return a value - -#define DJINNI_TRANSLATE_EXCEPTIONS() \ - catch (const std::exception&) { \ - ::djinni::ThrowNativeExceptionFromCurrent(__FUNCTION__); \ - } \ No newline at end of file diff --git a/djinni/cppcli/Marshal.hpp b/djinni/cppcli/Marshal.hpp deleted file mode 100644 index a5f9cee..0000000 --- a/djinni/cppcli/Marshal.hpp +++ /dev/null @@ -1,286 +0,0 @@ -// -// Copyright 2021 cross-language-cpp -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#pragma once - -#include - -#include -#include -#include -#include -#include -#include - -#include "Assert.hpp" - -namespace djinni { - -template -struct Primitive { - using CppType = CppTypeArg; - using CsType = CsTypeArg; - - static CppType ToCpp(CsType x) noexcept { - return x; - } - static CsType FromCpp(CppType x) noexcept { - return x; - } -}; - -using Bool = Primitive; -using I8 = Primitive; -using I16 = Primitive; -using I32 = Primitive; -using I64 = Primitive; -using F32 = Primitive; -using F64 = Primitive; - -template -struct Enum { - using CppType = CppEnum; - using CsType = CsEnum; - - static CppType ToCpp(CsType e) noexcept { - return static_cast(e); - } - - static CsType FromCpp(CppType e) noexcept { - return static_cast(e); - } -}; - -struct String { - using CppType = std::string; - using CsType = System::String^; - - static CppType ToCpp(CsType string) { - ASSERT(string != nullptr); - cli::array^ bytes = System::Text::Encoding::UTF8->GetBytes(string); - CppType cpp_str; - cpp_str.resize(bytes->Length); - System::Runtime::InteropServices::Marshal::Copy(bytes,0,System::IntPtr(const_cast(cpp_str.data())),cpp_str.length()); - return cpp_str; - } - - static CsType FromCpp(const CppType& string) { - cli::array^ bytes = gcnew cli::array(string.length()); - for(size_t i=0; i< string.length(); i++) { - bytes[i] = string[i]; - } - return System::Text::Encoding::UTF8->GetString(bytes); - } -}; - -struct WString { - using CppType = std::wstring; - using CsType = System::String^; - - static CppType ToCpp(CsType string) { - ASSERT(string != nullptr); - return msclr::interop::marshal_as(string); - } - - static CsType FromCpp(const CppType& string) { - return msclr::interop::marshal_as(string); - } -}; - -struct Date { - using CppType = std::chrono::system_clock::time_point; - using CsType = System::DateTime; - - using Ticks = std::chrono::duration>; - static const auto TicksBeforeEpoch = 621355968000000000; - - static CppType ToCpp(CsType date) { - auto ticks = Ticks(date.Ticks - TicksBeforeEpoch); - return std::chrono::system_clock::time_point(ticks); - } - - static CsType FromCpp(const CppType& date) { - auto ticks = std::chrono::duration_cast(date.time_since_epoch()).count(); - return CsType(ticks + TicksBeforeEpoch); - } -}; - -struct Binary { - using CppType = std::vector; - using CsType = array^; - - using Boxed = Binary; - - static CppType ToCpp(CsType data) { - ASSERT(data != nullptr); - CppType v; - v.reserve(data->Length); - for each (auto value in data) { - v.emplace_back(value); - } - return v; - } - - static CsType FromCpp(const CppType& bytes) { - auto len = bytes.size(); - auto ret = gcnew array(len); - System::Runtime::InteropServices::Marshal::Copy(System::IntPtr(const_cast(&bytes[0])), ret, 0, len); - return ret; - } -}; - -template -struct IsRef : std::false_type {}; - -template -struct IsRef : std::true_type {}; - -template -struct IsRef^> : std::true_type {}; - -template -struct CsOptional { - typedef System::Nullable type; -}; - -template -struct CsOptional { - typedef T^ type; -}; - -template -struct CsOptional^> { - typedef array^ type; -}; - - -template class OptionalType, class T> -struct Optional { - // SFINAE helper: if C::CppOptType exists, opt_type(nullptr) will return - // that type. If not, it returns OptionalType. This is necessary - // because we special-case optional interfaces to be represented as a nullable - // std::shared_ptr, not optional> or optional>>. - template static OptionalType opt_type(...); - template static typename C::CppOptType opt_type(typename C::CppOptType*); - - using CppType = decltype(opt_type(0)); - using CsType = typename T::CsType; - - using CsOptionalType = typename ::djinni::CsOptional::type; - - // Enabled for reference types (^). - template ::value, int>::type = 0> - static CppType ToCpp(O obj) { - if (obj != nullptr) { - return T::ToCpp(obj); - } - return CppType(); - } - - // Enabled for value types that require System::Nullable<>. - template ::value, int>::type = 0> - static CppType ToCpp(O obj) { - if (obj.HasValue) { - return T::ToCpp(obj.Value); - } - return CppType(); - } - - // FromCpp used for normal optionals - static CsOptionalType FromCpp(const OptionalType& opt) { - return opt ? T::FromCpp(*opt) : CsOptionalType(); - } - - // FromCpp used for nullable objects - template - static CsType FromCpp(const typename C::CppOptType& cppOpt) { - return T::FromCppOpt(cppOpt); - } -}; - -template -struct List { - using CppType = std::vector; - using CsType = System::Collections::Generic::List^; - - static CppType ToCpp(CsType l) { - ASSERT(l != nullptr); - CppType v; - v.reserve(l->Count); - for each (auto value in l) { - v.emplace_back(T::ToCpp(value)); - } - return v; - } - - static CsType FromCpp(const CppType& v) { - auto l = gcnew System::Collections::Generic::List(); - for (const auto& value : v) { - l->Add(T::FromCpp(value)); - } - return l; - } -}; - -template -class Set { -public: - using CppType = std::unordered_set; - using CsType = System::Collections::Generic::HashSet^; - - static CppType ToCpp(CsType set) { - ASSERT(set != nullptr); - CppType s; - for each (auto value in set) { - s.insert(T::ToCpp(value)); - } - return s; - } - - static CsType FromCpp(const CppType& s) { - auto set = gcnew System::Collections::Generic::HashSet(); - for (const auto& value : s) { - set->Add(T::FromCpp(value)); - } - return set; - } -}; - -template -struct Map { - using CppType = std::unordered_map; - using CsType = System::Collections::Generic::Dictionary^; - - static CppType ToCpp(CsType map) { - ASSERT(map != nullptr); - CppType m; - m.reserve(map->Count); - for each (auto& kvp in map) { - m.emplace(Key::ToCpp(kvp.Key), Value::ToCpp(kvp.Value)); - } - return m; - } - - static CsType FromCpp(const CppType& m) { - auto map = gcnew System::Collections::Generic::Dictionary(m.size()); - for (const auto& kvp : m) { - map->Add(Key::FromCpp(kvp.first), Value::FromCpp(kvp.second)); - } - return map; - } -}; - -} // namespace djinni diff --git a/djinni/cppcli/WrapperCache.cpp b/djinni/cppcli/WrapperCache.cpp deleted file mode 100644 index 35553e8..0000000 --- a/djinni/cppcli/WrapperCache.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright 2021 cross-language-cpp -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#pragma once - -#include "WrapperCache.hpp" -#include "../proxy_cache_impl.hpp" - -namespace djinni { - -using UnowningImplPointer = CsProxyCacheTraits::UnowningImplPointer; - -struct CsHashCode { size_t operator() (UnowningImplPointer obj) const; }; -struct CsReferenceEquals { bool operator() (UnowningImplPointer obj1, UnowningImplPointer obj2) const; }; - -size_t CsHashCode::operator() (UnowningImplPointer obj) const { - return obj.hash_code(); -} -bool CsReferenceEquals::operator() (UnowningImplPointer obj1, UnowningImplPointer obj2) const { - auto ptr1 = obj1.lock(); - auto ptr2 = obj2.lock(); - return System::Object::ReferenceEquals(ptr1.get(), ptr2.get()); -} - -template class ProxyCache; -template class ProxyCache; - -} diff --git a/djinni/cppcli/WrapperCache.hpp b/djinni/cppcli/WrapperCache.hpp deleted file mode 100644 index 22f9c10..0000000 --- a/djinni/cppcli/WrapperCache.hpp +++ /dev/null @@ -1,139 +0,0 @@ -// -// Copyright 2021 cross-language-cpp -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#pragma once - -#include "AutoPtr.hpp" -#include "../proxy_cache_interface.hpp" -#include - -namespace djinni { - -template -class CsRef; - -template -class CsRef { -public: - CsRef() : _ref(nullptr) {} - CsRef(CsType ref) : _ref(ref) {} - - CsRef(CsRef&&) = default; - CsRef& operator=(CsRef&&) = default; - - CsRef(const CsRef&) = default; - CsRef& operator=(const CsRef&) = default; - - operator bool() { return static_cast(_ref) != nullptr; } - CsType operator->() const { return get(); } - CsType get() const { return _ref; } - -private: - gcroot _ref; -}; - -/* -* Native wrapper to C#'s WeakReference type. Instances of this type do not prevent the -* garbage collector from reclaiming referred-to objects. -*/ -class WeakCsRef { -public: - WeakCsRef(System::Object^ ref) - : _weak_ref(gcnew System::WeakReference(ref)) - , _hash_code(ref->GetHashCode()) {} - - WeakCsRef(const CsRef& ref) - : _weak_ref(gcnew System::WeakReference(ref.get())) - , _hash_code(ref->GetHashCode()) {} - - CsRef lock() const { return dynamic_cast(_weak_ref->Target); } - bool expired() const { return !_weak_ref->IsAlive; } - size_t hash_code() { return _hash_code; } - -private: - CsRef _weak_ref; - size_t _hash_code; -}; - -struct CsHashCode; -struct CsReferenceEquals; -struct CsProxyCacheTraits { - using UnowningImplPointer = WeakCsRef; - using OwningImplPointer = CsRef; - using OwningProxyPointer = std::shared_ptr; - using WeakProxyPointer = std::weak_ptr; - using UnowningImplPointerHash = CsHashCode; - using UnowningImplPointerEqual = CsReferenceEquals; -}; - -// This declares that GenericProxyCache will be instantiated separately. The actual -// explicit instantiations are in DJIProxyCaches.mm. -extern template class ProxyCache; -using CsProxyCache = ProxyCache; - -template -static std::shared_ptr get_cs_proxy(CsType cs) { - return std::static_pointer_cast(CsProxyCache::get( - typeid(CppType), - cs, - [](const CsProxyCacheTraits::OwningImplPointer& cs) -> std::pair, CsProxyCacheTraits::UnowningImplPointer> { - return std::make_pair, CsProxyCacheTraits::UnowningImplPointer>(std::make_shared(cs), cs); - } - )); -} - -struct CppProxyCacheTraits { - using UnowningImplPointer = void *; - using OwningImplPointer = std::shared_ptr; - using OwningProxyPointer = CsRef; - using WeakProxyPointer = WeakCsRef; - using UnowningImplPointerHash = std::hash; - using UnowningImplPointerEqual = std::equal_to; -}; - -// This declares that GenericProxyCache will be instantiated separately. The actual -// explicit instantiations are in CppWrapperCache.cpp. -extern template class ProxyCache; -using CppProxyCache = ProxyCache; - -// If the type T has a handle declarator (^), provides the member typedef type which is the type referred to by T. Otherwise type is T. -template struct remove_handle { typedef T type; }; -template struct remove_handle { typedef T type; }; - -// Helper for get_cpp_proxy_impl that takes a std::shared_ptr. -template -CsType get_cpp_proxy_impl(const std::shared_ptr & cppRef) { - auto proxy = CppProxyCache::get( - typeid(cppRef), - cppRef, - [](const std::shared_ptr & cppRef) -> std::pair { - return { - CsRef(gcnew typename remove_handle::type(std::static_pointer_cast(cppRef))), - cppRef.get() - }; - } - ); - return dynamic_cast(proxy.get()); -} - -// get_cpp_proxy takes any smart pointer type, as long as it can be implicitly cast -// to std::shared_ptr. This means get_cpp_proxy can also be passed non-nullable pointers. -template -CsType get_cpp_proxy(const CppPtrType& cppRef) { - return get_cpp_proxy_impl::type>(cppRef); -} - -} diff --git a/djinni/cwrapper/wrapper_marshal.cpp b/djinni/cwrapper/wrapper_marshal.cpp deleted file mode 100644 index c373d97..0000000 --- a/djinni/cwrapper/wrapper_marshal.cpp +++ /dev/null @@ -1,333 +0,0 @@ -// preliminary -// Part of support library for djinni4python, handwritten - -#include // for debugging -#include "wrapper_marshal.hpp" - -#include "djinni/djinni_common.hpp" -#include -#include // for debugging -#include - -using namespace djinni; -using namespace djinni::optionals; -using std::optional; -using std::nullopt; - -// Helpers to convert from a 'handle type' to a 'optional-handle type' or the other way around -// Useful in generated code, when marshaling and unmarshaling optional structured types, as it helps differentiate -// which overload of a toCpp, fromCpp function to be used -Handle optionals::toOptionalHandle(Handle handle, - DeleterFn deletefn) { - return Handle((DjinniOptionalObjectHandle *) handle.release(), deletefn); -} - -Handle optionals::fromOptionalHandle(Handle handle, - DeleterFn deletefn) { - return Handle((DjinniObjectHandle *) handle.release(), deletefn); -} - -Handle optionals::toOptionalHandle(Handle handle, - DeleterFn deletefn) { - return Handle((DjinniOptionalRecordHandle *) handle.release(), deletefn); - -} - -Handle optionals::fromOptionalHandle(Handle handle, - DeleterFn deletefn) { - return Handle((DjinniRecordHandle *) handle.release(), deletefn); -} - -// Support for Handling Exceptions -static CreateExceptionFnPtr s_djinni_create_exception; -static DeleteExceptionFnPtr s_djinni_exception___delete; - -// Structure holding current exception, if any -struct ExceptionState { - static djinni::Handle newHandle(DjinniFrontEndExceptionHandle * c_ptr) { - return djinni::Handle(c_ptr, s_djinni_exception___delete); - } - - djinni::Handle takeException() { - auto aux = std::move(handle); - handle = nullptr; - return aux; - } - - djinni::Handle handle; -}; - -// Current exception state -static thread_local ExceptionState s_exception_state; - -// to be called from front-end -void djinni_create_and_set_cpp_exception(DjinniFrontEndExceptionHandle * exception_handle) { - s_exception_state.handle = ExceptionState::newHandle(exception_handle); -} - -void _djinni_add_callback_create_exception_from_cpp(CreateExceptionFnPtr fct_ptr) { - s_djinni_create_exception = fct_ptr; -} -void _djinni_add_callback_exception___delete(DeleteExceptionFnPtr fct_ptr) { - s_djinni_exception___delete = fct_ptr; -} - -void djinni::cw_default_throw_exception(djinni::Handle e_handle) { - throw djinni::front_end_exception(std::move(e_handle)); -} - -DJINNI_WEAK_DEFINITION -void djinni::cw_throw_exception(djinni::Handle e_handle) { - cw_default_throw_exception(std::move(e_handle)); -} - -// to be called from cpp to allow cpp impl to know about front-end exception -void djinni::cw_throw_if_pending() { - auto e_handle = s_exception_state.takeException(); - - if (e_handle) { - cw_throw_exception(std::move(e_handle)); - } -} - -djinni::Handle djinni::cw_default_get_front_end_exception(const std::exception_ptr & e_ptr) noexcept { - try { - if (e_ptr) { - std::rethrow_exception(e_ptr); - } - } catch (djinni::front_end_exception & e) { // exception generated by front-end code - return e.takeFrontEndException(); - } catch (const std::exception & e) { // exception generated by user cpp code - auto e_mesg = DjinniString::fromCpp(e.what()); - return ExceptionState::newHandle(s_djinni_create_exception(e_mesg.release())); - } - assert(false); - return {}; //avoid compiler warning not returning anything -} - -// The argument is an exception_ptr for either a std::exception or a subclass of std::exception called front_end_exception -// Creates or retrieves a handle to a front-end exception from the exception_ptr -DJINNI_WEAK_DEFINITION -djinni::Handle djinni::cw_get_front_end_exception(const std::exception_ptr & e_ptr) noexcept { - return cw_default_get_front_end_exception(e_ptr); -} - -// Create a front-end exception from the exception pointer, and set it in s_exception_state to allow -// the front-end code to notice an exception was thrown. The argument is an exception_ptr for either -// a std::exception or a subclass of std::exception called front_end_exception -void djinni::cw_set_pending_exception(const std::exception_ptr & e_ptr) { - s_exception_state.handle = cw_get_front_end_exception(e_ptr); -} - -DjinniFrontEndExceptionHandle * djinni_check_and_clear_exception() { - if (s_exception_state.handle) { - return s_exception_state.takeException().release(); - } - return nullptr; -} - -// DJINNI PRIMITIVE OPTIONALS -// OPTIONAL INTEGERS -DjinniBoxedI8 * create_djinni_boxed_i8(int8_t dopt) { - return DjinniBoxedI8::newOptional(dopt).release(); -} -void delete_djinni_boxed_i8(DjinniBoxedI8 * dopt) { - delete dopt; -} -int8_t get_djinni_boxed_i8_data(DjinniBoxedI8 * dopt) { - return dopt->m_data; -} - -DjinniBoxedI16 * create_djinni_boxed_i16(int16_t dopt) { - return DjinniBoxedI16::newOptional(dopt).release(); -} -void delete_djinni_boxed_i16(DjinniBoxedI16 * dopt) { - delete dopt; -} -int16_t get_djinni_boxed_i16_data(DjinniBoxedI16 * dopt) { - return dopt->m_data; -} - -DjinniBoxedI32 * create_djinni_boxed_i32(int32_t dopt) { - return DjinniBoxedI32::newOptional(dopt).release(); -} -void delete_djinni_boxed_i32(DjinniBoxedI32 * dopt) { - delete dopt; -} -int32_t get_djinni_boxed_i32_data(DjinniBoxedI32 * dopt) { - return dopt->m_data; -} - -DjinniBoxedI64 * create_djinni_boxed_i64(int64_t dopt) { - return DjinniBoxedI64::newOptional(dopt).release(); -} -void delete_djinni_boxed_i64(DjinniBoxedI64 * dopt) { - delete dopt; -} -int64_t get_djinni_boxed_i64_data(DjinniBoxedI64 * dopt) { - return dopt->m_data; -} - -// OPTIONAL FLOATING POINTS -DjinniBoxedF32 * create_djinni_boxed_f32(float dopt) { - return DjinniBoxedF32::newOptional(dopt).release(); -} -void delete_djinni_boxed_f32(DjinniBoxedF32 * dopt) { - delete dopt; -} -float get_djinni_boxed_f32_data(DjinniBoxedF32 * dopt) { - return dopt->m_data; -} - -DjinniBoxedF64 * create_djinni_boxed_f64(double dopt) { - return DjinniBoxedF64::newOptional(dopt).release(); -} -void delete_djinni_boxed_f64(DjinniBoxedF64 * dopt) { - delete dopt; -} -double get_djinni_boxed_f64_data(DjinniBoxedF64 * dopt) { - return dopt->m_data; -} - -// OPTIONAL BOOL -DjinniBoxedBool * create_djinni_boxed_bool(bool dopt) { - return DjinniBoxedBool::newOptional(dopt).release(); -} -void delete_djinni_boxed_bool(DjinniBoxedBool * dopt) { - delete dopt; -} -bool get_djinni_boxed_bool_data(DjinniBoxedBool * dopt) { - return dopt->m_data; -} - -// DJINNI STRING -DjinniString::DjinniString(std::string s) { - this->cppstr = std::move(s); -} - -DjinniString * create_djinni_string(const char * s, size_t len) { - return DjinniString::fromCpp(std::string(s,len)).release(); -} - -void delete_djinni_string(DjinniString * ss) { - delete ss; -} - -const char * get_djinni_string_chars(const DjinniString * ds) { - return ds->cppstr.c_str(); -} - -size_t get_djinni_string_len(const DjinniString * ds) { - return ds->cppstr.length(); -} - -std::unique_ptr DjinniString::fromCpp(std::string cppstr) { - return std::unique_ptr(new DjinniString(std::move(cppstr))); -} - -std::string DjinniString::toCpp(std::unique_ptr ds) { - return std::move(ds->cppstr); -} - -// OPTIONAL DJINNI STRING -optional DjinniOptionalString::toCpp(std::unique_ptr ds) { - if (ds) { - return std::move(ds->cppstr); - } - return nullopt; -} - -std::unique_ptr DjinniOptionalString::fromCpp(optional s) { - if (s) { - return DjinniString::fromCpp(std::move(* s)); - } - return nullptr; -} - -// DJINNI BINARY -DjinniBinary::DjinniBinary(std::vector b) { - this->cppbinary = std::move(b); -} - -DjinniBinary * create_djinni_binary(const uint8_t * b, size_t len) { - return DjinniBinary::fromCpp(std::vector(b, b+len)).release(); -} - -void delete_djinni_binary(DjinniBinary * db) { - delete db; -} - -const uint8_t * get_djinni_binary_uint8s(const DjinniBinary * db) { - return db->cppbinary.data(); -} - -size_t get_djinni_binary_len(const DjinniBinary * db) { - return db->cppbinary.size(); -} - -std::unique_ptr DjinniBinary::fromCpp(std::vector cppbinary) { - return std::unique_ptr(new DjinniBinary(std::move(cppbinary))); -} - -std::vector DjinniBinary::toCpp(std::unique_ptr db) { - return std::move(db->cppbinary); -} - -// OPTIONAL DJINNI BINARY -std::unique_ptr DjinniOptionalBinary::fromCpp(optional> cppbinary) { - if (cppbinary) { - return DjinniBinary::fromCpp(std::move(* cppbinary)); - } - return nullptr; -} - -optional> DjinniOptionalBinary::toCpp(std::unique_ptr db) { - if (db) { - return std::move(db->cppbinary); - } - return nullopt; -} - -// DJINNI DATE -auto static const POSIX_EPOCH = std::chrono::system_clock::from_time_t(0); -std::chrono::system_clock::time_point DjinniDate::toCpp(uint64_t duration) { - return POSIX_EPOCH + std::chrono::milliseconds{duration}; -} - -uint64_t DjinniDate::fromCpp(std::chrono::system_clock::time_point date) { - return std::chrono::duration_cast(date - POSIX_EPOCH).count(); -} - -// OPTIONAL DJINNI DATE -std::optional -DjinniBoxedDate::toCpp(std::unique_ptr dopt) { - if (!dopt) { - return nullopt; - } - return DjinniDate::toCpp(dopt->m_data); -} - -std::unique_ptr -DjinniBoxedDate::fromCpp(std::optional dopt) { - if (!dopt) { - return nullptr; - } - return newOptional(*dopt); -} - -std::unique_ptr -DjinniBoxedDate::newOptional(std::chrono::system_clock::time_point data) { - return std::unique_ptr(new DjinniBoxedDate(DjinniDate::fromCpp(data))); -} - -DjinniBoxedDate * create_djinni_boxed_date(uint64_t dopt) { - return DjinniBoxedDate::newOptional(DjinniDate::toCpp(dopt)).release(); -} - -void delete_djinni_boxed_date(DjinniBoxedDate * dopt) { - delete dopt; -} - -uint64_t get_djinni_boxed_date_data(DjinniBoxedDate * dopt) { - return dopt->m_data; -} diff --git a/djinni/cwrapper/wrapper_marshal.h b/djinni/cwrapper/wrapper_marshal.h deleted file mode 100644 index 27bd5e3..0000000 --- a/djinni/cwrapper/wrapper_marshal.h +++ /dev/null @@ -1,92 +0,0 @@ -// preliminary -// Part of support library for djinni4python, handwritten -// pure C header to be passed as argument to the generated cffi code (to be used for creating a pycffi lib) - -#pragma once // python_cdef_ignore -#include // python_cdef_ignore -#include // python_cdef_ignore - -// Exceptions: relevant for exceptions thrown both from front-end and C++. -struct DjinniFrontEndExceptionHandle; - -// Exceptions: create C++ exceptions from front-end. -void djinni_create_and_set_cpp_exception(struct DjinniFrontEndExceptionHandle * exception_handle); - -// Exceptions: create front-end exceptions from C++. -typedef struct DjinniFrontEndExceptionHandle * (* CreateExceptionFnPtr) (struct DjinniString *); -void _djinni_add_callback_create_exception_from_cpp(CreateExceptionFnPtr fct_ptr); // called in cpp - -typedef void (* DeleteExceptionFnPtr) (struct DjinniFrontEndExceptionHandle *); -void _djinni_add_callback_exception___delete(DeleteExceptionFnPtr fct_ptr); // called in cpp - -struct DjinniFrontEndExceptionHandle * djinni_check_and_clear_exception(void); // called in front-end - -// Djinni Structs and Boxed Types and Optionals -struct DjinniBoxedI8; -struct DjinniBoxedI16; -struct DjinniBoxedI32; -struct DjinniBoxedI64; -struct DjinniBoxedF32; -struct DjinniBoxedF64; -struct DjinniBoxedBool; -struct DjinniBoxedDate; - -struct DjinniOptionalString; -struct DjinniString; - -struct DjinniOptionalBinary; -struct DjinniBinary; - -struct DjinniOptionalObjectHandle; -struct DjinniObjectHandle; // wrapper around void*, should be left without definition -struct DjinniOptionalRecordHandle; -struct DjinniRecordHandle; // wrapper around void*, should be left without definition - -// DJINNI STRING -struct DjinniString * create_djinni_string(const char * s, size_t len); -void delete_djinni_string(struct DjinniString * ss); -const char * get_djinni_string_chars(const struct DjinniString * ds); -size_t get_djinni_string_len(const struct DjinniString * ds); - -// DJINNI BINARY -struct DjinniBinary * create_djinni_binary(const uint8_t * b, size_t len); -void delete_djinni_binary(struct DjinniBinary * db); -const uint8_t * get_djinni_binary_uint8s(const struct DjinniBinary *); -size_t get_djinni_binary_len(const struct DjinniBinary *); - -// DJINNI PRIMITIVE OPTIONALS -// OPTIONAL INTEGERS -struct DjinniBoxedI8 * create_djinni_boxed_i8(int8_t dopt); -void delete_djinni_boxed_i8(struct DjinniBoxedI8 * dopt); -int8_t get_djinni_boxed_i8_data(struct DjinniBoxedI8 * dopt); - -struct DjinniBoxedI16 * create_djinni_boxed_i16(int16_t dopt); -void delete_djinni_boxed_i16(struct DjinniBoxedI16 * dopt); -int16_t get_djinni_boxed_i16_data(struct DjinniBoxedI16 * dopt); - -struct DjinniBoxedI32 * create_djinni_boxed_i32(int32_t dopt); -void delete_djinni_boxed_i32(struct DjinniBoxedI32 * dopt); -int32_t get_djinni_boxed_i32_data(struct DjinniBoxedI32 * dopt); - -struct DjinniBoxedI64 * create_djinni_boxed_i64(int64_t dopt); -void delete_djinni_boxed_i64(struct DjinniBoxedI64 * dopt); -int64_t get_djinni_boxed_i64_data(struct DjinniBoxedI64 * dopt); - -// OPTIONAL FLOATING POINTS -struct DjinniBoxedF32 * create_djinni_boxed_f32(float dopt); -void delete_djinni_boxed_f32(struct DjinniBoxedF32 * dopt); -float get_djinni_boxed_f32_data(struct DjinniBoxedF32 * dopt); - -struct DjinniBoxedF64 * create_djinni_boxed_f64(double dopt); -void delete_djinni_boxed_f64(struct DjinniBoxedF64 * dopt); -double get_djinni_boxed_f64_data(struct DjinniBoxedF64 * dopt); - -// OPTIONAL BOOL -struct DjinniBoxedBool * create_djinni_boxed_bool(bool dopt); -void delete_djinni_boxed_bool(struct DjinniBoxedBool * dopt); -bool get_djinni_boxed_bool_data(struct DjinniBoxedBool * dopt); - -// OPTIONAL DATE -struct DjinniBoxedDate * create_djinni_boxed_date(uint64_t dopt); -void delete_djinni_boxed_date(struct DjinniBoxedDate * dopt); -uint64_t get_djinni_boxed_date_data(struct DjinniBoxedDate * dopt); diff --git a/djinni/cwrapper/wrapper_marshal.hpp b/djinni/cwrapper/wrapper_marshal.hpp deleted file mode 100644 index 6d6a7cc..0000000 --- a/djinni/cwrapper/wrapper_marshal.hpp +++ /dev/null @@ -1,220 +0,0 @@ -// preliminary -// Part of support library for djinni4python, handwritten - -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#include "wrapper_marshal.h" - -#ifdef __cplusplus -} -#endif - -namespace djinni { -// Deleter Function Type -template -using DeleterFn = void (T *); - -// Custom deleter for unique ptr around Djinni Structs or Handles -template -class HandleDeleter { -public: - typedef T ObjectHandle; - HandleDeleter(DeleterFn * deleter_fn): m_deleter_fn(deleter_fn) {}; - - void operator() (ObjectHandle * dh) const { - if (m_deleter_fn && dh) { - m_deleter_fn(dh); - } - } -private: - DeleterFn * m_deleter_fn; -}; - -// Unique ptr for RAII of Djinni Structs or Handles -template -using BaseHandle = std::unique_ptr>; - -template -class Handle: public BaseHandle { -public: - // Constructors set up to avoid having nullptr with no deleter - Handle(): BaseHandle(nullptr, nullptr) {}; - Handle(T * handle, DeleterFn * deleter): BaseHandle(handle, deleter) { - assert (deleter); - } - Handle(T * handle, std::nullptr_t) = delete; - Handle(std::nullptr_t): BaseHandle(nullptr, nullptr) {} -}; - -// Used to make explicit that unique ptrs around djinni wrappers are implemented using references -template -using WrapperRef = Handle; - -namespace optionals { -// Helpers to convert from handle to optional-handle or the other way around -Handle toOptionalHandle(Handle handle, - DeleterFn * deletefn); -Handle fromOptionalHandle(Handle handle, - DeleterFn * deletefn); - -Handle toOptionalHandle(Handle handle, - DeleterFn * deletefn); -Handle fromOptionalHandle(Handle handle, - DeleterFn * deletefn); -// Optional Primitives Template -template -class Primitive { -public: - explicit Primitive(CppType data): m_data(data) {}; - - static std::optional toCpp(std::unique_ptr dopt); - static std::unique_ptr fromCpp(std::optional copt); - - static std::unique_ptr newOptional(CppType data); - CppType m_data; -}; - -// Optional Primitives toCpp -template -std::optional Primitive::toCpp(std::unique_ptr dopt) { - if (dopt) { - return std::move(dopt->m_data); - } - return std::nullopt; -} - -// Optional Primitives fromCpp -template -std::unique_ptr Primitive::fromCpp(std::optional copt) { - if (copt){ - return std::unique_ptr(new DjinniType {std::move(* copt)}); - } - return nullptr; -} - -// Optional Primitives newOptional -template -std::unique_ptr Primitive::newOptional(CppType data) { - return std::unique_ptr(new DjinniType {data}); -} - -} // namespace djinni::optional - -// Throw in cpp exception coming from front-end -void cw_throw_if_pending(); -void cw_throw_exception(Handle e_handle); // weak -void cw_default_throw_exception(djinni::Handle e_handle); - -// Register in the exception state a handle to the current exception that occured in either -// front-end or cpp user code to allow the front-end to retrieve the exception -void cw_set_pending_exception(const std::exception_ptr & e_ptr); -djinni::Handle cw_get_front_end_exception(const std::exception_ptr & e_ptr) noexcept; // weak -djinni::Handle cw_default_get_front_end_exception(const std::exception_ptr & e_ptr) noexcept; - -#define CW_TRANSLATE_EXCEPTIONS_RETURN(ret) \ - catch (const std::exception &) { \ - djinni::cw_set_pending_exception(std::current_exception()); \ - return ret; \ - } - -class front_end_exception: public std::exception { -public: - explicit front_end_exception(Handle handle): m_front_end_exception(std::move(handle)) { }; - Handle takeFrontEndException() { - auto aux = std::move(m_front_end_exception); - m_front_end_exception = nullptr; - return aux; - } - -private: - Handle m_front_end_exception; -}; - -} // namespace djinni - -// OPTIONAL INTEGERS -struct DjinniBoxedI8 : public djinni::optionals::Primitive { - explicit DjinniBoxedI8(int8_t data): djinni::optionals::Primitive(data) {}; -}; - -struct DjinniBoxedI16 : public djinni::optionals::Primitive { - explicit DjinniBoxedI16(int16_t data): djinni::optionals::Primitive(data) {}; -}; - -struct DjinniBoxedI32 : public djinni::optionals::Primitive { - explicit DjinniBoxedI32(int32_t data): djinni::optionals::Primitive(data) {}; -}; - -struct DjinniBoxedI64 : public djinni::optionals::Primitive { - DjinniBoxedI64(int64_t data): djinni::optionals::Primitive(data) {}; -}; - -// OPTIONAL FLOATING POINTS -struct DjinniBoxedF32 : public djinni::optionals::Primitive { - DjinniBoxedF32(float data): djinni::optionals::Primitive(data) {}; -}; - -struct DjinniBoxedF64 : public djinni::optionals::Primitive { - DjinniBoxedF64(double data): djinni::optionals::Primitive(data) {}; -}; - -// OPTIONAL BOOL -struct DjinniBoxedBool : public djinni::optionals::Primitive { - DjinniBoxedBool(bool data): djinni::optionals::Primitive(data) {}; -}; - -struct DjinniString { - explicit DjinniString(std::string s); - static std::unique_ptr fromCpp(std::string cppstr); - static std::string toCpp(std::unique_ptr ds); - - std::string cppstr; -}; - -struct DjinniBinary { - explicit DjinniBinary(std::vector); - static std::unique_ptr fromCpp(std::vector cppbinary); - static std::vector toCpp(std::unique_ptr db); - - std::vector cppbinary; -}; - -struct DjinniDate { - static std::chrono::system_clock::time_point toCpp(uint64_t duration); - static uint64_t fromCpp(std::chrono::system_clock::time_point date); -}; - -// OPTIONAL DATE -struct DjinniBoxedDate : public djinni::optionals::Primitive { - DjinniBoxedDate(uint64_t data): djinni::optionals::Primitive(data) {}; - - static std::optional toCpp(std::unique_ptr dopt); - static std::unique_ptr fromCpp(std::optional dopt); - - static std::unique_ptr newOptional(std::chrono::system_clock::time_point data); -}; - -using DjinniObject = std::shared_ptr; - -// OTHER OPTIONALS -struct DjinniOptionalString { - static std::optional toCpp(std::unique_ptr dopt); - static std::unique_ptr fromCpp(std::optional ds); -}; - -struct DjinniOptionalBinary { - static std::optional> toCpp(std::unique_ptr dopt); - static std::unique_ptr fromCpp(std::optional> ds); -}; diff --git a/djinni/py/djinni/__init__.py b/djinni/py/djinni/__init__.py deleted file mode 100644 index 41ce62c..0000000 --- a/djinni/py/djinni/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -__all__ = ["pycffi_marshal", "support", "exception"] - diff --git a/djinni/py/djinni/exception.py b/djinni/py/djinni/exception.py deleted file mode 100644 index ec18fc1..0000000 --- a/djinni/py/djinni/exception.py +++ /dev/null @@ -1,51 +0,0 @@ -from PyCFFIlib_cffi import ffi, lib -from djinni.pycffi_marshal import CPyString -from djinni.support import MultiSet - -# Allows python developer to differentiate exceptions coming via djinni code -class DjinniException(RuntimeError): - def __init__(self, error_message): - self.args = error_message - -class ExceptionHelper: - # keeping the callback for exceptions alive, and cleaning it up at the end of a process - # holding c_data_set for exception handles (handles to python exception passed into c/cpp) - c_data_set = MultiSet() - - @staticmethod - @ffi.callback("struct DjinniFrontEndExceptionHandle * (struct DjinniString *)") - def create_py_from_cpp_exception(ds_error_message): - e = DjinniException(CPyString.toPy(ds_error_message)) - c_ptr = ffi.new_handle(e) - ExceptionHelper.c_data_set.add(c_ptr) - return c_ptr - - @staticmethod - @ffi.callback("void(struct DjinniFrontEndExceptionHandle * )") - def exception_delete(c_ptr): - assert c_ptr in ExceptionHelper.c_data_set - ExceptionHelper.c_data_set.remove(c_ptr) - -class CPyException: - @staticmethod - def toPyCheckAndRaise(ret_val): - c_ptr = lib.djinni_check_and_clear_exception() - if c_ptr == ffi.NULL: # no exception was thrown - return - - assert c_ptr in ExceptionHelper.c_data_set - try: - # if exception was thrown, return value must be null - exception = ffi.from_handle(ffi.cast("void * ", c_ptr)) - assert ret_val == ffi.NULL - raise exception - finally: - ExceptionHelper.c_data_set.remove(c_ptr) - @staticmethod - def setExceptionFromPy(py_e): - bare_c_ptr = ffi.new_handle(py_e) - ExceptionHelper.c_data_set.add(bare_c_ptr) - lib.djinni_create_and_set_cpp_exception(bare_c_ptr) - -lib._djinni_add_callback_create_exception_from_cpp(ExceptionHelper.create_py_from_cpp_exception) -lib._djinni_add_callback_exception___delete(ExceptionHelper.exception_delete) diff --git a/djinni/py/djinni/pycffi_marshal.py b/djinni/py/djinni/pycffi_marshal.py deleted file mode 100644 index 489bee4..0000000 --- a/djinni/py/djinni/pycffi_marshal.py +++ /dev/null @@ -1,443 +0,0 @@ -# Part of support library for djinni4python, handwritten - -from __future__ import absolute_import, division, print_function, unicode_literals -from PyCFFIlib_cffi import ffi, lib -from djinni.support import encoded_utf_8 -import datetime -import math - -class CPyPrimitive: - @staticmethod - def toPy(p): - assert p is not None - return p - - @staticmethod - def fromPy(p): - assert p is not None - return p - -class CPyBoxedBase: - def __init__(self, data, delete_fn, cpyoptional): - self._data = data - self._delete_fn = delete_fn - - def __enter__(self): - return self - - def __exit__(self, ty, value, traceback): - self.__del__() - - def __del__(self): - if self._data: - self._delete_fn(self._data) - self._data= None - - def get_djinni_boxed(self): - return self._data - def release_djinni_boxed(self): # renounce ownership of resource - dopt = self._data - self._data= None - return dopt - - @staticmethod - def toPyOptWithoutTakingOwnership(dopt, get_fn): - if dopt == ffi.NULL: - return None - return get_fn(dopt) - - @staticmethod - def toPyOpt(dopt, get_fn, cpytype): - with cpytype(dopt) as py_opt: - return cpytype.toPyOptWithoutTakingOwnership(py_opt._data) - - @staticmethod - def fromPyOpt(pyopt, create_fn, cpyoptional): - if pyopt is None: - return cpyoptional(ffi.NULL) - - dopt = create_fn(pyopt) - return cpyoptional(dopt) - -class CPyBoxedI8(CPyBoxedBase): - def __init__(self, data): - CPyBoxedBase.__init__(self, data, lib.delete_djinni_boxed_i8, CPyBoxedI8) - - @staticmethod - def toPyOptWithoutTakingOwnership(dopt): - return CPyBoxedBase.toPyOptWithoutTakingOwnership(dopt, lib.get_djinni_boxed_i8_data) - @staticmethod - def toPyOpt(dopt): - return CPyBoxedBase.toPyOpt(dopt, lib.get_djinni_boxed_i8_data, CPyBoxedI8) - @staticmethod - def fromPyOpt(pyopt): - return CPyBoxedBase.fromPyOpt(pyopt, lib.create_djinni_boxed_i8, CPyBoxedI8) - -class CPyBoxedI16(CPyBoxedBase): - def __init__(self, data): - CPyBoxedBase.__init__(self, data, lib.delete_djinni_boxed_i16, CPyBoxedI1) - - @staticmethod - def toPyOptWithoutTakingOwnership(dopt): - return CPyBoxedBase.toPyOptWithoutTakingOwnership(dopt, lib.get_djinni_boxed_i16_data) - @staticmethod - def toPyOpt(dopt): - return CPyBoxedBase.toPyOpt(dopt, lib.get_djinni_boxed_i16_data, CPyBoxedI16) - @staticmethod - def fromPyOpt(pyopt): - return CPyBoxedBase.fromPyOpt(pyopt, lib.create_djinni_boxed_i16, CPyBoxedI16) - -class CPyBoxedI32(CPyBoxedBase): - def __init__(self, data): - CPyBoxedBase.__init__(self, data, lib.delete_djinni_boxed_i32, CPyBoxedI32) - - @staticmethod - def toPyOptWithoutTakingOwnership(dopt): - return CPyBoxedBase.toPyOptWithoutTakingOwnership(dopt, lib.get_djinni_boxed_i32_data) - @staticmethod - def toPyOpt(dopt): - return CPyBoxedBase.toPyOpt(dopt, lib.get_djinni_boxed_i32_data, CPyBoxedI32) - @staticmethod - def fromPyOpt(pyopt): - return CPyBoxedBase.fromPyOpt(pyopt, lib.create_djinni_boxed_i32, CPyBoxedI32) - -class CPyBoxedI64(CPyBoxedBase): - def __init__(self, data): - CPyBoxedBase.__init__(self, data, lib.delete_djinni_boxed_i64, CPyBoxedI64) - - @staticmethod - def toPyOptWithoutTakingOwnership(dopt): - return CPyBoxedBase.toPyOptWithoutTakingOwnership(dopt, lib.get_djinni_boxed_i64_data) - @staticmethod - def toPyOpt(dopt): - return CPyBoxedBase.toPyOpt(dopt, lib.get_djinni_boxed_i64_data, CPyBoxedI64) - @staticmethod - def fromPyOpt(pyopt): - return CPyBoxedBase.fromPyOpt(pyopt, lib.create_djinni_boxed_i64, CPyBoxedI64) - -class CPyBoxedF32(CPyBoxedBase): - def __init__(self, data): - CPyBoxedBase.__init__(self, data, lib.delete_djinni_boxed_f32, CPyBoxedF32) - - @staticmethod - def toPyOptWithoutTakingOwnership(dopt): - return CPyBoxedBase.toPyOptWithoutTakingOwnership(dopt, lib.get_djinni_boxed_f32_data) - @staticmethod - def toPyOpt(dopt): - return CPyBoxedBase.toPyOpt(dopt, lib.get_djinni_boxed_f32_data, CPyBoxedF32) - @staticmethod - def fromPyOpt(pyopt): - return CPyBoxedBase.fromPyOpt(pyopt, lib.create_djinni_boxed_f32, CPyBoxedF32) - -class CPyBoxedF64(CPyBoxedBase): - def __init__(self, data): - CPyBoxedBase.__init__(self, data, lib.delete_djinni_boxed_f64, CPyBoxedF64) - - @staticmethod - def toPyOptWithoutTakingOwnership(dopt): - return CPyBoxedBase.toPyOptWithoutTakingOwnership(dopt, lib.get_djinni_boxed_f64_data) - @staticmethod - def toPyOpt(dopt): - return CPyBoxedBase.toPyOpt(dopt, lib.get_djinni_boxed_f64_data, CPyBoxedF64) - @staticmethod - def fromPyOpt(pyopt): - return CPyBoxedBase.fromPyOpt(pyopt, lib.create_djinni_boxed_f64, CPyBoxedF64) - -class CPyBoxedBool(CPyBoxedBase): - def __init__(self, data): - CPyBoxedBase.__init__(self, data, lib.delete_djinni_boxed_bool, CPyBoxedBool) - - @staticmethod - def toPyOptWithoutTakingOwnership(dopt): - return CPyBoxedBase.toPyOptWithoutTakingOwnership(dopt, lib.get_djinni_boxed_bool_data) - @staticmethod - def toPyOpt(dopt): - return CPyBoxedBase.toPyOpt(dopt, lib.get_djinni_boxed_bool_data, CPyBoxedBool) - @staticmethod - def fromPyOpt(pyopt): - return CPyBoxedBase.fromPyOpt(pyopt, lib.create_djinni_boxed_bool, CPyBoxedBool) - -class CPyBoxedDate(CPyBoxedBase): - def __init__(self, data): - CPyBoxedBase.__init__(self, data, lib.delete_djinni_boxed_date, CPyBoxedDate) - - @staticmethod - def _get_fn(c_boxed): - return CPyDate.toPy(lib.get_djinni_boxed_date_data(c_boxed)) - - @staticmethod - def _create_fn(py_val): - return lib.create_djinni_boxed_date(CPyDate.fromPy(py_val)) - - @staticmethod - def toPyOptWithoutTakingOwnership(dopt): - return CPyBoxedBase.toPyOptWithoutTakingOwnership(dopt, CPyBoxedDate._get_fn) - @staticmethod - def toPyOpt(dopt): - return CPyBoxedBase.toPyOpt(dopt, CPyBoxedDate._get_fn, CPyBoxedDate) - @staticmethod - def fromPyOpt(pyopt): - return CPyBoxedBase.fromPyOpt(pyopt, CPyBoxedDate._create_fn, CPyBoxedDate) - -class CPyStringBinaryHelper: - @staticmethod - def toPyHelper(ds, cpytype): - with cpytype(ds) as py_ds: # for easy memory release - return cpytype.toPyWithoutTakingOwnership(ds) - - @staticmethod - def toPy(ds, cpytype): - assert (ds != ffi.NULL) # not sure if assert(ds) means the same thing because Python.. - return cpytype.toPyHelper(ds) - - @staticmethod - def toPyOpt(ds, cpytype): - if ds == ffi.NULL: - return None - return cpytype.toPyHelper(ds) - - @staticmethod - def toPyOptWithoutTakingOwnership(ds, cpytype): - if ds == ffi.NULL: - return None - return cpytype.toPyWithoutTakingOwnership(ds) - -class CPyString: # Python RAII for C DjinniString - def __init__(self, djinni_string): - self._djinni_string = djinni_string - def __enter__(self): - return self - def __exit__(self, ty, value, traceback): - self.__del__() - def __del__(self): - if self._djinni_string: - lib.delete_djinni_string(self._djinni_string) - self._djinni_string = None - - def get_djinni_string(self): - return self._djinni_string - def release_djinni_string(self): # renounce ownership of resource - ds = self._djinni_string - self._djinni_string = None - return ds - - @staticmethod - def toPyOptWithoutTakingOwnership(ds): - return CPyStringBinaryHelper.toPyOptWithoutTakingOwnership(ds, CPyString) - - @staticmethod - def toPyWithoutTakingOwnership(ds): # to Py with no with block - ss = lib.get_djinni_string_chars(ds) # maybe: py_ds.get... - l = lib.get_djinni_string_len(ds) - return b''.join(ss[0:l]).decode('utf-8') - - @staticmethod - def toPyHelper(ds): - return CPyStringBinaryHelper.toPyHelper(ds, CPyString) - - @staticmethod - def toPy(ds): - return CPyStringBinaryHelper.toPy(ds, CPyString) - - @staticmethod - def toPyOpt(ds): - return CPyStringBinaryHelper.toPyOpt(ds, CPyString) - - @staticmethod - def fromPyHelper(ps): - s = encoded_utf_8(ps) - ds = lib.create_djinni_string(s, len(s)) - return CPyString(ds) - - @staticmethod - def fromPy(ps): - assert ps is not None - return CPyString.fromPyHelper(ps) - - @staticmethod - def fromPyOpt(ps): - if ps is None: - return CPyString(ffi.NULL) - return CPyString.fromPyHelper(ps) - -class CPyBinary: # Python RAII for C DjinniBinary - def __init__(self, djinni_binary): - self._djinni_binary = djinni_binary - def __enter__(self): - return self - def __exit__(self, ty, value, traceback): - self.__del__() - def __del__(self): - if self._djinni_binary: - lib.delete_djinni_binary(self._djinni_binary) - self._djinni_binary = None - def get_djinni_binary(self): - return self._djinni_binary - - def release_djinni_binary(self): # renounce ownership of resource - db = self._djinni_binary - self._djinni_binary = None - return db - - @staticmethod - def toPyOptWithoutTakingOwnership(pb): - return CPyStringBinaryHelper.toPyOptWithoutTakingOwnership(pb, CPyBinary) - - @staticmethod - def toPyWithoutTakingOwnership(pb): # toPy with no with block - ss = lib.get_djinni_binary_uint8s(pb) # maybe: py_db.get... - l = lib.get_djinni_binary_len(pb) - return ffi.buffer(ss,l)[:] - - @staticmethod - def toPyHelper(ds): - return CPyStringBinaryHelper.toPyHelper(ds, CPyBinary) - - @staticmethod - def toPy(ds): - return CPyStringBinaryHelper.toPy(ds, CPyBinary) - - @staticmethod - def toPyOpt(ds): - return CPyStringBinaryHelper.toPyOpt(ds, CPyBinary) - - @staticmethod - def fromPyHelper(pb): - ffipb = ffi.new("uint8_t []", pb) - db = lib.create_djinni_binary(ffipb, len(pb)) - return CPyBinary(db) - - @staticmethod - def fromPy(pb): - assert pb is not None - return CPyBinary.fromPyHelper(pb) - - @staticmethod - def fromPyOpt(pb): - if pb is None: - return CPyBinary(ffi.NULL) - return CPyBinary.fromPyHelper(pb) - -class CPyDate: - epoch = datetime.datetime.utcfromtimestamp(0) - - @staticmethod - def toPy(date): - return CPyDate.epoch + datetime.timedelta(milliseconds = date) - - @staticmethod - def fromPy(pb): - return int((pb-CPyDate.epoch).total_seconds() * 1000) # to milliseconds - -class CPyStructuredBase: - @staticmethod - def toPyHelper(c_data_set, c_ptr): - aux = ffi.from_handle(ffi.cast("void * ",c_ptr)) - if c_data_set is not None: # aka, if we want to remove c_ptr - assert c_ptr in c_data_set - c_data_set.remove(c_ptr) - return aux - - @staticmethod - def toPy(c_data_set, c_ptr): - assert c_ptr != ffi.NULL # not sure if assert(c_ptr) means the same thing because Python.. - return CPyStructuredBase.toPyHelper(c_data_set, c_ptr) - - @staticmethod - def toPyOpt(c_data_set, c_ptr): - if c_ptr == ffi.NULL: - return None - return CPyStructuredBase.toPyHelper(c_data_set, c_ptr) - - @staticmethod - def fromPyHelper(c_data_set, py_obj): - c_ptr = ffi.new_handle(py_obj) - c_data_set.add(c_ptr) - return c_ptr - - @staticmethod - def fromPy(c_data_set, py_obj): - assert py_obj is not None - return CPyStructuredBase.fromPyHelper(c_data_set, py_obj) - - @staticmethod - def fromPyOpt(c_data_set, py_obj): - if py_obj is None: - return ffi.NULL - return CPyStructuredBase.fromPyHelper(c_data_set, py_obj) - -class CPyRecord(CPyStructuredBase): - pass - -# all containers are passed to and from C as abstract objects (void* pointers with a name) -class CPyObject(CPyStructuredBase): - pass - -# maps and sets have proxies that hold the implementations and state of their iterators -class CPyObjectProxy(CPyStructuredBase): - @staticmethod - def toPyObj(c_data_set, c_ptr): - aux = CPyStructuredBase.toPy(c_data_set, c_ptr) - assert aux is not None - return aux._py_obj - - @staticmethod - def toPyObjOpt(c_data_set, c_ptr): - aux = CPyStructuredBase.toPyOpt(c_data_set, c_ptr) - if aux is not None: - return aux._py_obj - return None - - @staticmethod - def toPyIter(c_ptr): - assert c_ptr != ffi.NULL - aux = ffi.from_handle(ffi.cast("void * ", c_ptr)) - assert aux is not None - return aux._py_iter - - @staticmethod - def toPyIterOpt(c_ptr): - if c_ptr == ffi.NULL: - return None - - return CPyObjectProxy.toPyIter(c_ptr) - - @staticmethod - def fromPyHelper(c_data_set, py_obj_proxy): - bare_c_ptr = ffi.new_handle(py_obj_proxy) - c_data_set.add(bare_c_ptr) - return bare_c_ptr - - @staticmethod - def fromPy(c_data_set, py_obj_proxy): - assert py_obj_proxy._py_obj is not None - return CPyObjectProxy.fromPyHelper(c_data_set, py_obj_proxy) - - @staticmethod - def fromPyOpt(c_data_set, py_obj_proxy): - if py_obj_proxy._py_obj is None: - return ffi.NULL - return CPyObjectProxy.fromPyHelper(c_data_set, py_obj_proxy) - -class CPyEnum: - @staticmethod - def fromPy(e): - assert e is not None - return int(e) - - @staticmethod - def fromPyOpt(e): - if e is None: - return -1 # to signal null optional enum - return int(e) - - @staticmethod - def toPy(enum_class, e): - assert e >= 0 - return enum_class(e) - - @staticmethod - def toPyOpt(enum_class, e): - if e == -1: - return None - return enum_class(e) diff --git a/djinni/py/djinni/support.py b/djinni/py/djinni/support.py deleted file mode 100644 index 625c6ad..0000000 --- a/djinni/py/djinni/support.py +++ /dev/null @@ -1,75 +0,0 @@ -from __future__ import absolute_import, division, print_function, unicode_literals -from threading import Lock -import re - -class MultiSet: - def __init__(self): - self._dict = dict() - self._lock = Lock() - - def add(self, item): - with self._lock: - if item not in self._dict: - self._dict[item] = 1 - else: - self._dict[item] += 1 - - def remove(self, item): - with self._lock: - assert item in self._dict - self._dict[item] -= 1 - if self._dict[item] == 0: - del self._dict[item] - - def __len__(self): - with self._lock: - return len(self._dict) - def __contains__(self, item): - with self._lock: - return item in self._dict - -# Handwritten utility functions, currently used in both client (for testing) -# and in to-be-generated code ( should eventually be split) - -def decoded_utf_8(s): - if isinstance(s, bytes): - return s.decode('utf-8') - return s - -def encoded_utf_8(s): - if isinstance(s, bytes): - return s - return s.encode('utf-8') - -def clean_header_for(s, to_ignore): - lines = s.split('\n') - - cleans = [] - for line in lines: - if to_ignore not in line: - cleans.append(line + "\n") - return cleans - -def clean_headers_for(headers, to_ignore): - cleaned_headers = [] - for header in headers: - f = open(header, "r") - f_h = f.read() - f.close() - cleaned_headers.extend(clean_header_for(f_h, to_ignore)) - - return cleaned_headers - -# match forward declarations of DjinniStructs like: struct DjinniStructureName; -# don't match anything that containts a struct DjnniStructName but is not a forward declaration -pattern = re.compile("struct Djinni[a-zA-Z0-9]*[^\s)];") -def sort_by_import_order(lines): - first_lines = "" - last_lines = "" - for line in lines: - if pattern.search(line): - first_lines += line - else: - last_lines += line - - return first_lines + last_lines diff --git a/docs/developer-guide.md b/docs/developer-guide.md index bbbeaf6..eceebd7 100644 --- a/docs/developer-guide.md +++ b/docs/developer-guide.md @@ -39,18 +39,6 @@ cd build/test-suite ctest ``` -#### C++/CLI - -1. Generate Visual Studio Solution with `-G "Visual Studio 16 2019"`: - - ```sh - cmake -S . -B build -DDJINNI_WITH_CPPCLI=ON -DDJINNI_STATIC_LIB=ON -G "Visual Studio 16 2019" - ``` - -2. Open the solution `djinni_support_lib.sln` in Visual Studio. -3. Build `DjinniCppCliTest`. -4. Run the tests: Test > Run All Tests. - ## Preview Documentation The documentation in `docs` will be rendered as a part of [djinni.xlcpp.dev](https://djinni.xlcpp.dev/). diff --git a/docs/install.md b/docs/install.md index 4121a0a..84c7cd4 100644 --- a/docs/install.md +++ b/docs/install.md @@ -13,7 +13,7 @@ project(foo) set(DJINNI_BUILD_TESTING OFF CACHE INTERNAL "") # choose for which target language the djinni-support-lib should be compiled. # At least one of the following options must be set to true: -# DJINNI_WITH_JNI, DJINNI_WITH_OBJC, DJINNI_WITH_PYTHON, DJINNI_WITH_CPPCLI +# DJINNI_WITH_JNI, DJINNI_WITH_OBJC # In this example the target language depends on the target system: if(ANDROID) set(DJINNI_WITH_JNI ON CACHE INTERNAL "") diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index fc947f6..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -cffi==1.14.5 -future==0.18.2 -pytest==6.2.5 diff --git a/test-suite/CMakeLists.txt b/test-suite/CMakeLists.txt index 5fa2a04..1f7dfb8 100644 --- a/test-suite/CMakeLists.txt +++ b/test-suite/CMakeLists.txt @@ -40,7 +40,6 @@ add_djinni_target(DjinniAllTests JNI_OUT_FILES JNI_GENERATED_SRCS OBJC_OUT_FILES OBJC_GENERATED_SRCS OBJCPP_OUT_FILES OBJCPP_GENERATED_SRCS - CPPCLI_OUT_FILES CPPCLI_GENERATED_SRCS YAML_OUT_FILE YAML_GENERATED_SRCS ) @@ -74,7 +73,6 @@ add_djinni_target(DjinniWCharTests JNI_OUT_FILES WCHAR_JNI_GENERATED_SRCS OBJC_OUT_FILES WCHAR_OBJC_GENERATED_SRCS OBJCPP_OUT_FILES WCHAR_OBJCPP_GENERATED_SRCS - CPPCLI_OUT_FILES WCHAR_CPPCLI_GENERATED_SRCS YAML_OUT_FILE WCHAR_YAML_GENERATED_SRCS ) @@ -83,8 +81,6 @@ file(GLOB_RECURSE CPP_HANDWRITTEN_SRCS "handwritten-src/cpp/*") file(GLOB_RECURSE JAVA_TEST_SRCS "handwritten-src/java/*") file(GLOB_RECURSE OBJC_HANDWRITTEN_SRCS "handwritten-src/objc/impl/*") file(GLOB_RECURSE OBJC_TEST_SRCS "handwritten-src/objc/tests/*") -file(GLOB_RECURSE C_WRAPPER_HANDWRITTEN_SRCS "handwritten-src/cwrapper/*") -file(GLOB_RECURSE PYCPP_HANDWRITTEN_SRCS "handwritten-src/pycpp/*") source_group("handwritten-cpp" FILES ${CPP_HANDWRITTEN_SRCS}) source_group("handwritten-objc" FILES ${OBJC_HANDWRITTEN_SRCS}) @@ -182,105 +178,4 @@ if(DJINNI_WITH_OBJC) endif() -if(DJINNI_WITH_PYTHON) - # There's no YAML support in Djinni for Python yet. - set(FILTERED_CPP_HANDWRITTEN_SRCS ${CPP_HANDWRITTEN_SRCS}) - list(REMOVE_ITEM FILTERED_CPP_HANDWRITTEN_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/handwritten-src/cpp/TranslateDuration.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/handwritten-src/cpp/flag_roundtrip.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/handwritten-src/cpp/wchar_test_helpers.cpp" - ) - - add_library(mylib SHARED - ${FILTERED_CPP_HANDWRITTEN_SRCS} - ${C_WRAPPER_HANDWRITTEN_SRCS} - ${PYCPP_HANDWRITTEN_SRCS} - ${C_WRAPPER_GENERATED_SRCS} - ${PYCPP_GENERATED_SRCS} - ) - target_include_directories(mylib PUBLIC - ${CMAKE_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/handwritten-src/cpp - ${CMAKE_CURRENT_SOURCE_DIR}/handwritten-src/pycpp - ${CMAKE_CURRENT_BINARY_DIR}/generated-src/pycpp - ) - target_link_libraries(mylib PUBLIC djinni-support-lib::djinni-support-lib) - - # Prepare Python 3 environment - find_package(PythonInterp "3" REQUIRED) - if (WIN32) - message(WARNING "Python support on Windwos is not fully implemented, for more details visit https://github.com/cross-language-cpp/djinni-support-lib/issues") - string(JOIN $ PYTHONPATH - "${CMAKE_SOURCE_DIR}/djinni/py" - "${CMAKE_CURRENT_BINARY_DIR}/generated-src/python" - $ENV{PYTHONPATH}) - else() - string(JOIN ":" PYTHONPATH - "${CMAKE_SOURCE_DIR}/djinni/py" - "${CMAKE_CURRENT_BINARY_DIR}/generated-src/python" - $ENV{PYTHONPATH}) - endif() - # Compile Python extension module (CFFI) - set(C_WRAPPER_GENERATED_HEADERS ${C_WRAPPER_GENERATED_SRCS}) - list(FILTER C_WRAPPER_GENERATED_HEADERS INCLUDE REGEX "\\.h$") - add_custom_target(PyCFFIlib_cffi ALL - ${CMAKE_COMMAND} -E env PYTHONPATH=${PYTHONPATH} LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} - ${PYCFFI_GENERATED_SRCS} - ${CMAKE_SOURCE_DIR}/djinni/cwrapper/wrapper_marshal.h - ${C_WRAPPER_GENERATED_HEADERS} - ${CMAKE_CURRENT_SOURCE_DIR}/handwritten-src/cwrapper/limits_helper.h - DEPENDS mylib ${PYCFFI_GENERATED_SRCS} ${PYTHON_GENERATED_SRCS} ${C_WRAPPER_GENERATED_HEADERS} - COMMENT "Building CFFI lib" - VERBATIM - WORKING_DIRECTORY $ - ) - - add_test(NAME PythonTests COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${PYTHONPATH} - ${PYTHON_EXECUTABLE} -m pytest -s "${CMAKE_CURRENT_SOURCE_DIR}/handwritten-src/python" - ) -endif() - -if(DJINNI_WITH_CPPCLI) - add_library(DjinniCppCli SHARED - ${CPP_HANDWRITTEN_SRCS} - ${CPP_GENERATED_SRCS} - ${CPPCLI_GENERATED_SRCS} - ${WCHAR_CPP_GENERATED_SRCS} - ${WCHAR_CPPCLI_GENERATED_SRCS} - ) - target_include_directories(DjinniCppCli PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/handwritten-src/cpp - ${CMAKE_CURRENT_SOURCE_DIR}/handwritten-src - ${CMAKE_CURRENT_BINARY_DIR}/generated-src/cpp - ${CMAKE_CURRENT_BINARY_DIR}/generated-src - ) - set_target_properties(DjinniCppCli PROPERTIES - VS_DOTNET_REFERENCES "System;System.Core" - COMMON_LANGUAGE_RUNTIME "" - ) - target_link_libraries(DjinniCppCli PUBLIC djinni-support-lib::djinni-support-lib) - - add_library(DjinniCppCliTest SHARED - handwritten-src/cs/ClientInterfaceImpl.cs - handwritten-src/cs/ClientInterfaceTest.cs - handwritten-src/cs/CppExceptionTest.cs - handwritten-src/cs/DurationTest.cs - handwritten-src/cs/EnumTest.cs - handwritten-src/cs/MapRecordTest.cs - handwritten-src/cs/MockRecordTest.cs - handwritten-src/cs/NestedCollectionTest.cs - handwritten-src/cs/PrimitiveListTest.cs - handwritten-src/cs/PrimitivesTest.cs - handwritten-src/cs/RecordWithDerivingsTest.cs - handwritten-src/cs/SetRecordTest.cs - handwritten-src/cs/TokenTest.cs - handwritten-src/cs/WcharTest.cs - ) - set_target_properties(DjinniCppCliTest PROPERTIES - VS_DOTNET_REFERENCES "System;System.Core" - VS_PACKAGE_REFERENCES "nunit_3.13.1;NUnit3TestAdapter_3.17.0;Microsoft.NET.Test.Sdk_16.9.4" - ) - - target_link_libraries(DjinniCppCliTest PUBLIC DjinniCppCli) -endif() diff --git a/zconf-new.sh b/zconf-new.sh index 3f74645..fa0b9ed 100644 --- a/zconf-new.sh +++ b/zconf-new.sh @@ -1,4 +1,4 @@ cmake -G "Ninja Multi-Config" -B build/new -S . --fresh \ - -DDJINNI_WITH_OBJC=ON -DDJINNI_WITH_JNI=ON -DDJINNI_WITH_CPPCLI=OFF \ + -DDJINNI_WITH_OBJC=ON -DDJINNI_WITH_JNI=ON \ -DDJINNI_EXECUTABLE=$(pwd)/../djinni-generator/target/bin/djinni \ - -DCMAKE_OSX_SYSROOT=/Applications/Xcode-16.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk + -DCMAKE_OSX_SYSROOT=/Applications/Xcode-16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk From aab9028bc4100c64ff58a812ab1a3389e74b2d66 Mon Sep 17 00:00:00 2001 From: a4z Date: Tue, 7 Oct 2025 13:58:32 +0200 Subject: [PATCH 20/22] Plan execution --- AGENT.md | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 AGENT.md diff --git a/AGENT.md b/AGENT.md new file mode 100644 index 0000000..e9c926d --- /dev/null +++ b/AGENT.md @@ -0,0 +1,121 @@ +# Bazel build + +I want a bazel build for this djinni-support-library + +Some AI gave it already a try, but produced mostly garbage. +Simplify the overengeneerd BUILD.bazel, and check the rest + +Please explore the existing CMake file and do what is required so I can `bazel build ...` and `bazel test ...` +on this mac, and per default, i get both, objective c and jni binding + +## Existing CMake build + +see CMakeLists.txt in the project root folder + +Info, the CMake build is run by + +```sh +sh zconf-new.sh +cmake --build build/new --config Debug +(cd build/new && ctest . -C Debug) +``` + +## Goals + +- we want modern Bazel, no workspace stuff, bazel 8.4 and above +- I want to libraries, djinni-jni and djinni-objc, there can be a djinni-base that always links and is internal +- Test are using those libraries, +- No fuzz in the .bazelrc except what is heavily needed, use the default debug and release configs, +- keep in mind, we want in future select if we build jni and / or objc + +## Implementation + +We work stage wise, one stage after another. + +## Stage 1 + +make the libs build on my Mac + +this is an example for a (probably old) BUILD file + +```bazel +load("@rules_cc//cc:defs.bzl", "cc_library", "objc_library") + +cc_library( + name = "djinni-base", + srcs = [ + "djinni/cwrapper/wrapper_marshal.cpp", + ], + hdrs = [ + "djinni/cwrapper/wrapper_marshal.h", + "djinni/cwrapper/wrapper_marshal.hpp", + "djinni/djinni_common.hpp", + "djinni/proxy_cache_impl.hpp", + "djinni/proxy_cache_interface.hpp", + ], + copts = ["--std=c++17"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "djinni-jni", + srcs = [ + "djinni/jni/djinni_jni_main.cpp", + "djinni/jni/djinni_support.cpp", + ], + hdrs = [ + "djinni/jni/Marshal.hpp", + "djinni/jni/djinni_jni_main.hpp", + "djinni/jni/djinni_support.hpp", + ], + copts = ["--std=c++17"], + linkstatic = True, + visibility = ["//visibility:public"], + deps = [ + ":djinni-base", + "@bazel_tools//tools/jdk:jni", # TODO , not needed in Android build + ], + alwayslink = 1, +) + +objc_library( + name = "djinni-objc", + srcs = [ + "djinni/objc/DJICppWrapperCache+Private.h", + "djinni/objc/DJIError.mm", + "djinni/objc/DJIMarshal+Private.h", + "djinni/objc/DJIObjcWrapperCache+Private.h", + "djinni/objc/DJIProxyCaches.mm", + ], + hdrs = [ + "djinni/objc/DJIError.h", + ], + copts = [ + "-ObjC++", + ], + visibility = ["//visibility:public"], + deps = [":djinni-base"], +) +``` + +stay to something like this + +## Stage 2 + +make selectable, if we are on Mac, we have objective-c and jni selectable (or, de-selectable) + +on non mac, objective-c shall not exist + +## Stage 3 + +Discuss how to add testing. Testing needs the djinni-generator , which is available in this repo/branch +https://github.com/a4z/djinni-generator/tree/build/bzl + +That provides it with a bazel build. + +Testing might, by itself needed to be added iterative, that will be defined after the discussion. + +## Stage 4 + +- I want to be able to filp that against the default developer version in ../djinni-generator +- we look at jni for android From b7f731ea15d2f126cc3f759fc72d031819c7f4d5 Mon Sep 17 00:00:00 2001 From: a4z Date: Tue, 7 Oct 2025 20:12:43 +0200 Subject: [PATCH 21/22] First basic bazel build support --- .bazelrc | 79 ++------- .gitignore | 3 + BUILD.bazel | 58 +++++++ MODULE.bazel | 11 ++ MODULE.bazel.lock | 421 ++++++++++++++++++++++++++++++++++++++++++++++ README.md | 7 + zconf-new.sh | 2 +- 7 files changed, 513 insertions(+), 68 deletions(-) create mode 100644 BUILD.bazel create mode 100644 MODULE.bazel create mode 100644 MODULE.bazel.lock diff --git a/.bazelrc b/.bazelrc index 940dee9..984f571 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,71 +1,16 @@ -# Bazel configuration for djinni-support-lib +# Enable platform-specific config +common --enable_platform_specific_config -# Import common configs -import %workspace%/.bazelrc.common +# GCC/Clang warnings +build:unix --copt=-Wall --copt=-Wextra --copt=-Wpedantic --copt=-Werror --copt=-std=c++17 +# MSVC warnings +# build:msvc --copt=/W4 --copt=/WX -# Build optimizations -build --compilation_mode=opt -build --copt=-O2 -build --copt=-DNDEBUG +# Map configs to platforms/toolchains +build:macos --config=unix +build:linux --config=unix +# build:windows --config=msvc -# C++ Configuration -build --cxxopt=-std=c++17 -build --host_cxxopt=-std=c++17 -build --copt=-Wall -build --copt=-Wextra -build --copt=-Werror - -# Platform-specific configurations -build:linux --copt=-fPIC -build:linux --linkopt=-ldl - -build:macos --copt=-fPIC -build:macos --linkopt=-framework Foundation -build:macos --apple_platform_type=macos - -build:ios --apple_platform_type=ios -build:ios --copt=-fobjc-arc -build:ios --linkopt=-framework Foundation - -build:windows --copt=/std:c++17 -build:windows --host_copt=/std:c++17 - -# JNI Configuration -build --define=with_jni=true - -# Objective-C Configuration (when building on macOS/iOS) -build:objc --copt=-fobjc-arc -build:objc --copt=-x -build:objc --copt=objective-c++ - -# Python Configuration -build:python --define=with_python=true - -# C++/CLI Configuration (Windows only) -build:cppcli --define=with_cppcli=true -build:cppcli --copt=/clr - -# Test Configuration -test --test_output=errors -test --test_summary=detailed -test --test_verbose_timeout_warnings - -# Coverage -coverage --combined_report=lcov -coverage --coverage_report_generator=@bazel_tools//tools/test:coverage_report_generator - -# Debug Configuration +# Compilation mode configs (optional) build:debug --compilation_mode=dbg -build:debug --copt=-g -build:debug --strip=never -build:debug --linkopt=-g - -# Fast build (for development) -build:fastbuild --compilation_mode=fastbuild - -# Remote execution (if using remote build execution) -build:remote --remote_executor=... -build:remote --remote_cache=... - -# Try to import user-specific .bazelrc.user file if it exists -try-import %workspace%/.bazelrc.user +build:release --compilation_mode=opt diff --git a/.gitignore b/.gitignore index d9a7146..72de4f1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ build/* cmake-build-debug/ check_install_root/ .vscode/ + +# Bazel +/bazel-* diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000..86cacc4 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,58 @@ +load("@rules_cc//cc:defs.bzl", "cc_library", "objc_library") + +# Base library - internal use only, contains shared C++ headers +cc_library( + name = "djinni-base", + hdrs = [ + "djinni/djinni_common.hpp", + "djinni/proxy_cache_impl.hpp", + "djinni/proxy_cache_interface.hpp", + ], + copts = ["-std=c++17"], + strip_include_prefix = ".", + visibility = ["//visibility:private"], +) + +# JNI library - public API +cc_library( + name = "djinni-jni", + srcs = [ + "djinni/jni/djinni_jni_main.cpp", + "djinni/jni/djinni_support.cpp", + ], + hdrs = [ + "djinni/jni/Marshal.hpp", + "djinni/jni/djinni_jni_main.hpp", + "djinni/jni/djinni_support.hpp", + ], + linkstatic = True, + strip_include_prefix = ".", + visibility = ["//visibility:public"], + deps = [ + ":djinni-base", + "@bazel_tools//tools/jdk:jni", + ], + alwayslink = True, +) + +# Objective-C library - public API +objc_library( + name = "djinni-objc", + srcs = [ + "djinni/objc/DJICppWrapperCache+Private.h", + "djinni/objc/DJIError.mm", + "djinni/objc/DJIMarshal+Private.h", + "djinni/objc/DJIObjcWrapperCache+Private.h", + "djinni/objc/DJIProxyCaches.mm", + ], + hdrs = [ + "djinni/objc/DJIError.h", + ], + copts = [ + "-ObjC++", + "-fobjc-arc", + ], + sdk_frameworks = ["Foundation"], + visibility = ["//visibility:public"], + deps = [":djinni-base"], +) diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..acd8a0c --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,11 @@ +""" doc string """ + +module( + name = "djinni-support-lib", + version = "1.0.0", +) + +# IMPORTANT: apple_support must come before rules_cc to take precedence +bazel_dep(name = "apple_support", version = "1.23.1") +bazel_dep(name = "rules_apple", version = "4.2.0", repo_name = "build_bazel_rules_apple") +bazel_dep(name = "rules_cc", version = "0.2.9") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock new file mode 100644 index 0000000..beb48b5 --- /dev/null +++ b/MODULE.bazel.lock @@ -0,0 +1,421 @@ +{ + "lockFileVersion": 18, + "registryFileHashes": { + "https://bcr.bazel.build/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", + "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", + "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/MODULE.bazel": "70390338f7a5106231d20620712f7cccb659cd0e9d073d1991c038eb9fc57589", + "https://bcr.bazel.build/modules/abseil-cpp/20230125.1/MODULE.bazel": "89047429cb0207707b2dface14ba7f8df85273d484c2572755be4bab7ce9c3a0", + "https://bcr.bazel.build/modules/abseil-cpp/20230802.0.bcr.1/MODULE.bazel": "1c8cec495288dccd14fdae6e3f95f772c1c91857047a098fad772034264cc8cb", + "https://bcr.bazel.build/modules/abseil-cpp/20230802.0/MODULE.bazel": "d253ae36a8bd9ee3c5955384096ccb6baf16a1b1e93e858370da0a3b94f77c16", + "https://bcr.bazel.build/modules/abseil-cpp/20230802.1/MODULE.bazel": "fa92e2eb41a04df73cdabeec37107316f7e5272650f81d6cc096418fe647b915", + "https://bcr.bazel.build/modules/abseil-cpp/20240116.1/MODULE.bazel": "37bcdb4440fbb61df6a1c296ae01b327f19e9bb521f9b8e26ec854b6f97309ed", + "https://bcr.bazel.build/modules/abseil-cpp/20240116.1/source.json": "9be551b8d4e3ef76875c0d744b5d6a504a27e3ae67bc6b28f46415fd2d2957da", + "https://bcr.bazel.build/modules/apple_support/1.11.1/MODULE.bazel": "1843d7cd8a58369a444fc6000e7304425fba600ff641592161d9f15b179fb896", + "https://bcr.bazel.build/modules/apple_support/1.15.1/MODULE.bazel": "a0556fefca0b1bb2de8567b8827518f94db6a6e7e7d632b4c48dc5f865bc7c85", + "https://bcr.bazel.build/modules/apple_support/1.21.1/MODULE.bazel": "5809fa3efab15d1f3c3c635af6974044bac8a4919c62238cce06acee8a8c11f1", + "https://bcr.bazel.build/modules/apple_support/1.23.1/MODULE.bazel": "53763fed456a968cf919b3240427cf3a9d5481ec5466abc9d5dc51bc70087442", + "https://bcr.bazel.build/modules/apple_support/1.23.1/source.json": "d888b44312eb0ad2c21a91d026753f330caa48a25c9b2102fae75eb2b0dcfdd2", + "https://bcr.bazel.build/modules/bazel_features/1.1.1/MODULE.bazel": "27b8c79ef57efe08efccbd9dd6ef70d61b4798320b8d3c134fd571f78963dbcd", + "https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8", + "https://bcr.bazel.build/modules/bazel_features/1.15.0/MODULE.bazel": "d38ff6e517149dc509406aca0db3ad1efdd890a85e049585b7234d04238e2a4d", + "https://bcr.bazel.build/modules/bazel_features/1.17.0/MODULE.bazel": "039de32d21b816b47bd42c778e0454217e9c9caac4a3cf8e15c7231ee3ddee4d", + "https://bcr.bazel.build/modules/bazel_features/1.18.0/MODULE.bazel": "1be0ae2557ab3a72a57aeb31b29be347bcdc5d2b1eb1e70f39e3851a7e97041a", + "https://bcr.bazel.build/modules/bazel_features/1.19.0/MODULE.bazel": "59adcdf28230d220f0067b1f435b8537dd033bfff8db21335ef9217919c7fb58", + "https://bcr.bazel.build/modules/bazel_features/1.21.0/MODULE.bazel": "675642261665d8eea09989aa3b8afb5c37627f1be178382c320d1b46afba5e3b", + "https://bcr.bazel.build/modules/bazel_features/1.27.0/MODULE.bazel": "621eeee06c4458a9121d1f104efb80f39d34deff4984e778359c60eaf1a8cb65", + "https://bcr.bazel.build/modules/bazel_features/1.28.0/MODULE.bazel": "4b4200e6cbf8fa335b2c3f43e1d6ef3e240319c33d43d60cc0fbd4b87ece299d", + "https://bcr.bazel.build/modules/bazel_features/1.3.0/MODULE.bazel": "cdcafe83ec318cda34e02948e81d790aab8df7a929cec6f6969f13a489ccecd9", + "https://bcr.bazel.build/modules/bazel_features/1.30.0/MODULE.bazel": "a14b62d05969a293b80257e72e597c2da7f717e1e69fa8b339703ed6731bec87", + "https://bcr.bazel.build/modules/bazel_features/1.30.0/source.json": "b07e17f067fe4f69f90b03b36ef1e08fe0d1f3cac254c1241a1818773e3423bc", + "https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7", + "https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a", + "https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8", + "https://bcr.bazel.build/modules/bazel_skylib/1.1.1/MODULE.bazel": "1add3e7d93ff2e6998f9e118022c84d163917d912f5afafb3058e3d2f1545b5e", + "https://bcr.bazel.build/modules/bazel_skylib/1.2.0/MODULE.bazel": "44fe84260e454ed94ad326352a698422dbe372b21a1ac9f3eab76eb531223686", + "https://bcr.bazel.build/modules/bazel_skylib/1.2.1/MODULE.bazel": "f35baf9da0efe45fa3da1696ae906eea3d615ad41e2e3def4aeb4e8bc0ef9a7a", + "https://bcr.bazel.build/modules/bazel_skylib/1.3.0/MODULE.bazel": "20228b92868bf5cfc41bda7afc8a8ba2a543201851de39d990ec957b513579c5", + "https://bcr.bazel.build/modules/bazel_skylib/1.4.1/MODULE.bazel": "a0dcb779424be33100dcae821e9e27e4f2901d9dfd5333efe5ac6a8d7ab75e1d", + "https://bcr.bazel.build/modules/bazel_skylib/1.4.2/MODULE.bazel": "3bd40978e7a1fac911d5989e6b09d8f64921865a45822d8b09e815eaa726a651", + "https://bcr.bazel.build/modules/bazel_skylib/1.5.0/MODULE.bazel": "32880f5e2945ce6a03d1fbd588e9198c0a959bb42297b2cfaf1685b7bc32e138", + "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917", + "https://bcr.bazel.build/modules/bazel_skylib/1.7.0/MODULE.bazel": "0db596f4563de7938de764cc8deeabec291f55e8ec15299718b93c4423e9796d", + "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/MODULE.bazel": "3120d80c5861aa616222ec015332e5f8d3171e062e3e804a2a0253e1be26e59b", + "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/source.json": "f121b43eeefc7c29efbd51b83d08631e2347297c95aac9764a701f2a6a2bb953", + "https://bcr.bazel.build/modules/buildozer/7.1.2/MODULE.bazel": "2e8dd40ede9c454042645fd8d8d0cd1527966aa5c919de86661e62953cd73d84", + "https://bcr.bazel.build/modules/buildozer/7.1.2/source.json": "c9028a501d2db85793a6996205c8de120944f50a0d570438fcae0457a5f9d1f8", + "https://bcr.bazel.build/modules/google_benchmark/1.8.2/MODULE.bazel": "a70cf1bba851000ba93b58ae2f6d76490a9feb74192e57ab8e8ff13c34ec50cb", + "https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4", + "https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "22c31a561553727960057361aa33bf20fb2e98584bc4fec007906e27053f80c6", + "https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/source.json": "41e9e129f80d8c8bf103a7acc337b76e54fad1214ac0a7084bf24f4cd924b8b4", + "https://bcr.bazel.build/modules/googletest/1.14.0/MODULE.bazel": "cfbcbf3e6eac06ef9d85900f64424708cc08687d1b527f0ef65aa7517af8118f", + "https://bcr.bazel.build/modules/jsoncpp/1.9.5/MODULE.bazel": "31271aedc59e815656f5736f282bb7509a97c7ecb43e927ac1a37966e0578075", + "https://bcr.bazel.build/modules/jsoncpp/1.9.5/source.json": "4108ee5085dd2885a341c7fab149429db457b3169b86eb081fa245eadf69169d", + "https://bcr.bazel.build/modules/libpfm/4.11.0/MODULE.bazel": "45061ff025b301940f1e30d2c16bea596c25b176c8b6b3087e92615adbd52902", + "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/MODULE.bazel": "6f7b417dcc794d9add9e556673ad25cb3ba835224290f4f848f8e2db1e1fca74", + "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/source.json": "f448c6e8963fdfa7eb831457df83ad63d3d6355018f6574fb017e8169deb43a9", + "https://bcr.bazel.build/modules/platforms/0.0.10/MODULE.bazel": "8cb8efaf200bdeb2150d93e162c40f388529a25852b332cec879373771e48ed5", + "https://bcr.bazel.build/modules/platforms/0.0.11/MODULE.bazel": "0daefc49732e227caa8bfa834d65dc52e8cc18a2faf80df25e8caea151a9413f", + "https://bcr.bazel.build/modules/platforms/0.0.11/source.json": "f7e188b79ebedebfe75e9e1d098b8845226c7992b307e28e1496f23112e8fc29", + "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", + "https://bcr.bazel.build/modules/platforms/0.0.5/MODULE.bazel": "5733b54ea419d5eaf7997054bb55f6a1d0b5ff8aedf0176fef9eea44f3acda37", + "https://bcr.bazel.build/modules/platforms/0.0.6/MODULE.bazel": "ad6eeef431dc52aefd2d77ed20a4b353f8ebf0f4ecdd26a807d2da5aa8cd0615", + "https://bcr.bazel.build/modules/platforms/0.0.7/MODULE.bazel": "72fd4a0ede9ee5c021f6a8dd92b503e089f46c227ba2813ff183b71616034814", + "https://bcr.bazel.build/modules/platforms/0.0.8/MODULE.bazel": "9f142c03e348f6d263719f5074b21ef3adf0b139ee4c5133e2aa35664da9eb2d", + "https://bcr.bazel.build/modules/platforms/0.0.9/MODULE.bazel": "4a87a60c927b56ddd67db50c89acaa62f4ce2a1d2149ccb63ffd871d5ce29ebc", + "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7", + "https://bcr.bazel.build/modules/protobuf/27.0/MODULE.bazel": "7873b60be88844a0a1d8f80b9d5d20cfbd8495a689b8763e76c6372998d3f64c", + "https://bcr.bazel.build/modules/protobuf/27.1/MODULE.bazel": "703a7b614728bb06647f965264967a8ef1c39e09e8f167b3ca0bb1fd80449c0d", + "https://bcr.bazel.build/modules/protobuf/29.0-rc2/MODULE.bazel": "6241d35983510143049943fc0d57937937122baf1b287862f9dc8590fc4c37df", + "https://bcr.bazel.build/modules/protobuf/29.0-rc3/MODULE.bazel": "33c2dfa286578573afc55a7acaea3cada4122b9631007c594bf0729f41c8de92", + "https://bcr.bazel.build/modules/protobuf/29.0/MODULE.bazel": "319dc8bf4c679ff87e71b1ccfb5a6e90a6dbc4693501d471f48662ac46d04e4e", + "https://bcr.bazel.build/modules/protobuf/29.0/source.json": "b857f93c796750eef95f0d61ee378f3420d00ee1dd38627b27193aa482f4f981", + "https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0", + "https://bcr.bazel.build/modules/pybind11_bazel/2.11.1/MODULE.bazel": "88af1c246226d87e65be78ed49ecd1e6f5e98648558c14ce99176da041dc378e", + "https://bcr.bazel.build/modules/pybind11_bazel/2.11.1/source.json": "be4789e951dd5301282729fe3d4938995dc4c1a81c2ff150afc9f1b0504c6022", + "https://bcr.bazel.build/modules/re2/2023-09-01/MODULE.bazel": "cb3d511531b16cfc78a225a9e2136007a48cf8a677e4264baeab57fe78a80206", + "https://bcr.bazel.build/modules/re2/2023-09-01/source.json": "e044ce89c2883cd957a2969a43e79f7752f9656f6b20050b62f90ede21ec6eb4", + "https://bcr.bazel.build/modules/rules_android/0.1.1/MODULE.bazel": "48809ab0091b07ad0182defb787c4c5328bd3a278938415c00a7b69b50c4d3a8", + "https://bcr.bazel.build/modules/rules_android/0.1.1/source.json": "e6986b41626ee10bdc864937ffb6d6bf275bb5b9c65120e6137d56e6331f089e", + "https://bcr.bazel.build/modules/rules_apple/4.2.0/MODULE.bazel": "e2e4362a8a5cbe24e9952aaea1f7f731d3677db83957056f57acfd5f2103c00f", + "https://bcr.bazel.build/modules/rules_apple/4.2.0/source.json": "a435c16fbd1af03b66559a3e894ff6d19a53e1503db13b7c1ab6074112f55970", + "https://bcr.bazel.build/modules/rules_cc/0.0.1/MODULE.bazel": "cb2aa0747f84c6c3a78dad4e2049c154f08ab9d166b1273835a8174940365647", + "https://bcr.bazel.build/modules/rules_cc/0.0.10/MODULE.bazel": "ec1705118f7eaedd6e118508d3d26deba2a4e76476ada7e0e3965211be012002", + "https://bcr.bazel.build/modules/rules_cc/0.0.13/MODULE.bazel": "0e8529ed7b323dad0775ff924d2ae5af7640b23553dfcd4d34344c7e7a867191", + "https://bcr.bazel.build/modules/rules_cc/0.0.14/MODULE.bazel": "5e343a3aac88b8d7af3b1b6d2093b55c347b8eefc2e7d1442f7a02dc8fea48ac", + "https://bcr.bazel.build/modules/rules_cc/0.0.15/MODULE.bazel": "6704c35f7b4a72502ee81f61bf88706b54f06b3cbe5558ac17e2e14666cd5dcc", + "https://bcr.bazel.build/modules/rules_cc/0.0.16/MODULE.bazel": "7661303b8fc1b4d7f532e54e9d6565771fea666fbdf839e0a86affcd02defe87", + "https://bcr.bazel.build/modules/rules_cc/0.0.2/MODULE.bazel": "6915987c90970493ab97393024c156ea8fb9f3bea953b2f3ec05c34f19b5695c", + "https://bcr.bazel.build/modules/rules_cc/0.0.6/MODULE.bazel": "abf360251023dfe3efcef65ab9d56beefa8394d4176dd29529750e1c57eaa33f", + "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", + "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", + "https://bcr.bazel.build/modules/rules_cc/0.1.1/MODULE.bazel": "2f0222a6f229f0bf44cd711dc13c858dad98c62d52bd51d8fc3a764a83125513", + "https://bcr.bazel.build/modules/rules_cc/0.1.2/MODULE.bazel": "557ddc3a96858ec0d465a87c0a931054d7dcfd6583af2c7ed3baf494407fd8d0", + "https://bcr.bazel.build/modules/rules_cc/0.2.9/MODULE.bazel": "34263f1dca62ea664265438cef714d7db124c03e1ed55ebb4f1dc860164308d1", + "https://bcr.bazel.build/modules/rules_cc/0.2.9/source.json": "4e49b40effcbd14fbfb233eb929de42dfff7b66538b4ffda310ad501638e7986", + "https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6", + "https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/MODULE.bazel": "40c97d1144356f52905566c55811f13b299453a14ac7769dfba2ac38192337a8", + "https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/source.json": "c8b1e2c717646f1702290959a3302a178fb639d987ab61d548105019f11e527e", + "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", + "https://bcr.bazel.build/modules/rules_java/5.3.5/MODULE.bazel": "a4ec4f2db570171e3e5eb753276ee4b389bae16b96207e9d3230895c99644b86", + "https://bcr.bazel.build/modules/rules_java/6.0.0/MODULE.bazel": "8a43b7df601a7ec1af61d79345c17b31ea1fedc6711fd4abfd013ea612978e39", + "https://bcr.bazel.build/modules/rules_java/6.4.0/MODULE.bazel": "e986a9fe25aeaa84ac17ca093ef13a4637f6107375f64667a15999f77db6c8f6", + "https://bcr.bazel.build/modules/rules_java/6.5.2/MODULE.bazel": "1d440d262d0e08453fa0c4d8f699ba81609ed0e9a9a0f02cd10b3e7942e61e31", + "https://bcr.bazel.build/modules/rules_java/7.10.0/MODULE.bazel": "530c3beb3067e870561739f1144329a21c851ff771cd752a49e06e3dc9c2e71a", + "https://bcr.bazel.build/modules/rules_java/7.12.2/MODULE.bazel": "579c505165ee757a4280ef83cda0150eea193eed3bef50b1004ba88b99da6de6", + "https://bcr.bazel.build/modules/rules_java/7.2.0/MODULE.bazel": "06c0334c9be61e6cef2c8c84a7800cef502063269a5af25ceb100b192453d4ab", + "https://bcr.bazel.build/modules/rules_java/7.3.2/MODULE.bazel": "50dece891cfdf1741ea230d001aa9c14398062f2b7c066470accace78e412bc2", + "https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe", + "https://bcr.bazel.build/modules/rules_java/8.14.0/MODULE.bazel": "717717ed40cc69994596a45aec6ea78135ea434b8402fb91b009b9151dd65615", + "https://bcr.bazel.build/modules/rules_java/8.14.0/source.json": "8a88c4ca9e8759da53cddc88123880565c520503321e2566b4e33d0287a3d4bc", + "https://bcr.bazel.build/modules/rules_java/8.3.2/MODULE.bazel": "7336d5511ad5af0b8615fdc7477535a2e4e723a357b6713af439fe8cf0195017", + "https://bcr.bazel.build/modules/rules_java/8.5.1/MODULE.bazel": "d8a9e38cc5228881f7055a6079f6f7821a073df3744d441978e7a43e20226939", + "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", + "https://bcr.bazel.build/modules/rules_jvm_external/5.1/MODULE.bazel": "33f6f999e03183f7d088c9be518a63467dfd0be94a11d0055fe2d210f89aa909", + "https://bcr.bazel.build/modules/rules_jvm_external/5.2/MODULE.bazel": "d9351ba35217ad0de03816ef3ed63f89d411349353077348a45348b096615036", + "https://bcr.bazel.build/modules/rules_jvm_external/5.3/MODULE.bazel": "bf93870767689637164657731849fb887ad086739bd5d360d90007a581d5527d", + "https://bcr.bazel.build/modules/rules_jvm_external/6.1/MODULE.bazel": "75b5fec090dbd46cf9b7d8ea08cf84a0472d92ba3585b476f44c326eda8059c4", + "https://bcr.bazel.build/modules/rules_jvm_external/6.3/MODULE.bazel": "c998e060b85f71e00de5ec552019347c8bca255062c990ac02d051bb80a38df0", + "https://bcr.bazel.build/modules/rules_jvm_external/6.3/source.json": "6f5f5a5a4419ae4e37c35a5bb0a6ae657ed40b7abc5a5189111b47fcebe43197", + "https://bcr.bazel.build/modules/rules_kotlin/1.9.0/MODULE.bazel": "ef85697305025e5a61f395d4eaede272a5393cee479ace6686dba707de804d59", + "https://bcr.bazel.build/modules/rules_kotlin/1.9.6/MODULE.bazel": "d269a01a18ee74d0335450b10f62c9ed81f2321d7958a2934e44272fe82dcef3", + "https://bcr.bazel.build/modules/rules_kotlin/1.9.6/source.json": "2faa4794364282db7c06600b7e5e34867a564ae91bda7cae7c29c64e9466b7d5", + "https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0", + "https://bcr.bazel.build/modules/rules_license/0.0.7/MODULE.bazel": "088fbeb0b6a419005b89cf93fe62d9517c0a2b8bb56af3244af65ecfe37e7d5d", + "https://bcr.bazel.build/modules/rules_license/1.0.0/MODULE.bazel": "a7fda60eefdf3d8c827262ba499957e4df06f659330bbe6cdbdb975b768bb65c", + "https://bcr.bazel.build/modules/rules_license/1.0.0/source.json": "a52c89e54cc311196e478f8382df91c15f7a2bfdf4c6cd0e2675cc2ff0b56efb", + "https://bcr.bazel.build/modules/rules_pkg/0.7.0/MODULE.bazel": "df99f03fc7934a4737122518bb87e667e62d780b610910f0447665a7e2be62dc", + "https://bcr.bazel.build/modules/rules_pkg/1.0.1/MODULE.bazel": "5b1df97dbc29623bccdf2b0dcd0f5cb08e2f2c9050aab1092fd39a41e82686ff", + "https://bcr.bazel.build/modules/rules_pkg/1.0.1/source.json": "bd82e5d7b9ce2d31e380dd9f50c111d678c3bdaca190cb76b0e1c71b05e1ba8a", + "https://bcr.bazel.build/modules/rules_proto/4.0.0/MODULE.bazel": "a7a7b6ce9bee418c1a760b3d84f83a299ad6952f9903c67f19e4edd964894e06", + "https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/MODULE.bazel": "e8dff86b0971688790ae75528fe1813f71809b5afd57facb44dad9e8eca631b7", + "https://bcr.bazel.build/modules/rules_proto/6.0.2/MODULE.bazel": "ce916b775a62b90b61888052a416ccdda405212b6aaeb39522f7dc53431a5e73", + "https://bcr.bazel.build/modules/rules_proto/7.0.2/MODULE.bazel": "bf81793bd6d2ad89a37a40693e56c61b0ee30f7a7fdbaf3eabbf5f39de47dea2", + "https://bcr.bazel.build/modules/rules_proto/7.0.2/source.json": "1e5e7260ae32ef4f2b52fd1d0de8d03b606a44c91b694d2f1afb1d3b28a48ce1", + "https://bcr.bazel.build/modules/rules_python/0.10.2/MODULE.bazel": "cc82bc96f2997baa545ab3ce73f196d040ffb8756fd2d66125a530031cd90e5f", + "https://bcr.bazel.build/modules/rules_python/0.23.1/MODULE.bazel": "49ffccf0511cb8414de28321f5fcf2a31312b47c40cc21577144b7447f2bf300", + "https://bcr.bazel.build/modules/rules_python/0.25.0/MODULE.bazel": "72f1506841c920a1afec76975b35312410eea3aa7b63267436bfb1dd91d2d382", + "https://bcr.bazel.build/modules/rules_python/0.28.0/MODULE.bazel": "cba2573d870babc976664a912539b320cbaa7114cd3e8f053c720171cde331ed", + "https://bcr.bazel.build/modules/rules_python/0.31.0/MODULE.bazel": "93a43dc47ee570e6ec9f5779b2e64c1476a6ce921c48cc9a1678a91dd5f8fd58", + "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", + "https://bcr.bazel.build/modules/rules_python/0.40.0/MODULE.bazel": "9d1a3cd88ed7d8e39583d9ffe56ae8a244f67783ae89b60caafc9f5cf318ada7", + "https://bcr.bazel.build/modules/rules_python/1.3.0/MODULE.bazel": "8361d57eafb67c09b75bf4bbe6be360e1b8f4f18118ab48037f2bd50aa2ccb13", + "https://bcr.bazel.build/modules/rules_python/1.3.0/source.json": "25932f917cd279c7baefa6cb1d3fa8750a7a29de522024449b19af6eab51f4a0", + "https://bcr.bazel.build/modules/rules_shell/0.2.0/MODULE.bazel": "fda8a652ab3c7d8fee214de05e7a9916d8b28082234e8d2c0094505c5268ed3c", + "https://bcr.bazel.build/modules/rules_shell/0.3.0/MODULE.bazel": "de4402cd12f4cc8fda2354fce179fdb068c0b9ca1ec2d2b17b3e21b24c1a937b", + "https://bcr.bazel.build/modules/rules_shell/0.3.0/source.json": "c55ed591aa5009401ddf80ded9762ac32c358d2517ee7820be981e2de9756cf3", + "https://bcr.bazel.build/modules/rules_swift/1.16.0/MODULE.bazel": "4a09f199545a60d09895e8281362b1ff3bb08bbde69c6fc87aff5b92fcc916ca", + "https://bcr.bazel.build/modules/rules_swift/2.4.0/MODULE.bazel": "1639617eb1ede28d774d967a738b4a68b0accb40650beadb57c21846beab5efd", + "https://bcr.bazel.build/modules/rules_swift/2.4.0/source.json": "a6577f57f9febbdc015a01f2a8f3487422032f134d6c61d18ed8e8ca3b9acc7c", + "https://bcr.bazel.build/modules/stardoc/0.5.1/MODULE.bazel": "1a05d92974d0c122f5ccf09291442580317cdd859f07a8655f1db9a60374f9f8", + "https://bcr.bazel.build/modules/stardoc/0.5.3/MODULE.bazel": "c7f6948dae6999bf0db32c1858ae345f112cacf98f174c7a8bb707e41b974f1c", + "https://bcr.bazel.build/modules/stardoc/0.5.6/MODULE.bazel": "c43dabc564990eeab55e25ed61c07a1aadafe9ece96a4efabb3f8bf9063b71ef", + "https://bcr.bazel.build/modules/stardoc/0.7.0/MODULE.bazel": "05e3d6d30c099b6770e97da986c53bd31844d7f13d41412480ea265ac9e8079c", + "https://bcr.bazel.build/modules/stardoc/0.7.1/MODULE.bazel": "3548faea4ee5dda5580f9af150e79d0f6aea934fc60c1cc50f4efdd9420759e7", + "https://bcr.bazel.build/modules/stardoc/0.7.2/MODULE.bazel": "fc152419aa2ea0f51c29583fab1e8c99ddefd5b3778421845606ee628629e0e5", + "https://bcr.bazel.build/modules/stardoc/0.7.2/source.json": "58b029e5e901d6802967754adf0a9056747e8176f017cfe3607c0851f4d42216", + "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/MODULE.bazel": "5e463fbfba7b1701d957555ed45097d7f984211330106ccd1352c6e0af0dcf91", + "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/source.json": "32bd87e5f4d7acc57c5b2ff7c325ae3061d5e242c0c4c214ae87e0f1c13e54cb", + "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43", + "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.5/MODULE.bazel": "eec517b5bbe5492629466e11dae908d043364302283de25581e3eb944326c4ca", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.5/source.json": "22bc55c47af97246cfc093d0acf683a7869377de362b5d1c552c2c2e16b7a806", + "https://bcr.bazel.build/modules/zlib/1.3.1/MODULE.bazel": "751c9940dcfe869f5f7274e1295422a34623555916eb98c174c1e945594bf198" + }, + "selectedYankedVersions": {}, + "moduleExtensions": { + "@@rules_kotlin+//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": { + "general": { + "bzlTransitiveDigest": "OlvsB0HsvxbR8ZN+J9Vf00X/+WVz/Y/5Xrq2LgcVfdo=", + "usagesDigest": "QI2z8ZUR+mqtbwsf2fLqYdJAkPOHdOV+tF2yVAUgRzw=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "com_github_jetbrains_kotlin_git": { + "repoRuleId": "@@rules_kotlin+//src/main/starlark/core/repositories:compiler.bzl%kotlin_compiler_git_repository", + "attributes": { + "urls": [ + "https://github.com/JetBrains/kotlin/releases/download/v1.9.23/kotlin-compiler-1.9.23.zip" + ], + "sha256": "93137d3aab9afa9b27cb06a824c2324195c6b6f6179d8a8653f440f5bd58be88" + } + }, + "com_github_jetbrains_kotlin": { + "repoRuleId": "@@rules_kotlin+//src/main/starlark/core/repositories:compiler.bzl%kotlin_capabilities_repository", + "attributes": { + "git_repository_name": "com_github_jetbrains_kotlin_git", + "compiler_version": "1.9.23" + } + }, + "com_github_google_ksp": { + "repoRuleId": "@@rules_kotlin+//src/main/starlark/core/repositories:ksp.bzl%ksp_compiler_plugin_repository", + "attributes": { + "urls": [ + "https://github.com/google/ksp/releases/download/1.9.23-1.0.20/artifacts.zip" + ], + "sha256": "ee0618755913ef7fd6511288a232e8fad24838b9af6ea73972a76e81053c8c2d", + "strip_version": "1.9.23-1.0.20" + } + }, + "com_github_pinterest_ktlint": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_file", + "attributes": { + "sha256": "01b2e0ef893383a50dbeb13970fe7fa3be36ca3e83259e01649945b09d736985", + "urls": [ + "https://github.com/pinterest/ktlint/releases/download/1.3.0/ktlint" + ], + "executable": true + } + }, + "rules_android": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "sha256": "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806", + "strip_prefix": "rules_android-0.1.1", + "urls": [ + "https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip" + ] + } + } + }, + "recordedRepoMappingEntries": [ + [ + "rules_kotlin+", + "bazel_tools", + "bazel_tools" + ] + ] + } + }, + "@@rules_python+//python/uv:uv.bzl%uv": { + "general": { + "bzlTransitiveDigest": "Xpqjnjzy6zZ90Es9Wa888ZLHhn7IsNGbph/e6qoxzw8=", + "usagesDigest": "vJ5RHUxAnV24M5swNGiAnkdxMx3Hp/iOLmNANTC5Xc8=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "uv": { + "repoRuleId": "@@rules_python+//python/uv/private:uv_toolchains_repo.bzl%uv_toolchains_repo", + "attributes": { + "toolchain_type": "'@@rules_python+//python/uv:uv_toolchain_type'", + "toolchain_names": [ + "none" + ], + "toolchain_implementations": { + "none": "'@@rules_python+//python:none'" + }, + "toolchain_compatible_with": { + "none": [ + "@platforms//:incompatible" + ] + }, + "toolchain_target_settings": {} + } + } + }, + "recordedRepoMappingEntries": [ + [ + "rules_python+", + "platforms", + "platforms" + ] + ] + } + }, + "@@rules_swift+//swift:extensions.bzl%non_module_deps": { + "general": { + "bzlTransitiveDigest": "wyM5KNlXr2xTVDyXRNH+6P1gq3ZCbFxUscWY1jDXrDM=", + "usagesDigest": "9w18ec4dj90mX/JqpR2tBU2YVc1GU9yNxi/d7q6lLVA=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "com_github_apple_swift_protobuf": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "urls": [ + "https://github.com/apple/swift-protobuf/archive/1.20.2.tar.gz" + ], + "sha256": "3fb50bd4d293337f202d917b6ada22f9548a0a0aed9d9a4d791e6fbd8a246ebb", + "strip_prefix": "swift-protobuf-1.20.2/", + "build_file": "@@rules_swift+//third_party:com_github_apple_swift_protobuf/BUILD.overlay" + } + }, + "com_github_grpc_grpc_swift": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "urls": [ + "https://github.com/grpc/grpc-swift/archive/1.16.0.tar.gz" + ], + "sha256": "58b60431d0064969f9679411264b82e40a217ae6bd34e17096d92cc4e47556a5", + "strip_prefix": "grpc-swift-1.16.0/", + "build_file": "@@rules_swift+//third_party:com_github_grpc_grpc_swift/BUILD.overlay" + } + }, + "com_github_apple_swift_docc_symbolkit": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "urls": [ + "https://github.com/apple/swift-docc-symbolkit/archive/refs/tags/swift-5.10-RELEASE.tar.gz" + ], + "sha256": "de1d4b6940468ddb53b89df7aa1a81323b9712775b0e33e8254fa0f6f7469a97", + "strip_prefix": "swift-docc-symbolkit-swift-5.10-RELEASE", + "build_file": "@@rules_swift+//third_party:com_github_apple_swift_docc_symbolkit/BUILD.overlay" + } + }, + "com_github_apple_swift_nio": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "urls": [ + "https://github.com/apple/swift-nio/archive/2.42.0.tar.gz" + ], + "sha256": "e3304bc3fb53aea74a3e54bd005ede11f6dc357117d9b1db642d03aea87194a0", + "strip_prefix": "swift-nio-2.42.0/", + "build_file": "@@rules_swift+//third_party:com_github_apple_swift_nio/BUILD.overlay" + } + }, + "com_github_apple_swift_nio_http2": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "urls": [ + "https://github.com/apple/swift-nio-http2/archive/1.26.0.tar.gz" + ], + "sha256": "f0edfc9d6a7be1d587e5b403f2d04264bdfae59aac1d74f7d974a9022c6d2b25", + "strip_prefix": "swift-nio-http2-1.26.0/", + "build_file": "@@rules_swift+//third_party:com_github_apple_swift_nio_http2/BUILD.overlay" + } + }, + "com_github_apple_swift_nio_transport_services": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "urls": [ + "https://github.com/apple/swift-nio-transport-services/archive/1.15.0.tar.gz" + ], + "sha256": "f3498dafa633751a52b9b7f741f7ac30c42bcbeb3b9edca6d447e0da8e693262", + "strip_prefix": "swift-nio-transport-services-1.15.0/", + "build_file": "@@rules_swift+//third_party:com_github_apple_swift_nio_transport_services/BUILD.overlay" + } + }, + "com_github_apple_swift_nio_extras": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "urls": [ + "https://github.com/apple/swift-nio-extras/archive/1.4.0.tar.gz" + ], + "sha256": "4684b52951d9d9937bb3e8ccd6b5daedd777021ef2519ea2f18c4c922843b52b", + "strip_prefix": "swift-nio-extras-1.4.0/", + "build_file": "@@rules_swift+//third_party:com_github_apple_swift_nio_extras/BUILD.overlay" + } + }, + "com_github_apple_swift_log": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "urls": [ + "https://github.com/apple/swift-log/archive/1.4.4.tar.gz" + ], + "sha256": "48fe66426c784c0c20031f15dc17faf9f4c9037c192bfac2f643f65cb2321ba0", + "strip_prefix": "swift-log-1.4.4/", + "build_file": "@@rules_swift+//third_party:com_github_apple_swift_log/BUILD.overlay" + } + }, + "com_github_apple_swift_nio_ssl": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "urls": [ + "https://github.com/apple/swift-nio-ssl/archive/2.23.0.tar.gz" + ], + "sha256": "4787c63f61dd04d99e498adc3d1a628193387e41efddf8de19b8db04544d016d", + "strip_prefix": "swift-nio-ssl-2.23.0/", + "build_file": "@@rules_swift+//third_party:com_github_apple_swift_nio_ssl/BUILD.overlay" + } + }, + "com_github_apple_swift_collections": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "urls": [ + "https://github.com/apple/swift-collections/archive/1.0.4.tar.gz" + ], + "sha256": "d9e4c8a91c60fb9c92a04caccbb10ded42f4cb47b26a212bc6b39cc390a4b096", + "strip_prefix": "swift-collections-1.0.4/", + "build_file": "@@rules_swift+//third_party:com_github_apple_swift_collections/BUILD.overlay" + } + }, + "com_github_apple_swift_atomics": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "urls": [ + "https://github.com/apple/swift-atomics/archive/1.1.0.tar.gz" + ], + "sha256": "1bee7f469f7e8dc49f11cfa4da07182fbc79eab000ec2c17bfdce468c5d276fb", + "strip_prefix": "swift-atomics-1.1.0/", + "build_file": "@@rules_swift+//third_party:com_github_apple_swift_atomics/BUILD.overlay" + } + }, + "build_bazel_rules_swift_index_import": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "build_file": "@@rules_swift+//third_party:build_bazel_rules_swift_index_import/BUILD.overlay", + "canonical_id": "index-import-5.8", + "urls": [ + "https://github.com/MobileNativeFoundation/index-import/releases/download/5.8.0.1/index-import.tar.gz" + ], + "sha256": "28c1ffa39d99e74ed70623899b207b41f79214c498c603915aef55972a851a15" + } + }, + "build_bazel_rules_swift_local_config": { + "repoRuleId": "@@rules_swift+//swift/internal:swift_autoconfiguration.bzl%swift_autoconfiguration", + "attributes": {} + } + }, + "recordedRepoMappingEntries": [ + [ + "rules_swift+", + "bazel_tools", + "bazel_tools" + ] + ] + } + } + } +} diff --git a/README.md b/README.md index e3f8bc6..af6a9c3 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,10 @@ :arrow_right: Documentation: [djinni.xlcpp.dev](https://djinni.xlcpp.dev/djinni-support-lib/install) C++ support library that is required as a foundation for the gluecode generated by [djinni-generator](https://github.com/cross-language-cpp/djinni-generator). + +## Bazel + +Adding basic build support via bazel + + bazel build //:djinni-jni + bazel build //:djinni-objc diff --git a/zconf-new.sh b/zconf-new.sh index fa0b9ed..d67a89c 100644 --- a/zconf-new.sh +++ b/zconf-new.sh @@ -1,4 +1,4 @@ cmake -G "Ninja Multi-Config" -B build/new -S . --fresh \ -DDJINNI_WITH_OBJC=ON -DDJINNI_WITH_JNI=ON \ -DDJINNI_EXECUTABLE=$(pwd)/../djinni-generator/target/bin/djinni \ - -DCMAKE_OSX_SYSROOT=/Applications/Xcode-16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk + -DCMAKE_OSX_SYSROOT=/Applications/Xcode-26.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk From 8ff0e511326deba900dc6cb41e07a8b742ec2096 Mon Sep 17 00:00:00 2001 From: a4z Date: Tue, 7 Oct 2025 20:14:29 +0200 Subject: [PATCH 22/22] Add basic bazel ci run --- .github/workflows/build-bazel.yml | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/build-bazel.yml diff --git a/.github/workflows/build-bazel.yml b/.github/workflows/build-bazel.yml new file mode 100644 index 0000000..6fb6314 --- /dev/null +++ b/.github/workflows/build-bazel.yml @@ -0,0 +1,33 @@ +name: build bazel + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + build: + name: ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - macos-latest +# - ubuntu-latest + steps: + - uses: bazel-contrib/setup-bazel@0.15.0 + with: + bazelisk-cache: true + disk-cache: ${{ github.workflow }} + external-cache: true + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build (fastbuild) + run: bazel build //... + + # - name: Test (fastbuild) + # run: bazel test //...