diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 00000000..a2f28f43 --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +8.4.0 diff --git a/.github/workflows/bazel-build.yaml b/.github/workflows/bazel-build.yaml new file mode 100644 index 00000000..129e464a --- /dev/null +++ b/.github/workflows/bazel-build.yaml @@ -0,0 +1,34 @@ +name: build bazel + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + build: + name: ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest +# - windows-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 //... diff --git a/.gitignore b/.gitignore index c2b52298..f328fa88 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,8 @@ ztest/ # OS specific .DS_Store + +bazel-bin +bazel-djinni-generator +bazel-out +bazel-testlogs diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 00000000..9ec258f5 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,23 @@ +load("@rules_scala//scala:scala.bzl", "scala_binary", "scala_test") + +scala_binary( + name = "djinni", + srcs = glob(["src/main/scala/**/*.scala"]), + main_class = "djinni.Main", + resources = glob(["src/main/resources/**"]), + visibility = ["//visibility:public"], + deps = [ + "@maven//:com_github_scopt_scopt_2_12", + "@maven//:commons_io_commons_io", + "@maven//:org_scala_lang_modules_scala_parser_combinators_2_12", + "@maven//:org_yaml_snakeyaml", + ], +) + +scala_test( + name = "test", + srcs = glob(["src/it/scala/djinni/**/*.scala"]), + data = glob(["src/it/resources/**"]), + deps = [":djinni"], + timeout="short", +) diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 00000000..db3a3969 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,67 @@ +"""Djinni generator - Cross-language bindings generator for C++, Java, Objective-C""" + +module( + name = "djinni-generator", + version = "1.4.1", +) + +# MODULE.bazel + +bazel_dep(name = "rules_scala", version = "7.1.2") + +# Selects the Scala version and other configuration parameters. +# +# 2.12 is the default version. Use other versions by passing them explicitly, as +# illustrated below. +# +# See the documentation of `_settings_attrs` in `scala/extensions/config.bzl` +# for other available parameters. +# +# You may define your own custom toolchain using Maven artifact dependencies +# configured by your `WORKSPACE` file, imported using an external loader like +# https://github.com/bazelbuild/rules_jvm_external. See docs/scala_toolchain.md. +scala_config = use_extension( + "@rules_scala//scala/extensions:config.bzl", + "scala_config", +) +scala_config.settings(scala_version = "2.12.20") + +# See the `scala/extensions/deps.bzl` docstring for a high level description of +# the tag classes exported by this module extension. +scala_deps = use_extension( + "@rules_scala//scala/extensions:deps.bzl", + "scala_deps", +) + +# Defines a default toolchain repo for the configured Scala version that loads +# Maven deps like the Scala compiler and standard libs. Enable and configure +# other builtin toolchains by instantiating their corresponding tag classes. +# See the documentation in `scala/extensions/deps.bzl` for all builtin +# toolchain configuration options. +# +# On production projects, you may consider defining a custom toolchain to use +# your project's required dependencies instead. In that case, you can omit using +# the module extension and this next line altogether. Or, you can still use the +# module extension to instantiate other optional `rules_scala` toolchains +# without it. +scala_deps.scala() +scala_deps.scalatest() + +# Add Maven dependencies for djinni +bazel_dep(name = "rules_jvm_external", version = "6.4") + +maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") +maven.install( + artifacts = [ + "org.scala-lang.modules:scala-parser-combinators_2.12:2.1.0", + "org.yaml:snakeyaml:1.29", + "com.github.scopt:scopt_2.12:4.0.1", + "commons-io:commons-io:2.11.0", + "org.scalactic:scalactic_2.12:3.2.10", + "org.scalatest:scalatest_2.12:3.2.10", + ], + repositories = [ + "https://repo1.maven.org/maven2", + ], +) +use_repo(maven, "maven") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock new file mode 100644 index 00000000..6f835815 --- /dev/null +++ b/MODULE.bazel.lock @@ -0,0 +1,1292 @@ +{ + "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.13.0/MODULE.bazel": "7c8cdea7e031b7f9f67f0b497adf6d2c6a2675e9304ca93a9af6ed84eef5a524", + "https://bcr.bazel.build/modules/aspect_bazel_lib/1.31.2/MODULE.bazel": "7bee702b4862612f29333590f4b658a5832d433d6f8e4395f090e8f4e85d442f", + "https://bcr.bazel.build/modules/aspect_bazel_lib/1.38.0/MODULE.bazel": "6307fec451ba9962c1c969eb516ebfe1e46528f7fa92e1c9ac8646bef4cdaa3f", + "https://bcr.bazel.build/modules/aspect_bazel_lib/1.40.3/MODULE.bazel": "668e6bcb4d957fc0e284316dba546b705c8d43c857f87119619ee83c4555b859", + "https://bcr.bazel.build/modules/aspect_rules_js/1.33.1/MODULE.bazel": "db3e7f16e471cf6827059d03af7c21859e7a0d2bc65429a3a11f005d46fc501b", + "https://bcr.bazel.build/modules/aspect_rules_js/1.39.0/MODULE.bazel": "aece421d479e3c31dc3e5f6d49a12acc2700457c03c556650ec7a0ff23fc0d95", + "https://bcr.bazel.build/modules/aspect_rules_lint/0.12.0/MODULE.bazel": "e767c5dbfeb254ec03275a7701b5cfde2c4d2873676804bc7cb27ddff3728fed", + "https://bcr.bazel.build/modules/bazel_features/0.1.0/MODULE.bazel": "47011d645b0f949f42ee67f2e8775188a9cf4a0a1528aa2fa4952f2fd00906fd", + "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.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.0/MODULE.bazel": "f84162c41b86658c8a054584495594a94eae476555d07cc1d17507150e69f706", + "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/bazel_worker_api/0.0.6/MODULE.bazel": "fd1f9432ca04c947e91b500df69ce7c5b6dbfe1bc45ab1820338205dae3383a6", + "https://bcr.bazel.build/modules/bazel_worker_api/0.0.6/source.json": "5d68545f224904745a3cabd35aea6bc2b6cc5a78b7f49f3f69660eab2eeeb273", + "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/gazelle/0.27.0/MODULE.bazel": "3446abd608295de6d90b4a8a118ed64a9ce11dcb3dda2dc3290a22056bd20996", + "https://bcr.bazel.build/modules/gazelle/0.30.0/MODULE.bazel": "f888a1effe338491f35f0e0e85003b47bb9d8295ccba73c37e07702d8d31c65b", + "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/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/27.2/MODULE.bazel": "32450b50673882e4c8c3d10a83f3bc82161b213ed2f80d17e38bece8f165c295", + "https://bcr.bazel.build/modules/protobuf/28.2/MODULE.bazel": "c0c8e51757df486d0314fa290e174d707bad4a6c2aa5ccb08a4b4abd76a23e90", + "https://bcr.bazel.build/modules/protobuf/29.0-rc2/MODULE.bazel": "6241d35983510143049943fc0d57937937122baf1b287862f9dc8590fc4c37df", + "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/protobuf/3.19.2/MODULE.bazel": "532ffe5f2186b69fdde039efe6df13ba726ff338c6bc82275ad433013fa10573", + "https://bcr.bazel.build/modules/protobuf/3.19.6/MODULE.bazel": "9233edc5e1f2ee276a60de3eaa47ac4132302ef9643238f23128fea53ea12858", + "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_buf/0.1.1/MODULE.bazel": "6189aec18a4f7caff599ad41b851ab7645d4f1e114aa6431acf9b0666eb92162", + "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.1/source.json": "d61627377bd7dd1da4652063e368d9366fc9a73920bfa396798ad92172cf645c", + "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_go/0.33.0/MODULE.bazel": "a2b11b64cd24bf94f57454f53288a5dacfe6cb86453eee7761b7637728c1910c", + "https://bcr.bazel.build/modules/rules_go/0.38.1/MODULE.bazel": "fb8e73dd3b6fc4ff9d260ceacd830114891d49904f5bda1c16bc147bcc254f71", + "https://bcr.bazel.build/modules/rules_go/0.39.1/MODULE.bazel": "d34fb2a249403a5f4339c754f1e63dc9e5ad70b47c5e97faee1441fc6636cd61", + "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.11.1/MODULE.bazel": "b4782e019dd0b0151bd49fd8929136fd4441f527eb208fbd991b77e480b7236e", + "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.0/MODULE.bazel": "14cd36d05b60aa53c345b5b436c1c4a1f1dec58e82e480ffb9657038e323d330", + "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_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.4/MODULE.bazel": "e859f460f0fcebbee0af2ac65a38c952eedb60612956395ba414fdf78babae2f", + "https://bcr.bazel.build/modules/rules_jvm_external/6.4/source.json": "752c79441c87f8945b1aeddbde2864661e2ca594c82700b8c2d4550d080070d9", + "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/0.0.8/MODULE.bazel": "5669c6fe49b5134dbf534db681ad3d67a2d49cfc197e4a95f1ca2fd7f3aebe96", + "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_nodejs/5.8.2/MODULE.bazel": "6bc03c8f37f69401b888023bf511cb6ee4781433b0cb56236b2e55a21e3a026a", + "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.0/MODULE.bazel": "b531d7f09f58dce456cd61b4579ce8c86b38544da75184eadaf0a7cb7966453f", + "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/0.40.0/source.json": "939d4bd2e3110f27bfb360292986bb79fd8dcefb874358ccd6cdaa7bda029320", + "https://bcr.bazel.build/modules/rules_rust/0.45.1/MODULE.bazel": "a69d0db3a958fab2c6520961e1b2287afcc8b36690fd31bbc4f6f7391397150d", + "https://bcr.bazel.build/modules/rules_scala/7.1.2/MODULE.bazel": "39705cddb98ee57400d310ac0df88d89abf39b8289f136397623411c74638843", + "https://bcr.bazel.build/modules/rules_scala/7.1.2/source.json": "36b3649f8f08f924a84d652b9ae1b60d528d785b53a841bd2231357571281401", + "https://bcr.bazel.build/modules/rules_shell/0.2.0/MODULE.bazel": "fda8a652ab3c7d8fee214de05e7a9916d8b28082234e8d2c0094505c5268ed3c", + "https://bcr.bazel.build/modules/rules_shell/0.2.0/source.json": "7f27af3c28037d9701487c4744b5448d26537cc66cdef0d8df7ae85411f8de95", + "https://bcr.bazel.build/modules/stardoc/0.5.0/MODULE.bazel": "f9f1f46ba8d9c3362648eea571c6f9100680efc44913618811b58cc9c02cd678", + "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.4/MODULE.bazel": "6569966df04610b8520957cb8e97cf2e9faac2c0309657c537ab51c16c18a2a4", + "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.1/source.json": "b6500ffcd7b48cd72c29bb67bcac781e12701cc0d6d55d266a652583cfcdab01", + "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.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27", + "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_scala+//scala/extensions:config.bzl%scala_config": { + "general": { + "bzlTransitiveDigest": "TdBxhkZTM7VU6teIFS+KoonKU7wmb5BL7leCWWx7yX8=", + "usagesDigest": "wlRjl8R1X3OGx/jZdFB1bU7Ch5CNaM9ayuuWEWlKMHw=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": { + "ENABLE_COMPILER_DEPENDENCY_TRACKING": null, + "SCALA_VERSION": null + }, + "generatedRepoSpecs": { + "rules_scala_config": { + "repoRuleId": "@@rules_scala+//:scala_config.bzl%_config_repository", + "attributes": { + "scala_version": "2.12.20", + "scala_versions": [ + "2.12.20" + ], + "enable_compiler_dependency_tracking": false + } + } + }, + "recordedRepoMappingEntries": [] + } + }, + "@@rules_scala+//scala/extensions:deps.bzl%scala_deps": { + "general": { + "bzlTransitiveDigest": "PNb7xha3GA98nLXpW5Fho7heUpLciDzpQzLJb+0xyNc=", + "usagesDigest": "hrPDEe1I223x8mx3napLD9oiBLXohXaeWCXWQXNa8vk=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "scala_compiler_source_2_12_20": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\nfilegroup(\n name = \"src\",\n srcs=[\"scala/tools/nsc/symtab/SymbolLoaders.scala\"],\n)", + "patches": [ + "@@rules_scala+//dt_patches:dt_compiler_2.12.patch" + ], + "url": "https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.12.20/scala-compiler-2.12.20-sources.jar", + "urls": [], + "sha256": "", + "integrity": "sha256-B8FAyBh6e8vPznUJ608XBPy/oSrTx3mPjdyrlHfcUCg=" + } + }, + "scala_compiler_sources": { + "repoRuleId": "@@rules_scala+//scala/private:macros/scala_repositories.bzl%compiler_sources_repo", + "attributes": {} + }, + "io_bazel_rules_scala_scalactic_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scalactic_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalactic/scalactic_2.12/3.2.19/scalactic_2.12-3.2.19.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalactic/scalactic_2.12/3.2.19/scalactic_2.12-3.2.19.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalactic/scalactic_2.12/3.2.19/scalactic_2.12-3.2.19.jar", + "https://jcenter.bintray.com/org/scalactic/scalactic_2.12/3.2.19/scalactic_2.12-3.2.19.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalactic/scalactic_2.12/3.2.19/scalactic_2.12-3.2.19-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalactic/scalactic_2.12/3.2.19/scalactic_2.12-3.2.19-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalactic/scalactic_2.12/3.2.19/scalactic_2.12-3.2.19-sources.jar", + "https://jcenter.bintray.com/org/scalactic/scalactic_2.12/3.2.19/scalactic_2.12-3.2.19-sources.jar" + ], + "coordinates": "org.scalactic:scalactic_2.12:3.2.19", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "a50a3248208b25e9797c447709fe4276026510beae01e82366f405a66d9a8d57", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20", + "@io_bazel_rules_scala_scala_reflect_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scalactic": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scalactic", + "target": "io_bazel_rules_scala_scalactic_2_12_20" + } + }, + "io_bazel_rules_scala_scalatest_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scalatest_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest_2.12/3.2.19/scalatest_2.12-3.2.19.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest_2.12/3.2.19/scalatest_2.12-3.2.19.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest_2.12/3.2.19/scalatest_2.12-3.2.19.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest_2.12/3.2.19/scalatest_2.12-3.2.19.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest_2.12/3.2.19/scalatest_2.12-3.2.19-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest_2.12/3.2.19/scalatest_2.12-3.2.19-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest_2.12/3.2.19/scalatest_2.12-3.2.19-sources.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest_2.12/3.2.19/scalatest_2.12-3.2.19-sources.jar" + ], + "coordinates": "org.scalatest:scalatest_2.12:3.2.19", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "9f7dc750bbd6eeb52f0d8bc7c542ace46da9efdca0128a5a92769a448e065a62", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20", + "@io_bazel_rules_scala_scala_reflect_2_12_20", + "@io_bazel_rules_scala_scalatest_core_2_12_20", + "@io_bazel_rules_scala_scalatest_diagrams_2_12_20", + "@io_bazel_rules_scala_scalatest_featurespec_2_12_20", + "@io_bazel_rules_scala_scalatest_flatspec_2_12_20", + "@io_bazel_rules_scala_scalatest_freespec_2_12_20", + "@io_bazel_rules_scala_scalatest_funspec_2_12_20", + "@io_bazel_rules_scala_scalatest_funsuite_2_12_20", + "@io_bazel_rules_scala_scalatest_matchers_core_2_12_20", + "@io_bazel_rules_scala_scalatest_mustmatchers_2_12_20", + "@io_bazel_rules_scala_scalatest_propspec_2_12_20", + "@io_bazel_rules_scala_scalatest_refspec_2_12_20", + "@io_bazel_rules_scala_scalatest_shouldmatchers_2_12_20", + "@io_bazel_rules_scala_scalatest_wordspec_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scalatest": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scalatest", + "target": "io_bazel_rules_scala_scalatest_2_12_20" + } + }, + "io_bazel_rules_scala_scalatest_compatible_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scalatest_compatible_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-compatible/3.2.19/scalatest-compatible-3.2.19.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-compatible/3.2.19/scalatest-compatible-3.2.19.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-compatible/3.2.19/scalatest-compatible-3.2.19.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-compatible/3.2.19/scalatest-compatible-3.2.19.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-compatible/3.2.19/scalatest-compatible-3.2.19-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-compatible/3.2.19/scalatest-compatible-3.2.19-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-compatible/3.2.19/scalatest-compatible-3.2.19-sources.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-compatible/3.2.19/scalatest-compatible-3.2.19-sources.jar" + ], + "coordinates": "org.scalatest:scalatest-compatible:3.2.19", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "5dc6b8fa5396fe9e1a7c2b72df174a8eb3e92770cdc3e70636d3eba673cd0da3", + "licenses": [ + "notice" + ], + "deps": [], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scalatest_compatible": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scalatest_compatible", + "target": "io_bazel_rules_scala_scalatest_compatible_2_12_20" + } + }, + "io_bazel_rules_scala_scalatest_core_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scalatest_core_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-core_2.12/3.2.19/scalatest-core_2.12-3.2.19.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-core_2.12/3.2.19/scalatest-core_2.12-3.2.19.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-core_2.12/3.2.19/scalatest-core_2.12-3.2.19.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-core_2.12/3.2.19/scalatest-core_2.12-3.2.19.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-core_2.12/3.2.19/scalatest-core_2.12-3.2.19-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-core_2.12/3.2.19/scalatest-core_2.12-3.2.19-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-core_2.12/3.2.19/scalatest-core_2.12-3.2.19-sources.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-core_2.12/3.2.19/scalatest-core_2.12-3.2.19-sources.jar" + ], + "coordinates": "org.scalatest:scalatest-core_2.12:3.2.19", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "57b683ac16954fae147182bae9619a1d3070286bc2febc18c059600dd2885a99", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20", + "@io_bazel_rules_scala_scala_reflect_2_12_20", + "@io_bazel_rules_scala_scala_xml_2_12_20", + "@io_bazel_rules_scala_scalactic_2_12_20", + "@io_bazel_rules_scala_scalatest_compatible_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scalatest_core": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scalatest_core", + "target": "io_bazel_rules_scala_scalatest_core_2_12_20" + } + }, + "io_bazel_rules_scala_scalatest_diagrams_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scalatest_diagrams_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-diagrams_2.12/3.2.19/scalatest-diagrams_2.12-3.2.19.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-diagrams_2.12/3.2.19/scalatest-diagrams_2.12-3.2.19.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-diagrams_2.12/3.2.19/scalatest-diagrams_2.12-3.2.19.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-diagrams_2.12/3.2.19/scalatest-diagrams_2.12-3.2.19.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-diagrams_2.12/3.2.19/scalatest-diagrams_2.12-3.2.19-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-diagrams_2.12/3.2.19/scalatest-diagrams_2.12-3.2.19-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-diagrams_2.12/3.2.19/scalatest-diagrams_2.12-3.2.19-sources.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-diagrams_2.12/3.2.19/scalatest-diagrams_2.12-3.2.19-sources.jar" + ], + "coordinates": "org.scalatest:scalatest-diagrams_2.12:3.2.19", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "4644e596643982591ab335adfecd55cd3ca773a859cd9a163bb14fed032b0c9f", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20", + "@io_bazel_rules_scala_scala_reflect_2_12_20", + "@io_bazel_rules_scala_scalatest_core_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scalatest_diagrams": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scalatest_diagrams", + "target": "io_bazel_rules_scala_scalatest_diagrams_2_12_20" + } + }, + "io_bazel_rules_scala_scalatest_featurespec_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scalatest_featurespec_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-featurespec_2.12/3.2.19/scalatest-featurespec_2.12-3.2.19.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-featurespec_2.12/3.2.19/scalatest-featurespec_2.12-3.2.19.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-featurespec_2.12/3.2.19/scalatest-featurespec_2.12-3.2.19.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-featurespec_2.12/3.2.19/scalatest-featurespec_2.12-3.2.19.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-featurespec_2.12/3.2.19/scalatest-featurespec_2.12-3.2.19-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-featurespec_2.12/3.2.19/scalatest-featurespec_2.12-3.2.19-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-featurespec_2.12/3.2.19/scalatest-featurespec_2.12-3.2.19-sources.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-featurespec_2.12/3.2.19/scalatest-featurespec_2.12-3.2.19-sources.jar" + ], + "coordinates": "org.scalatest:scalatest-featurespec_2.12:3.2.19", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "a7173e04338830b03cb366839bd03deb1765e06bacd3414c306548ba03280016", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20", + "@io_bazel_rules_scala_scala_reflect_2_12_20", + "@io_bazel_rules_scala_scalatest_core_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scalatest_featurespec": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scalatest_featurespec", + "target": "io_bazel_rules_scala_scalatest_featurespec_2_12_20" + } + }, + "io_bazel_rules_scala_scalatest_flatspec_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scalatest_flatspec_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-flatspec_2.12/3.2.19/scalatest-flatspec_2.12-3.2.19.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-flatspec_2.12/3.2.19/scalatest-flatspec_2.12-3.2.19.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-flatspec_2.12/3.2.19/scalatest-flatspec_2.12-3.2.19.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-flatspec_2.12/3.2.19/scalatest-flatspec_2.12-3.2.19.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-flatspec_2.12/3.2.19/scalatest-flatspec_2.12-3.2.19-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-flatspec_2.12/3.2.19/scalatest-flatspec_2.12-3.2.19-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-flatspec_2.12/3.2.19/scalatest-flatspec_2.12-3.2.19-sources.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-flatspec_2.12/3.2.19/scalatest-flatspec_2.12-3.2.19-sources.jar" + ], + "coordinates": "org.scalatest:scalatest-flatspec_2.12:3.2.19", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "b3974fa6f1f4b97b583ac94911adbb5b78a48a5c06101860d015f0e9df0e0131", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20", + "@io_bazel_rules_scala_scala_reflect_2_12_20", + "@io_bazel_rules_scala_scalatest_core_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scalatest_flatspec": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scalatest_flatspec", + "target": "io_bazel_rules_scala_scalatest_flatspec_2_12_20" + } + }, + "io_bazel_rules_scala_scalatest_freespec_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scalatest_freespec_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-freespec_2.12/3.2.19/scalatest-freespec_2.12-3.2.19.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-freespec_2.12/3.2.19/scalatest-freespec_2.12-3.2.19.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-freespec_2.12/3.2.19/scalatest-freespec_2.12-3.2.19.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-freespec_2.12/3.2.19/scalatest-freespec_2.12-3.2.19.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-freespec_2.12/3.2.19/scalatest-freespec_2.12-3.2.19-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-freespec_2.12/3.2.19/scalatest-freespec_2.12-3.2.19-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-freespec_2.12/3.2.19/scalatest-freespec_2.12-3.2.19-sources.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-freespec_2.12/3.2.19/scalatest-freespec_2.12-3.2.19-sources.jar" + ], + "coordinates": "org.scalatest:scalatest-freespec_2.12:3.2.19", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "008cad5f68215028f3120ce24cd8f40ee435260d14455143884da8f66496c7b2", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20", + "@io_bazel_rules_scala_scala_reflect_2_12_20", + "@io_bazel_rules_scala_scalatest_core_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scalatest_freespec": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scalatest_freespec", + "target": "io_bazel_rules_scala_scalatest_freespec_2_12_20" + } + }, + "io_bazel_rules_scala_scalatest_funspec_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scalatest_funspec_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-funspec_2.12/3.2.19/scalatest-funspec_2.12-3.2.19.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-funspec_2.12/3.2.19/scalatest-funspec_2.12-3.2.19.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-funspec_2.12/3.2.19/scalatest-funspec_2.12-3.2.19.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-funspec_2.12/3.2.19/scalatest-funspec_2.12-3.2.19.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-funspec_2.12/3.2.19/scalatest-funspec_2.12-3.2.19-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-funspec_2.12/3.2.19/scalatest-funspec_2.12-3.2.19-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-funspec_2.12/3.2.19/scalatest-funspec_2.12-3.2.19-sources.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-funspec_2.12/3.2.19/scalatest-funspec_2.12-3.2.19-sources.jar" + ], + "coordinates": "org.scalatest:scalatest-funspec_2.12:3.2.19", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "24646029011aa0528cbba3d14320167f16604225eb72eaf95521134ac82944e6", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20", + "@io_bazel_rules_scala_scala_reflect_2_12_20", + "@io_bazel_rules_scala_scalatest_core_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scalatest_funspec": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scalatest_funspec", + "target": "io_bazel_rules_scala_scalatest_funspec_2_12_20" + } + }, + "io_bazel_rules_scala_scalatest_funsuite_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scalatest_funsuite_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-funsuite_2.12/3.2.19/scalatest-funsuite_2.12-3.2.19.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-funsuite_2.12/3.2.19/scalatest-funsuite_2.12-3.2.19.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-funsuite_2.12/3.2.19/scalatest-funsuite_2.12-3.2.19.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-funsuite_2.12/3.2.19/scalatest-funsuite_2.12-3.2.19.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-funsuite_2.12/3.2.19/scalatest-funsuite_2.12-3.2.19-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-funsuite_2.12/3.2.19/scalatest-funsuite_2.12-3.2.19-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-funsuite_2.12/3.2.19/scalatest-funsuite_2.12-3.2.19-sources.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-funsuite_2.12/3.2.19/scalatest-funsuite_2.12-3.2.19-sources.jar" + ], + "coordinates": "org.scalatest:scalatest-funsuite_2.12:3.2.19", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "4ccea10ecf3f1ecfd16d7cab4da2dbec965da1cebc5e956aeddc814e27845ba8", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20", + "@io_bazel_rules_scala_scala_reflect_2_12_20", + "@io_bazel_rules_scala_scalatest_core_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scalatest_funsuite": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scalatest_funsuite", + "target": "io_bazel_rules_scala_scalatest_funsuite_2_12_20" + } + }, + "io_bazel_rules_scala_scalatest_matchers_core_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scalatest_matchers_core_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-matchers-core_2.12/3.2.19/scalatest-matchers-core_2.12-3.2.19.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-matchers-core_2.12/3.2.19/scalatest-matchers-core_2.12-3.2.19.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-matchers-core_2.12/3.2.19/scalatest-matchers-core_2.12-3.2.19.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-matchers-core_2.12/3.2.19/scalatest-matchers-core_2.12-3.2.19.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-matchers-core_2.12/3.2.19/scalatest-matchers-core_2.12-3.2.19-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-matchers-core_2.12/3.2.19/scalatest-matchers-core_2.12-3.2.19-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-matchers-core_2.12/3.2.19/scalatest-matchers-core_2.12-3.2.19-sources.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-matchers-core_2.12/3.2.19/scalatest-matchers-core_2.12-3.2.19-sources.jar" + ], + "coordinates": "org.scalatest:scalatest-matchers-core_2.12:3.2.19", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "1048196692ce8ad06fed0e6fb41ce87d6b205646be3c2a78d3654ce90a9d5bc5", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20", + "@io_bazel_rules_scala_scala_reflect_2_12_20", + "@io_bazel_rules_scala_scalatest_core_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scalatest_matchers_core": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scalatest_matchers_core", + "target": "io_bazel_rules_scala_scalatest_matchers_core_2_12_20" + } + }, + "io_bazel_rules_scala_scalatest_mustmatchers_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scalatest_mustmatchers_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-mustmatchers_2.12/3.2.19/scalatest-mustmatchers_2.12-3.2.19.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-mustmatchers_2.12/3.2.19/scalatest-mustmatchers_2.12-3.2.19.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-mustmatchers_2.12/3.2.19/scalatest-mustmatchers_2.12-3.2.19.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-mustmatchers_2.12/3.2.19/scalatest-mustmatchers_2.12-3.2.19.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-mustmatchers_2.12/3.2.19/scalatest-mustmatchers_2.12-3.2.19-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-mustmatchers_2.12/3.2.19/scalatest-mustmatchers_2.12-3.2.19-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-mustmatchers_2.12/3.2.19/scalatest-mustmatchers_2.12-3.2.19-sources.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-mustmatchers_2.12/3.2.19/scalatest-mustmatchers_2.12-3.2.19-sources.jar" + ], + "coordinates": "org.scalatest:scalatest-mustmatchers_2.12:3.2.19", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "e879ad96f7c5ab558994b34d9a96cf50dc6b32f7c34e7df0586d72ba6c3cbddc", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20", + "@io_bazel_rules_scala_scala_reflect_2_12_20", + "@io_bazel_rules_scala_scalatest_matchers_core_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scalatest_mustmatchers": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scalatest_mustmatchers", + "target": "io_bazel_rules_scala_scalatest_mustmatchers_2_12_20" + } + }, + "io_bazel_rules_scala_scalatest_propspec_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scalatest_propspec_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-propspec_2.12/3.2.19/scalatest-propspec_2.12-3.2.19.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-propspec_2.12/3.2.19/scalatest-propspec_2.12-3.2.19.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-propspec_2.12/3.2.19/scalatest-propspec_2.12-3.2.19.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-propspec_2.12/3.2.19/scalatest-propspec_2.12-3.2.19.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-propspec_2.12/3.2.19/scalatest-propspec_2.12-3.2.19-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-propspec_2.12/3.2.19/scalatest-propspec_2.12-3.2.19-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-propspec_2.12/3.2.19/scalatest-propspec_2.12-3.2.19-sources.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-propspec_2.12/3.2.19/scalatest-propspec_2.12-3.2.19-sources.jar" + ], + "coordinates": "org.scalatest:scalatest-propspec_2.12:3.2.19", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "7482f4b139e870f14b8d32f4ad57a11846d7d5e7ea6448aebd34416bee7c2749", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20", + "@io_bazel_rules_scala_scala_reflect_2_12_20", + "@io_bazel_rules_scala_scalatest_core_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scalatest_propspec": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scalatest_propspec", + "target": "io_bazel_rules_scala_scalatest_propspec_2_12_20" + } + }, + "io_bazel_rules_scala_scalatest_refspec_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scalatest_refspec_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-refspec_2.12/3.2.19/scalatest-refspec_2.12-3.2.19.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-refspec_2.12/3.2.19/scalatest-refspec_2.12-3.2.19.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-refspec_2.12/3.2.19/scalatest-refspec_2.12-3.2.19.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-refspec_2.12/3.2.19/scalatest-refspec_2.12-3.2.19.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-refspec_2.12/3.2.19/scalatest-refspec_2.12-3.2.19-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-refspec_2.12/3.2.19/scalatest-refspec_2.12-3.2.19-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-refspec_2.12/3.2.19/scalatest-refspec_2.12-3.2.19-sources.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-refspec_2.12/3.2.19/scalatest-refspec_2.12-3.2.19-sources.jar" + ], + "coordinates": "org.scalatest:scalatest-refspec_2.12:3.2.19", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "3c0ae4964bd2f56fd71404480724bf2ee94d081187ddf2704b603f897f1faa16", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20", + "@io_bazel_rules_scala_scala_reflect_2_12_20", + "@io_bazel_rules_scala_scalatest_core_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scalatest_refspec": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scalatest_refspec", + "target": "io_bazel_rules_scala_scalatest_refspec_2_12_20" + } + }, + "io_bazel_rules_scala_scalatest_shouldmatchers_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scalatest_shouldmatchers_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-shouldmatchers_2.12/3.2.19/scalatest-shouldmatchers_2.12-3.2.19.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-shouldmatchers_2.12/3.2.19/scalatest-shouldmatchers_2.12-3.2.19.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-shouldmatchers_2.12/3.2.19/scalatest-shouldmatchers_2.12-3.2.19.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-shouldmatchers_2.12/3.2.19/scalatest-shouldmatchers_2.12-3.2.19.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-shouldmatchers_2.12/3.2.19/scalatest-shouldmatchers_2.12-3.2.19-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-shouldmatchers_2.12/3.2.19/scalatest-shouldmatchers_2.12-3.2.19-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-shouldmatchers_2.12/3.2.19/scalatest-shouldmatchers_2.12-3.2.19-sources.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-shouldmatchers_2.12/3.2.19/scalatest-shouldmatchers_2.12-3.2.19-sources.jar" + ], + "coordinates": "org.scalatest:scalatest-shouldmatchers_2.12:3.2.19", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "36e8fa4935945c913c6989e98050355814c2f6ee96b0b350da3cc76e471eb14f", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20", + "@io_bazel_rules_scala_scala_reflect_2_12_20", + "@io_bazel_rules_scala_scalatest_matchers_core_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scalatest_shouldmatchers": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scalatest_shouldmatchers", + "target": "io_bazel_rules_scala_scalatest_shouldmatchers_2_12_20" + } + }, + "io_bazel_rules_scala_scalatest_wordspec_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scalatest_wordspec_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-wordspec_2.12/3.2.19/scalatest-wordspec_2.12-3.2.19.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-wordspec_2.12/3.2.19/scalatest-wordspec_2.12-3.2.19.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-wordspec_2.12/3.2.19/scalatest-wordspec_2.12-3.2.19.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-wordspec_2.12/3.2.19/scalatest-wordspec_2.12-3.2.19.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalatest/scalatest-wordspec_2.12/3.2.19/scalatest-wordspec_2.12-3.2.19-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalatest/scalatest-wordspec_2.12/3.2.19/scalatest-wordspec_2.12-3.2.19-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalatest/scalatest-wordspec_2.12/3.2.19/scalatest-wordspec_2.12-3.2.19-sources.jar", + "https://jcenter.bintray.com/org/scalatest/scalatest-wordspec_2.12/3.2.19/scalatest-wordspec_2.12-3.2.19-sources.jar" + ], + "coordinates": "org.scalatest:scalatest-wordspec_2.12:3.2.19", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "ff5c1ebe03dbf728f6d2a698b8757d940cbeae0102b4ba3301c4ef7447033e18", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20", + "@io_bazel_rules_scala_scala_reflect_2_12_20", + "@io_bazel_rules_scala_scalatest_core_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scalatest_wordspec": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scalatest_wordspec", + "target": "io_bazel_rules_scala_scalatest_wordspec_2_12_20" + } + }, + "io_bazel_rules_scala_scala_compiler_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scala_compiler_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scala-lang/scala-compiler/2.12.20/scala-compiler-2.12.20.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scala-lang/scala-compiler/2.12.20/scala-compiler-2.12.20.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.12.20/scala-compiler-2.12.20.jar", + "https://jcenter.bintray.com/org/scala-lang/scala-compiler/2.12.20/scala-compiler-2.12.20.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scala-lang/scala-compiler/2.12.20/scala-compiler-2.12.20-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scala-lang/scala-compiler/2.12.20/scala-compiler-2.12.20-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.12.20/scala-compiler-2.12.20-sources.jar", + "https://jcenter.bintray.com/org/scala-lang/scala-compiler/2.12.20/scala-compiler-2.12.20-sources.jar" + ], + "coordinates": "org.scala-lang:scala-compiler:2.12.20", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "c88676d75c69721b717ea6c441ece04fff262abab9d210a2936abc2be3731fa2", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_xml_2_12_20", + "@io_bazel_rules_scala_scala_library_2_12_20", + "@io_bazel_rules_scala_scala_reflect_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scala_compiler": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scala_compiler", + "target": "io_bazel_rules_scala_scala_compiler_2_12_20" + } + }, + "io_bazel_rules_scala_scala_library_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scala_library_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scala-lang/scala-library/2.12.20/scala-library-2.12.20.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scala-lang/scala-library/2.12.20/scala-library-2.12.20.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.20/scala-library-2.12.20.jar", + "https://jcenter.bintray.com/org/scala-lang/scala-library/2.12.20/scala-library-2.12.20.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scala-lang/scala-library/2.12.20/scala-library-2.12.20-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scala-lang/scala-library/2.12.20/scala-library-2.12.20-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.20/scala-library-2.12.20-sources.jar", + "https://jcenter.bintray.com/org/scala-lang/scala-library/2.12.20/scala-library-2.12.20-sources.jar" + ], + "coordinates": "org.scala-lang:scala-library:2.12.20", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "4d8a8f984cce31a329a24f10b0bf336f042cb62aeb435290a1b20243154cfccb", + "licenses": [ + "notice" + ], + "deps": [], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scala_library": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scala_library", + "target": "io_bazel_rules_scala_scala_library_2_12_20" + } + }, + "io_bazel_rules_scala_scala_parser_combinators_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scala_parser_combinators_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scala-lang/modules/scala-parser-combinators_2.12/1.1.2/scala-parser-combinators_2.12-1.1.2.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scala-lang/modules/scala-parser-combinators_2.12/1.1.2/scala-parser-combinators_2.12-1.1.2.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scala-lang/modules/scala-parser-combinators_2.12/1.1.2/scala-parser-combinators_2.12-1.1.2.jar", + "https://jcenter.bintray.com/org/scala-lang/modules/scala-parser-combinators_2.12/1.1.2/scala-parser-combinators_2.12-1.1.2.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scala-lang/modules/scala-parser-combinators_2.12/1.1.2/scala-parser-combinators_2.12-1.1.2-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scala-lang/modules/scala-parser-combinators_2.12/1.1.2/scala-parser-combinators_2.12-1.1.2-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scala-lang/modules/scala-parser-combinators_2.12/1.1.2/scala-parser-combinators_2.12-1.1.2-sources.jar", + "https://jcenter.bintray.com/org/scala-lang/modules/scala-parser-combinators_2.12/1.1.2/scala-parser-combinators_2.12-1.1.2-sources.jar" + ], + "coordinates": "org.scala-lang.modules:scala-parser-combinators_2.12:1.1.2", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "24985eb43e295a9dd77905ada307a850ca25acf819cdb579c093fc6987b0dbc2", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scala_parser_combinators": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scala_parser_combinators", + "target": "io_bazel_rules_scala_scala_parser_combinators_2_12_20" + } + }, + "io_bazel_rules_scala_scala_xml_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scala_xml_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scala-lang/modules/scala-xml_2.12/2.3.0/scala-xml_2.12-2.3.0.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scala-lang/modules/scala-xml_2.12/2.3.0/scala-xml_2.12-2.3.0.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scala-lang/modules/scala-xml_2.12/2.3.0/scala-xml_2.12-2.3.0.jar", + "https://jcenter.bintray.com/org/scala-lang/modules/scala-xml_2.12/2.3.0/scala-xml_2.12-2.3.0.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scala-lang/modules/scala-xml_2.12/2.3.0/scala-xml_2.12-2.3.0-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scala-lang/modules/scala-xml_2.12/2.3.0/scala-xml_2.12-2.3.0-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scala-lang/modules/scala-xml_2.12/2.3.0/scala-xml_2.12-2.3.0-sources.jar", + "https://jcenter.bintray.com/org/scala-lang/modules/scala-xml_2.12/2.3.0/scala-xml_2.12-2.3.0-sources.jar" + ], + "coordinates": "org.scala-lang.modules:scala-xml_2.12:2.3.0", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "4932c56a2d5aae77ae8d7ac6bed1f21d48268fdbac8b4e5f3ca5196ad10fd93e", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scala_xml": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scala_xml", + "target": "io_bazel_rules_scala_scala_xml_2_12_20" + } + }, + "org_scala_lang_modules_scala_collection_compat_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "org_scala_lang_modules_scala_collection_compat_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scala-lang/modules/scala-collection-compat_2.12/2.13.0/scala-collection-compat_2.12-2.13.0.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scala-lang/modules/scala-collection-compat_2.12/2.13.0/scala-collection-compat_2.12-2.13.0.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scala-lang/modules/scala-collection-compat_2.12/2.13.0/scala-collection-compat_2.12-2.13.0.jar", + "https://jcenter.bintray.com/org/scala-lang/modules/scala-collection-compat_2.12/2.13.0/scala-collection-compat_2.12-2.13.0.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scala-lang/modules/scala-collection-compat_2.12/2.13.0/scala-collection-compat_2.12-2.13.0-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scala-lang/modules/scala-collection-compat_2.12/2.13.0/scala-collection-compat_2.12-2.13.0-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scala-lang/modules/scala-collection-compat_2.12/2.13.0/scala-collection-compat_2.12-2.13.0-sources.jar", + "https://jcenter.bintray.com/org/scala-lang/modules/scala-collection-compat_2.12/2.13.0/scala-collection-compat_2.12-2.13.0-sources.jar" + ], + "coordinates": "org.scala-lang.modules:scala-collection-compat_2.12:2.13.0", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "a0eb3523bf46797afd3ede3e402122fcaf56f661f4721f9058360f4036f17610", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "org_scala_lang_modules_scala_collection_compat": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "org_scala_lang_modules_scala_collection_compat", + "target": "org_scala_lang_modules_scala_collection_compat_2_12_20" + } + }, + "io_bazel_rules_scala_scala_reflect_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "io_bazel_rules_scala_scala_reflect_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scala-lang/scala-reflect/2.12.20/scala-reflect-2.12.20.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scala-lang/scala-reflect/2.12.20/scala-reflect-2.12.20.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.12.20/scala-reflect-2.12.20.jar", + "https://jcenter.bintray.com/org/scala-lang/scala-reflect/2.12.20/scala-reflect-2.12.20.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scala-lang/scala-reflect/2.12.20/scala-reflect-2.12.20-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scala-lang/scala-reflect/2.12.20/scala-reflect-2.12.20-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.12.20/scala-reflect-2.12.20-sources.jar", + "https://jcenter.bintray.com/org/scala-lang/scala-reflect/2.12.20/scala-reflect-2.12.20-sources.jar" + ], + "coordinates": "org.scala-lang:scala-reflect:2.12.20", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "5f1914cdc7a70580ea6038d929ebb25736ecf2234f677e2d47f8a4b2bc81e1fb", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "io_bazel_rules_scala_scala_reflect": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "io_bazel_rules_scala_scala_reflect", + "target": "io_bazel_rules_scala_scala_reflect_2_12_20" + } + }, + "org_scalameta_semanticdb_scalac_2_12_20": { + "repoRuleId": "@@rules_scala+//scala:scala_maven_import_external.bzl%_jvm_import_external", + "attributes": { + "generated_rule_name": "org_scalameta_semanticdb_scalac_2_12_20", + "jar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalameta/semanticdb-scalac_2.12.20/4.9.9/semanticdb-scalac_2.12.20-4.9.9.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalameta/semanticdb-scalac_2.12.20/4.9.9/semanticdb-scalac_2.12.20-4.9.9.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalameta/semanticdb-scalac_2.12.20/4.9.9/semanticdb-scalac_2.12.20-4.9.9.jar", + "https://jcenter.bintray.com/org/scalameta/semanticdb-scalac_2.12.20/4.9.9/semanticdb-scalac_2.12.20-4.9.9.jar" + ], + "srcjar_urls": [ + "https://repo.maven.apache.org/maven2/org/scalameta/semanticdb-scalac_2.12.20/4.9.9/semanticdb-scalac_2.12.20-4.9.9-sources.jar", + "https://maven-central.storage-download.googleapis.com/maven2/org/scalameta/semanticdb-scalac_2.12.20/4.9.9/semanticdb-scalac_2.12.20-4.9.9-sources.jar", + "https://mirror.bazel.build/repo1.maven.org/maven2/org/scalameta/semanticdb-scalac_2.12.20/4.9.9/semanticdb-scalac_2.12.20-4.9.9-sources.jar", + "https://jcenter.bintray.com/org/scalameta/semanticdb-scalac_2.12.20/4.9.9/semanticdb-scalac_2.12.20-4.9.9-sources.jar" + ], + "coordinates": "org.scalameta:semanticdb-scalac_2.12.20:4.9.9", + "rule_name": "scala_import", + "rule_load": "load(\"@@rules_scala+//scala:scala_import.bzl\", \"scala_import\")", + "artifact_sha256": "7f0e44262b2b1003668f2f51eb0f978ed5a4b94f734e3a6138ce9d7d1a40fc83", + "licenses": [ + "notice" + ], + "deps": [ + "@io_bazel_rules_scala_scala_library_2_12_20" + ], + "runtime_deps": [], + "testonly_": false + } + }, + "org_scalameta_semanticdb_scalac": { + "repoRuleId": "@@rules_scala+//third_party/repositories:repositories.bzl%_alias_repository", + "attributes": { + "default_target_name": "org_scalameta_semanticdb_scalac", + "target": "org_scalameta_semanticdb_scalac_2_12_20" + } + }, + "rules_scala_toolchains": { + "repoRuleId": "@@rules_scala+//scala:toolchains_repo.bzl%scala_toolchains_repo", + "attributes": { + "scalatest": true, + "junit": false, + "specs2": false, + "scalafmt": false, + "scalafmt_default_config": "@@rules_scala+//:.scalafmt.conf", + "scala_proto": false, + "scala_proto_options": [ + "grpc" + ], + "jmh": false, + "twitter_scrooge": false, + "twitter_scrooge_deps": {} + } + } + }, + "recordedRepoMappingEntries": [ + [ + "bazel_features+", + "bazel_features_globals", + "bazel_features++version_extension+bazel_features_globals" + ], + [ + "bazel_features+", + "bazel_features_version", + "bazel_features++version_extension+bazel_features_version" + ], + [ + "protobuf+", + "proto_bazel_features", + "bazel_features+" + ], + [ + "rules_cc+", + "bazel_tools", + "bazel_tools" + ], + [ + "rules_cc+", + "rules_cc", + "rules_cc+" + ], + [ + "rules_java+", + "bazel_features", + "bazel_features+" + ], + [ + "rules_java+", + "bazel_skylib", + "bazel_skylib+" + ], + [ + "rules_java+", + "bazel_tools", + "bazel_tools" + ], + [ + "rules_java+", + "com_google_protobuf", + "protobuf+" + ], + [ + "rules_java+", + "compatibility_proxy", + "rules_java++compatibility_proxy+compatibility_proxy" + ], + [ + "rules_java+", + "rules_cc", + "rules_cc+" + ], + [ + "rules_java++compatibility_proxy+compatibility_proxy", + "rules_java", + "rules_java+" + ], + [ + "rules_proto+", + "com_google_protobuf", + "protobuf+" + ], + [ + "rules_scala+", + "bazel_tools", + "bazel_tools" + ], + [ + "rules_scala+", + "com_google_protobuf", + "protobuf+" + ], + [ + "rules_scala+", + "rules_java", + "rules_java+" + ], + [ + "rules_scala+", + "rules_proto", + "rules_proto+" + ], + [ + "rules_scala+", + "rules_scala_config", + "rules_scala++scala_config+rules_scala_config" + ] + ] + } + } + } +} diff --git a/README.md b/README.md index abe2e3c6..857fd922 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,9 @@ Djinni generator parses an interface definition file and generates: - C++ implementations of types (enums, records) - Java implementations of types - Objective-C implementations of types -- Python implementation of types -- C++/CLI implementation of types - C++ code to convert between C++ and Java over JNI - C++ code to serialize/deserialize types to/from JSON - Objective-C++ code to convert between C++ and Objective-C -- Python and C code to convert between C++ and Python over CFFI -- C++/CLI code to convert between C++ and C# ## Installation diff --git a/REPO.bazel b/REPO.bazel new file mode 100644 index 00000000..c30e9183 --- /dev/null +++ b/REPO.bazel @@ -0,0 +1,15 @@ +"""Repository configuration for djinni-generator""" + +# Repository boundary - mark directories to ignore +ignored_directories = [ + "target", + "project/target", + "project/project/target", + ".bloop", + ".bsp", + ".metals", + ".vscode", + ".idea", + ".cache", + "test/result", +] diff --git a/build.sbt b/build.sbt index ed204fe6..37c01474 100644 --- a/build.sbt +++ b/build.sbt @@ -1,10 +1,10 @@ import sbtassembly.AssemblyPlugin.defaultUniversalScript -ThisBuild / scalaVersion := "2.12.18" +ThisBuild / scalaVersion := "2.12.20" ThisBuild / organization := "com.github.cross-language-cpp" ThisBuild / semanticdbEnabled := true // enable SemanticDB -ThisBuild / semanticdbVersion := scalafixSemanticdb.revision // use Scalafix compatible version +ThisBuild / semanticdbVersion := "4.13.10" // latest available version // Keep this as a reminder, we will use that later // ThisBuild / scalacOptions += "-Ywarn-unused" diff --git a/docs/cli-usage.md b/docs/cli-usage.md index b05d5bbf..808782f4 100644 --- a/docs/cli-usage.md +++ b/docs/cli-usage.md @@ -20,12 +20,6 @@ djinni \ \ --objcpp-out OBJC_OUTPUT_FOLDER \ \ - --py-out PYTHON_OUTPUT_FOLDER \ - --pycffi-out CFFI_OUTPUT_FOLDER \ # Required for Python support - --pycffi-package-name PyCFFIlib \ - --pycffi-dynamic-lib-list mylib \ - --c-wrapper-out C_WRAPPER_OUTPUT_FOLDER \ # Required for Python support - \ --idl MY_PROJECT.djinni ``` @@ -118,32 +112,10 @@ djinni \ | `--objc-extended-record-include-prefix ` | The prefix path for `#import` of the extended record Objective-C header (`.h`) files | | `--objcpp-namespace ` | The namespace name to use for generated Objective-C++ classes. | -### Python - -| Argument | Description | -|--------------------------------------|-------------------------------------------------------------------------| -| `--py-out ` | The output folder for Python files (Generator disabled if unspecified). | -| `--pycffi-out ` | The output folder for PyCFFI files (Generator disabled if unspecified). | -| `--pycffi-package-name ...` | The package name to use for the generated PyCFFI classes. | -| `--pycffi-dynamic-lib-list ...` | The names of the dynamic libraries to be linked with PyCFFI. | -| `--py-import-prefix ` | The import prefix used within python generated files (default: "") | -### C wrapper -| Argument | Description | -|-------------------------------------------|----------------------------------------------------------------------------------------| -| `--c-wrapper-out ` | The output folder for C wrapper files (Generator disabled if unspecified). | -| `--c-wrapper-header-out ` | The output folder for C wrapper header files (default: the same as `--c-wrapper-out`). | -| `--c-wrapper-include-prefix ` | The prefix for #includes of C wrapper header files from C wrapper C++ files. | -| `--c-wrapper-include-cpp-prefix ` | The prefix for #includes of C++ header files from C wrapper C++ files. | -### C++/CLI -| Argument | Description | -|----------------------------------------|----------------------------------------------------------------------------| -| `--cppcli-out ` | The output folder for C++/CLI files (Generator disabled if unspecified). | -| `--cppcli-namespace ...` | The namespace name to use for generated C++/CLI classes. | -| `--cppcli-include-cpp-prefix ` | The prefix for `#include` of the main C++ header files from C++/CLI files. | ### Yaml Generation @@ -204,31 +176,9 @@ Possible values: `FooBar`, `fooBar`, `foo_bar`, `FOO_BAR`, `m_fooBar`. | `--ident-objc-local` | `fooBar` | | `--ident-objc-file` | `FooBar` | -#### Python - -| Argument | Default | -|-------------------------|-----------| -| `--ident-py-type` | `foo_bar` | -| `--ident-py-class-name` | `FooBar` | -| `--ident-py-type-param` | `foo_bar` | -| `--ident-py-method` | `foo_bar` | -| `--ident-py-field` | `foo_bar` | -| `--ident-py-local` | `foo_bar` | -| `--ident-py-enum` | `Foo_Bar` | -| `--ident-py-const` | `FOO_BAR` | - -#### C++/CLI - -| Argument | Default | -|-----------------------------|----------| -| `--ident-cppcli-type` | `FooBar` | -| `--ident-cppcli-type-param` | `FooBar` | -| `--ident-cppcli-property` | `FooBar` | -| `--ident-cppcli-method` | `FooBar` | -| `--ident-cppcli-local` | `fooBar` | -| `--ident-cppcli-enum` | `FooBar` | -| `--ident-cppcli-const` | `FooBar` | -| `--ident-cppcli-file` | `FooBar` | + + + Example: diff --git a/docs/developer-guide.md b/docs/developer-guide.md index d0cdd11e..7648da95 100644 --- a/docs/developer-guide.md +++ b/docs/developer-guide.md @@ -35,11 +35,7 @@ sbt "run --cpp-out out/cpp --java-out out/java/src --jni-out out/java/jni - --objc-out out/objc - --py-out out/python - --pycffi-out out/cffi - --c-wrapper-out out/cwrapper - --cppcli-out out/cppcli" + --objc-out out/objc" ``` ```bash diff --git a/docs/generated-code-usage.md b/docs/generated-code-usage.md index c2f88304..2e2a601a 100644 --- a/docs/generated-code-usage.md +++ b/docs/generated-code-usage.md @@ -78,93 +78,9 @@ Add all generated files to your build target, and link against the [djinni-suppo Note that `+Private` files can only be used with ObjC++ source (other headers are pure ObjC) and are not required by Objective-C users of your interface. -## Python / C++ Project (Experimental) -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 available online. -### Includes & Build Target - -When bridging to Python, Djinni generates 4 types of output: - -* `python` Generated Python classes and proxies for interacting with C++ via [CFFI](https://cffi.readthedocs.org/). -* `cffi` Python code run at build time to create a Python extension out of the C++ code. -* `cwrapper` A C interface implemented in C++ to allowing Python to interact with C++ classes. -* `cpp` The same C++ classes generated for all other Djinni languages. - -Generated files for Python / C++ are as follows: - -| Type | C++ header | C++ source | Python files | CFFI | C Wrapper | -|------------|----------------------------|------------------------------|---------------------|---------------------|----------------------| -| Enum/Flags | my\_enum.hpp | | my_enum.py | | dh__my_enum.cpp | -| | my\_enum+json.hpp :two: | | | | dh__my_enum.h | -| | | | | | dh__my_enum.hpp | -| Record | my\_record[\_base].hpp | my\_record[\_base].cpp :one: | my_record[_base].py | | dh__my_record.cpp | -| | my\_record[\_base]+json.hpp| | | | dh__my_record.h | -| | :two:| | | | dh__my_record.hpp | -| Interface | my\_interface.hpp | my\_interface.cpp :one: | my_interface.py | pycffi_lib_build.py | cw__my_interface.cpp | -| | | | | | cw__my_interface.h | -| | | | | | cw__my_interface.hpp | - -- :one: Generated only for types that contain constants. -- :two: Generated only if cpp json serialization is enabled. - -Additional C Wrapper files are generated for data structures; their names are encoded as: - - dh__{list,set,map}_{encoded_type(s)}.cpp - dh__{list,set,map}_{encoded_type(s)}.h - dh__{list,set,map}_{encoded_type(s)}.hpp - -See the in the table below a few examples: - -| Type | C Wrapper | -|-------------------------|----------------------------------------| -| `list` | dh__list_int32_t.{cpp,h,hpp} | -| `set` | dh__set_string.{cpp,h,hpp} | -| `map>` | dh__map_int32_t_set_string.{cpp,h,hpp} | - -Add all generated C and C++ source files to your build target, and link it against the -[djinni-support-lib](https://github.com/cross-language-cpp/djinni-support-lib). - -Compile the Python extension module (CFFI) by executing `pycffi_lib_build.py` while providing all C -Wrapper header files (`.h`) as arguments. The resulting shared library will enable Python to access -your C++ library through the CFFI bridge. - -### Known limitations of the generator - -* External types defined in YAML are not yet supported. -* Use of non-nullable pointers is not yet supported. - - -## C++/CLI / C++ Project - -C++/CLI is a technology by Microsoft that provides interoperability of C++ with Microsoft .NET languages such as C#. -It is only supported on Windows. - -Djinni generates a shallow C++/CLI wrapper around the C++ interfaces. Once compiled to a shared library, the resulting `dll` -just needs to be added to your C# project as reference, and you can call your Djinni interfaces from C# like any other .NET library. - -### Includes & Build target - -The following code will be generated for each defined type: - -| Type | C++ header | C++ source | C++/CLI header/sources | -|------------|--------------------------|----------------------------|-------------------------------------| -| Enum/Flags | my\_enum.hpp | | MyEnum.hpp, MyEnum.cpp | -| | my\_enum+json.hpp :two: | | | -| Record | my\_record.hpp | my\_record.cpp | MyRecord.hpp, MyRecord.cpp | -| | my\_record+json.hpp :two:| | | -| Interface | my\_interface.hpp | my\_interface.cpp :one: | MyInterface.hpp, MyInterface.cpp | - -- :one: Generated only for types that contain constants. -- :two: Generated only if cpp json serialization is enabled. - -Add all generated files to your build target, and link against the [djinni-support-lib](https://github.com/cross-language-cpp/djinni-support-lib). - -C++/CLI sources have to be compiled with MSVC and the [`/clr` (Common Language Runtime Compilation)](https://docs.microsoft.com/en-us/cpp/build/reference/clr-common-language-runtime-compilation?view=msvc-160) option. ## C++ JSON Serialization support diff --git a/docs/idl.md b/docs/idl.md index 3fb4fa35..3752b6fe 100644 --- a/docs/idl.md +++ b/docs/idl.md @@ -52,8 +52,8 @@ my_cpp_interface = interface +c { const version: i32 = 1; } -# This interface will be implemented in Java, ObjC, Python and C# and can be called from C++. -my_client_interface = interface +j +o +p +s { +# This interface will be implemented in Java and Objective-C and can be called from C++. +my_client_interface = interface +j +o { log_string(str: string): bool; } ``` @@ -135,20 +135,6 @@ The available data types for a record, argument, or return value, and their equi | `map` | `System.Collections.Generic.Dictionary` | | `optional` | `System.Nullable` | -=== "Python" - - | Djinni | Python | - |---------------------------|-------------------------------------------| - | `bool` | | - | `i8`, `i16`, `i32`, `i64` | | - | `f32`, `f64` | | - | `string` | | - | `binary` | object supporting the `buffer` interface | - | `date` | `datetime.datetime` | - | `list` | `List` | - | `set` | `Set` | - | `map` | `Dictionary` | - | `optional` | | ✱ *Primitives will be boxed in Java and Objective-C.* @@ -163,13 +149,13 @@ Additional possible data types are: An IDL file can contain 4 kinds of declarations: enums, flags, records, and interfaces. -* [**Enums**](#enums) become C++ enum classes, Java enums, ObjC `NS_ENUM`s, Python `IntEnum`s, or C# `System.Enum`s. +* [**Enums**](#enums) become C++ enum classes, Java enums, or ObjC `NS_ENUM`s. * [**Flags**](#flags) become C++ enum classes with convenient bit-oriented operators, Java enums with `EnumSet`, - ObjC `NS_OPTIONS`, Python `IntFlag`s, or C# `System.Enum`s with the [`[Flags]` Attribute](https://docs.microsoft.com/en-us/dotnet/api/system.flagsattribute?view=net-5.0). + or ObjC `NS_OPTIONS`. * [**Records**](#records) are pure-data value objects. * [**Interfaces**](#interfaces) are objects with defined methods to call (in C++, passed by `shared_ptr`). Djinni - produces code allowing an interface implemented in C++ to be transparently used from ObjC, - Java, Python or C#, and vice versa. + produces code allowing an interface implemented in C++ to be transparently used from ObjC + and Java, and vice versa. ### Enums @@ -182,7 +168,7 @@ my_enum = enum { ``` Enums are translated to C++ `enum class`es with underlying type `int`, ObjC `NS_ENUM`s with -underlying type `NSInteger`, Java enums, Python `IntEnum`s, and C# `System.Enum`s. +underlying type `NSInteger`, and Java enums. ### Flags @@ -198,11 +184,11 @@ my_flags = flags { Flags are translated to C++ `enum class`es with underlying type `unsigned` and a generated set of overloaded bitwise operators for convenience, ObjC `NS_OPTIONS` with underlying type `NSUInteger`, -Java `EnumSet<>`, Python `IntFlag`, and C# `System.Enum`s with the [`[Flags]` Attribute](https://docs.microsoft.com/en-us/dotnet/api/system.flagsattribute?view=net-5.0). +and Java `EnumSet<>`. Contrary to the above enums, the enumerants of flags represent single bits instead of integral values. -In the above example the elements marked with `none` and `all` are given special meaning. In C++, -ObjC, and Python the `no_flags` option is generated with a value that has no bits set (i.e. `0`), +In the above example the elements marked with `none` and `all` are given special meaning. In C++ +and ObjC the `no_flags` option is generated with a value that has no bits set (i.e. `0`), and `all_flags` is generated as a bitwise-or combination of all other values. In Java these special options are not generated as one can just use `EnumSet.noneOf()` and `EnumSet.allOf()`. @@ -234,7 +220,7 @@ records (so a record cannot contain itself). #### Extensions To support extra fields and/or methods, a record can be "extended" in any language. To extend a -record in a language, you can add a `+c` (C++), `+j` (Java), `+o` (ObjC), `+p` (Python), or `+s` (C#) flag +record in a language, you can add a `+c` (C++), `+j` (Java), or `+o` (ObjC) flag after the record tag. The generated type will have a `Base` suffix, and you should create a derived type without the suffix that extends the record type. @@ -252,7 +238,7 @@ another_record = record { For record types, Haskell-style "deriving" declarations are supported to generate some common methods. Djinni is capable of generating equality and order comparators, implemented as operator -overloading in C++ and standard comparison functions in Java, Objective-C, Python and C#. +overloading in C++ and standard comparison functions in Java and Objective-C. !!! note @@ -275,15 +261,15 @@ my_cpp_interface = interface +c { const version: i32 = 1; } -# This interface will be implemented in Java, ObjC, Python and C# and can be called from C++. -my_client_interface = interface +j +o +p +s { +# This interface will be implemented in Java and Objective-C and can be called from C++. +my_client_interface = interface +j +o { log_string(str: string): bool; } ``` Interfaces are objects with defined methods to call (in C++, passed by `shared_ptr`). Djinni -produces code allowing an interface implemented in C++ to be transparently used from ObjC, -Java Python or C# and vice versa. +produces code allowing an interface implemented in C++ to be transparently used from ObjC +and Java, and vice versa. #### Special Methods for C++ Only `+c` interfaces (implementable only in C++) can have methods flagged with the special keywords const and static which @@ -339,23 +325,22 @@ public: #### Exception Handling When an interface implemented in C++ throws a `std::exception`, it will be translated to a -`java.lang.RuntimeException` in Java, an `NSException` in Objective-C, a `RuntimeError` in Python, -or a `System.Exception` in C#. +`java.lang.RuntimeException` in Java or an `NSException` in Objective-C. The `what()` message will be translated as well. #### Constants -Constants can be defined within interfaces and records. In Java, Python, C# and C++ they are part of the +Constants can be defined within interfaces and records. In Java and C++ they are part of the generated class; and in Objective-C, constant names are globals with the name of the interface/record prefixed. Example: ``` -record_with_const = record +c +j +o +p +s { +record_with_const = record +c +j +o { const const_value: i32 = 8; } ``` will be `RecordWithConst::CONST_VALUE` in C++, `RecordWithConst.CONST_VALUE` in Java, -`RecordWithConst.CONST_VALUE` in Python, `RecordWithConst.ConstValue` in C#, and `RecordWithConstConstValue` in Objective-C. +and `RecordWithConstConstValue` in Objective-C. ## Comments @@ -364,8 +349,7 @@ will be `RecordWithConst::CONST_VALUE` in C++, `RecordWithConst.CONST_VALUE` in ``` If comments are placed on top or inside a type definition, they will be converted to -Javadoc / Doxygen compatible comments in the generated Java, C++, Objective-C and C++/CLI interfaces, or a -Python docstring. +Javadoc / Doxygen compatible comments in the generated Java, C++, and Objective-C interfaces. ## Deprecation Comments diff --git a/docs/modularization.md b/docs/modularization.md index 4f6d5c7e..b474fee6 100644 --- a/docs/modularization.md +++ b/docs/modularization.md @@ -5,9 +5,7 @@ C++/Objective-C/Java/C# you can tell Djinni to generate a special YAML file as p This file then contains all the information Djinni requires to include your types in a different project. Instructing Djinni to create these YAML files is controlled by the [YAML generation parameters](cli-usage.md#yaml-generation). -!!! caution - External types defined in YAML are not yet supported for Python. ## YAML file structure @@ -127,20 +125,7 @@ struct Record1 }; ``` -```cpp -// For C++ <-> C++/CLI -public ref class Record1 { -public: - // Record1 public properties -internal: - using CppType = ::mylib::Record1; - using CsType = Record1^; - static CppType ToCpp(CsType cs) { return /* your magic here */; } - static CsType FromCpp(const CppType& cs) { return /* your magic here */; } -private: - // Record1 properties' backing fields -} -``` + For `interface` classes the `CppType` alias is expected to be a `std::shared_ptr`. diff --git a/src/it/resources/cppcli_circular_dependent_interface.djinni b/src/it/resources/cppcli_circular_dependent_interface.djinni deleted file mode 100644 index 75bc92b0..00000000 --- a/src/it/resources/cppcli_circular_dependent_interface.djinni +++ /dev/null @@ -1,13 +0,0 @@ -one_interface = interface +c { - method_taking_another_interface(dep: another_interface); - method_taking_optional_another_interface(dep: optional); - method_returning_another_interface(): another_interface; - method_returning_optional_another_interface(): optional; -} - -another_interface = interface +c { - method_taking_one_interface(dep: one_interface); - method_taking_optional_one_interface(dep: optional); - method_returning_one_interface(): one_interface; - method_returning_optional_one_interface(): optional; -} diff --git a/src/it/resources/cppcli_extern_dependent_interface.djinni b/src/it/resources/cppcli_extern_dependent_interface.djinni deleted file mode 100644 index 06ac267f..00000000 --- a/src/it/resources/cppcli_extern_dependent_interface.djinni +++ /dev/null @@ -1,8 +0,0 @@ -@extern "cpp_interface_dependency.yml" - -dependent_interface = interface +c { - method_taking_interface_dependency(dep: interface_dependency); - method_taking_optional_interface_dependency(dep: optional); - method_returning_interface_dependency(): interface_dependency; - method_returning_optional_interface_dependency(): optional; -} diff --git a/src/it/resources/cppcli_interface_nonnull.djinni b/src/it/resources/cppcli_interface_nonnull.djinni deleted file mode 100644 index 6b1d31fa..00000000 --- a/src/it/resources/cppcli_interface_nonnull.djinni +++ /dev/null @@ -1,11 +0,0 @@ -# interface comment -my_cpp_interface = interface +c { - # method comment - method_returning_nothing(value: i32); - method_returning_some_type(key: string): i32; - const method_changing_nothing(): i32; - static get_version(): i32; - - # Interfaces can also have constants - const version: i32 = 1; -} diff --git a/src/it/resources/expected/all_datatypes/cppcli/AllDatatypes.cpp b/src/it/resources/expected/all_datatypes/cppcli/AllDatatypes.cpp deleted file mode 100644 index f52f2807..00000000 --- a/src/it/resources/expected/all_datatypes/cppcli/AllDatatypes.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#include "AllDatatypes.hpp" // my header -#include "djinni/cppcli/Marshal.hpp" -#include - -AllDatatypes::AllDatatypes(bool booleanData, - char integer8Data, - short integer16Data, - int integer32Data, - __int64 integer64Data, - float float32Data, - double float64Data, - System::String^ stringData, - array^ binaryData, - System::DateTime dateData, - System::Collections::Generic::List^ listData, - System::Collections::Generic::HashSet^ setData, - System::Collections::Generic::Dictionary^ mapData, - System::Nullable optionalData, - ::EnumData enumData) -: _booleanData(booleanData) -, _integer8Data(integer8Data) -, _integer16Data(integer16Data) -, _integer32Data(integer32Data) -, _integer64Data(integer64Data) -, _float32Data(float32Data) -, _float64Data(float64Data) -, _stringData(stringData) -, _binaryData(binaryData) -, _dateData(dateData) -, _listData(listData) -, _setData(setData) -, _mapData(mapData) -, _optionalData(optionalData) -, _enumData(enumData) -{} - -bool AllDatatypes::BooleanData::get() -{ - return _booleanData; -} - -char AllDatatypes::Integer8Data::get() -{ - return _integer8Data; -} - -short AllDatatypes::Integer16Data::get() -{ - return _integer16Data; -} - -int AllDatatypes::Integer32Data::get() -{ - return _integer32Data; -} - -__int64 AllDatatypes::Integer64Data::get() -{ - return _integer64Data; -} - -float AllDatatypes::Float32Data::get() -{ - return _float32Data; -} - -double AllDatatypes::Float64Data::get() -{ - return _float64Data; -} - -System::String^ AllDatatypes::StringData::get() -{ - return _stringData; -} - -array^ AllDatatypes::BinaryData::get() -{ - return _binaryData; -} - -System::DateTime AllDatatypes::DateData::get() -{ - return _dateData; -} - -System::Collections::Generic::List^ AllDatatypes::ListData::get() -{ - return _listData; -} - -System::Collections::Generic::HashSet^ AllDatatypes::SetData::get() -{ - return _setData; -} - -System::Collections::Generic::Dictionary^ AllDatatypes::MapData::get() -{ - return _mapData; -} - -System::Nullable AllDatatypes::OptionalData::get() -{ - return _optionalData; -} - -EnumData AllDatatypes::EnumData::get() -{ - return _enumData; -} - -System::String^ AllDatatypes::ToString() -{ - return System::String::Format("AllDatatypes {{BooleanData{0}, Integer8Data{1}, Integer16Data{2}, Integer32Data{3}, Integer64Data{4}, Float32Data{5}, Float64Data{6}, StringData{7}, BinaryData{8}, DateData{9}, ListData{10}, SetData{11}, MapData{12}, OptionalData{13}, EnumData{14}}}", - BooleanData, - Integer8Data, - Integer16Data, - Integer32Data, - Integer64Data, - Float32Data, - Float64Data, - StringData, - BinaryData, - DateData, - ListData, - SetData, - MapData, - OptionalData, - EnumData); -} - -AllDatatypes::CppType AllDatatypes::ToCpp(AllDatatypes::CsType cs) -{ - ASSERT(cs != nullptr); - return {::djinni::Bool::ToCpp(cs->BooleanData), - ::djinni::I8::ToCpp(cs->Integer8Data), - ::djinni::I16::ToCpp(cs->Integer16Data), - ::djinni::I32::ToCpp(cs->Integer32Data), - ::djinni::I64::ToCpp(cs->Integer64Data), - ::djinni::F32::ToCpp(cs->Float32Data), - ::djinni::F64::ToCpp(cs->Float64Data), - ::djinni::String::ToCpp(cs->StringData), - ::djinni::Binary::ToCpp(cs->BinaryData), - ::djinni::Date::ToCpp(cs->DateData), - ::djinni::List<::djinni::Bool>::ToCpp(cs->ListData), - ::djinni::Set<::djinni::Bool>::ToCpp(cs->SetData), - ::djinni::Map<::djinni::I8, ::djinni::Bool>::ToCpp(cs->MapData), - ::djinni::Optional::ToCpp(cs->OptionalData), - ::djinni::Enum<::EnumData, ::EnumData>::ToCpp(cs->EnumData)}; -} - -AllDatatypes::CsType AllDatatypes::FromCpp(const AllDatatypes::CppType& cpp) -{ - return gcnew AllDatatypes(::djinni::Bool::FromCpp(cpp.booleanData), - ::djinni::I8::FromCpp(cpp.integer8Data), - ::djinni::I16::FromCpp(cpp.integer16Data), - ::djinni::I32::FromCpp(cpp.integer32Data), - ::djinni::I64::FromCpp(cpp.integer64Data), - ::djinni::F32::FromCpp(cpp.float32Data), - ::djinni::F64::FromCpp(cpp.float64Data), - ::djinni::String::FromCpp(cpp.stringData), - ::djinni::Binary::FromCpp(cpp.binaryData), - ::djinni::Date::FromCpp(cpp.dateData), - ::djinni::List<::djinni::Bool>::FromCpp(cpp.listData), - ::djinni::Set<::djinni::Bool>::FromCpp(cpp.setData), - ::djinni::Map<::djinni::I8, ::djinni::Bool>::FromCpp(cpp.mapData), - ::djinni::Optional::FromCpp(cpp.optionalData), - ::djinni::Enum<::EnumData, ::EnumData>::FromCpp(cpp.enum_data)); -} diff --git a/src/it/resources/expected/all_datatypes/cppcli/AllDatatypes.hpp b/src/it/resources/expected/all_datatypes/cppcli/AllDatatypes.hpp deleted file mode 100644 index a44612b4..00000000 --- a/src/it/resources/expected/all_datatypes/cppcli/AllDatatypes.hpp +++ /dev/null @@ -1,129 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#pragma once - -#include "../cpp-headers/all_datatypes.hpp" -#include "EnumData.hpp" - -[System::Serializable] -public ref class AllDatatypes { -public: - - property bool BooleanData - { - bool get(); - } - - property char Integer8Data - { - char get(); - } - - property short Integer16Data - { - short get(); - } - - property int Integer32Data - { - int get(); - } - - property __int64 Integer64Data - { - __int64 get(); - } - - property float Float32Data - { - float get(); - } - - property double Float64Data - { - double get(); - } - - property System::String^ StringData - { - System::String^ get(); - } - - property array^ BinaryData - { - array^ get(); - } - - property System::DateTime DateData - { - System::DateTime get(); - } - - property System::Collections::Generic::List^ ListData - { - System::Collections::Generic::List^ get(); - } - - property System::Collections::Generic::HashSet^ SetData - { - System::Collections::Generic::HashSet^ get(); - } - - property System::Collections::Generic::Dictionary^ MapData - { - System::Collections::Generic::Dictionary^ get(); - } - - property System::Nullable OptionalData - { - System::Nullable get(); - } - - property ::EnumData EnumData - { - ::EnumData get(); - } - - AllDatatypes(bool booleanData, - char integer8Data, - short integer16Data, - int integer32Data, - __int64 integer64Data, - float float32Data, - double float64Data, - System::String^ stringData, - array^ binaryData, - System::DateTime dateData, - System::Collections::Generic::List^ listData, - System::Collections::Generic::HashSet^ setData, - System::Collections::Generic::Dictionary^ mapData, - System::Nullable optionalData, - ::EnumData enumData); - - System::String^ ToString() override; - -internal: - using CppType = ::AllDatatypes; - using CsType = AllDatatypes^; - - static CppType ToCpp(CsType cs); - static CsType FromCpp(const CppType& cpp); - -private: - bool _booleanData; - char _integer8Data; - short _integer16Data; - int _integer32Data; - __int64 _integer64Data; - float _float32Data; - double _float64Data; - System::String^ _stringData; - array^ _binaryData; - System::DateTime _dateData; - System::Collections::Generic::List^ _listData; - System::Collections::Generic::HashSet^ _setData; - System::Collections::Generic::Dictionary^ _mapData; - System::Nullable _optionalData; - ::EnumData _enumData; -}; diff --git a/src/it/resources/expected/all_datatypes/cppcli/EnumData.cpp b/src/it/resources/expected/all_datatypes/cppcli/EnumData.cpp deleted file mode 100644 index b55fbadc..00000000 --- a/src/it/resources/expected/all_datatypes/cppcli/EnumData.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#include "EnumData.hpp" // my header -#include "../cpp-headers/enum_data.hpp" - -// Empty... making sure the symbols get included in the build. diff --git a/src/it/resources/expected/all_datatypes/cppcli/EnumData.hpp b/src/it/resources/expected/all_datatypes/cppcli/EnumData.hpp deleted file mode 100644 index 46f80147..00000000 --- a/src/it/resources/expected/all_datatypes/cppcli/EnumData.hpp +++ /dev/null @@ -1,11 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#pragma once - -#include "../cpp-headers/enum_data.hpp" - -public enum class EnumData { - A, - B, -}; diff --git a/src/it/resources/expected/all_datatypes/cwrapper-headers/dh__all_datatypes.h b/src/it/resources/expected/all_datatypes/cwrapper-headers/dh__all_datatypes.h deleted file mode 100644 index 7000cd00..00000000 --- a/src/it/resources/expected/all_datatypes/cwrapper-headers/dh__all_datatypes.h +++ /dev/null @@ -1,29 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#pragma once // python_cdef_ignore -#include // python_cdef_ignore - -#include // python_cdef_ignore -#include // python_cdef_ignore - -struct DjinniAllDatatypes; -void all_datatypes___delete(struct DjinniRecordHandle * ); -void optional_all_datatypes___delete(struct DjinniOptionalRecordHandle * ); -void all_datatypes_add_callback_get_all_datatypes_f1(bool( * ptr)(struct DjinniRecordHandle *)); -void all_datatypes_add_callback_get_all_datatypes_f2(int8_t( * ptr)(struct DjinniRecordHandle *)); -void all_datatypes_add_callback_get_all_datatypes_f3(int16_t( * ptr)(struct DjinniRecordHandle *)); -void all_datatypes_add_callback_get_all_datatypes_f4(int32_t( * ptr)(struct DjinniRecordHandle *)); -void all_datatypes_add_callback_get_all_datatypes_f5(int64_t( * ptr)(struct DjinniRecordHandle *)); -void all_datatypes_add_callback_get_all_datatypes_f6(float( * ptr)(struct DjinniRecordHandle *)); -void all_datatypes_add_callback_get_all_datatypes_f7(double( * ptr)(struct DjinniRecordHandle *)); -void all_datatypes_add_callback_get_all_datatypes_f8(struct DjinniString *( * ptr)(struct DjinniRecordHandle *)); -void all_datatypes_add_callback_get_all_datatypes_f9(struct DjinniBinary *( * ptr)(struct DjinniRecordHandle *)); -void all_datatypes_add_callback_get_all_datatypes_f10(uint64_t( * ptr)(struct DjinniRecordHandle *)); -void all_datatypes_add_callback_get_all_datatypes_f11(struct DjinniObjectHandle *( * ptr)(struct DjinniRecordHandle *)); -void all_datatypes_add_callback_get_all_datatypes_f12(struct DjinniObjectHandle *( * ptr)(struct DjinniRecordHandle *)); -void all_datatypes_add_callback_get_all_datatypes_f13(struct DjinniObjectHandle *( * ptr)(struct DjinniRecordHandle *)); -void all_datatypes_add_callback_get_all_datatypes_f14(struct DjinniBoxedBool *( * ptr)(struct DjinniRecordHandle *)); -void all_datatypes_add_callback_get_all_datatypes_f15(int( * ptr)(struct DjinniRecordHandle *)); -void all_datatypes_add_callback_create_all_datatypes(struct DjinniRecordHandle *( * ptr)(bool, int8_t, int16_t, int32_t, int64_t, float, double, struct DjinniString *, struct DjinniBinary *, uint64_t, struct DjinniObjectHandle *, struct DjinniObjectHandle *, struct DjinniObjectHandle *, struct DjinniBoxedBool *, int)); -void all_datatypes_add_callback___delete(void( * ptr)(struct DjinniRecordHandle *)); diff --git a/src/it/resources/expected/all_datatypes/cwrapper-headers/dh__enum_data.h b/src/it/resources/expected/all_datatypes/cwrapper-headers/dh__enum_data.h deleted file mode 100644 index 0a2ae93c..00000000 --- a/src/it/resources/expected/all_datatypes/cwrapper-headers/dh__enum_data.h +++ /dev/null @@ -1,6 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#pragma once // python_cdef_ignore -#include // python_cdef_ignore - diff --git a/src/it/resources/expected/all_datatypes/cwrapper-headers/dh__list_bool.h b/src/it/resources/expected/all_datatypes/cwrapper-headers/dh__list_bool.h deleted file mode 100644 index 577ab0d0..00000000 --- a/src/it/resources/expected/all_datatypes/cwrapper-headers/dh__list_bool.h +++ /dev/null @@ -1,16 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#pragma once // python_cdef_ignore -#include // python_cdef_ignore - -#include // python_cdef_ignore -#include // python_cdef_ignore - -void list_bool___delete(struct DjinniObjectHandle *); -void optional_list_bool___delete(struct DjinniOptionalObjectHandle *); -void list_bool_add_callback___delete(void(* ptr)(struct DjinniObjectHandle * )); -void list_bool_add_callback__get_elem(bool( * ptr)(struct DjinniObjectHandle *, size_t)); -void list_bool_add_callback__get_size(size_t( * ptr)(struct DjinniObjectHandle *)); -void list_bool_add_callback__create(struct DjinniObjectHandle *( * ptr)(void)); -void list_bool_add_callback__add(void( * ptr)(struct DjinniObjectHandle *, bool)); diff --git a/src/it/resources/expected/all_datatypes/cwrapper-headers/dh__map_int8_t_bool.h b/src/it/resources/expected/all_datatypes/cwrapper-headers/dh__map_int8_t_bool.h deleted file mode 100644 index dc9c3310..00000000 --- a/src/it/resources/expected/all_datatypes/cwrapper-headers/dh__map_int8_t_bool.h +++ /dev/null @@ -1,17 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#pragma once // python_cdef_ignore -#include // python_cdef_ignore - -#include // python_cdef_ignore -#include // python_cdef_ignore - -void map_int8_t_bool___delete(struct DjinniObjectHandle *); -void optional_map_int8_t_bool___delete(struct DjinniOptionalObjectHandle *); -void map_int8_t_bool_add_callback___delete(void(* ptr)(struct DjinniObjectHandle * )); -void map_int8_t_bool_add_callback__get_value(bool( * ptr)(struct DjinniObjectHandle *, int8_t)); -void map_int8_t_bool_add_callback__get_size(size_t( * ptr)(struct DjinniObjectHandle *)); -void map_int8_t_bool_add_callback__create(struct DjinniObjectHandle *( * ptr)(void)); -void map_int8_t_bool_add_callback__add(void( * ptr)(struct DjinniObjectHandle *, int8_t, bool)); -void map_int8_t_bool_add_callback__next(int8_t( * ptr)(struct DjinniObjectHandle *)); diff --git a/src/it/resources/expected/all_datatypes/cwrapper-headers/dh__set_bool.h b/src/it/resources/expected/all_datatypes/cwrapper-headers/dh__set_bool.h deleted file mode 100644 index a9cd9a80..00000000 --- a/src/it/resources/expected/all_datatypes/cwrapper-headers/dh__set_bool.h +++ /dev/null @@ -1,16 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#pragma once // python_cdef_ignore -#include // python_cdef_ignore - -#include // python_cdef_ignore -#include // python_cdef_ignore - -void set_bool___delete(struct DjinniObjectHandle *); -void optional_set_bool___delete(struct DjinniOptionalObjectHandle *); -void set_bool_add_callback___delete(void(* ptr)(struct DjinniObjectHandle * )); -void set_bool_add_callback__get_size(size_t( * ptr)(struct DjinniObjectHandle *)); -void set_bool_add_callback__create(struct DjinniObjectHandle *( * ptr)(void)); -void set_bool_add_callback__add(void( * ptr)(struct DjinniObjectHandle *, bool)); -void set_bool_add_callback__next(bool( * ptr)(struct DjinniObjectHandle *)); diff --git a/src/it/resources/expected/all_datatypes/cwrapper/dh__all_datatypes.cpp b/src/it/resources/expected/all_datatypes/cwrapper/dh__all_datatypes.cpp deleted file mode 100644 index 914bdd99..00000000 --- a/src/it/resources/expected/all_datatypes/cwrapper/dh__all_datatypes.cpp +++ /dev/null @@ -1,195 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#include // for debugging -#include -#include "djinni/cwrapper/wrapper_marshal.hpp" -#include "../cpp-headers/all_datatypes.hpp" - -#include "dh__all_datatypes.hpp" -#include "dh__enum_data.hpp" -#include "dh__list_bool.hpp" -#include "dh__map_int8_t_bool.hpp" -#include "dh__set_bool.hpp" -#include "enum_data.hpp" -#include -#include -#include - -static void(*s_callback_all_datatypes___delete)(DjinniRecordHandle * ); -void all_datatypes_add_callback___delete(void(* ptr)(DjinniRecordHandle * )) { - s_callback_all_datatypes___delete = ptr; -} - -void all_datatypes___delete(DjinniRecordHandle * drh) { - s_callback_all_datatypes___delete(drh); -} -void optional_all_datatypes___delete(DjinniOptionalRecordHandle * drh) { - s_callback_all_datatypes___delete((DjinniRecordHandle *) drh); // can't static cast, find better way -} -static bool ( * s_callback_all_datatypes_get_all_datatypes_f1)(DjinniRecordHandle *); - -void all_datatypes_add_callback_get_all_datatypes_f1(bool( * ptr)(DjinniRecordHandle *)) { - s_callback_all_datatypes_get_all_datatypes_f1 = ptr; -} - -static int8_t ( * s_callback_all_datatypes_get_all_datatypes_f2)(DjinniRecordHandle *); - -void all_datatypes_add_callback_get_all_datatypes_f2(int8_t( * ptr)(DjinniRecordHandle *)) { - s_callback_all_datatypes_get_all_datatypes_f2 = ptr; -} - -static int16_t ( * s_callback_all_datatypes_get_all_datatypes_f3)(DjinniRecordHandle *); - -void all_datatypes_add_callback_get_all_datatypes_f3(int16_t( * ptr)(DjinniRecordHandle *)) { - s_callback_all_datatypes_get_all_datatypes_f3 = ptr; -} - -static int32_t ( * s_callback_all_datatypes_get_all_datatypes_f4)(DjinniRecordHandle *); - -void all_datatypes_add_callback_get_all_datatypes_f4(int32_t( * ptr)(DjinniRecordHandle *)) { - s_callback_all_datatypes_get_all_datatypes_f4 = ptr; -} - -static int64_t ( * s_callback_all_datatypes_get_all_datatypes_f5)(DjinniRecordHandle *); - -void all_datatypes_add_callback_get_all_datatypes_f5(int64_t( * ptr)(DjinniRecordHandle *)) { - s_callback_all_datatypes_get_all_datatypes_f5 = ptr; -} - -static float ( * s_callback_all_datatypes_get_all_datatypes_f6)(DjinniRecordHandle *); - -void all_datatypes_add_callback_get_all_datatypes_f6(float( * ptr)(DjinniRecordHandle *)) { - s_callback_all_datatypes_get_all_datatypes_f6 = ptr; -} - -static double ( * s_callback_all_datatypes_get_all_datatypes_f7)(DjinniRecordHandle *); - -void all_datatypes_add_callback_get_all_datatypes_f7(double( * ptr)(DjinniRecordHandle *)) { - s_callback_all_datatypes_get_all_datatypes_f7 = ptr; -} - -static DjinniString * ( * s_callback_all_datatypes_get_all_datatypes_f8)(DjinniRecordHandle *); - -void all_datatypes_add_callback_get_all_datatypes_f8(DjinniString *( * ptr)(DjinniRecordHandle *)) { - s_callback_all_datatypes_get_all_datatypes_f8 = ptr; -} - -static DjinniBinary * ( * s_callback_all_datatypes_get_all_datatypes_f9)(DjinniRecordHandle *); - -void all_datatypes_add_callback_get_all_datatypes_f9(DjinniBinary *( * ptr)(DjinniRecordHandle *)) { - s_callback_all_datatypes_get_all_datatypes_f9 = ptr; -} - -static uint64_t ( * s_callback_all_datatypes_get_all_datatypes_f10)(DjinniRecordHandle *); - -void all_datatypes_add_callback_get_all_datatypes_f10(uint64_t( * ptr)(DjinniRecordHandle *)) { - s_callback_all_datatypes_get_all_datatypes_f10 = ptr; -} - -static DjinniObjectHandle * ( * s_callback_all_datatypes_get_all_datatypes_f11)(DjinniRecordHandle *); - -void all_datatypes_add_callback_get_all_datatypes_f11(DjinniObjectHandle *( * ptr)(DjinniRecordHandle *)) { - s_callback_all_datatypes_get_all_datatypes_f11 = ptr; -} - -static DjinniObjectHandle * ( * s_callback_all_datatypes_get_all_datatypes_f12)(DjinniRecordHandle *); - -void all_datatypes_add_callback_get_all_datatypes_f12(DjinniObjectHandle *( * ptr)(DjinniRecordHandle *)) { - s_callback_all_datatypes_get_all_datatypes_f12 = ptr; -} - -static DjinniObjectHandle * ( * s_callback_all_datatypes_get_all_datatypes_f13)(DjinniRecordHandle *); - -void all_datatypes_add_callback_get_all_datatypes_f13(DjinniObjectHandle *( * ptr)(DjinniRecordHandle *)) { - s_callback_all_datatypes_get_all_datatypes_f13 = ptr; -} - -static DjinniBoxedBool * ( * s_callback_all_datatypes_get_all_datatypes_f14)(DjinniRecordHandle *); - -void all_datatypes_add_callback_get_all_datatypes_f14(DjinniBoxedBool *( * ptr)(DjinniRecordHandle *)) { - s_callback_all_datatypes_get_all_datatypes_f14 = ptr; -} - -static int ( * s_callback_all_datatypes_get_all_datatypes_f15)(DjinniRecordHandle *); - -void all_datatypes_add_callback_get_all_datatypes_f15(int( * ptr)(DjinniRecordHandle *)) { - s_callback_all_datatypes_get_all_datatypes_f15 = ptr; -} - -static DjinniRecordHandle * ( * s_callback_all_datatypes_create_all_datatypes)(bool, int8_t, int16_t, int32_t, int64_t, float, double, DjinniString *, DjinniBinary *, uint64_t, DjinniObjectHandle *, DjinniObjectHandle *, DjinniObjectHandle *, DjinniBoxedBool *, int); - -void all_datatypes_add_callback_create_all_datatypes(DjinniRecordHandle *( * ptr)(bool, int8_t, int16_t, int32_t, int64_t, float, double, DjinniString *, DjinniBinary *, uint64_t, DjinniObjectHandle *, DjinniObjectHandle *, DjinniObjectHandle *, DjinniBoxedBool *, int)) { - s_callback_all_datatypes_create_all_datatypes = ptr; -} - -djinni::Handle DjinniAllDatatypes::fromCpp(const ::AllDatatypes& dr) { - auto _field_stringData = DjinniString::fromCpp(dr.stringData); - auto _field_binaryData = DjinniBinary::fromCpp(dr.binaryData); - auto _field_listData = DjinniListBool::fromCpp(dr.listData); - auto _field_setData = DjinniSetBool::fromCpp(dr.setData); - auto _field_mapData = DjinniMapInt8TBool::fromCpp(dr.mapData); - auto _field_optionalData = DjinniBoxedBool::fromCpp(dr.optionalData); - - djinni::Handle _aux( - s_callback_all_datatypes_create_all_datatypes( - dr.booleanData, - dr.integer8Data, - dr.integer16Data, - dr.integer32Data, - dr.integer64Data, - dr.float32Data, - dr.float64Data, - _field_stringData.release(), - _field_binaryData.release(), - DjinniDate::fromCpp(dr.dateData), - _field_listData.release(), - _field_setData.release(), - _field_mapData.release(), - _field_optionalData.release(), - int32_from_enum_enum_data(dr.enum_data)), - all_datatypes___delete); - return _aux; -} - -::AllDatatypes DjinniAllDatatypes::toCpp(djinni::Handle dh) { - std::unique_ptr _field_stringData(s_callback_all_datatypes_get_all_datatypes_f8(dh.get())); - std::unique_ptr _field_binaryData(s_callback_all_datatypes_get_all_datatypes_f9(dh.get())); - djinni::Handle _field_listData(s_callback_all_datatypes_get_all_datatypes_f11(dh.get()), list_bool___delete); - djinni::Handle _field_setData(s_callback_all_datatypes_get_all_datatypes_f12(dh.get()), set_bool___delete); - djinni::Handle _field_mapData(s_callback_all_datatypes_get_all_datatypes_f13(dh.get()), map_int8_t_bool___delete); - std::unique_ptr _field_optionalData(s_callback_all_datatypes_get_all_datatypes_f14(dh.get())); - - auto _aux = ::AllDatatypes( - s_callback_all_datatypes_get_all_datatypes_f1(dh.get()), - s_callback_all_datatypes_get_all_datatypes_f2(dh.get()), - s_callback_all_datatypes_get_all_datatypes_f3(dh.get()), - s_callback_all_datatypes_get_all_datatypes_f4(dh.get()), - s_callback_all_datatypes_get_all_datatypes_f5(dh.get()), - s_callback_all_datatypes_get_all_datatypes_f6(dh.get()), - s_callback_all_datatypes_get_all_datatypes_f7(dh.get()), - DjinniString::toCpp(std::move( _field_stringData)), - DjinniBinary::toCpp(std::move( _field_binaryData)), - DjinniDate::toCpp(s_callback_all_datatypes_get_all_datatypes_f10(dh.get())), - DjinniListBool::toCpp(std::move( _field_listData)), - DjinniSetBool::toCpp(std::move( _field_setData)), - DjinniMapInt8TBool::toCpp(std::move( _field_mapData)), - DjinniBoxedBool::toCpp(std::move( _field_optionalData)), - static_cast<::EnumData>(s_callback_all_datatypes_get_all_datatypes_f15(dh.get()))); - return _aux; -} - -djinni::Handle DjinniAllDatatypes::fromCpp(std::optional<::AllDatatypes> dc) { - if (!dc) { - return nullptr; - } - return djinni::optionals::toOptionalHandle(DjinniAllDatatypes::fromCpp(std::move(* dc)), optional_all_datatypes___delete); -} - -std::optional<::AllDatatypes>DjinniAllDatatypes::toCpp(djinni::Handle dh) { - if (dh) { - return std::optional<::AllDatatypes>(DjinniAllDatatypes::toCpp(djinni::optionals::fromOptionalHandle(std::move(dh), all_datatypes___delete))); - } - return {}; -} - diff --git a/src/it/resources/expected/all_datatypes/cwrapper/dh__all_datatypes.hpp b/src/it/resources/expected/all_datatypes/cwrapper/dh__all_datatypes.hpp deleted file mode 100644 index 82fecda0..00000000 --- a/src/it/resources/expected/all_datatypes/cwrapper/dh__all_datatypes.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#pragma once - -#include -#include -#include "../cpp-headers/all_datatypes.hpp" -#ifdef __cplusplus -extern "C" { -#endif - -#include "../cwrapper-headers/dh__all_datatypes.h" - -#ifdef __cplusplus -} -#endif -struct DjinniAllDatatypes { - static djinni::Handle fromCpp(const ::AllDatatypes& dr); - static ::AllDatatypes toCpp(djinni::Handle dh); - static djinni::Handle fromCpp(std::optional<::AllDatatypes> dc); - static std::optional<::AllDatatypes> toCpp(djinni::Handle dh); -}; diff --git a/src/it/resources/expected/all_datatypes/cwrapper/dh__enum_data.cpp b/src/it/resources/expected/all_datatypes/cwrapper/dh__enum_data.cpp deleted file mode 100644 index b7b7d02e..00000000 --- a/src/it/resources/expected/all_datatypes/cwrapper/dh__enum_data.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#include // for debugging -#include -#include "djinni/cwrapper/wrapper_marshal.hpp" -#include "../cpp-headers/enum_data.hpp" - -int32_t int32_from_enum_enum_data(std::optional<::EnumData> e) { - if (e) { - return static_cast(* e); - } - return -1; // -1 to signal null boxed enum -} - -int32_t int32_from_enum_enum_data(::EnumData e) { - return static_cast(e); -} -std::optional<::EnumData> get_boxed_enum_enum_data_from_int32(int32_t e) { - if (e == -1) { // to signal null enum - return {}; - } - return std::optional<::EnumData>(static_cast<::EnumData>(e)); -} diff --git a/src/it/resources/expected/all_datatypes/cwrapper/dh__enum_data.hpp b/src/it/resources/expected/all_datatypes/cwrapper/dh__enum_data.hpp deleted file mode 100644 index 04058a70..00000000 --- a/src/it/resources/expected/all_datatypes/cwrapper/dh__enum_data.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#pragma once - -#include -#include -#include "../cpp-headers/enum_data.hpp" -#ifdef __cplusplus -extern "C" { -#endif - -#include "../cwrapper-headers/dh__enum_data.h" - -#ifdef __cplusplus -} -#endif -int32_t int32_from_enum_enum_data(std::optional<::EnumData> e); -int32_t int32_from_enum_enum_data(::EnumData e); -std::optional<::EnumData> get_boxed_enum_enum_data_from_int32(int32_t e); diff --git a/src/it/resources/expected/all_datatypes/cwrapper/dh__list_bool.cpp b/src/it/resources/expected/all_datatypes/cwrapper/dh__list_bool.cpp deleted file mode 100644 index 40b0ce38..00000000 --- a/src/it/resources/expected/all_datatypes/cwrapper/dh__list_bool.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#include // for debugging -#include -#include "djinni/cwrapper/wrapper_marshal.hpp" -#include "../cpp-headers/all_datatypes.hpp" - -#include "dh__all_datatypes.hpp" -#include "dh__enum_data.hpp" -#include "dh__list_bool.hpp" -#include "dh__map_int8_t_bool.hpp" -#include "dh__set_bool.hpp" -#include "enum_data.hpp" -#include -#include -#include - -static void(*s_callback_list_bool___delete)(DjinniObjectHandle *); -void list_bool_add_callback___delete(void(* ptr)(DjinniObjectHandle *)) { - s_callback_list_bool___delete = ptr; -} - -void list_bool___delete(DjinniObjectHandle * drh) { - s_callback_list_bool___delete(drh); -} -void optional_list_bool___delete(DjinniOptionalObjectHandle * drh) { - s_callback_list_bool___delete((DjinniObjectHandle *) drh); -} -static bool ( * s_callback_list_bool__get_elem)(DjinniObjectHandle *, size_t); - -void list_bool_add_callback__get_elem(bool( * ptr)(DjinniObjectHandle *, size_t)) { - s_callback_list_bool__get_elem = ptr; -} - -static size_t ( * s_callback_list_bool__get_size)(DjinniObjectHandle *); - -void list_bool_add_callback__get_size(size_t( * ptr)(DjinniObjectHandle *)) { - s_callback_list_bool__get_size = ptr; -} - -static DjinniObjectHandle * ( * s_callback_list_bool__create)(void); - -void list_bool_add_callback__create(DjinniObjectHandle *( * ptr)(void)) { - s_callback_list_bool__create = ptr; -} - -static void ( * s_callback_list_bool__add)(DjinniObjectHandle *, bool); - -void list_bool_add_callback__add(void( * ptr)(DjinniObjectHandle *, bool)) { - s_callback_list_bool__add = ptr; -} - -djinni::Handle DjinniListBool::fromCpp(const std::vector & dc) { - djinni::Handle _handle(s_callback_list_bool__create(), & list_bool___delete); - size_t size = dc.size(); - for (int i = 0; i < size; i++) { - s_callback_list_bool__add(_handle.get(), dc[i]); - } - - return _handle; -} - -std::vector DjinniListBool::toCpp(djinni::Handle dh) { - std::vector_ret; - size_t size = s_callback_list_bool__get_size(dh.get()); - _ret.reserve(size); - - for (int i = 0; i < size; i++) { - _ret.push_back(s_callback_list_bool__get_elem(dh.get(), i)); - } - - return _ret; -} - -djinni::Handle DjinniListBool::fromCpp(std::optional> dc) { - if (!dc) { - return nullptr; - } - return djinni::optionals::toOptionalHandle(DjinniListBool::fromCpp(std::move(* dc)), optional_list_bool___delete); -} - -std::optional>DjinniListBool::toCpp(djinni::Handle dh) { - if (dh) { - return std::optional>(DjinniListBool::toCpp(djinni::optionals::fromOptionalHandle(std::move(dh), list_bool___delete))); - } - return {}; -} - diff --git a/src/it/resources/expected/all_datatypes/cwrapper/dh__list_bool.hpp b/src/it/resources/expected/all_datatypes/cwrapper/dh__list_bool.hpp deleted file mode 100644 index 1a71f25f..00000000 --- a/src/it/resources/expected/all_datatypes/cwrapper/dh__list_bool.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#pragma once - -#include -#include -#include "../cpp-headers/all_datatypes.hpp" -#ifdef __cplusplus -extern "C" { -#endif - -#include "../cwrapper-headers/dh__list_bool.h" - -#ifdef __cplusplus -} -#endif -struct DjinniListBool { - static djinni::Handle fromCpp(const std::vector & dc); - static std::vector toCpp(djinni::Handle dh); - static djinni::HandlefromCpp(std::optional> dc); - static std::optional> toCpp(djinni::Handle dh); -}; diff --git a/src/it/resources/expected/all_datatypes/cwrapper/dh__map_int8_t_bool.cpp b/src/it/resources/expected/all_datatypes/cwrapper/dh__map_int8_t_bool.cpp deleted file mode 100644 index 40a1c8b6..00000000 --- a/src/it/resources/expected/all_datatypes/cwrapper/dh__map_int8_t_bool.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#include // for debugging -#include -#include "djinni/cwrapper/wrapper_marshal.hpp" -#include "../cpp-headers/all_datatypes.hpp" - -#include "dh__all_datatypes.hpp" -#include "dh__enum_data.hpp" -#include "dh__list_bool.hpp" -#include "dh__map_int8_t_bool.hpp" -#include "dh__set_bool.hpp" -#include "enum_data.hpp" -#include -#include -#include - -static void(*s_callback_map_int8_t_bool___delete)(DjinniObjectHandle *); -void map_int8_t_bool_add_callback___delete(void(* ptr)(DjinniObjectHandle *)) { - s_callback_map_int8_t_bool___delete = ptr; -} - -void map_int8_t_bool___delete(DjinniObjectHandle * drh) { - s_callback_map_int8_t_bool___delete(drh); -} -void optional_map_int8_t_bool___delete(DjinniOptionalObjectHandle * drh) { - s_callback_map_int8_t_bool___delete((DjinniObjectHandle *) drh); -} -static bool ( * s_callback_map_int8_t_bool__get_value)(DjinniObjectHandle *, int8_t); - -void map_int8_t_bool_add_callback__get_value(bool( * ptr)(DjinniObjectHandle *, int8_t)) { - s_callback_map_int8_t_bool__get_value = ptr; -} - -static size_t ( * s_callback_map_int8_t_bool__get_size)(DjinniObjectHandle *); - -void map_int8_t_bool_add_callback__get_size(size_t( * ptr)(DjinniObjectHandle *)) { - s_callback_map_int8_t_bool__get_size = ptr; -} - -static DjinniObjectHandle * ( * s_callback_map_int8_t_bool__create)(void); - -void map_int8_t_bool_add_callback__create(DjinniObjectHandle *( * ptr)(void)) { - s_callback_map_int8_t_bool__create = ptr; -} - -static void ( * s_callback_map_int8_t_bool__add)(DjinniObjectHandle *, int8_t, bool); - -void map_int8_t_bool_add_callback__add(void( * ptr)(DjinniObjectHandle *, int8_t, bool)) { - s_callback_map_int8_t_bool__add = ptr; -} - -static int8_t ( * s_callback_map_int8_t_bool__next)(DjinniObjectHandle *); - -void map_int8_t_bool_add_callback__next(int8_t( * ptr)(DjinniObjectHandle *)) { - s_callback_map_int8_t_bool__next = ptr; -} - -djinni::Handle DjinniMapInt8TBool::fromCpp(const std::unordered_map & dc) { - djinni::Handle _handle(s_callback_map_int8_t_bool__create(), & map_int8_t_bool___delete); - for (const auto & it : dc) { - s_callback_map_int8_t_bool__add(_handle.get(), it.first, it.second); - } - - return _handle; -} - -std::unordered_map DjinniMapInt8TBool::toCpp(djinni::Handle dh) { - std::unordered_map_ret; - size_t size = s_callback_map_int8_t_bool__get_size(dh.get()); - - for (int i = 0; i < size; i++) { - auto _key_c = s_callback_map_int8_t_bool__next(dh.get()); // key that would potentially be surrounded by unique pointer - auto _val = s_callback_map_int8_t_bool__get_value(dh.get(), _key_c); - - auto _key = _key_c; - _ret.emplace(std::move(_key), std::move(_val)); - } - - return _ret; -} - -djinni::Handle DjinniMapInt8TBool::fromCpp(std::optional> dc) { - if (!dc) { - return nullptr; - } - return djinni::optionals::toOptionalHandle(DjinniMapInt8TBool::fromCpp(std::move(* dc)), optional_map_int8_t_bool___delete); -} - -std::optional>DjinniMapInt8TBool::toCpp(djinni::Handle dh) { - if (dh) { - return std::optional>(DjinniMapInt8TBool::toCpp(djinni::optionals::fromOptionalHandle(std::move(dh), map_int8_t_bool___delete))); - } - return {}; -} - diff --git a/src/it/resources/expected/all_datatypes/cwrapper/dh__map_int8_t_bool.hpp b/src/it/resources/expected/all_datatypes/cwrapper/dh__map_int8_t_bool.hpp deleted file mode 100644 index a1885135..00000000 --- a/src/it/resources/expected/all_datatypes/cwrapper/dh__map_int8_t_bool.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#pragma once - -#include -#include -#include "../cpp-headers/all_datatypes.hpp" -#ifdef __cplusplus -extern "C" { -#endif - -#include "../cwrapper-headers/dh__map_int8_t_bool.h" - -#ifdef __cplusplus -} -#endif -struct DjinniMapInt8TBool { - static djinni::Handle fromCpp(const std::unordered_map & dc); - static std::unordered_map toCpp(djinni::Handle dh); - static djinni::HandlefromCpp(std::optional> dc); - static std::optional> toCpp(djinni::Handle dh); -}; diff --git a/src/it/resources/expected/all_datatypes/cwrapper/dh__set_bool.cpp b/src/it/resources/expected/all_datatypes/cwrapper/dh__set_bool.cpp deleted file mode 100644 index 9ac496f9..00000000 --- a/src/it/resources/expected/all_datatypes/cwrapper/dh__set_bool.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#include // for debugging -#include -#include "djinni/cwrapper/wrapper_marshal.hpp" -#include "../cpp-headers/all_datatypes.hpp" - -#include "dh__all_datatypes.hpp" -#include "dh__enum_data.hpp" -#include "dh__list_bool.hpp" -#include "dh__map_int8_t_bool.hpp" -#include "dh__set_bool.hpp" -#include "enum_data.hpp" -#include -#include -#include - -static void(*s_callback_set_bool___delete)(DjinniObjectHandle *); -void set_bool_add_callback___delete(void(* ptr)(DjinniObjectHandle *)) { - s_callback_set_bool___delete = ptr; -} - -void set_bool___delete(DjinniObjectHandle * drh) { - s_callback_set_bool___delete(drh); -} -void optional_set_bool___delete(DjinniOptionalObjectHandle * drh) { - s_callback_set_bool___delete((DjinniObjectHandle *) drh); -} -static size_t ( * s_callback_set_bool__get_size)(DjinniObjectHandle *); - -void set_bool_add_callback__get_size(size_t( * ptr)(DjinniObjectHandle *)) { - s_callback_set_bool__get_size = ptr; -} - -static DjinniObjectHandle * ( * s_callback_set_bool__create)(void); - -void set_bool_add_callback__create(DjinniObjectHandle *( * ptr)(void)) { - s_callback_set_bool__create = ptr; -} - -static void ( * s_callback_set_bool__add)(DjinniObjectHandle *, bool); - -void set_bool_add_callback__add(void( * ptr)(DjinniObjectHandle *, bool)) { - s_callback_set_bool__add = ptr; -} - -static bool ( * s_callback_set_bool__next)(DjinniObjectHandle *); - -void set_bool_add_callback__next(bool( * ptr)(DjinniObjectHandle *)) { - s_callback_set_bool__next = ptr; -} - -djinni::Handle DjinniSetBool::fromCpp(const std::unordered_set & dc) { - djinni::Handle _handle(s_callback_set_bool__create(), & set_bool___delete); - for (const auto & it : dc) { - s_callback_set_bool__add(_handle.get(), it); - } - - return _handle; -} - -std::unordered_set DjinniSetBool::toCpp(djinni::Handle dh) { - std::unordered_set_ret; - size_t size = s_callback_set_bool__get_size(dh.get()); - - for (int i = 0; i < size; i++) { - auto _el = s_callback_set_bool__next(dh.get()); - _ret.insert(std::move(_el)); - } - - return _ret; -} - -djinni::Handle DjinniSetBool::fromCpp(std::optional> dc) { - if (!dc) { - return nullptr; - } - return djinni::optionals::toOptionalHandle(DjinniSetBool::fromCpp(std::move(* dc)), optional_set_bool___delete); -} - -std::optional>DjinniSetBool::toCpp(djinni::Handle dh) { - if (dh) { - return std::optional>(DjinniSetBool::toCpp(djinni::optionals::fromOptionalHandle(std::move(dh), set_bool___delete))); - } - return {}; -} - diff --git a/src/it/resources/expected/all_datatypes/cwrapper/dh__set_bool.hpp b/src/it/resources/expected/all_datatypes/cwrapper/dh__set_bool.hpp deleted file mode 100644 index b59fc0bb..00000000 --- a/src/it/resources/expected/all_datatypes/cwrapper/dh__set_bool.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from all_datatypes.djinni - -#pragma once - -#include -#include -#include "../cpp-headers/all_datatypes.hpp" -#ifdef __cplusplus -extern "C" { -#endif - -#include "../cwrapper-headers/dh__set_bool.h" - -#ifdef __cplusplus -} -#endif -struct DjinniSetBool { - static djinni::Handle fromCpp(const std::unordered_set & dc); - static std::unordered_set toCpp(djinni::Handle dh); - static djinni::HandlefromCpp(std::optional> dc); - static std::optional> toCpp(djinni::Handle dh); -}; diff --git a/src/it/resources/expected/all_datatypes/generated-files.txt b/src/it/resources/expected/all_datatypes/generated-files.txt index f5b6ec3a..7a91bd78 100644 --- a/src/it/resources/expected/all_datatypes/generated-files.txt +++ b/src/it/resources/expected/all_datatypes/generated-files.txt @@ -13,28 +13,3 @@ src/it/resources/result/all_datatypes/objcpp-headers/ITEnumData+Private.h src/it/resources/result/all_datatypes/objcpp-headers/ITAllDatatypes+Private.h src/it/resources/result/all_datatypes/objcpp/ITAllDatatypes+Private.mm src/it/resources/result/all_datatypes/objc-headers/bridging-header.h -src/it/resources/result/all_datatypes/cppcli/EnumData.hpp -src/it/resources/result/all_datatypes/cppcli/EnumData.cpp -src/it/resources/result/all_datatypes/cppcli/AllDatatypes.hpp -src/it/resources/result/all_datatypes/cppcli/AllDatatypes.cpp -src/it/resources/result/all_datatypes/python/enum_data.py -src/it/resources/result/all_datatypes/python/dh__list_bool.py -src/it/resources/result/all_datatypes/python/dh__set_bool.py -src/it/resources/result/all_datatypes/python/dh__map_int8_t_bool.py -src/it/resources/result/all_datatypes/python/all_datatypes.py -src/it/resources/result/all_datatypes/python/all_datatypes_helper.py -src/it/resources/result/all_datatypes/cwrapper-headers/dh__enum_data.h -src/it/resources/result/all_datatypes/cwrapper/dh__enum_data.hpp -src/it/resources/result/all_datatypes/cwrapper/dh__enum_data.cpp -src/it/resources/result/all_datatypes/cwrapper-headers/dh__list_bool.h -src/it/resources/result/all_datatypes/cwrapper/dh__list_bool.hpp -src/it/resources/result/all_datatypes/cwrapper/dh__list_bool.cpp -src/it/resources/result/all_datatypes/cwrapper-headers/dh__set_bool.h -src/it/resources/result/all_datatypes/cwrapper/dh__set_bool.hpp -src/it/resources/result/all_datatypes/cwrapper/dh__set_bool.cpp -src/it/resources/result/all_datatypes/cwrapper-headers/dh__map_int8_t_bool.h -src/it/resources/result/all_datatypes/cwrapper/dh__map_int8_t_bool.hpp -src/it/resources/result/all_datatypes/cwrapper/dh__map_int8_t_bool.cpp -src/it/resources/result/all_datatypes/cwrapper-headers/dh__all_datatypes.h -src/it/resources/result/all_datatypes/cwrapper/dh__all_datatypes.hpp -src/it/resources/result/all_datatypes/cwrapper/dh__all_datatypes.cpp diff --git a/src/it/resources/expected/all_datatypes/python/all_datatypes.py b/src/it/resources/expected/all_datatypes/python/all_datatypes.py deleted file mode 100644 index e4bf407d..00000000 --- a/src/it/resources/expected/all_datatypes/python/all_datatypes.py +++ /dev/null @@ -1,46 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from all_datatypes.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files -from djinni.pycffi_marshal import CPyBinary, CPyBoxedBool, CPyDate, CPyEnum, CPyObject, CPyObject, CPyObjectProxy, CPyPrimitive, CPyRecord, CPyString - -from dh__list_bool import ListBoolHelper -from dh__map_int8_t_bool import MapInt8TBoolHelper -from dh__map_int8_t_bool import MapInt8TBoolProxy -from dh__set_bool import SetBoolHelper -from dh__set_bool import SetBoolProxy -from enum_data import EnumData -from _cffi import ffi, lib - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -class AllDatatypes: - c_data_set = MultiSet() - - @staticmethod - def check_c_data_set_empty(): - assert len(AllDatatypes.c_data_set) == 0 - ListBoolHelper.check_c_data_set_empty() - SetBoolHelper.check_c_data_set_empty() - MapInt8TBoolHelper.check_c_data_set_empty() - EnumData.check_c_data_set_empty() - - - def __init__(self, booleanData, integer8Data, integer16Data, integer32Data, integer64Data, float32Data, float64Data, stringData, binaryData, dateData, listData, setData, mapData, optionalData, enum_data): - self.booleanData = booleanData - self.integer8Data = integer8Data - self.integer16Data = integer16Data - self.integer32Data = integer32Data - self.integer64Data = integer64Data - self.float32Data = float32Data - self.float64Data = float64Data - self.stringData = stringData - self.binaryData = binaryData - self.dateData = dateData - self.listData = listData - self.setData = setData - self.mapData = mapData - self.optionalData = optionalData - self.enum_data = enum_data - diff --git a/src/it/resources/expected/all_datatypes/python/all_datatypes_helper.py b/src/it/resources/expected/all_datatypes/python/all_datatypes_helper.py deleted file mode 100644 index 1a4a4454..00000000 --- a/src/it/resources/expected/all_datatypes/python/all_datatypes_helper.py +++ /dev/null @@ -1,216 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from all_datatypes.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files -from djinni.pycffi_marshal import CPyBinary, CPyBoxedBool, CPyDate, CPyEnum, CPyObject, CPyObject, CPyObjectProxy, CPyPrimitive, CPyRecord, CPyString - -from dh__list_bool import ListBoolHelper -from dh__map_int8_t_bool import MapInt8TBoolHelper -from dh__map_int8_t_bool import MapInt8TBoolProxy -from dh__set_bool import SetBoolHelper -from dh__set_bool import SetBoolProxy -from enum_data import EnumData -from _cffi import ffi, lib - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -from all_datatypes import AllDatatypes - -class AllDatatypesHelper: - @staticmethod - def release(c_ptr): - assert c_ptr in c_data_set - c_data_set.remove(ffi.cast("void*", c_ptr)) - - @ffi.callback("bool(struct DjinniRecordHandle *)") - def get_all_datatypes_f1(cself): - try: - _ret = CPyPrimitive.fromPy(CPyRecord.toPy(None, cself).booleanData) - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("int8_t(struct DjinniRecordHandle *)") - def get_all_datatypes_f2(cself): - try: - _ret = CPyPrimitive.fromPy(CPyRecord.toPy(None, cself).integer8Data) - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("int16_t(struct DjinniRecordHandle *)") - def get_all_datatypes_f3(cself): - try: - _ret = CPyPrimitive.fromPy(CPyRecord.toPy(None, cself).integer16Data) - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("int32_t(struct DjinniRecordHandle *)") - def get_all_datatypes_f4(cself): - try: - _ret = CPyPrimitive.fromPy(CPyRecord.toPy(None, cself).integer32Data) - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("int64_t(struct DjinniRecordHandle *)") - def get_all_datatypes_f5(cself): - try: - _ret = CPyPrimitive.fromPy(CPyRecord.toPy(None, cself).integer64Data) - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("float(struct DjinniRecordHandle *)") - def get_all_datatypes_f6(cself): - try: - _ret = CPyPrimitive.fromPy(CPyRecord.toPy(None, cself).float32Data) - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("double(struct DjinniRecordHandle *)") - def get_all_datatypes_f7(cself): - try: - _ret = CPyPrimitive.fromPy(CPyRecord.toPy(None, cself).float64Data) - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("struct DjinniString *(struct DjinniRecordHandle *)") - def get_all_datatypes_f8(cself): - try: - with CPyString.fromPy(CPyRecord.toPy(None, cself).stringData) as py_obj: - _ret = py_obj.release_djinni_string() - assert _ret != ffi.NULL - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("struct DjinniBinary *(struct DjinniRecordHandle *)") - def get_all_datatypes_f9(cself): - try: - with CPyBinary.fromPy(CPyRecord.toPy(None, cself).binaryData) as py_obj: - _ret = py_obj.release_djinni_binary() - assert _ret != ffi.NULL - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("uint64_t(struct DjinniRecordHandle *)") - def get_all_datatypes_f10(cself): - try: - _ret = CPyDate.fromPy(CPyRecord.toPy(None, cself).dateData) - assert _ret != ffi.NULL - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("struct DjinniObjectHandle *(struct DjinniRecordHandle *)") - def get_all_datatypes_f11(cself): - try: - _ret = CPyObject.fromPy(ListBoolHelper.c_data_set, CPyRecord.toPy(None, cself).listData) - assert _ret != ffi.NULL - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("struct DjinniObjectHandle *(struct DjinniRecordHandle *)") - def get_all_datatypes_f12(cself): - try: - _ret = CPyObjectProxy.fromPy(SetBoolHelper.c_data_set, SetBoolProxy(CPyRecord.toPy(None, cself).setData)) - assert _ret != ffi.NULL - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("struct DjinniObjectHandle *(struct DjinniRecordHandle *)") - def get_all_datatypes_f13(cself): - try: - _ret = CPyObjectProxy.fromPy(MapInt8TBoolHelper.c_data_set, MapInt8TBoolProxy(CPyRecord.toPy(None, cself).mapData)) - assert _ret != ffi.NULL - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("struct DjinniBoxedBool *(struct DjinniRecordHandle *)") - def get_all_datatypes_f14(cself): - try: - with CPyBoxedBool.fromPyOpt(CPyRecord.toPy(None, cself).optionalData) as py_obj: - return py_obj.release_djinni_boxed() - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("int(struct DjinniRecordHandle *)") - def get_all_datatypes_f15(cself): - try: - _ret = CPyEnum.fromPy(CPyRecord.toPy(None, cself).enum_data) - assert _ret != -1 - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("struct DjinniRecordHandle *(bool,int8_t,int16_t,int32_t,int64_t,float,double,struct DjinniString *,struct DjinniBinary *,uint64_t,struct DjinniObjectHandle *,struct DjinniObjectHandle *,struct DjinniObjectHandle *,struct DjinniBoxedBool *,int)") - def create_all_datatypes(booleanData,integer8Data,integer16Data,integer32Data,integer64Data,float32Data,float64Data,stringData,binaryData,dateData,listData,setData,mapData,optionalData,enum_data): - py_rec = AllDatatypes( - CPyPrimitive.toPy(booleanData), - CPyPrimitive.toPy(integer8Data), - CPyPrimitive.toPy(integer16Data), - CPyPrimitive.toPy(integer32Data), - CPyPrimitive.toPy(integer64Data), - CPyPrimitive.toPy(float32Data), - CPyPrimitive.toPy(float64Data), - CPyString.toPy(stringData), - CPyBinary.toPy(binaryData), - CPyDate.toPy(dateData), - CPyObject.toPy(ListBoolHelper.c_data_set, listData), - CPyObjectProxy.toPyObj(SetBoolHelper.c_data_set, setData), - CPyObjectProxy.toPyObj(MapInt8TBoolHelper.c_data_set, mapData), - CPyBoxedBool.toPyOpt(optionalData), - CPyEnum.toPy(EnumData, enum_data)) - return CPyRecord.fromPy(AllDatatypes.c_data_set, py_rec) #to do: can be optional? - - @ffi.callback("void (struct DjinniRecordHandle *)") - def __delete(dh): - assert dh in AllDatatypes.c_data_set - AllDatatypes.c_data_set.remove(dh) - - @staticmethod - def _add_callbacks(): - lib.all_datatypes_add_callback___delete(AllDatatypesHelper.__delete) - lib.all_datatypes_add_callback_create_all_datatypes(AllDatatypesHelper.create_all_datatypes) - lib.all_datatypes_add_callback_get_all_datatypes_f1(AllDatatypesHelper.get_all_datatypes_f1) - lib.all_datatypes_add_callback_get_all_datatypes_f10(AllDatatypesHelper.get_all_datatypes_f10) - lib.all_datatypes_add_callback_get_all_datatypes_f11(AllDatatypesHelper.get_all_datatypes_f11) - lib.all_datatypes_add_callback_get_all_datatypes_f12(AllDatatypesHelper.get_all_datatypes_f12) - lib.all_datatypes_add_callback_get_all_datatypes_f13(AllDatatypesHelper.get_all_datatypes_f13) - lib.all_datatypes_add_callback_get_all_datatypes_f14(AllDatatypesHelper.get_all_datatypes_f14) - lib.all_datatypes_add_callback_get_all_datatypes_f15(AllDatatypesHelper.get_all_datatypes_f15) - lib.all_datatypes_add_callback_get_all_datatypes_f2(AllDatatypesHelper.get_all_datatypes_f2) - lib.all_datatypes_add_callback_get_all_datatypes_f3(AllDatatypesHelper.get_all_datatypes_f3) - lib.all_datatypes_add_callback_get_all_datatypes_f4(AllDatatypesHelper.get_all_datatypes_f4) - lib.all_datatypes_add_callback_get_all_datatypes_f5(AllDatatypesHelper.get_all_datatypes_f5) - lib.all_datatypes_add_callback_get_all_datatypes_f6(AllDatatypesHelper.get_all_datatypes_f6) - lib.all_datatypes_add_callback_get_all_datatypes_f7(AllDatatypesHelper.get_all_datatypes_f7) - lib.all_datatypes_add_callback_get_all_datatypes_f8(AllDatatypesHelper.get_all_datatypes_f8) - lib.all_datatypes_add_callback_get_all_datatypes_f9(AllDatatypesHelper.get_all_datatypes_f9) - -AllDatatypesHelper._add_callbacks() - diff --git a/src/it/resources/expected/all_datatypes/python/dh__list_bool.py b/src/it/resources/expected/all_datatypes/python/dh__list_bool.py deleted file mode 100644 index 681f9f29..00000000 --- a/src/it/resources/expected/all_datatypes/python/dh__list_bool.py +++ /dev/null @@ -1,55 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from all_datatypes.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files -from djinni.pycffi_marshal import CPyObject, CPyPrimitive -from _cffi import ffi, lib - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -class ListBoolHelper: - c_data_set = MultiSet() - - @staticmethod - def check_c_data_set_empty(): - assert len(ListBoolHelper.c_data_set) == 0 - - @ffi.callback("bool(struct DjinniObjectHandle *, size_t)") - def __get_elem(cself, index): - try: - _ret = CPyPrimitive.fromPy(CPyObject.toPy(None, cself)[index]) - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("size_t(struct DjinniObjectHandle *)") - def __get_size(cself): - return len(CPyObject.toPy(None, cself)) - - @ffi.callback("struct DjinniObjectHandle *()") - def __create(): - c_ptr = ffi.new_handle(list()) - ListBoolHelper.c_data_set.add(c_ptr) - return ffi.cast("struct DjinniObjectHandle *", c_ptr) - - @ffi.callback("void(struct DjinniObjectHandle *, bool)") - def __add(cself, el): - CPyObject.toPy(None, cself).append(CPyPrimitive.toPy(el)) - - @ffi.callback("void(struct DjinniObjectHandle * )") - def __delete(c_ptr): - assert c_ptr in ListBoolHelper.c_data_set - ListBoolHelper.c_data_set.remove(c_ptr) - - @staticmethod - def _add_callbacks(): - lib.list_bool_add_callback__get_elem(ListBoolHelper.__get_elem) - lib.list_bool_add_callback___delete(ListBoolHelper.__delete) - lib.list_bool_add_callback__get_size(ListBoolHelper.__get_size) - lib.list_bool_add_callback__create(ListBoolHelper.__create) - lib.list_bool_add_callback__add(ListBoolHelper.__add) - -ListBoolHelper._add_callbacks() - diff --git a/src/it/resources/expected/all_datatypes/python/dh__map_int8_t_bool.py b/src/it/resources/expected/all_datatypes/python/dh__map_int8_t_bool.py deleted file mode 100644 index 949e310d..00000000 --- a/src/it/resources/expected/all_datatypes/python/dh__map_int8_t_bool.py +++ /dev/null @@ -1,78 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from all_datatypes.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files -from djinni.pycffi_marshal import CPyObject, CPyObjectProxy, CPyPrimitive -from _cffi import ffi, lib - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -class MapInt8TBoolHelper: - c_data_set = MultiSet() - - @staticmethod - def check_c_data_set_empty(): - assert len(MapInt8TBoolHelper.c_data_set) == 0 - - @ffi.callback("bool(struct DjinniObjectHandle *, int8_t)") - def __get_value(cself, key): - pyKey = CPyPrimitive.toPy(key) - assert pyKey is not None - try: - _ret = CPyPrimitive.fromPy(CPyObjectProxy.toPyObj(None, cself)[pyKey]) - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("size_t(struct DjinniObjectHandle *)") - def __get_size(cself): - return len(CPyObjectProxy.toPyObj(None, cself)) - - @ffi.callback("struct DjinniObjectHandle *()") - def __create(): - c_ptr = ffi.new_handle(MapInt8TBoolProxy(dict())) - MapInt8TBoolHelper.c_data_set.add(c_ptr) - return ffi.cast("struct DjinniObjectHandle *", c_ptr) - - @ffi.callback("void(struct DjinniObjectHandle *, int8_t, bool)") - def __add(cself, key, value): - CPyObjectProxy.toPyObj(None, cself)[CPyPrimitive.toPy(key)] = CPyPrimitive.toPy(value) - - @ffi.callback("void(struct DjinniObjectHandle * )") - def __delete(c_ptr): - assert c_ptr in MapInt8TBoolHelper.c_data_set - MapInt8TBoolHelper.c_data_set.remove(c_ptr) - - @ffi.callback("int8_t(struct DjinniObjectHandle *)") - def __next(cself): - try: - _ret = CPyPrimitive.fromPy(next(CPyObjectProxy.toPyIter(cself))) - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @staticmethod - def _add_callbacks(): - lib.map_int8_t_bool_add_callback__get_value(MapInt8TBoolHelper.__get_value) - lib.map_int8_t_bool_add_callback___delete(MapInt8TBoolHelper.__delete) - lib.map_int8_t_bool_add_callback__get_size(MapInt8TBoolHelper.__get_size) - lib.map_int8_t_bool_add_callback__create(MapInt8TBoolHelper.__create) - lib.map_int8_t_bool_add_callback__add(MapInt8TBoolHelper.__add) - lib.map_int8_t_bool_add_callback__next(MapInt8TBoolHelper.__next) - -MapInt8TBoolHelper._add_callbacks() - -class MapInt8TBoolProxy: - def iter(d): - for k in d: - yield k - - def __init__(self, py_obj): - self._py_obj = py_obj - if py_obj is not None: - self._py_iter = iter(py_obj) - else: - self._py_iter = None diff --git a/src/it/resources/expected/all_datatypes/python/dh__set_bool.py b/src/it/resources/expected/all_datatypes/python/dh__set_bool.py deleted file mode 100644 index ef90d493..00000000 --- a/src/it/resources/expected/all_datatypes/python/dh__set_bool.py +++ /dev/null @@ -1,66 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from all_datatypes.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files -from djinni.pycffi_marshal import CPyObject, CPyObjectProxy, CPyPrimitive -from _cffi import ffi, lib - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -class SetBoolHelper: - c_data_set = MultiSet() - - @staticmethod - def check_c_data_set_empty(): - assert len(SetBoolHelper.c_data_set) == 0 - - @ffi.callback("size_t(struct DjinniObjectHandle *)") - def __get_size(cself): - return len(CPyObjectProxy.toPyObj(None, cself)) - - @ffi.callback("struct DjinniObjectHandle *()") - def __create(): - c_ptr = ffi.new_handle(SetBoolProxy(set())) - SetBoolHelper.c_data_set.add(c_ptr) - return ffi.cast("struct DjinniObjectHandle *", c_ptr) - - @ffi.callback("void(struct DjinniObjectHandle *, bool)") - def __add(cself, el): - CPyObjectProxy.toPyObj(None, cself).add(CPyPrimitive.toPy(el)) - - @ffi.callback("void(struct DjinniObjectHandle * )") - def __delete(c_ptr): - assert c_ptr in SetBoolHelper.c_data_set - SetBoolHelper.c_data_set.remove(c_ptr) - - @ffi.callback("bool(struct DjinniObjectHandle *)") - def __next(cself): - try: - _ret = CPyPrimitive.fromPy(next(CPyObjectProxy.toPyIter(cself))) - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @staticmethod - def _add_callbacks(): - lib.set_bool_add_callback___delete(SetBoolHelper.__delete) - lib.set_bool_add_callback__get_size(SetBoolHelper.__get_size) - lib.set_bool_add_callback__create(SetBoolHelper.__create) - lib.set_bool_add_callback__add(SetBoolHelper.__add) - lib.set_bool_add_callback__next(SetBoolHelper.__next) - -SetBoolHelper._add_callbacks() - -class SetBoolProxy: - def iter(d): - for k in d: - yield k - - def __init__(self, py_obj): - self._py_obj = py_obj - if py_obj is not None: - self._py_iter = iter(py_obj) - else: - self._py_iter = None diff --git a/src/it/resources/expected/all_datatypes/python/enum_data.py b/src/it/resources/expected/all_datatypes/python/enum_data.py deleted file mode 100644 index 71ebf031..00000000 --- a/src/it/resources/expected/all_datatypes/python/enum_data.py +++ /dev/null @@ -1,13 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from all_datatypes.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -from enum import IntEnum - -class EnumData(IntEnum): - A = 0 - B = 1 diff --git a/src/it/resources/expected/cppcli_circular_dependent_interface/cppcli/AnotherInterface.cpp b/src/it/resources/expected/cppcli_circular_dependent_interface/cppcli/AnotherInterface.cpp deleted file mode 100644 index d241b681..00000000 --- a/src/it/resources/expected/cppcli_circular_dependent_interface/cppcli/AnotherInterface.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from cppcli_circular_dependent_interface.djinni - -#include "AnotherInterface.hpp" // my header -#include "djinni/cppcli/Error.hpp" -#include "djinni/cppcli/Marshal.hpp" -#include "djinni/cppcli/WrapperCache.hpp" -#include "one_interface.hpp" - -ref class AnotherInterfaceCppProxy : public AnotherInterface { - using CppType = std::shared_ptr<::AnotherInterface>; - using HandleType = ::djinni::CppProxyCache::Handle; -public: - AnotherInterfaceCppProxy(const CppType& cppRef) : _cppRefHandle(new HandleType(cppRef)) {} - - void MethodTakingOneInterface(OneInterface^ dep) override { - try { - _cppRefHandle->get()->method_taking_one_interface(::OneInterface::ToCpp(dep)); - } DJINNI_TRANSLATE_EXCEPTIONS() - } - - void MethodTakingOptionalOneInterface(OneInterface^ dep) override { - try { - _cppRefHandle->get()->method_taking_optional_one_interface(::djinni::Optional::ToCpp(dep)); - } DJINNI_TRANSLATE_EXCEPTIONS() - } - - OneInterface^ MethodReturningOneInterface() override { - try { - auto cs_result = _cppRefHandle->get()->method_returning_one_interface(); - return ::OneInterface::FromCpp(cs_result); - } DJINNI_TRANSLATE_EXCEPTIONS() - return nullptr; // Unreachable! (Silencing compiler warnings.) - } - - OneInterface^ MethodReturningOptionalOneInterface() override { - try { - auto cs_result = _cppRefHandle->get()->method_returning_optional_one_interface(); - return ::djinni::Optional::FromCpp(cs_result); - } DJINNI_TRANSLATE_EXCEPTIONS() - return nullptr; // Unreachable! (Silencing compiler warnings.) - } - - CppType djinni_private_get_proxied_cpp_object() { - return _cppRefHandle->get(); - } - -private: - AutoPtr _cppRefHandle; -}; - -AnotherInterface::CppType AnotherInterface::ToCpp(AnotherInterface::CsType cs) -{ - if (!cs) { - return nullptr; - } - return dynamic_cast(cs)->djinni_private_get_proxied_cpp_object(); -} - -AnotherInterface::CsType AnotherInterface::FromCppOpt(const AnotherInterface::CppOptType& cpp) -{ - if (!cpp) { - return nullptr; - } - return ::djinni::get_cpp_proxy(cpp); -} diff --git a/src/it/resources/expected/cppcli_circular_dependent_interface/cppcli/AnotherInterface.hpp b/src/it/resources/expected/cppcli_circular_dependent_interface/cppcli/AnotherInterface.hpp deleted file mode 100644 index 25607ef5..00000000 --- a/src/it/resources/expected/cppcli_circular_dependent_interface/cppcli/AnotherInterface.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from cppcli_circular_dependent_interface.djinni - -#pragma once - -#include "../cpp-headers/another_interface.hpp" -#include "OneInterface.hpp" -#include - -ref class OneInterface; - -public ref class AnotherInterface abstract { -public: - virtual void MethodTakingOneInterface(OneInterface^ dep) abstract; - - virtual void MethodTakingOptionalOneInterface(OneInterface^ dep) abstract; - - virtual OneInterface^ MethodReturningOneInterface() abstract; - - virtual OneInterface^ MethodReturningOptionalOneInterface() abstract; - -internal: - using CppType = std::shared_ptr<::AnotherInterface>; - using CppOptType = std::shared_ptr<::AnotherInterface>; - using CsType = AnotherInterface^; - - static CppType ToCpp(CsType cs); - static CsType FromCppOpt(const CppOptType& cpp); - static CsType FromCpp(const CppType& cpp) { return FromCppOpt(cpp); } -}; diff --git a/src/it/resources/expected/cppcli_circular_dependent_interface/cppcli/OneInterface.cpp b/src/it/resources/expected/cppcli_circular_dependent_interface/cppcli/OneInterface.cpp deleted file mode 100644 index b3c3d530..00000000 --- a/src/it/resources/expected/cppcli_circular_dependent_interface/cppcli/OneInterface.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from cppcli_circular_dependent_interface.djinni - -#include "OneInterface.hpp" // my header -#include "another_interface.hpp" -#include "djinni/cppcli/Error.hpp" -#include "djinni/cppcli/Marshal.hpp" -#include "djinni/cppcli/WrapperCache.hpp" - -ref class OneInterfaceCppProxy : public OneInterface { - using CppType = std::shared_ptr<::OneInterface>; - using HandleType = ::djinni::CppProxyCache::Handle; -public: - OneInterfaceCppProxy(const CppType& cppRef) : _cppRefHandle(new HandleType(cppRef)) {} - - void MethodTakingAnotherInterface(AnotherInterface^ dep) override { - try { - _cppRefHandle->get()->method_taking_another_interface(::AnotherInterface::ToCpp(dep)); - } DJINNI_TRANSLATE_EXCEPTIONS() - } - - void MethodTakingOptionalAnotherInterface(AnotherInterface^ dep) override { - try { - _cppRefHandle->get()->method_taking_optional_another_interface(::djinni::Optional::ToCpp(dep)); - } DJINNI_TRANSLATE_EXCEPTIONS() - } - - AnotherInterface^ MethodReturningAnotherInterface() override { - try { - auto cs_result = _cppRefHandle->get()->method_returning_another_interface(); - return ::AnotherInterface::FromCpp(cs_result); - } DJINNI_TRANSLATE_EXCEPTIONS() - return nullptr; // Unreachable! (Silencing compiler warnings.) - } - - AnotherInterface^ MethodReturningOptionalAnotherInterface() override { - try { - auto cs_result = _cppRefHandle->get()->method_returning_optional_another_interface(); - return ::djinni::Optional::FromCpp(cs_result); - } DJINNI_TRANSLATE_EXCEPTIONS() - return nullptr; // Unreachable! (Silencing compiler warnings.) - } - - CppType djinni_private_get_proxied_cpp_object() { - return _cppRefHandle->get(); - } - -private: - AutoPtr _cppRefHandle; -}; - -OneInterface::CppType OneInterface::ToCpp(OneInterface::CsType cs) -{ - if (!cs) { - return nullptr; - } - return dynamic_cast(cs)->djinni_private_get_proxied_cpp_object(); -} - -OneInterface::CsType OneInterface::FromCppOpt(const OneInterface::CppOptType& cpp) -{ - if (!cpp) { - return nullptr; - } - return ::djinni::get_cpp_proxy(cpp); -} diff --git a/src/it/resources/expected/cppcli_circular_dependent_interface/cppcli/OneInterface.hpp b/src/it/resources/expected/cppcli_circular_dependent_interface/cppcli/OneInterface.hpp deleted file mode 100644 index a8b62bd3..00000000 --- a/src/it/resources/expected/cppcli_circular_dependent_interface/cppcli/OneInterface.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from cppcli_circular_dependent_interface.djinni - -#pragma once - -#include "../cpp-headers/one_interface.hpp" -#include "AnotherInterface.hpp" -#include - -ref class AnotherInterface; - -public ref class OneInterface abstract { -public: - virtual void MethodTakingAnotherInterface(AnotherInterface^ dep) abstract; - - virtual void MethodTakingOptionalAnotherInterface(AnotherInterface^ dep) abstract; - - virtual AnotherInterface^ MethodReturningAnotherInterface() abstract; - - virtual AnotherInterface^ MethodReturningOptionalAnotherInterface() abstract; - -internal: - using CppType = std::shared_ptr<::OneInterface>; - using CppOptType = std::shared_ptr<::OneInterface>; - using CsType = OneInterface^; - - static CppType ToCpp(CsType cs); - static CsType FromCppOpt(const CppOptType& cpp); - static CsType FromCpp(const CppType& cpp) { return FromCppOpt(cpp); } -}; diff --git a/src/it/resources/expected/cppcli_circular_dependent_interface/generated-files.txt b/src/it/resources/expected/cppcli_circular_dependent_interface/generated-files.txt deleted file mode 100644 index 55b5ce2f..00000000 --- a/src/it/resources/expected/cppcli_circular_dependent_interface/generated-files.txt +++ /dev/null @@ -1,4 +0,0 @@ -src/it/resources/result/cppcli_circular_dependent_interface/cppcli/OneInterface.hpp -src/it/resources/result/cppcli_circular_dependent_interface/cppcli/OneInterface.cpp -src/it/resources/result/cppcli_circular_dependent_interface/cppcli/AnotherInterface.hpp -src/it/resources/result/cppcli_circular_dependent_interface/cppcli/AnotherInterface.cpp diff --git a/src/it/resources/expected/cppcli_extern_dependent_interface/cppcli/DependentInterface.cpp b/src/it/resources/expected/cppcli_extern_dependent_interface/cppcli/DependentInterface.cpp deleted file mode 100644 index ca3c50b0..00000000 --- a/src/it/resources/expected/cppcli_extern_dependent_interface/cppcli/DependentInterface.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from cppcli_extern_dependent_interface.djinni - -#include "DependentInterface.hpp" // my header -#include "djinni/cppcli/Error.hpp" -#include "djinni/cppcli/Marshal.hpp" -#include "djinni/cppcli/WrapperCache.hpp" - -ref class DependentInterfaceCppProxy : public DependentInterface { - using CppType = std::shared_ptr<::DependentInterface>; - using HandleType = ::djinni::CppProxyCache::Handle; -public: - DependentInterfaceCppProxy(const CppType& cppRef) : _cppRefHandle(new HandleType(cppRef)) {} - - void MethodTakingInterfaceDependency(InterfaceDependency^ dep) override { - try { - _cppRefHandle->get()->method_taking_interface_dependency(::InterfaceDependency::ToCpp(dep)); - } DJINNI_TRANSLATE_EXCEPTIONS() - } - - void MethodTakingOptionalInterfaceDependency(InterfaceDependency^ dep) override { - try { - _cppRefHandle->get()->method_taking_optional_interface_dependency(::djinni::Optional::ToCpp(dep)); - } DJINNI_TRANSLATE_EXCEPTIONS() - } - - InterfaceDependency^ MethodReturningInterfaceDependency() override { - try { - auto cs_result = _cppRefHandle->get()->method_returning_interface_dependency(); - return ::InterfaceDependency::FromCpp(cs_result); - } DJINNI_TRANSLATE_EXCEPTIONS() - return nullptr; // Unreachable! (Silencing compiler warnings.) - } - - InterfaceDependency^ MethodReturningOptionalInterfaceDependency() override { - try { - auto cs_result = _cppRefHandle->get()->method_returning_optional_interface_dependency(); - return ::djinni::Optional::FromCpp(cs_result); - } DJINNI_TRANSLATE_EXCEPTIONS() - return nullptr; // Unreachable! (Silencing compiler warnings.) - } - - CppType djinni_private_get_proxied_cpp_object() { - return _cppRefHandle->get(); - } - -private: - AutoPtr _cppRefHandle; -}; - -DependentInterface::CppType DependentInterface::ToCpp(DependentInterface::CsType cs) -{ - if (!cs) { - return nullptr; - } - return dynamic_cast(cs)->djinni_private_get_proxied_cpp_object(); -} - -DependentInterface::CsType DependentInterface::FromCppOpt(const DependentInterface::CppOptType& cpp) -{ - if (!cpp) { - return nullptr; - } - return ::djinni::get_cpp_proxy(cpp); -} diff --git a/src/it/resources/expected/cppcli_extern_dependent_interface/cppcli/DependentInterface.hpp b/src/it/resources/expected/cppcli_extern_dependent_interface/cppcli/DependentInterface.hpp deleted file mode 100644 index 163f8442..00000000 --- a/src/it/resources/expected/cppcli_extern_dependent_interface/cppcli/DependentInterface.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from cppcli_extern_dependent_interface.djinni - -#pragma once - -#include "../cpp-headers/dependent_interface.hpp" -#include "InterfaceDependency.hpp" -#include - -public ref class DependentInterface abstract { -public: - virtual void MethodTakingInterfaceDependency(InterfaceDependency^ dep) abstract; - - virtual void MethodTakingOptionalInterfaceDependency(InterfaceDependency^ dep) abstract; - - virtual InterfaceDependency^ MethodReturningInterfaceDependency() abstract; - - virtual InterfaceDependency^ MethodReturningOptionalInterfaceDependency() abstract; - -internal: - using CppType = std::shared_ptr<::DependentInterface>; - using CppOptType = std::shared_ptr<::DependentInterface>; - using CsType = DependentInterface^; - - static CppType ToCpp(CsType cs); - static CsType FromCppOpt(const CppOptType& cpp); - static CsType FromCpp(const CppType& cpp) { return FromCppOpt(cpp); } -}; diff --git a/src/it/resources/expected/cppcli_extern_dependent_interface/generated-files.txt b/src/it/resources/expected/cppcli_extern_dependent_interface/generated-files.txt deleted file mode 100644 index 28db92ca..00000000 --- a/src/it/resources/expected/cppcli_extern_dependent_interface/generated-files.txt +++ /dev/null @@ -1,2 +0,0 @@ -src/it/resources/result/cppcli_extern_dependent_interface/cppcli/DependentInterface.hpp -src/it/resources/result/cppcli_extern_dependent_interface/cppcli/DependentInterface.cpp diff --git a/src/it/resources/expected/cppcli_interface_nonnull/cppcli/MyCppInterface.cpp b/src/it/resources/expected/cppcli_interface_nonnull/cppcli/MyCppInterface.cpp deleted file mode 100644 index 877ab62c..00000000 --- a/src/it/resources/expected/cppcli_interface_nonnull/cppcli/MyCppInterface.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from cppcli_interface_nonnull.djinni - -#include "MyCppInterface.hpp" // my header -#include "djinni/cppcli/Error.hpp" -#include "djinni/cppcli/Marshal.hpp" -#include "djinni/cppcli/WrapperCache.hpp" - -int MyCppInterface::GetVersion() { - try { - auto cs_result = ::MyCppInterface::get_version(); - return ::djinni::I32::FromCpp(cs_result); - } DJINNI_TRANSLATE_EXCEPTIONS() - return 0; // Unreachable! (Silencing compiler warnings.) -} - -ref class MyCppInterfaceCppProxy : public MyCppInterface { - using CppType = std::shared_ptr<::MyCppInterface>; - using HandleType = ::djinni::CppProxyCache::Handle; -public: - MyCppInterfaceCppProxy(const CppType& cppRef) : _cppRefHandle(new HandleType(cppRef)) {} - - void MethodReturningNothing(int value) override { - try { - _cppRefHandle->get()->method_returning_nothing(::djinni::I32::ToCpp(value)); - } DJINNI_TRANSLATE_EXCEPTIONS() - } - - int MethodReturningSomeType(System::String^ key) override { - try { - auto cs_result = _cppRefHandle->get()->method_returning_some_type(::djinni::String::ToCpp(key)); - return ::djinni::I32::FromCpp(cs_result); - } DJINNI_TRANSLATE_EXCEPTIONS() - return 0; // Unreachable! (Silencing compiler warnings.) - } - - int MethodChangingNothing() override { - try { - auto cs_result = _cppRefHandle->get()->method_changing_nothing(); - return ::djinni::I32::FromCpp(cs_result); - } DJINNI_TRANSLATE_EXCEPTIONS() - return 0; // Unreachable! (Silencing compiler warnings.) - } - - CppType djinni_private_get_proxied_cpp_object() { - return _cppRefHandle->get(); - } - -private: - AutoPtr _cppRefHandle; -}; - -MyCppInterface::CppType MyCppInterface::ToCpp(MyCppInterface::CsType cs) -{ - if (!cs) { - throw gcnew System::Exception("MyCppInterface::ToCpp requires non-nil object."); - } - return NN_CHECK_ASSERT(dynamic_cast(cs)->djinni_private_get_proxied_cpp_object()); -} - -MyCppInterface::CsType MyCppInterface::FromCppOpt(const MyCppInterface::CppOptType& cpp) -{ - if (!cpp) { - return nullptr; - } - return ::djinni::get_cpp_proxy(cpp); -} diff --git a/src/it/resources/expected/cppcli_interface_nonnull/cppcli/MyCppInterface.hpp b/src/it/resources/expected/cppcli_interface_nonnull/cppcli/MyCppInterface.hpp deleted file mode 100644 index da17721f..00000000 --- a/src/it/resources/expected/cppcli_interface_nonnull/cppcli/MyCppInterface.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from cppcli_interface_nonnull.djinni - -#pragma once - -#include "../cpp-headers/my_cpp_interface.hpp" -#include "nn.hpp" -#include - -/** interface comment */ -public ref class MyCppInterface abstract { -public: - /** method comment */ - virtual void MethodReturningNothing(int value) abstract; - - virtual int MethodReturningSomeType(System::String^ key) abstract; - - virtual int MethodChangingNothing() abstract; - - static int GetVersion(); - -internal: - using CppType = dropbox::oxygen::nn_shared_ptr<::MyCppInterface>; - using CppOptType = std::shared_ptr<::MyCppInterface>; - using CsType = MyCppInterface^; - - static CppType ToCpp(CsType cs); - static CsType FromCppOpt(const CppOptType& cpp); - static CsType FromCpp(const CppType& cpp) { return FromCppOpt(cpp); } -}; diff --git a/src/it/resources/expected/cppcli_interface_nonnull/generated-files.txt b/src/it/resources/expected/cppcli_interface_nonnull/generated-files.txt deleted file mode 100644 index cf027269..00000000 --- a/src/it/resources/expected/cppcli_interface_nonnull/generated-files.txt +++ /dev/null @@ -1,2 +0,0 @@ -src/it/resources/result/cppcli_interface_nonnull/cppcli/MyCppInterface.hpp -src/it/resources/result/cppcli_interface_nonnull/cppcli/MyCppInterface.cpp diff --git a/src/it/resources/expected/extern_generics/cppcli/MyRecord.cpp b/src/it/resources/expected/extern_generics/cppcli/MyRecord.cpp deleted file mode 100644 index 9be52d0f..00000000 --- a/src/it/resources/expected/extern_generics/cppcli/MyRecord.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from extern_generics.djinni - -#include "MyRecord.hpp" // my header -#include "djinni/cppcli/Marshal.hpp" -#include - -MyRecord::MyRecord(System::Collections::Generic::List^ builtin, - System::Collections::Generic::List^ external, - System::Collections::Generic::List^ optionalBuiltin, - System::Collections::Generic::List^ optionalExternal, - System::Collections::Generic::List^>^ listOfList, - System::Collections::Generic::List^>^ listOfExternal) -: _builtin(builtin) -, _external(external) -, _optionalBuiltin(optionalBuiltin) -, _optionalExternal(optionalExternal) -, _listOfList(listOfList) -, _listOfExternal(listOfExternal) -{} - -System::Collections::Generic::List^ MyRecord::Builtin::get() -{ - return _builtin; -} - -System::Collections::Generic::List^ MyRecord::External::get() -{ - return _external; -} - -System::Collections::Generic::List^ MyRecord::OptionalBuiltin::get() -{ - return _optionalBuiltin; -} - -System::Collections::Generic::List^ MyRecord::OptionalExternal::get() -{ - return _optionalExternal; -} - -System::Collections::Generic::List^>^ MyRecord::ListOfList::get() -{ - return _listOfList; -} - -System::Collections::Generic::List^>^ MyRecord::ListOfExternal::get() -{ - return _listOfExternal; -} - -System::String^ MyRecord::ToString() -{ - return System::String::Format("MyRecord {{Builtin{0}, External{1}, OptionalBuiltin{2}, OptionalExternal{3}, ListOfList{4}, ListOfExternal{5}}}", - Builtin, - External, - OptionalBuiltin, - OptionalExternal, - ListOfList, - ListOfExternal); -} - -bool MyRecord::Equals(MyRecord^ other) { - if (ReferenceEquals(nullptr, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Builtin->Equals(other->Builtin) && External->Equals(other->External) && OptionalBuiltin.Equals(other->OptionalBuiltin) && OptionalExternal.Equals(other->OptionalExternal) && ListOfList->Equals(other->ListOfList) && ListOfExternal->Equals(other->ListOfExternal); -} - -bool MyRecord::Equals(System::Object^ obj) { - if (ReferenceEquals(nullptr, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj->GetType() == GetType() && Equals((MyRecord^) obj); -} - -int MyRecord::GetHashCode() { - auto hashCode = Builtin->GetHashCode(); - hashCode = (hashCode * 397) ^ External->GetHashCode(); - hashCode = (hashCode * 397) ^ OptionalBuiltin.GetHashCode(); - hashCode = (hashCode * 397) ^ OptionalExternal.GetHashCode(); - hashCode = (hashCode * 397) ^ ListOfList->GetHashCode(); - hashCode = (hashCode * 397) ^ ListOfExternal->GetHashCode(); - return hashCode; -} - -MyRecord::CppType MyRecord::ToCpp(MyRecord::CsType cs) -{ - ASSERT(cs != nullptr); - return {::djinni::List<::djinni::String>::ToCpp(cs->Builtin), - ::djinni::List<::djinni::String>::ToCpp(cs->External), - ::djinni::Optional>::ToCpp(cs->OptionalBuiltin), - ::djinni::Optional>::ToCpp(cs->OptionalExternal), - ::djinni::List<::djinni::List<::djinni::String>>::ToCpp(cs->ListOfList), - ::djinni::List<::djinni::List<::djinni::String>>::ToCpp(cs->ListOfExternal)}; -} - -MyRecord::CsType MyRecord::FromCpp(const MyRecord::CppType& cpp) -{ - return gcnew MyRecord(::djinni::List<::djinni::String>::FromCpp(cpp.builtin), - ::djinni::List<::djinni::String>::FromCpp(cpp.external), - ::djinni::Optional>::FromCpp(cpp.optional_builtin), - ::djinni::Optional>::FromCpp(cpp.optional_external), - ::djinni::List<::djinni::List<::djinni::String>>::FromCpp(cpp.list_of_list), - ::djinni::List<::djinni::List<::djinni::String>>::FromCpp(cpp.list_of_external)); -} diff --git a/src/it/resources/expected/extern_generics/cppcli/MyRecord.hpp b/src/it/resources/expected/extern_generics/cppcli/MyRecord.hpp deleted file mode 100644 index 8f2c2dda..00000000 --- a/src/it/resources/expected/extern_generics/cppcli/MyRecord.hpp +++ /dev/null @@ -1,71 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from extern_generics.djinni - -#pragma once - -#include "../cpp-headers/my_record.hpp" -#include "djinni/cppcli/Marshal.hpp" - -/** record comment */ -[System::Serializable] -public ref class MyRecord : System::IEquatable { -public: - - property System::Collections::Generic::List^ Builtin - { - System::Collections::Generic::List^ get(); - } - - property System::Collections::Generic::List^ External - { - System::Collections::Generic::List^ get(); - } - - property System::Collections::Generic::List^ OptionalBuiltin - { - System::Collections::Generic::List^ get(); - } - - property System::Collections::Generic::List^ OptionalExternal - { - System::Collections::Generic::List^ get(); - } - - property System::Collections::Generic::List^>^ ListOfList - { - System::Collections::Generic::List^>^ get(); - } - - property System::Collections::Generic::List^>^ ListOfExternal - { - System::Collections::Generic::List^>^ get(); - } - - MyRecord(System::Collections::Generic::List^ builtin, - System::Collections::Generic::List^ external, - System::Collections::Generic::List^ optionalBuiltin, - System::Collections::Generic::List^ optionalExternal, - System::Collections::Generic::List^>^ listOfList, - System::Collections::Generic::List^>^ listOfExternal); - - System::String^ ToString() override; - - virtual bool Equals(MyRecord^ other); - bool Equals(System::Object^ obj) override; - int GetHashCode() override; - -internal: - using CppType = ::MyRecord; - using CsType = MyRecord^; - - static CppType ToCpp(CsType cs); - static CsType FromCpp(const CppType& cpp); - -private: - System::Collections::Generic::List^ _builtin; - System::Collections::Generic::List^ _external; - System::Collections::Generic::List^ _optionalBuiltin; - System::Collections::Generic::List^ _optionalExternal; - System::Collections::Generic::List^>^ _listOfList; - System::Collections::Generic::List^>^ _listOfExternal; -}; diff --git a/src/it/resources/expected/my_client_interface/cffi/pycffi_lib_build.py b/src/it/resources/expected/my_client_interface/cffi/pycffi_lib_build.py deleted file mode 100644 index a77e8fb7..00000000 --- a/src/it/resources/expected/my_client_interface/cffi/pycffi_lib_build.py +++ /dev/null @@ -1,25 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from my_client_interface.djinni - -import sys -from cffi import FFI -from djinni.support import * -ffi = FFI() - -args = sys.argv[1:] -cdef_headers = sort_by_import_order(clean_headers_for(args, 'python_cdef_ignore')) -setsource_headers = sort_by_import_order(clean_headers_for(args, 'python_setsource_ignore')) - -f = open('clean_headers.h', 'w') -f.write(setsource_headers) -f.close() - -ffi.set_source('_cffi', '''#include "clean_headers.h"''', - runtime_library_dirs=['.']) - -ffi.cdef("typedef _Bool bool;" - + cdef_headers) - -if __name__ == '__main__': - ffi.compile() - diff --git a/src/it/resources/expected/my_client_interface/cppcli/MyClientInterface.cpp b/src/it/resources/expected/my_client_interface/cppcli/MyClientInterface.cpp deleted file mode 100644 index 1e9510b2..00000000 --- a/src/it/resources/expected/my_client_interface/cppcli/MyClientInterface.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_client_interface.djinni - -#include "MyClientInterface.hpp" // my header -#include "djinni/cppcli/Error.hpp" -#include "djinni/cppcli/Marshal.hpp" -#include "djinni/cppcli/WrapperCache.hpp" - -class MyClientInterfaceCsProxy : public ::MyClientInterface { - using CsType = ::MyClientInterface^; - using CsRefType = ::djinni::CsRef; - using HandleType = ::djinni::CsProxyCache::Handle<::djinni::CsRef>; -public: - MyClientInterfaceCsProxy(CsRefType cs) : m_djinni_private_proxy_handle(std::move(cs)) {} - MyClientInterfaceCsProxy(const ::djinni::CsRef& ptr) : MyClientInterfaceCsProxy(CsRefType(dynamic_cast(ptr.get()))) {} - - bool log_string(const std::string & str) override - { - auto cs_result = djinni_private_get_proxied_cs_object()->LogString(::djinni::String::FromCpp(str)); - // TODO check cs_result for null - return ::djinni::Bool::ToCpp(cs_result); - } - - CsType djinni_private_get_proxied_cs_object() { - return m_djinni_private_proxy_handle.get().get(); - } - -private: - HandleType m_djinni_private_proxy_handle; -}; - -MyClientInterface::CppType MyClientInterface::ToCpp(MyClientInterface::CsType cs) -{ - if (!cs) { - return nullptr; - } - return ::djinni::get_cs_proxy(cs); -} - -MyClientInterface::CsType MyClientInterface::FromCppOpt(const MyClientInterface::CppOptType& cpp) -{ - if (!cpp) { - return nullptr; - } - return dynamic_cast(cpp.get())->djinni_private_get_proxied_cs_object(); -} diff --git a/src/it/resources/expected/my_client_interface/cppcli/MyClientInterface.hpp b/src/it/resources/expected/my_client_interface/cppcli/MyClientInterface.hpp deleted file mode 100644 index 35fa34b5..00000000 --- a/src/it/resources/expected/my_client_interface/cppcli/MyClientInterface.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_client_interface.djinni - -#pragma once - -#include "../cpp-headers/my_client_interface.hpp" -#include - -public ref class MyClientInterface abstract { -public: - virtual bool LogString(System::String^ str) abstract; - -internal: - using CppType = std::shared_ptr<::MyClientInterface>; - using CppOptType = std::shared_ptr<::MyClientInterface>; - using CsType = MyClientInterface^; - - static CppType ToCpp(CsType cs); - static CsType FromCppOpt(const CppOptType& cpp); - static CsType FromCpp(const CppType& cpp) { return FromCppOpt(cpp); } -}; diff --git a/src/it/resources/expected/my_client_interface/cwrapper-headers/cw__my_client_interface.h b/src/it/resources/expected/my_client_interface/cwrapper-headers/cw__my_client_interface.h deleted file mode 100644 index f12ad43d..00000000 --- a/src/it/resources/expected/my_client_interface/cwrapper-headers/cw__my_client_interface.h +++ /dev/null @@ -1,11 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_client_interface.djinni - -#pragma once // python_cdef_ignore -#include // python_cdef_ignore - -#include // python_cdef_ignore - -struct DjinniWrapperMyClientInterface; -void my_client_interface___wrapper_dec_ref(struct DjinniWrapperMyClientInterface * dh); -void my_client_interface___wrapper_add_ref(struct DjinniWrapperMyClientInterface * dh); diff --git a/src/it/resources/expected/my_client_interface/cwrapper/cw__my_client_interface.cpp b/src/it/resources/expected/my_client_interface/cwrapper/cw__my_client_interface.cpp deleted file mode 100644 index 3ab093a7..00000000 --- a/src/it/resources/expected/my_client_interface/cwrapper/cw__my_client_interface.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_client_interface.djinni - -#include // for debugging -#include -#include "djinni/cwrapper/wrapper_marshal.hpp" -#include "../cpp-headers/my_client_interface.hpp" - -#include "cw__my_client_interface.hpp" - -std::shared_ptr<::MyClientInterface> DjinniWrapperMyClientInterface::get(djinni::WrapperRef dw) { - if (dw) { - return dw->wrapped_obj; - } - return nullptr; -} - -void my_client_interface___wrapper_add_ref(DjinniWrapperMyClientInterface * dh) { - dh->ref_count.fetch_add(1); -} -void my_client_interface___wrapper_dec_ref(DjinniWrapperMyClientInterface * dh) { - const size_t ref = dh->ref_count.fetch_sub(1); - if (ref == 1) {// value before sub is returned - delete dh; - } -} -djinni::Handle DjinniWrapperMyClientInterface::wrap(std::shared_ptr<::MyClientInterface> obj) { - if (obj) - return djinni::Handle(new DjinniWrapperMyClientInterface{ std::move(obj) }, my_client_interface___wrapper_dec_ref); - return nullptr; -} - diff --git a/src/it/resources/expected/my_client_interface/cwrapper/cw__my_client_interface.hpp b/src/it/resources/expected/my_client_interface/cwrapper/cw__my_client_interface.hpp deleted file mode 100644 index 26e309ea..00000000 --- a/src/it/resources/expected/my_client_interface/cwrapper/cw__my_client_interface.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_client_interface.djinni - -#pragma once - -#include -#include -#include "../cpp-headers/my_client_interface.hpp" -#ifdef __cplusplus -extern "C" { -#endif - -#include "../cwrapper-headers/cw__my_client_interface.h" - -#ifdef __cplusplus -} -#endif -struct DjinniWrapperMyClientInterface final { - DjinniWrapperMyClientInterface(std::shared_ptr<::MyClientInterface>wo): wrapped_obj(wo) {}; - - static std::shared_ptr<::MyClientInterface> get(djinni::Handle dw); - static djinni::Handle wrap(std::shared_ptr<::MyClientInterface> obj); - - const std::shared_ptr<::MyClientInterface> wrapped_obj; - std::atomic ref_count {1}; -}; diff --git a/src/it/resources/expected/my_client_interface/generated-files.txt b/src/it/resources/expected/my_client_interface/generated-files.txt index 09c24044..2c63be44 100644 --- a/src/it/resources/expected/my_client_interface/generated-files.txt +++ b/src/it/resources/expected/my_client_interface/generated-files.txt @@ -7,10 +7,3 @@ src/it/resources/result/my_client_interface/objc-headers/ITMyClientInterface.h src/it/resources/result/my_client_interface/objcpp-headers/ITMyClientInterface+Private.h src/it/resources/result/my_client_interface/objcpp/ITMyClientInterface+Private.mm src/it/resources/result/my_client_interface/objc-headers/bridging-header.h -src/it/resources/result/my_client_interface/cppcli/MyClientInterface.hpp -src/it/resources/result/my_client_interface/cppcli/MyClientInterface.cpp -src/it/resources/result/my_client_interface/python/my_client_interface.py -src/it/resources/result/my_client_interface/cwrapper-headers/cw__my_client_interface.h -src/it/resources/result/my_client_interface/cwrapper/cw__my_client_interface.hpp -src/it/resources/result/my_client_interface/cwrapper/cw__my_client_interface.cpp -src/it/resources/result/my_client_interface/cffi/pycffi_lib_build.py diff --git a/src/it/resources/expected/my_client_interface/python/my_client_interface.py b/src/it/resources/expected/my_client_interface/python/my_client_interface.py deleted file mode 100644 index 5c78fd32..00000000 --- a/src/it/resources/expected/my_client_interface/python/my_client_interface.py +++ /dev/null @@ -1,19 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from my_client_interface.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files -from djinni.pycffi_marshal import CPyPrimitive, CPyString - -from abc import ABCMeta, abstractmethod -from future.utils import with_metaclass -from _cffi import ffi, lib - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -class MyClientInterface(with_metaclass(ABCMeta)): - @abstractmethod - def log_string(self, str): - raise NotImplementedError - - diff --git a/src/it/resources/expected/my_cpp_interface/cffi/pycffi_lib_build.py b/src/it/resources/expected/my_cpp_interface/cffi/pycffi_lib_build.py deleted file mode 100644 index eb25a548..00000000 --- a/src/it/resources/expected/my_cpp_interface/cffi/pycffi_lib_build.py +++ /dev/null @@ -1,25 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from my_cpp_interface.djinni - -import sys -from cffi import FFI -from djinni.support import * -ffi = FFI() - -args = sys.argv[1:] -cdef_headers = sort_by_import_order(clean_headers_for(args, 'python_cdef_ignore')) -setsource_headers = sort_by_import_order(clean_headers_for(args, 'python_setsource_ignore')) - -f = open('clean_headers.h', 'w') -f.write(setsource_headers) -f.close() - -ffi.set_source('_cffi', '''#include "clean_headers.h"''', - runtime_library_dirs=['.']) - -ffi.cdef("typedef _Bool bool;" - + cdef_headers) - -if __name__ == '__main__': - ffi.compile() - diff --git a/src/it/resources/expected/my_cpp_interface/cppcli/MyCppInterface.cpp b/src/it/resources/expected/my_cpp_interface/cppcli/MyCppInterface.cpp deleted file mode 100644 index 348f132d..00000000 --- a/src/it/resources/expected/my_cpp_interface/cppcli/MyCppInterface.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_cpp_interface.djinni - -#include "MyCppInterface.hpp" // my header -#include "djinni/cppcli/Error.hpp" -#include "djinni/cppcli/Marshal.hpp" -#include "djinni/cppcli/WrapperCache.hpp" - -int MyCppInterface::GetVersion() { - try { - auto cs_result = ::MyCppInterface::get_version(); - return ::djinni::I32::FromCpp(cs_result); - } DJINNI_TRANSLATE_EXCEPTIONS() - return 0; // Unreachable! (Silencing compiler warnings.) -} - -ref class MyCppInterfaceCppProxy : public MyCppInterface { - using CppType = std::shared_ptr<::MyCppInterface>; - using HandleType = ::djinni::CppProxyCache::Handle; -public: - MyCppInterfaceCppProxy(const CppType& cppRef) : _cppRefHandle(new HandleType(cppRef)) {} - - void MethodReturningNothing(int value) override { - try { - _cppRefHandle->get()->method_returning_nothing(::djinni::I32::ToCpp(value)); - } DJINNI_TRANSLATE_EXCEPTIONS() - } - - int MethodReturningSomeType(System::String^ key) override { - try { - auto cs_result = _cppRefHandle->get()->method_returning_some_type(::djinni::String::ToCpp(key)); - return ::djinni::I32::FromCpp(cs_result); - } DJINNI_TRANSLATE_EXCEPTIONS() - return 0; // Unreachable! (Silencing compiler warnings.) - } - - int MethodChangingNothing() override { - try { - auto cs_result = _cppRefHandle->get()->method_changing_nothing(); - return ::djinni::I32::FromCpp(cs_result); - } DJINNI_TRANSLATE_EXCEPTIONS() - return 0; // Unreachable! (Silencing compiler warnings.) - } - - CppType djinni_private_get_proxied_cpp_object() { - return _cppRefHandle->get(); - } - -private: - AutoPtr _cppRefHandle; -}; - -MyCppInterface::CppType MyCppInterface::ToCpp(MyCppInterface::CsType cs) -{ - if (!cs) { - return nullptr; - } - return dynamic_cast(cs)->djinni_private_get_proxied_cpp_object(); -} - -MyCppInterface::CsType MyCppInterface::FromCppOpt(const MyCppInterface::CppOptType& cpp) -{ - if (!cpp) { - return nullptr; - } - return ::djinni::get_cpp_proxy(cpp); -} diff --git a/src/it/resources/expected/my_cpp_interface/cppcli/MyCppInterface.hpp b/src/it/resources/expected/my_cpp_interface/cppcli/MyCppInterface.hpp deleted file mode 100644 index 4c527e98..00000000 --- a/src/it/resources/expected/my_cpp_interface/cppcli/MyCppInterface.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_cpp_interface.djinni - -#pragma once - -#include "../cpp-headers/my_cpp_interface.hpp" -#include - -/** interface comment */ -public ref class MyCppInterface abstract { -public: - /** method comment */ - virtual void MethodReturningNothing(int value) abstract; - - virtual int MethodReturningSomeType(System::String^ key) abstract; - - virtual int MethodChangingNothing() abstract; - - static int GetVersion(); - -internal: - using CppType = std::shared_ptr<::MyCppInterface>; - using CppOptType = std::shared_ptr<::MyCppInterface>; - using CsType = MyCppInterface^; - - static CppType ToCpp(CsType cs); - static CsType FromCppOpt(const CppOptType& cpp); - static CsType FromCpp(const CppType& cpp) { return FromCppOpt(cpp); } -}; diff --git a/src/it/resources/expected/my_cpp_interface/cwrapper-headers/cw__my_cpp_interface.h b/src/it/resources/expected/my_cpp_interface/cwrapper-headers/cw__my_cpp_interface.h deleted file mode 100644 index 450e9027..00000000 --- a/src/it/resources/expected/my_cpp_interface/cwrapper-headers/cw__my_cpp_interface.h +++ /dev/null @@ -1,20 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_cpp_interface.djinni - -#pragma once // python_cdef_ignore -#include // python_cdef_ignore - -#include // python_cdef_ignore - -struct DjinniWrapperMyCppInterface; -void my_cpp_interface___wrapper_dec_ref(struct DjinniWrapperMyCppInterface * dh); -void my_cpp_interface___wrapper_add_ref(struct DjinniWrapperMyCppInterface * dh); - -void cw__my_cpp_interface_method_returning_nothing(struct DjinniWrapperMyCppInterface * djinni_this, int32_t value); - -int32_t cw__my_cpp_interface_method_returning_some_type(struct DjinniWrapperMyCppInterface * djinni_this, struct DjinniString * key); - -int32_t cw__my_cpp_interface_method_changing_nothing(struct DjinniWrapperMyCppInterface * djinni_this); - -int32_t cw__my_cpp_interface_get_version(void); - diff --git a/src/it/resources/expected/my_cpp_interface/cwrapper/cw__my_cpp_interface.cpp b/src/it/resources/expected/my_cpp_interface/cwrapper/cw__my_cpp_interface.cpp deleted file mode 100644 index 73b02686..00000000 --- a/src/it/resources/expected/my_cpp_interface/cwrapper/cw__my_cpp_interface.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_cpp_interface.djinni - -#include // for debugging -#include -#include "djinni/cwrapper/wrapper_marshal.hpp" -#include "../cpp-headers/my_cpp_interface.hpp" - -#include "cw__my_cpp_interface.hpp" - -std::shared_ptr<::MyCppInterface> DjinniWrapperMyCppInterface::get(djinni::WrapperRef dw) { - if (dw) { - return dw->wrapped_obj; - } - return nullptr; -} - -void my_cpp_interface___wrapper_add_ref(DjinniWrapperMyCppInterface * dh) { - dh->ref_count.fetch_add(1); -} -void my_cpp_interface___wrapper_dec_ref(DjinniWrapperMyCppInterface * dh) { - const size_t ref = dh->ref_count.fetch_sub(1); - if (ref == 1) {// value before sub is returned - delete dh; - } -} -djinni::Handle DjinniWrapperMyCppInterface::wrap(std::shared_ptr<::MyCppInterface> obj) { - if (obj) - return djinni::Handle(new DjinniWrapperMyCppInterface{ std::move(obj) }, my_cpp_interface___wrapper_dec_ref); - return nullptr; -} - -void cw__my_cpp_interface_method_returning_nothing(DjinniWrapperMyCppInterface * djinni_this, int32_t value) { - try { - djinni_this->wrapped_obj->method_returning_nothing(value); - } CW_TRANSLATE_EXCEPTIONS_RETURN(); -} - -int32_t cw__my_cpp_interface_method_returning_some_type(DjinniWrapperMyCppInterface * djinni_this, DjinniString * key) { - std::unique_ptr _key(key); - try { - return djinni_this->wrapped_obj->method_returning_some_type(DjinniString::toCpp(std::move(_key))); - } CW_TRANSLATE_EXCEPTIONS_RETURN(0); -} - -int32_t cw__my_cpp_interface_method_changing_nothing(DjinniWrapperMyCppInterface * djinni_this) { - try { - return djinni_this->wrapped_obj->method_changing_nothing(); - } CW_TRANSLATE_EXCEPTIONS_RETURN(0); -} -int32_t cw__my_cpp_interface_get_version(void) { - try { - return ::MyCppInterface::get_version(); - } CW_TRANSLATE_EXCEPTIONS_RETURN(0); -} diff --git a/src/it/resources/expected/my_cpp_interface/cwrapper/cw__my_cpp_interface.hpp b/src/it/resources/expected/my_cpp_interface/cwrapper/cw__my_cpp_interface.hpp deleted file mode 100644 index 7957212b..00000000 --- a/src/it/resources/expected/my_cpp_interface/cwrapper/cw__my_cpp_interface.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_cpp_interface.djinni - -#pragma once - -#include -#include -#include "../cpp-headers/my_cpp_interface.hpp" -#ifdef __cplusplus -extern "C" { -#endif - -#include "../cwrapper-headers/cw__my_cpp_interface.h" - -#ifdef __cplusplus -} -#endif -struct DjinniWrapperMyCppInterface final { - DjinniWrapperMyCppInterface(std::shared_ptr<::MyCppInterface>wo): wrapped_obj(wo) {}; - - static std::shared_ptr<::MyCppInterface> get(djinni::Handle dw); - static djinni::Handle wrap(std::shared_ptr<::MyCppInterface> obj); - - const std::shared_ptr<::MyCppInterface> wrapped_obj; - std::atomic ref_count {1}; -}; diff --git a/src/it/resources/expected/my_cpp_interface/generated-files.txt b/src/it/resources/expected/my_cpp_interface/generated-files.txt index 85da5b3a..da77e758 100644 --- a/src/it/resources/expected/my_cpp_interface/generated-files.txt +++ b/src/it/resources/expected/my_cpp_interface/generated-files.txt @@ -9,10 +9,3 @@ src/it/resources/result/my_cpp_interface/objc/ITMyCppInterface.mm src/it/resources/result/my_cpp_interface/objcpp-headers/ITMyCppInterface+Private.h src/it/resources/result/my_cpp_interface/objcpp/ITMyCppInterface+Private.mm src/it/resources/result/my_cpp_interface/objc-headers/bridging-header.h -src/it/resources/result/my_cpp_interface/cppcli/MyCppInterface.hpp -src/it/resources/result/my_cpp_interface/cppcli/MyCppInterface.cpp -src/it/resources/result/my_cpp_interface/python/my_cpp_interface.py -src/it/resources/result/my_cpp_interface/cwrapper-headers/cw__my_cpp_interface.h -src/it/resources/result/my_cpp_interface/cwrapper/cw__my_cpp_interface.hpp -src/it/resources/result/my_cpp_interface/cwrapper/cw__my_cpp_interface.cpp -src/it/resources/result/my_cpp_interface/cffi/pycffi_lib_build.py diff --git a/src/it/resources/expected/my_cpp_interface/python/my_cpp_interface.py b/src/it/resources/expected/my_cpp_interface/python/my_cpp_interface.py deleted file mode 100644 index e5c830ce..00000000 --- a/src/it/resources/expected/my_cpp_interface/python/my_cpp_interface.py +++ /dev/null @@ -1,84 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from my_cpp_interface.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files -from djinni.pycffi_marshal import CPyPrimitive, CPyString - -from abc import ABCMeta, abstractmethod -from future.utils import with_metaclass -from _cffi import ffi, lib - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -class MyCppInterface(with_metaclass(ABCMeta)): - """ - interface comment - Constants - VERSION: Interfaces can also have constants - """ - - VERSION = 1 - - @abstractmethod - def method_returning_nothing(self, value): - """ method comment """ - raise NotImplementedError - - @abstractmethod - def method_returning_some_type(self, key): - raise NotImplementedError - - @abstractmethod - def method_changing_nothing(self): - raise NotImplementedError - - @staticmethod - def get_version(): - return MyCppInterfaceCppProxy.get_version() - - -class MyCppInterfaceCppProxy(MyCppInterface): - def __init__(self, proxy): - self._is_cpp_proxy = True - self._cpp_impl = proxy - def __del__(self): - if not lib: - return - lib.my_cpp_interface___wrapper_dec_ref(self._cpp_impl) - - def method_returning_nothing(self, value): - lib.cw__my_cpp_interface_method_returning_nothing(self._cpp_impl, CPyPrimitive.fromPy(value)) - CPyException.toPyCheckAndRaise(ffi.NULL) - - def method_returning_some_type(self, key): - with CPyString.fromPy(key) as pys_key: - _ret_c = lib.cw__my_cpp_interface_method_returning_some_type(self._cpp_impl, pys_key.release_djinni_string()) - CPyException.toPyCheckAndRaise(_ret_c) - _ret = CPyPrimitive.toPy(_ret_c) - assert _ret is not None - return _ret - - def method_changing_nothing(self): - _ret_c = lib.cw__my_cpp_interface_method_changing_nothing(self._cpp_impl) - CPyException.toPyCheckAndRaise(_ret_c) - _ret = CPyPrimitive.toPy(_ret_c) - assert _ret is not None - return _ret - - @staticmethod - def get_version(): - _ret_c = lib.cw__my_cpp_interface_get_version() - CPyException.toPyCheckAndRaise(_ret_c) - _ret = CPyPrimitive.toPy(_ret_c) - assert _ret is not None - return _ret - -class MyCppInterfaceHelper: - c_data_set = MultiSet() - @staticmethod - def toPy(obj): - if obj == ffi.NULL: - return None - return MyCppInterfaceCppProxy(obj) - diff --git a/src/it/resources/expected/my_enum/cppcli/MyEnum.cpp b/src/it/resources/expected/my_enum/cppcli/MyEnum.cpp deleted file mode 100644 index 5da92c61..00000000 --- a/src/it/resources/expected/my_enum/cppcli/MyEnum.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_enum.djinni - -#include "MyEnum.hpp" // my header -#include "../cpp-headers/my_enum.hpp" - -// Empty... making sure the symbols get included in the build. diff --git a/src/it/resources/expected/my_enum/cppcli/MyEnum.hpp b/src/it/resources/expected/my_enum/cppcli/MyEnum.hpp deleted file mode 100644 index 9c333bc7..00000000 --- a/src/it/resources/expected/my_enum/cppcli/MyEnum.hpp +++ /dev/null @@ -1,14 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_enum.djinni - -#pragma once - -#include "../cpp-headers/my_enum.hpp" - -/** enum comment */ -public enum class MyEnum { - /** enum option comment */ - Option1, - Option2, - Option3, -}; diff --git a/src/it/resources/expected/my_enum/cwrapper-headers/dh__my_enum.h b/src/it/resources/expected/my_enum/cwrapper-headers/dh__my_enum.h deleted file mode 100644 index fe411db4..00000000 --- a/src/it/resources/expected/my_enum/cwrapper-headers/dh__my_enum.h +++ /dev/null @@ -1,6 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_enum.djinni - -#pragma once // python_cdef_ignore -#include // python_cdef_ignore - diff --git a/src/it/resources/expected/my_enum/cwrapper/dh__my_enum.cpp b/src/it/resources/expected/my_enum/cwrapper/dh__my_enum.cpp deleted file mode 100644 index 2772c5ba..00000000 --- a/src/it/resources/expected/my_enum/cwrapper/dh__my_enum.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_enum.djinni - -#include // for debugging -#include -#include "djinni/cwrapper/wrapper_marshal.hpp" -#include "../cpp-headers/my_enum.hpp" - -int32_t int32_from_enum_my_enum(std::optional<::MyEnum> e) { - if (e) { - return static_cast(* e); - } - return -1; // -1 to signal null boxed enum -} - -int32_t int32_from_enum_my_enum(::MyEnum e) { - return static_cast(e); -} -std::optional<::MyEnum> get_boxed_enum_my_enum_from_int32(int32_t e) { - if (e == -1) { // to signal null enum - return {}; - } - return std::optional<::MyEnum>(static_cast<::MyEnum>(e)); -} diff --git a/src/it/resources/expected/my_enum/cwrapper/dh__my_enum.hpp b/src/it/resources/expected/my_enum/cwrapper/dh__my_enum.hpp deleted file mode 100644 index 1d261a61..00000000 --- a/src/it/resources/expected/my_enum/cwrapper/dh__my_enum.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_enum.djinni - -#pragma once - -#include -#include -#include "../cpp-headers/my_enum.hpp" -#ifdef __cplusplus -extern "C" { -#endif - -#include "../cwrapper-headers/dh__my_enum.h" - -#ifdef __cplusplus -} -#endif -int32_t int32_from_enum_my_enum(std::optional<::MyEnum> e); -int32_t int32_from_enum_my_enum(::MyEnum e); -std::optional<::MyEnum> get_boxed_enum_my_enum_from_int32(int32_t e); diff --git a/src/it/resources/expected/my_enum/generated-files.txt b/src/it/resources/expected/my_enum/generated-files.txt index 4a177538..d6649780 100644 --- a/src/it/resources/expected/my_enum/generated-files.txt +++ b/src/it/resources/expected/my_enum/generated-files.txt @@ -5,9 +5,3 @@ src/it/resources/result/my_enum/jni-headers/my_enum.hpp src/it/resources/result/my_enum/objc-headers/ITMyEnum.h src/it/resources/result/my_enum/objcpp-headers/ITMyEnum+Private.h src/it/resources/result/my_enum/objc-headers/bridging-header.h -src/it/resources/result/my_enum/cppcli/MyEnum.hpp -src/it/resources/result/my_enum/cppcli/MyEnum.cpp -src/it/resources/result/my_enum/python/my_enum.py -src/it/resources/result/my_enum/cwrapper-headers/dh__my_enum.h -src/it/resources/result/my_enum/cwrapper/dh__my_enum.hpp -src/it/resources/result/my_enum/cwrapper/dh__my_enum.cpp diff --git a/src/it/resources/expected/my_enum/python/my_enum.py b/src/it/resources/expected/my_enum/python/my_enum.py deleted file mode 100644 index 820910bf..00000000 --- a/src/it/resources/expected/my_enum/python/my_enum.py +++ /dev/null @@ -1,17 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from my_enum.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -from enum import IntEnum - -class MyEnum(IntEnum): - """ enum comment """ - - """ enum option comment """ - Option1 = 0 - Option2 = 1 - Option3 = 2 diff --git a/src/it/resources/expected/my_flags/cppcli/MyFlags.cpp b/src/it/resources/expected/my_flags/cppcli/MyFlags.cpp deleted file mode 100644 index c195ef08..00000000 --- a/src/it/resources/expected/my_flags/cppcli/MyFlags.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_flags.djinni - -#include "MyFlags.hpp" // my header -#include "../cpp-headers/my_flags.hpp" - -// Empty... making sure the symbols get included in the build. diff --git a/src/it/resources/expected/my_flags/cppcli/MyFlags.hpp b/src/it/resources/expected/my_flags/cppcli/MyFlags.hpp deleted file mode 100644 index 070707d1..00000000 --- a/src/it/resources/expected/my_flags/cppcli/MyFlags.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_flags.djinni - -#pragma once - -#include "../cpp-headers/my_flags.hpp" - -/** flag comment */ -[System::Flags] -public enum class MyFlags { - NoFlags = 0, - /** flag option comment */ - Flag1 = 1u << 0, - Flag2 = 1u << 1, - Flag3 = 1u << 2, - AllFlags = 0 | Flag1 | Flag2 | Flag3, -}; diff --git a/src/it/resources/expected/my_flags/cwrapper-headers/dh__my_flags.h b/src/it/resources/expected/my_flags/cwrapper-headers/dh__my_flags.h deleted file mode 100644 index 9188e73c..00000000 --- a/src/it/resources/expected/my_flags/cwrapper-headers/dh__my_flags.h +++ /dev/null @@ -1,6 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_flags.djinni - -#pragma once // python_cdef_ignore -#include // python_cdef_ignore - diff --git a/src/it/resources/expected/my_flags/cwrapper/dh__my_flags.cpp b/src/it/resources/expected/my_flags/cwrapper/dh__my_flags.cpp deleted file mode 100644 index c771c779..00000000 --- a/src/it/resources/expected/my_flags/cwrapper/dh__my_flags.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_flags.djinni - -#include // for debugging -#include -#include "djinni/cwrapper/wrapper_marshal.hpp" -#include "../cpp-headers/my_flags.hpp" - -int32_t int32_from_enum_my_flags(std::optional<::MyFlags> e) { - if (e) { - return static_cast(* e); - } - return -1; // -1 to signal null boxed enum -} - -int32_t int32_from_enum_my_flags(::MyFlags e) { - return static_cast(e); -} -std::optional<::MyFlags> get_boxed_enum_my_flags_from_int32(int32_t e) { - if (e == -1) { // to signal null enum - return {}; - } - return std::optional<::MyFlags>(static_cast<::MyFlags>(e)); -} diff --git a/src/it/resources/expected/my_flags/cwrapper/dh__my_flags.hpp b/src/it/resources/expected/my_flags/cwrapper/dh__my_flags.hpp deleted file mode 100644 index 90008f3f..00000000 --- a/src/it/resources/expected/my_flags/cwrapper/dh__my_flags.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_flags.djinni - -#pragma once - -#include -#include -#include "../cpp-headers/my_flags.hpp" -#ifdef __cplusplus -extern "C" { -#endif - -#include "../cwrapper-headers/dh__my_flags.h" - -#ifdef __cplusplus -} -#endif -int32_t int32_from_enum_my_flags(std::optional<::MyFlags> e); -int32_t int32_from_enum_my_flags(::MyFlags e); -std::optional<::MyFlags> get_boxed_enum_my_flags_from_int32(int32_t e); diff --git a/src/it/resources/expected/my_flags/generated-files.txt b/src/it/resources/expected/my_flags/generated-files.txt index 197936ff..32f2c1bb 100644 --- a/src/it/resources/expected/my_flags/generated-files.txt +++ b/src/it/resources/expected/my_flags/generated-files.txt @@ -5,9 +5,3 @@ src/it/resources/result/my_flags/jni-headers/my_flags.hpp src/it/resources/result/my_flags/objc-headers/ITMyFlags.h src/it/resources/result/my_flags/objcpp-headers/ITMyFlags+Private.h src/it/resources/result/my_flags/objc-headers/bridging-header.h -src/it/resources/result/my_flags/cppcli/MyFlags.hpp -src/it/resources/result/my_flags/cppcli/MyFlags.cpp -src/it/resources/result/my_flags/python/my_flags.py -src/it/resources/result/my_flags/cwrapper-headers/dh__my_flags.h -src/it/resources/result/my_flags/cwrapper/dh__my_flags.hpp -src/it/resources/result/my_flags/cwrapper/dh__my_flags.cpp diff --git a/src/it/resources/expected/my_flags/python/my_flags.py b/src/it/resources/expected/my_flags/python/my_flags.py deleted file mode 100644 index 078739a7..00000000 --- a/src/it/resources/expected/my_flags/python/my_flags.py +++ /dev/null @@ -1,19 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from my_flags.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -from enum import IntFlag - -class MyFlags(IntFlag): - """ flag comment """ - - No_Flags = 0 - """ flag option comment """ - Flag1 = 1 - Flag2 = 2 - Flag3 = 4 - All_Flags = 7 diff --git a/src/it/resources/expected/my_record/cppcli/MyRecord.cpp b/src/it/resources/expected/my_record/cppcli/MyRecord.cpp deleted file mode 100644 index 74ec77fb..00000000 --- a/src/it/resources/expected/my_record/cppcli/MyRecord.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_record.djinni - -#include "MyRecord.hpp" // my header -#include "djinni/cppcli/Marshal.hpp" -#include - -MyRecord::MyRecord(int id, - System::String^ info, - System::Collections::Generic::HashSet^ store, - System::Collections::Generic::Dictionary^ hash) -: _id(id) -, _info(info) -, _store(store) -, _hash(hash) -{} - -int MyRecord::Id::get() -{ - return _id; -} - -System::String^ MyRecord::Info::get() -{ - return _info; -} - -System::Collections::Generic::HashSet^ MyRecord::Store::get() -{ - return _store; -} - -System::Collections::Generic::Dictionary^ MyRecord::Hash::get() -{ - return _hash; -} - -System::String^ MyRecord::ToString() -{ - return System::String::Format("MyRecord {{Id{0}, Info{1}, Store{2}, Hash{3}}}", - Id, - Info, - Store, - Hash); -} - -MyRecord::CppType MyRecord::ToCpp(MyRecord::CsType cs) -{ - ASSERT(cs != nullptr); - return {::djinni::I32::ToCpp(cs->Id), - ::djinni::String::ToCpp(cs->Info), - ::djinni::Set<::djinni::String>::ToCpp(cs->Store), - ::djinni::Map<::djinni::String, ::djinni::I32>::ToCpp(cs->Hash)}; -} - -MyRecord::CsType MyRecord::FromCpp(const MyRecord::CppType& cpp) -{ - return gcnew MyRecord(::djinni::I32::FromCpp(cpp.id), - ::djinni::String::FromCpp(cpp.info), - ::djinni::Set<::djinni::String>::FromCpp(cpp.store), - ::djinni::Map<::djinni::String, ::djinni::I32>::FromCpp(cpp.hash)); -} diff --git a/src/it/resources/expected/my_record/cppcli/MyRecord.hpp b/src/it/resources/expected/my_record/cppcli/MyRecord.hpp deleted file mode 100644 index f0f500f6..00000000 --- a/src/it/resources/expected/my_record/cppcli/MyRecord.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_record.djinni - -#pragma once - -#include "../cpp-headers/my_record.hpp" - -/** record comment */ -[System::Serializable] -public ref class MyRecord { -public: - - static initonly System::String^ StringConst; - - static MyRecord() { - StringConst = "Constants can be put here"; - } - - property int Id - { - int get(); - } - - property System::String^ Info - { - System::String^ get(); - } - - property System::Collections::Generic::HashSet^ Store - { - System::Collections::Generic::HashSet^ get(); - } - - property System::Collections::Generic::Dictionary^ Hash - { - System::Collections::Generic::Dictionary^ get(); - } - - MyRecord(int id, - System::String^ info, - System::Collections::Generic::HashSet^ store, - System::Collections::Generic::Dictionary^ hash); - - System::String^ ToString() override; - -internal: - using CppType = ::MyRecord; - using CsType = MyRecord^; - - static CppType ToCpp(CsType cs); - static CsType FromCpp(const CppType& cpp); - -private: - /** record property comment */ - int _id; - System::String^ _info; - System::Collections::Generic::HashSet^ _store; - System::Collections::Generic::Dictionary^ _hash; -}; diff --git a/src/it/resources/expected/my_record/cwrapper-headers/dh__map_string_int32_t.h b/src/it/resources/expected/my_record/cwrapper-headers/dh__map_string_int32_t.h deleted file mode 100644 index a67f6a82..00000000 --- a/src/it/resources/expected/my_record/cwrapper-headers/dh__map_string_int32_t.h +++ /dev/null @@ -1,16 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_record.djinni - -#pragma once // python_cdef_ignore -#include // python_cdef_ignore - -#include // python_cdef_ignore - -void map_string_int32_t___delete(struct DjinniObjectHandle *); -void optional_map_string_int32_t___delete(struct DjinniOptionalObjectHandle *); -void map_string_int32_t_add_callback___delete(void(* ptr)(struct DjinniObjectHandle * )); -void map_string_int32_t_add_callback__get_value(int32_t( * ptr)(struct DjinniObjectHandle *, struct DjinniString *)); -void map_string_int32_t_add_callback__get_size(size_t( * ptr)(struct DjinniObjectHandle *)); -void map_string_int32_t_add_callback__create(struct DjinniObjectHandle *( * ptr)(void)); -void map_string_int32_t_add_callback__add(void( * ptr)(struct DjinniObjectHandle *, struct DjinniString *, int32_t)); -void map_string_int32_t_add_callback__next(struct DjinniString *( * ptr)(struct DjinniObjectHandle *)); diff --git a/src/it/resources/expected/my_record/cwrapper-headers/dh__my_record.h b/src/it/resources/expected/my_record/cwrapper-headers/dh__my_record.h deleted file mode 100644 index 9c3c448d..00000000 --- a/src/it/resources/expected/my_record/cwrapper-headers/dh__my_record.h +++ /dev/null @@ -1,17 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_record.djinni - -#pragma once // python_cdef_ignore -#include // python_cdef_ignore - -#include // python_cdef_ignore - -struct DjinniMyRecord; -void my_record___delete(struct DjinniRecordHandle * ); -void optional_my_record___delete(struct DjinniOptionalRecordHandle * ); -void my_record_add_callback_get_my_record_f1(int32_t( * ptr)(struct DjinniRecordHandle *)); -void my_record_add_callback_get_my_record_f2(struct DjinniString *( * ptr)(struct DjinniRecordHandle *)); -void my_record_add_callback_get_my_record_f3(struct DjinniObjectHandle *( * ptr)(struct DjinniRecordHandle *)); -void my_record_add_callback_get_my_record_f4(struct DjinniObjectHandle *( * ptr)(struct DjinniRecordHandle *)); -void my_record_add_callback_create_my_record(struct DjinniRecordHandle *( * ptr)(int32_t, struct DjinniString *, struct DjinniObjectHandle *, struct DjinniObjectHandle *)); -void my_record_add_callback___delete(void( * ptr)(struct DjinniRecordHandle *)); diff --git a/src/it/resources/expected/my_record/cwrapper-headers/dh__set_string.h b/src/it/resources/expected/my_record/cwrapper-headers/dh__set_string.h deleted file mode 100644 index 2e2cca97..00000000 --- a/src/it/resources/expected/my_record/cwrapper-headers/dh__set_string.h +++ /dev/null @@ -1,15 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_record.djinni - -#pragma once // python_cdef_ignore -#include // python_cdef_ignore - -#include // python_cdef_ignore - -void set_string___delete(struct DjinniObjectHandle *); -void optional_set_string___delete(struct DjinniOptionalObjectHandle *); -void set_string_add_callback___delete(void(* ptr)(struct DjinniObjectHandle * )); -void set_string_add_callback__get_size(size_t( * ptr)(struct DjinniObjectHandle *)); -void set_string_add_callback__create(struct DjinniObjectHandle *( * ptr)(void)); -void set_string_add_callback__add(void( * ptr)(struct DjinniObjectHandle *, struct DjinniString *)); -void set_string_add_callback__next(struct DjinniString *( * ptr)(struct DjinniObjectHandle *)); diff --git a/src/it/resources/expected/my_record/cwrapper/dh__map_string_int32_t.cpp b/src/it/resources/expected/my_record/cwrapper/dh__map_string_int32_t.cpp deleted file mode 100644 index 4024bd8f..00000000 --- a/src/it/resources/expected/my_record/cwrapper/dh__map_string_int32_t.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_record.djinni - -#include // for debugging -#include -#include "djinni/cwrapper/wrapper_marshal.hpp" -#include "../cpp-headers/my_record.hpp" - -#include "dh__map_string_int32_t.hpp" -#include "dh__my_record.hpp" -#include "dh__set_string.hpp" - -static void(*s_callback_map_string_int32_t___delete)(DjinniObjectHandle *); -void map_string_int32_t_add_callback___delete(void(* ptr)(DjinniObjectHandle *)) { - s_callback_map_string_int32_t___delete = ptr; -} - -void map_string_int32_t___delete(DjinniObjectHandle * drh) { - s_callback_map_string_int32_t___delete(drh); -} -void optional_map_string_int32_t___delete(DjinniOptionalObjectHandle * drh) { - s_callback_map_string_int32_t___delete((DjinniObjectHandle *) drh); -} -static int32_t ( * s_callback_map_string_int32_t__get_value)(DjinniObjectHandle *, DjinniString *); - -void map_string_int32_t_add_callback__get_value(int32_t( * ptr)(DjinniObjectHandle *, DjinniString *)) { - s_callback_map_string_int32_t__get_value = ptr; -} - -static size_t ( * s_callback_map_string_int32_t__get_size)(DjinniObjectHandle *); - -void map_string_int32_t_add_callback__get_size(size_t( * ptr)(DjinniObjectHandle *)) { - s_callback_map_string_int32_t__get_size = ptr; -} - -static DjinniObjectHandle * ( * s_callback_map_string_int32_t__create)(void); - -void map_string_int32_t_add_callback__create(DjinniObjectHandle *( * ptr)(void)) { - s_callback_map_string_int32_t__create = ptr; -} - -static void ( * s_callback_map_string_int32_t__add)(DjinniObjectHandle *, DjinniString *, int32_t); - -void map_string_int32_t_add_callback__add(void( * ptr)(DjinniObjectHandle *, DjinniString *, int32_t)) { - s_callback_map_string_int32_t__add = ptr; -} - -static DjinniString * ( * s_callback_map_string_int32_t__next)(DjinniObjectHandle *); - -void map_string_int32_t_add_callback__next(DjinniString *( * ptr)(DjinniObjectHandle *)) { - s_callback_map_string_int32_t__next = ptr; -} - -djinni::Handle DjinniMapStringInt32T::fromCpp(const std::unordered_map & dc) { - djinni::Handle _handle(s_callback_map_string_int32_t__create(), & map_string_int32_t___delete); - for (const auto & it : dc) { - auto _key = DjinniString::fromCpp(it.first); - s_callback_map_string_int32_t__add(_handle.get(), _key.release(), it.second); - } - - return _handle; -} - -std::unordered_map DjinniMapStringInt32T::toCpp(djinni::Handle dh) { - std::unordered_map_ret; - size_t size = s_callback_map_string_int32_t__get_size(dh.get()); - - for (int i = 0; i < size; i++) { - auto _key_c = std::unique_ptr(s_callback_map_string_int32_t__next(dh.get())); // key that would potentially be surrounded by unique pointer - auto _val = s_callback_map_string_int32_t__get_value(dh.get(), _key_c.get()); - - auto _key = DjinniString::toCpp(std::move(_key_c)); - _ret.emplace(std::move(_key), std::move(_val)); - } - - return _ret; -} - -djinni::Handle DjinniMapStringInt32T::fromCpp(std::optional> dc) { - if (!dc) { - return nullptr; - } - return djinni::optionals::toOptionalHandle(DjinniMapStringInt32T::fromCpp(std::move(* dc)), optional_map_string_int32_t___delete); -} - -std::optional>DjinniMapStringInt32T::toCpp(djinni::Handle dh) { - if (dh) { - return std::optional>(DjinniMapStringInt32T::toCpp(djinni::optionals::fromOptionalHandle(std::move(dh), map_string_int32_t___delete))); - } - return {}; -} - diff --git a/src/it/resources/expected/my_record/cwrapper/dh__map_string_int32_t.hpp b/src/it/resources/expected/my_record/cwrapper/dh__map_string_int32_t.hpp deleted file mode 100644 index 4aff97fe..00000000 --- a/src/it/resources/expected/my_record/cwrapper/dh__map_string_int32_t.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_record.djinni - -#pragma once - -#include -#include -#include "../cpp-headers/my_record.hpp" -#ifdef __cplusplus -extern "C" { -#endif - -#include "../cwrapper-headers/dh__map_string_int32_t.h" - -#ifdef __cplusplus -} -#endif -struct DjinniMapStringInt32T { - static djinni::Handle fromCpp(const std::unordered_map & dc); - static std::unordered_map toCpp(djinni::Handle dh); - static djinni::HandlefromCpp(std::optional> dc); - static std::optional> toCpp(djinni::Handle dh); -}; diff --git a/src/it/resources/expected/my_record/cwrapper/dh__my_record.cpp b/src/it/resources/expected/my_record/cwrapper/dh__my_record.cpp deleted file mode 100644 index 5b86d017..00000000 --- a/src/it/resources/expected/my_record/cwrapper/dh__my_record.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_record.djinni - -#include // for debugging -#include -#include "djinni/cwrapper/wrapper_marshal.hpp" -#include "../cpp-headers/my_record.hpp" - -#include "dh__map_string_int32_t.hpp" -#include "dh__my_record.hpp" -#include "dh__set_string.hpp" - -static void(*s_callback_my_record___delete)(DjinniRecordHandle * ); -void my_record_add_callback___delete(void(* ptr)(DjinniRecordHandle * )) { - s_callback_my_record___delete = ptr; -} - -void my_record___delete(DjinniRecordHandle * drh) { - s_callback_my_record___delete(drh); -} -void optional_my_record___delete(DjinniOptionalRecordHandle * drh) { - s_callback_my_record___delete((DjinniRecordHandle *) drh); // can't static cast, find better way -} -static int32_t ( * s_callback_my_record_get_my_record_f1)(DjinniRecordHandle *); - -void my_record_add_callback_get_my_record_f1(int32_t( * ptr)(DjinniRecordHandle *)) { - s_callback_my_record_get_my_record_f1 = ptr; -} - -static DjinniString * ( * s_callback_my_record_get_my_record_f2)(DjinniRecordHandle *); - -void my_record_add_callback_get_my_record_f2(DjinniString *( * ptr)(DjinniRecordHandle *)) { - s_callback_my_record_get_my_record_f2 = ptr; -} - -static DjinniObjectHandle * ( * s_callback_my_record_get_my_record_f3)(DjinniRecordHandle *); - -void my_record_add_callback_get_my_record_f3(DjinniObjectHandle *( * ptr)(DjinniRecordHandle *)) { - s_callback_my_record_get_my_record_f3 = ptr; -} - -static DjinniObjectHandle * ( * s_callback_my_record_get_my_record_f4)(DjinniRecordHandle *); - -void my_record_add_callback_get_my_record_f4(DjinniObjectHandle *( * ptr)(DjinniRecordHandle *)) { - s_callback_my_record_get_my_record_f4 = ptr; -} - -static DjinniRecordHandle * ( * s_callback_my_record_create_my_record)(int32_t, DjinniString *, DjinniObjectHandle *, DjinniObjectHandle *); - -void my_record_add_callback_create_my_record(DjinniRecordHandle *( * ptr)(int32_t, DjinniString *, DjinniObjectHandle *, DjinniObjectHandle *)) { - s_callback_my_record_create_my_record = ptr; -} - -djinni::Handle DjinniMyRecord::fromCpp(const ::MyRecord& dr) { - auto _field_info = DjinniString::fromCpp(dr.info); - auto _field_store = DjinniSetString::fromCpp(dr.store); - auto _field_hash = DjinniMapStringInt32T::fromCpp(dr.hash); - - djinni::Handle _aux( - s_callback_my_record_create_my_record( - dr.id, - _field_info.release(), - _field_store.release(), - _field_hash.release()), - my_record___delete); - return _aux; -} - -::MyRecord DjinniMyRecord::toCpp(djinni::Handle dh) { - std::unique_ptr _field_info(s_callback_my_record_get_my_record_f2(dh.get())); - djinni::Handle _field_store(s_callback_my_record_get_my_record_f3(dh.get()), set_string___delete); - djinni::Handle _field_hash(s_callback_my_record_get_my_record_f4(dh.get()), map_string_int32_t___delete); - - auto _aux = ::MyRecord( - s_callback_my_record_get_my_record_f1(dh.get()), - DjinniString::toCpp(std::move( _field_info)), - DjinniSetString::toCpp(std::move( _field_store)), - DjinniMapStringInt32T::toCpp(std::move( _field_hash))); - return _aux; -} - -djinni::Handle DjinniMyRecord::fromCpp(std::optional<::MyRecord> dc) { - if (!dc) { - return nullptr; - } - return djinni::optionals::toOptionalHandle(DjinniMyRecord::fromCpp(std::move(* dc)), optional_my_record___delete); -} - -std::optional<::MyRecord>DjinniMyRecord::toCpp(djinni::Handle dh) { - if (dh) { - return std::optional<::MyRecord>(DjinniMyRecord::toCpp(djinni::optionals::fromOptionalHandle(std::move(dh), my_record___delete))); - } - return {}; -} - diff --git a/src/it/resources/expected/my_record/cwrapper/dh__my_record.hpp b/src/it/resources/expected/my_record/cwrapper/dh__my_record.hpp deleted file mode 100644 index 7561704a..00000000 --- a/src/it/resources/expected/my_record/cwrapper/dh__my_record.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_record.djinni - -#pragma once - -#include -#include -#include "../cpp-headers/my_record.hpp" -#ifdef __cplusplus -extern "C" { -#endif - -#include "../cwrapper-headers/dh__my_record.h" - -#ifdef __cplusplus -} -#endif -struct DjinniMyRecord { - static djinni::Handle fromCpp(const ::MyRecord& dr); - static ::MyRecord toCpp(djinni::Handle dh); - static djinni::Handle fromCpp(std::optional<::MyRecord> dc); - static std::optional<::MyRecord> toCpp(djinni::Handle dh); -}; diff --git a/src/it/resources/expected/my_record/cwrapper/dh__set_string.cpp b/src/it/resources/expected/my_record/cwrapper/dh__set_string.cpp deleted file mode 100644 index 0417dcc6..00000000 --- a/src/it/resources/expected/my_record/cwrapper/dh__set_string.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_record.djinni - -#include // for debugging -#include -#include "djinni/cwrapper/wrapper_marshal.hpp" -#include "../cpp-headers/my_record.hpp" - -#include "dh__map_string_int32_t.hpp" -#include "dh__my_record.hpp" -#include "dh__set_string.hpp" - -static void(*s_callback_set_string___delete)(DjinniObjectHandle *); -void set_string_add_callback___delete(void(* ptr)(DjinniObjectHandle *)) { - s_callback_set_string___delete = ptr; -} - -void set_string___delete(DjinniObjectHandle * drh) { - s_callback_set_string___delete(drh); -} -void optional_set_string___delete(DjinniOptionalObjectHandle * drh) { - s_callback_set_string___delete((DjinniObjectHandle *) drh); -} -static size_t ( * s_callback_set_string__get_size)(DjinniObjectHandle *); - -void set_string_add_callback__get_size(size_t( * ptr)(DjinniObjectHandle *)) { - s_callback_set_string__get_size = ptr; -} - -static DjinniObjectHandle * ( * s_callback_set_string__create)(void); - -void set_string_add_callback__create(DjinniObjectHandle *( * ptr)(void)) { - s_callback_set_string__create = ptr; -} - -static void ( * s_callback_set_string__add)(DjinniObjectHandle *, DjinniString *); - -void set_string_add_callback__add(void( * ptr)(DjinniObjectHandle *, DjinniString *)) { - s_callback_set_string__add = ptr; -} - -static DjinniString * ( * s_callback_set_string__next)(DjinniObjectHandle *); - -void set_string_add_callback__next(DjinniString *( * ptr)(DjinniObjectHandle *)) { - s_callback_set_string__next = ptr; -} - -djinni::Handle DjinniSetString::fromCpp(const std::unordered_set & dc) { - djinni::Handle _handle(s_callback_set_string__create(), & set_string___delete); - for (const auto & it : dc) { - auto _key_val = DjinniString::fromCpp(it); - s_callback_set_string__add(_handle.get(), _key_val.release()); - } - - return _handle; -} - -std::unordered_set DjinniSetString::toCpp(djinni::Handle dh) { - std::unordered_set_ret; - size_t size = s_callback_set_string__get_size(dh.get()); - - for (int i = 0; i < size; i++) { - auto _el = DjinniString::toCpp(std::unique_ptr(s_callback_set_string__next(dh.get()))); - _ret.insert(std::move(_el)); - } - - return _ret; -} - -djinni::Handle DjinniSetString::fromCpp(std::optional> dc) { - if (!dc) { - return nullptr; - } - return djinni::optionals::toOptionalHandle(DjinniSetString::fromCpp(std::move(* dc)), optional_set_string___delete); -} - -std::optional>DjinniSetString::toCpp(djinni::Handle dh) { - if (dh) { - return std::optional>(DjinniSetString::toCpp(djinni::optionals::fromOptionalHandle(std::move(dh), set_string___delete))); - } - return {}; -} - diff --git a/src/it/resources/expected/my_record/cwrapper/dh__set_string.hpp b/src/it/resources/expected/my_record/cwrapper/dh__set_string.hpp deleted file mode 100644 index 85e3b861..00000000 --- a/src/it/resources/expected/my_record/cwrapper/dh__set_string.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from my_record.djinni - -#pragma once - -#include -#include -#include "../cpp-headers/my_record.hpp" -#ifdef __cplusplus -extern "C" { -#endif - -#include "../cwrapper-headers/dh__set_string.h" - -#ifdef __cplusplus -} -#endif -struct DjinniSetString { - static djinni::Handle fromCpp(const std::unordered_set & dc); - static std::unordered_set toCpp(djinni::Handle dh); - static djinni::HandlefromCpp(std::optional> dc); - static std::optional> toCpp(djinni::Handle dh); -}; diff --git a/src/it/resources/expected/my_record/generated-files.txt b/src/it/resources/expected/my_record/generated-files.txt index 026b9239..9119b364 100644 --- a/src/it/resources/expected/my_record/generated-files.txt +++ b/src/it/resources/expected/my_record/generated-files.txt @@ -9,18 +9,3 @@ src/it/resources/result/my_record/objc/ITMyRecord.mm src/it/resources/result/my_record/objcpp-headers/ITMyRecord+Private.h src/it/resources/result/my_record/objcpp/ITMyRecord+Private.mm src/it/resources/result/my_record/objc-headers/bridging-header.h -src/it/resources/result/my_record/cppcli/MyRecord.hpp -src/it/resources/result/my_record/cppcli/MyRecord.cpp -src/it/resources/result/my_record/python/dh__set_string.py -src/it/resources/result/my_record/python/dh__map_string_int32_t.py -src/it/resources/result/my_record/python/my_record.py -src/it/resources/result/my_record/python/my_record_helper.py -src/it/resources/result/my_record/cwrapper-headers/dh__set_string.h -src/it/resources/result/my_record/cwrapper/dh__set_string.hpp -src/it/resources/result/my_record/cwrapper/dh__set_string.cpp -src/it/resources/result/my_record/cwrapper-headers/dh__map_string_int32_t.h -src/it/resources/result/my_record/cwrapper/dh__map_string_int32_t.hpp -src/it/resources/result/my_record/cwrapper/dh__map_string_int32_t.cpp -src/it/resources/result/my_record/cwrapper-headers/dh__my_record.h -src/it/resources/result/my_record/cwrapper/dh__my_record.hpp -src/it/resources/result/my_record/cwrapper/dh__my_record.cpp diff --git a/src/it/resources/expected/my_record/python/dh__map_string_int32_t.py b/src/it/resources/expected/my_record/python/dh__map_string_int32_t.py deleted file mode 100644 index f5f5c101..00000000 --- a/src/it/resources/expected/my_record/python/dh__map_string_int32_t.py +++ /dev/null @@ -1,80 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from my_record.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files -from djinni.pycffi_marshal import CPyObject, CPyObjectProxy, CPyPrimitive, CPyString -from _cffi import ffi, lib - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -class MapStringInt32THelper: - c_data_set = MultiSet() - - @staticmethod - def check_c_data_set_empty(): - assert len(MapStringInt32THelper.c_data_set) == 0 - - @ffi.callback("int32_t(struct DjinniObjectHandle *, struct DjinniString *)") - def __get_value(cself, key): - pyKey = CPyString.toPyWithoutTakingOwnership(key) - assert pyKey is not None - try: - _ret = CPyPrimitive.fromPy(CPyObjectProxy.toPyObj(None, cself)[pyKey]) - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("size_t(struct DjinniObjectHandle *)") - def __get_size(cself): - return len(CPyObjectProxy.toPyObj(None, cself)) - - @ffi.callback("struct DjinniObjectHandle *()") - def __create(): - c_ptr = ffi.new_handle(MapStringInt32TProxy(dict())) - MapStringInt32THelper.c_data_set.add(c_ptr) - return ffi.cast("struct DjinniObjectHandle *", c_ptr) - - @ffi.callback("void(struct DjinniObjectHandle *, struct DjinniString *, int32_t)") - def __add(cself, key, value): - CPyObjectProxy.toPyObj(None, cself)[CPyString.toPy(key)] = CPyPrimitive.toPy(value) - - @ffi.callback("void(struct DjinniObjectHandle * )") - def __delete(c_ptr): - assert c_ptr in MapStringInt32THelper.c_data_set - MapStringInt32THelper.c_data_set.remove(c_ptr) - - @ffi.callback("struct DjinniString *(struct DjinniObjectHandle *)") - def __next(cself): - try: - with CPyString.fromPy(next(CPyObjectProxy.toPyIter(cself))) as py_obj: - _ret = py_obj.release_djinni_string() - assert _ret != ffi.NULL - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @staticmethod - def _add_callbacks(): - lib.map_string_int32_t_add_callback__get_value(MapStringInt32THelper.__get_value) - lib.map_string_int32_t_add_callback___delete(MapStringInt32THelper.__delete) - lib.map_string_int32_t_add_callback__get_size(MapStringInt32THelper.__get_size) - lib.map_string_int32_t_add_callback__create(MapStringInt32THelper.__create) - lib.map_string_int32_t_add_callback__add(MapStringInt32THelper.__add) - lib.map_string_int32_t_add_callback__next(MapStringInt32THelper.__next) - -MapStringInt32THelper._add_callbacks() - -class MapStringInt32TProxy: - def iter(d): - for k in d: - yield k - - def __init__(self, py_obj): - self._py_obj = py_obj - if py_obj is not None: - self._py_iter = iter(py_obj) - else: - self._py_iter = None diff --git a/src/it/resources/expected/my_record/python/dh__set_string.py b/src/it/resources/expected/my_record/python/dh__set_string.py deleted file mode 100644 index da49f4c0..00000000 --- a/src/it/resources/expected/my_record/python/dh__set_string.py +++ /dev/null @@ -1,68 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from my_record.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files -from djinni.pycffi_marshal import CPyObject, CPyObjectProxy, CPyString -from _cffi import ffi, lib - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -class SetStringHelper: - c_data_set = MultiSet() - - @staticmethod - def check_c_data_set_empty(): - assert len(SetStringHelper.c_data_set) == 0 - - @ffi.callback("size_t(struct DjinniObjectHandle *)") - def __get_size(cself): - return len(CPyObjectProxy.toPyObj(None, cself)) - - @ffi.callback("struct DjinniObjectHandle *()") - def __create(): - c_ptr = ffi.new_handle(SetStringProxy(set())) - SetStringHelper.c_data_set.add(c_ptr) - return ffi.cast("struct DjinniObjectHandle *", c_ptr) - - @ffi.callback("void(struct DjinniObjectHandle *, struct DjinniString *)") - def __add(cself, el): - CPyObjectProxy.toPyObj(None, cself).add(CPyString.toPy(el)) - - @ffi.callback("void(struct DjinniObjectHandle * )") - def __delete(c_ptr): - assert c_ptr in SetStringHelper.c_data_set - SetStringHelper.c_data_set.remove(c_ptr) - - @ffi.callback("struct DjinniString *(struct DjinniObjectHandle *)") - def __next(cself): - try: - with CPyString.fromPy(next(CPyObjectProxy.toPyIter(cself))) as py_obj: - _ret = py_obj.release_djinni_string() - assert _ret != ffi.NULL - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @staticmethod - def _add_callbacks(): - lib.set_string_add_callback___delete(SetStringHelper.__delete) - lib.set_string_add_callback__get_size(SetStringHelper.__get_size) - lib.set_string_add_callback__create(SetStringHelper.__create) - lib.set_string_add_callback__add(SetStringHelper.__add) - lib.set_string_add_callback__next(SetStringHelper.__next) - -SetStringHelper._add_callbacks() - -class SetStringProxy: - def iter(d): - for k in d: - yield k - - def __init__(self, py_obj): - self._py_obj = py_obj - if py_obj is not None: - self._py_iter = iter(py_obj) - else: - self._py_iter = None diff --git a/src/it/resources/expected/my_record/python/my_record.py b/src/it/resources/expected/my_record/python/my_record.py deleted file mode 100644 index 978d52be..00000000 --- a/src/it/resources/expected/my_record/python/my_record.py +++ /dev/null @@ -1,43 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from my_record.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files -from djinni.pycffi_marshal import CPyObject, CPyObjectProxy, CPyPrimitive, CPyRecord, CPyString - -from dh__map_string_int32_t import MapStringInt32THelper -from dh__map_string_int32_t import MapStringInt32TProxy -from dh__set_string import SetStringHelper -from dh__set_string import SetStringProxy -from _cffi import ffi, lib - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -class MyRecord: - """ - record comment - Fields - id: record property comment - info - store - hash - """ - - c_data_set = MultiSet() - - @staticmethod - def check_c_data_set_empty(): - assert len(MyRecord.c_data_set) == 0 - SetStringHelper.check_c_data_set_empty() - MapStringInt32THelper.check_c_data_set_empty() - - STRING_CONST = "Constants can be put here" - - - def __init__(self, id, info, store, hash): - self.id = id - self.info = info - self.store = store - self.hash = hash - - diff --git a/src/it/resources/expected/my_record/python/my_record_helper.py b/src/it/resources/expected/my_record/python/my_record_helper.py deleted file mode 100644 index 35c35ed6..00000000 --- a/src/it/resources/expected/my_record/python/my_record_helper.py +++ /dev/null @@ -1,89 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from my_record.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files -from djinni.pycffi_marshal import CPyObject, CPyObjectProxy, CPyPrimitive, CPyRecord, CPyString - -from dh__map_string_int32_t import MapStringInt32THelper -from dh__map_string_int32_t import MapStringInt32TProxy -from dh__set_string import SetStringHelper -from dh__set_string import SetStringProxy -from _cffi import ffi, lib - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -from my_record import MyRecord - -class MyRecordHelper: - @staticmethod - def release(c_ptr): - assert c_ptr in c_data_set - c_data_set.remove(ffi.cast("void*", c_ptr)) - - @ffi.callback("int32_t(struct DjinniRecordHandle *)") - def get_my_record_f1(cself): - try: - _ret = CPyPrimitive.fromPy(CPyRecord.toPy(None, cself).id) - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("struct DjinniString *(struct DjinniRecordHandle *)") - def get_my_record_f2(cself): - try: - with CPyString.fromPy(CPyRecord.toPy(None, cself).info) as py_obj: - _ret = py_obj.release_djinni_string() - assert _ret != ffi.NULL - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("struct DjinniObjectHandle *(struct DjinniRecordHandle *)") - def get_my_record_f3(cself): - try: - _ret = CPyObjectProxy.fromPy(SetStringHelper.c_data_set, SetStringProxy(CPyRecord.toPy(None, cself).store)) - assert _ret != ffi.NULL - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("struct DjinniObjectHandle *(struct DjinniRecordHandle *)") - def get_my_record_f4(cself): - try: - _ret = CPyObjectProxy.fromPy(MapStringInt32THelper.c_data_set, MapStringInt32TProxy(CPyRecord.toPy(None, cself).hash)) - assert _ret != ffi.NULL - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("struct DjinniRecordHandle *(int32_t,struct DjinniString *,struct DjinniObjectHandle *,struct DjinniObjectHandle *)") - def create_my_record(id,info,store,hash): - py_rec = MyRecord( - CPyPrimitive.toPy(id), - CPyString.toPy(info), - CPyObjectProxy.toPyObj(SetStringHelper.c_data_set, store), - CPyObjectProxy.toPyObj(MapStringInt32THelper.c_data_set, hash)) - return CPyRecord.fromPy(MyRecord.c_data_set, py_rec) #to do: can be optional? - - @ffi.callback("void (struct DjinniRecordHandle *)") - def __delete(dh): - assert dh in MyRecord.c_data_set - MyRecord.c_data_set.remove(dh) - - @staticmethod - def _add_callbacks(): - lib.my_record_add_callback___delete(MyRecordHelper.__delete) - lib.my_record_add_callback_create_my_record(MyRecordHelper.create_my_record) - lib.my_record_add_callback_get_my_record_f1(MyRecordHelper.get_my_record_f1) - lib.my_record_add_callback_get_my_record_f2(MyRecordHelper.get_my_record_f2) - lib.my_record_add_callback_get_my_record_f3(MyRecordHelper.get_my_record_f3) - lib.my_record_add_callback_get_my_record_f4(MyRecordHelper.get_my_record_f4) - - -MyRecordHelper._add_callbacks() - diff --git a/src/it/resources/expected/using_custom_datatypes/cppcli/CustomDatatype.cpp b/src/it/resources/expected/using_custom_datatypes/cppcli/CustomDatatype.cpp deleted file mode 100644 index 42803dd2..00000000 --- a/src/it/resources/expected/using_custom_datatypes/cppcli/CustomDatatype.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from using_custom_datatypes.djinni - -#include "CustomDatatype.hpp" // my header -#include "djinni/cppcli/Marshal.hpp" -#include - -CustomDatatype::CustomDatatype(System::String^ recordData) -: _recordData(recordData) -{} - -System::String^ CustomDatatype::RecordData::get() -{ - return _recordData; -} - -System::String^ CustomDatatype::ToString() -{ - return System::String::Format("CustomDatatype {{RecordData{0}}}", - RecordData); -} - -CustomDatatype::CppType CustomDatatype::ToCpp(CustomDatatype::CsType cs) -{ - ASSERT(cs != nullptr); - return {::djinni::String::ToCpp(cs->RecordData)}; -} - -CustomDatatype::CsType CustomDatatype::FromCpp(const CustomDatatype::CppType& cpp) -{ - return gcnew CustomDatatype(::djinni::String::FromCpp(cpp.recordData)); -} diff --git a/src/it/resources/expected/using_custom_datatypes/cppcli/CustomDatatype.hpp b/src/it/resources/expected/using_custom_datatypes/cppcli/CustomDatatype.hpp deleted file mode 100644 index 0a96e541..00000000 --- a/src/it/resources/expected/using_custom_datatypes/cppcli/CustomDatatype.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from using_custom_datatypes.djinni - -#pragma once - -#include "../cpp-headers/custom_datatype.hpp" - -[System::Serializable] -public ref class CustomDatatype { -public: - - property System::String^ RecordData - { - System::String^ get(); - } - - CustomDatatype(System::String^ recordData); - - System::String^ ToString() override; - -internal: - using CppType = ::CustomDatatype; - using CsType = CustomDatatype^; - - static CppType ToCpp(CsType cs); - static CsType FromCpp(const CppType& cpp); - -private: - System::String^ _recordData; -}; diff --git a/src/it/resources/expected/using_custom_datatypes/cppcli/OtherRecord.cpp b/src/it/resources/expected/using_custom_datatypes/cppcli/OtherRecord.cpp deleted file mode 100644 index 4b6a9bd3..00000000 --- a/src/it/resources/expected/using_custom_datatypes/cppcli/OtherRecord.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from using_custom_datatypes.djinni - -#include "OtherRecord.hpp" // my header -#include "djinni/cppcli/Marshal.hpp" -#include - -OtherRecord::OtherRecord(CustomDatatype^ customDatatypeData) -: _customDatatypeData(customDatatypeData) -{} - -CustomDatatype^ OtherRecord::CustomDatatypeData::get() -{ - return _customDatatypeData; -} - -System::String^ OtherRecord::ToString() -{ - return System::String::Format("OtherRecord {{CustomDatatypeData{0}}}", - CustomDatatypeData); -} - -OtherRecord::CppType OtherRecord::ToCpp(OtherRecord::CsType cs) -{ - ASSERT(cs != nullptr); - return {::CustomDatatype::ToCpp(cs->CustomDatatypeData)}; -} - -OtherRecord::CsType OtherRecord::FromCpp(const OtherRecord::CppType& cpp) -{ - return gcnew OtherRecord(::CustomDatatype::FromCpp(cpp.customDatatypeData)); -} diff --git a/src/it/resources/expected/using_custom_datatypes/cppcli/OtherRecord.hpp b/src/it/resources/expected/using_custom_datatypes/cppcli/OtherRecord.hpp deleted file mode 100644 index 2dd84a51..00000000 --- a/src/it/resources/expected/using_custom_datatypes/cppcli/OtherRecord.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from using_custom_datatypes.djinni - -#pragma once - -#include "../cpp-headers/other_record.hpp" -#include "CustomDatatype.hpp" - -[System::Serializable] -public ref class OtherRecord { -public: - - property CustomDatatype^ CustomDatatypeData - { - CustomDatatype^ get(); - } - - OtherRecord(CustomDatatype^ customDatatypeData); - - System::String^ ToString() override; - -internal: - using CppType = ::OtherRecord; - using CsType = OtherRecord^; - - static CppType ToCpp(CsType cs); - static CsType FromCpp(const CppType& cpp); - -private: - CustomDatatype^ _customDatatypeData; -}; diff --git a/src/it/resources/expected/using_custom_datatypes/cwrapper-headers/dh__custom_datatype.h b/src/it/resources/expected/using_custom_datatypes/cwrapper-headers/dh__custom_datatype.h deleted file mode 100644 index 5b85a47b..00000000 --- a/src/it/resources/expected/using_custom_datatypes/cwrapper-headers/dh__custom_datatype.h +++ /dev/null @@ -1,12 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from using_custom_datatypes.djinni - -#pragma once // python_cdef_ignore -#include // python_cdef_ignore - -struct DjinniCustomDatatype; -void custom_datatype___delete(struct DjinniRecordHandle * ); -void optional_custom_datatype___delete(struct DjinniOptionalRecordHandle * ); -void custom_datatype_add_callback_get_custom_datatype_f1(struct DjinniString *( * ptr)(struct DjinniRecordHandle *)); -void custom_datatype_add_callback_create_custom_datatype(struct DjinniRecordHandle *( * ptr)(struct DjinniString *)); -void custom_datatype_add_callback___delete(void( * ptr)(struct DjinniRecordHandle *)); diff --git a/src/it/resources/expected/using_custom_datatypes/cwrapper-headers/dh__other_record.h b/src/it/resources/expected/using_custom_datatypes/cwrapper-headers/dh__other_record.h deleted file mode 100644 index 2d099261..00000000 --- a/src/it/resources/expected/using_custom_datatypes/cwrapper-headers/dh__other_record.h +++ /dev/null @@ -1,12 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from using_custom_datatypes.djinni - -#pragma once // python_cdef_ignore -#include // python_cdef_ignore - -struct DjinniOtherRecord; -void other_record___delete(struct DjinniRecordHandle * ); -void optional_other_record___delete(struct DjinniOptionalRecordHandle * ); -void other_record_add_callback_get_other_record_f1(struct DjinniRecordHandle *( * ptr)(struct DjinniRecordHandle *)); -void other_record_add_callback_create_other_record(struct DjinniRecordHandle *( * ptr)(struct DjinniRecordHandle *)); -void other_record_add_callback___delete(void( * ptr)(struct DjinniRecordHandle *)); diff --git a/src/it/resources/expected/using_custom_datatypes/cwrapper/dh__custom_datatype.cpp b/src/it/resources/expected/using_custom_datatypes/cwrapper/dh__custom_datatype.cpp deleted file mode 100644 index cd60bbf5..00000000 --- a/src/it/resources/expected/using_custom_datatypes/cwrapper/dh__custom_datatype.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from using_custom_datatypes.djinni - -#include // for debugging -#include -#include "djinni/cwrapper/wrapper_marshal.hpp" -#include "../cpp-headers/custom_datatype.hpp" - -#include "dh__custom_datatype.hpp" - -static void(*s_callback_custom_datatype___delete)(DjinniRecordHandle * ); -void custom_datatype_add_callback___delete(void(* ptr)(DjinniRecordHandle * )) { - s_callback_custom_datatype___delete = ptr; -} - -void custom_datatype___delete(DjinniRecordHandle * drh) { - s_callback_custom_datatype___delete(drh); -} -void optional_custom_datatype___delete(DjinniOptionalRecordHandle * drh) { - s_callback_custom_datatype___delete((DjinniRecordHandle *) drh); // can't static cast, find better way -} -static DjinniString * ( * s_callback_custom_datatype_get_custom_datatype_f1)(DjinniRecordHandle *); - -void custom_datatype_add_callback_get_custom_datatype_f1(DjinniString *( * ptr)(DjinniRecordHandle *)) { - s_callback_custom_datatype_get_custom_datatype_f1 = ptr; -} - -static DjinniRecordHandle * ( * s_callback_custom_datatype_create_custom_datatype)(DjinniString *); - -void custom_datatype_add_callback_create_custom_datatype(DjinniRecordHandle *( * ptr)(DjinniString *)) { - s_callback_custom_datatype_create_custom_datatype = ptr; -} - -djinni::Handle DjinniCustomDatatype::fromCpp(const ::CustomDatatype& dr) { - auto _field_recordData = DjinniString::fromCpp(dr.recordData); - - djinni::Handle _aux( - s_callback_custom_datatype_create_custom_datatype( - _field_recordData.release()), - custom_datatype___delete); - return _aux; -} - -::CustomDatatype DjinniCustomDatatype::toCpp(djinni::Handle dh) { - std::unique_ptr _field_recordData(s_callback_custom_datatype_get_custom_datatype_f1(dh.get())); - - auto _aux = ::CustomDatatype( - DjinniString::toCpp(std::move( _field_recordData))); - return _aux; -} - -djinni::Handle DjinniCustomDatatype::fromCpp(std::optional<::CustomDatatype> dc) { - if (!dc) { - return nullptr; - } - return djinni::optionals::toOptionalHandle(DjinniCustomDatatype::fromCpp(std::move(* dc)), optional_custom_datatype___delete); -} - -std::optional<::CustomDatatype>DjinniCustomDatatype::toCpp(djinni::Handle dh) { - if (dh) { - return std::optional<::CustomDatatype>(DjinniCustomDatatype::toCpp(djinni::optionals::fromOptionalHandle(std::move(dh), custom_datatype___delete))); - } - return {}; -} - diff --git a/src/it/resources/expected/using_custom_datatypes/cwrapper/dh__custom_datatype.hpp b/src/it/resources/expected/using_custom_datatypes/cwrapper/dh__custom_datatype.hpp deleted file mode 100644 index b3c2b3d5..00000000 --- a/src/it/resources/expected/using_custom_datatypes/cwrapper/dh__custom_datatype.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from using_custom_datatypes.djinni - -#pragma once - -#include -#include -#include "../cpp-headers/custom_datatype.hpp" -#ifdef __cplusplus -extern "C" { -#endif - -#include "../cwrapper-headers/dh__custom_datatype.h" - -#ifdef __cplusplus -} -#endif -struct DjinniCustomDatatype { - static djinni::Handle fromCpp(const ::CustomDatatype& dr); - static ::CustomDatatype toCpp(djinni::Handle dh); - static djinni::Handle fromCpp(std::optional<::CustomDatatype> dc); - static std::optional<::CustomDatatype> toCpp(djinni::Handle dh); -}; diff --git a/src/it/resources/expected/using_custom_datatypes/cwrapper/dh__other_record.cpp b/src/it/resources/expected/using_custom_datatypes/cwrapper/dh__other_record.cpp deleted file mode 100644 index 1eecc2ee..00000000 --- a/src/it/resources/expected/using_custom_datatypes/cwrapper/dh__other_record.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from using_custom_datatypes.djinni - -#include // for debugging -#include -#include "djinni/cwrapper/wrapper_marshal.hpp" -#include "../cpp-headers/other_record.hpp" - -#include "dh__custom_datatype.hpp" -#include "dh__other_record.hpp" - -static void(*s_callback_other_record___delete)(DjinniRecordHandle * ); -void other_record_add_callback___delete(void(* ptr)(DjinniRecordHandle * )) { - s_callback_other_record___delete = ptr; -} - -void other_record___delete(DjinniRecordHandle * drh) { - s_callback_other_record___delete(drh); -} -void optional_other_record___delete(DjinniOptionalRecordHandle * drh) { - s_callback_other_record___delete((DjinniRecordHandle *) drh); // can't static cast, find better way -} -static DjinniRecordHandle * ( * s_callback_other_record_get_other_record_f1)(DjinniRecordHandle *); - -void other_record_add_callback_get_other_record_f1(DjinniRecordHandle *( * ptr)(DjinniRecordHandle *)) { - s_callback_other_record_get_other_record_f1 = ptr; -} - -static DjinniRecordHandle * ( * s_callback_other_record_create_other_record)(DjinniRecordHandle *); - -void other_record_add_callback_create_other_record(DjinniRecordHandle *( * ptr)(DjinniRecordHandle *)) { - s_callback_other_record_create_other_record = ptr; -} - -djinni::Handle DjinniOtherRecord::fromCpp(const ::OtherRecord& dr) { - auto _field_customDatatypeData = DjinniCustomDatatype::fromCpp(dr.customDatatypeData); - - djinni::Handle _aux( - s_callback_other_record_create_other_record( - _field_customDatatypeData.release()), - other_record___delete); - return _aux; -} - -::OtherRecord DjinniOtherRecord::toCpp(djinni::Handle dh) { - djinni::Handle _field_customDatatypeData(s_callback_other_record_get_other_record_f1(dh.get()), custom_datatype___delete); - - auto _aux = ::OtherRecord( - DjinniCustomDatatype::toCpp(std::move( _field_customDatatypeData))); - return _aux; -} - -djinni::Handle DjinniOtherRecord::fromCpp(std::optional<::OtherRecord> dc) { - if (!dc) { - return nullptr; - } - return djinni::optionals::toOptionalHandle(DjinniOtherRecord::fromCpp(std::move(* dc)), optional_other_record___delete); -} - -std::optional<::OtherRecord>DjinniOtherRecord::toCpp(djinni::Handle dh) { - if (dh) { - return std::optional<::OtherRecord>(DjinniOtherRecord::toCpp(djinni::optionals::fromOptionalHandle(std::move(dh), other_record___delete))); - } - return {}; -} - diff --git a/src/it/resources/expected/using_custom_datatypes/cwrapper/dh__other_record.hpp b/src/it/resources/expected/using_custom_datatypes/cwrapper/dh__other_record.hpp deleted file mode 100644 index 0dd90c67..00000000 --- a/src/it/resources/expected/using_custom_datatypes/cwrapper/dh__other_record.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file was generated by Djinni from using_custom_datatypes.djinni - -#pragma once - -#include -#include -#include "../cpp-headers/other_record.hpp" -#ifdef __cplusplus -extern "C" { -#endif - -#include "../cwrapper-headers/dh__other_record.h" - -#ifdef __cplusplus -} -#endif -struct DjinniOtherRecord { - static djinni::Handle fromCpp(const ::OtherRecord& dr); - static ::OtherRecord toCpp(djinni::Handle dh); - static djinni::Handle fromCpp(std::optional<::OtherRecord> dc); - static std::optional<::OtherRecord> toCpp(djinni::Handle dh); -}; diff --git a/src/it/resources/expected/using_custom_datatypes/generated-files.txt b/src/it/resources/expected/using_custom_datatypes/generated-files.txt index afc8d921..dfa0c608 100644 --- a/src/it/resources/expected/using_custom_datatypes/generated-files.txt +++ b/src/it/resources/expected/using_custom_datatypes/generated-files.txt @@ -16,17 +16,3 @@ src/it/resources/result/using_custom_datatypes/objcpp/ITCustomDatatype+Private.m src/it/resources/result/using_custom_datatypes/objcpp-headers/ITOtherRecord+Private.h src/it/resources/result/using_custom_datatypes/objcpp/ITOtherRecord+Private.mm src/it/resources/result/using_custom_datatypes/objc-headers/bridging-header.h -src/it/resources/result/using_custom_datatypes/cppcli/CustomDatatype.hpp -src/it/resources/result/using_custom_datatypes/cppcli/CustomDatatype.cpp -src/it/resources/result/using_custom_datatypes/cppcli/OtherRecord.hpp -src/it/resources/result/using_custom_datatypes/cppcli/OtherRecord.cpp -src/it/resources/result/using_custom_datatypes/python/custom_datatype.py -src/it/resources/result/using_custom_datatypes/python/custom_datatype_helper.py -src/it/resources/result/using_custom_datatypes/python/other_record.py -src/it/resources/result/using_custom_datatypes/python/other_record_helper.py -src/it/resources/result/using_custom_datatypes/cwrapper-headers/dh__custom_datatype.h -src/it/resources/result/using_custom_datatypes/cwrapper/dh__custom_datatype.hpp -src/it/resources/result/using_custom_datatypes/cwrapper/dh__custom_datatype.cpp -src/it/resources/result/using_custom_datatypes/cwrapper-headers/dh__other_record.h -src/it/resources/result/using_custom_datatypes/cwrapper/dh__other_record.hpp -src/it/resources/result/using_custom_datatypes/cwrapper/dh__other_record.cpp diff --git a/src/it/resources/expected/using_custom_datatypes/python/custom_datatype.py b/src/it/resources/expected/using_custom_datatypes/python/custom_datatype.py deleted file mode 100644 index f88c1a39..00000000 --- a/src/it/resources/expected/using_custom_datatypes/python/custom_datatype.py +++ /dev/null @@ -1,21 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from using_custom_datatypes.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files -from djinni.pycffi_marshal import CPyRecord, CPyString -from _cffi import ffi, lib - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -class CustomDatatype: - c_data_set = MultiSet() - - @staticmethod - def check_c_data_set_empty(): - assert len(CustomDatatype.c_data_set) == 0 - - - def __init__(self, recordData): - self.recordData = recordData - diff --git a/src/it/resources/expected/using_custom_datatypes/python/custom_datatype_helper.py b/src/it/resources/expected/using_custom_datatypes/python/custom_datatype_helper.py deleted file mode 100644 index 700bdc88..00000000 --- a/src/it/resources/expected/using_custom_datatypes/python/custom_datatype_helper.py +++ /dev/null @@ -1,48 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from using_custom_datatypes.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files -from djinni.pycffi_marshal import CPyRecord, CPyString -from _cffi import ffi, lib - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -from custom_datatype import CustomDatatype - -class CustomDatatypeHelper: - @staticmethod - def release(c_ptr): - assert c_ptr in c_data_set - c_data_set.remove(ffi.cast("void*", c_ptr)) - - @ffi.callback("struct DjinniString *(struct DjinniRecordHandle *)") - def get_custom_datatype_f1(cself): - try: - with CPyString.fromPy(CPyRecord.toPy(None, cself).recordData) as py_obj: - _ret = py_obj.release_djinni_string() - assert _ret != ffi.NULL - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("struct DjinniRecordHandle *(struct DjinniString *)") - def create_custom_datatype(recordData): - py_rec = CustomDatatype( - CPyString.toPy(recordData)) - return CPyRecord.fromPy(CustomDatatype.c_data_set, py_rec) #to do: can be optional? - - @ffi.callback("void (struct DjinniRecordHandle *)") - def __delete(dh): - assert dh in CustomDatatype.c_data_set - CustomDatatype.c_data_set.remove(dh) - - @staticmethod - def _add_callbacks(): - lib.custom_datatype_add_callback___delete(CustomDatatypeHelper.__delete) - lib.custom_datatype_add_callback_create_custom_datatype(CustomDatatypeHelper.create_custom_datatype) - lib.custom_datatype_add_callback_get_custom_datatype_f1(CustomDatatypeHelper.get_custom_datatype_f1) - -CustomDatatypeHelper._add_callbacks() - diff --git a/src/it/resources/expected/using_custom_datatypes/python/other_record.py b/src/it/resources/expected/using_custom_datatypes/python/other_record.py deleted file mode 100644 index 508c239b..00000000 --- a/src/it/resources/expected/using_custom_datatypes/python/other_record.py +++ /dev/null @@ -1,25 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from using_custom_datatypes.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files -from djinni.pycffi_marshal import CPyRecord - -from custom_datatype import CustomDatatype -from custom_datatype_helper import CustomDatatypeHelper -from _cffi import ffi, lib - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -class OtherRecord: - c_data_set = MultiSet() - - @staticmethod - def check_c_data_set_empty(): - assert len(OtherRecord.c_data_set) == 0 - CustomDatatype.check_c_data_set_empty() - - - def __init__(self, customDatatypeData): - self.customDatatypeData = customDatatypeData - diff --git a/src/it/resources/expected/using_custom_datatypes/python/other_record_helper.py b/src/it/resources/expected/using_custom_datatypes/python/other_record_helper.py deleted file mode 100644 index bfc39192..00000000 --- a/src/it/resources/expected/using_custom_datatypes/python/other_record_helper.py +++ /dev/null @@ -1,50 +0,0 @@ -# AUTOGENERATED FILE - DO NOT MODIFY! -# This file was generated by Djinni from using_custom_datatypes.djinni - -from djinni.support import MultiSet # default imported in all files -from djinni.exception import CPyException # default imported in all files -from djinni.pycffi_marshal import CPyRecord - -from custom_datatype import CustomDatatype -from custom_datatype_helper import CustomDatatypeHelper -from _cffi import ffi, lib - -from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception - -from other_record import OtherRecord - -class OtherRecordHelper: - @staticmethod - def release(c_ptr): - assert c_ptr in c_data_set - c_data_set.remove(ffi.cast("void*", c_ptr)) - - @ffi.callback("struct DjinniRecordHandle *(struct DjinniRecordHandle *)") - def get_other_record_f1(cself): - try: - _ret = CPyRecord.fromPy(CustomDatatype.c_data_set, CPyRecord.toPy(None, cself).customDatatypeData) - assert _ret != ffi.NULL - return _ret - except Exception as _djinni_py_e: - CPyException.setExceptionFromPy(_djinni_py_e) - return ffi.NULL - - @ffi.callback("struct DjinniRecordHandle *(struct DjinniRecordHandle *)") - def create_other_record(customDatatypeData): - py_rec = OtherRecord( - CPyRecord.toPy(CustomDatatype.c_data_set, customDatatypeData)) - return CPyRecord.fromPy(OtherRecord.c_data_set, py_rec) #to do: can be optional? - - @ffi.callback("void (struct DjinniRecordHandle *)") - def __delete(dh): - assert dh in OtherRecord.c_data_set - OtherRecord.c_data_set.remove(dh) - - @staticmethod - def _add_callbacks(): - lib.other_record_add_callback___delete(OtherRecordHelper.__delete) - lib.other_record_add_callback_create_other_record(OtherRecordHelper.create_other_record) - lib.other_record_add_callback_get_other_record_f1(OtherRecordHelper.get_other_record_f1) - -OtherRecordHelper._add_callbacks() - diff --git a/src/it/scala/djinni/GeneratorIntegrationTest.scala b/src/it/scala/djinni/GeneratorIntegrationTest.scala index 6878b594..e90efc96 100644 --- a/src/it/scala/djinni/GeneratorIntegrationTest.scala +++ b/src/it/scala/djinni/GeneratorIntegrationTest.scala @@ -24,12 +24,7 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { "objcFilenames", "objcHeaderFilenames", "objcppFilenames", - "objcppHeaderFilenames", - "pythonFilenames", - "pyCffiFilenames", - "cWrapperFilenames", - "cWrapperHeaderFilenames", - "cppcliFilenames" + "objcppHeaderFilenames" ), ( "my_enum", @@ -41,12 +36,7 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { ObjC(), ObjCHeaders("ITMyEnum.h", "bridging-header.h"), ObjCpp(), - ObjCppHeaders("ITMyEnum+Private.h"), - Python("my_enum.py"), - PyCffi(), - CWrapper("dh__my_enum.cpp", "dh__my_enum.hpp"), - CWrapperHeaders("dh__my_enum.h"), - CppCli("MyEnum.hpp", "MyEnum.cpp") + ObjCppHeaders("ITMyEnum+Private.h") ), ( "my_flags", @@ -58,12 +48,7 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { ObjC(), ObjCHeaders("ITMyFlags.h"), ObjCpp(), - ObjCppHeaders("ITMyFlags+Private.h"), - Python("my_flags.py"), - PyCffi(), - CWrapper("dh__my_flags.cpp", "dh__my_flags.hpp"), - CWrapperHeaders("dh__my_flags.h"), - CppCli("MyFlags.hpp", "MyFlags.cpp") + ObjCppHeaders("ITMyFlags+Private.h") ), ( "my_record", @@ -75,28 +60,7 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { ObjC("ITMyRecord.mm"), ObjCHeaders("ITMyRecord.h", "bridging-header.h"), ObjCpp("ITMyRecord+Private.mm"), - ObjCppHeaders("ITMyRecord+Private.h"), - Python( - "dh__map_string_int32_t.py", - "dh__set_string.py", - "my_record.py", - "my_record_helper.py" - ), - PyCffi(), - CWrapper( - "dh__map_string_int32_t.cpp", - "dh__map_string_int32_t.hpp", - "dh__my_record.cpp", - "dh__my_record.hpp", - "dh__set_string.cpp", - "dh__set_string.hpp" - ), - CWrapperHeaders( - "dh__map_string_int32_t.h", - "dh__my_record.h", - "dh__set_string.h" - ), - CppCli("MyRecord.hpp", "MyRecord.cpp") + ObjCppHeaders("ITMyRecord+Private.h") ), ( "my_cpp_interface", @@ -108,12 +72,7 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { ObjC("ITMyCppInterface.mm"), ObjCHeaders("ITMyCppInterface.h", "bridging-header.h"), ObjCpp("ITMyCppInterface+Private.mm"), - ObjCppHeaders("ITMyCppInterface+Private.h"), - Python("my_cpp_interface.py"), - PyCffi("pycffi_lib_build.py"), - CWrapper("cw__my_cpp_interface.cpp", "cw__my_cpp_interface.hpp"), - CWrapperHeaders("cw__my_cpp_interface.h"), - CppCli("MyCppInterface.hpp", "MyCppInterface.cpp") + ObjCppHeaders("ITMyCppInterface+Private.h") ), ( "my_client_interface", @@ -125,12 +84,7 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { ObjC(), ObjCHeaders("ITMyClientInterface.h", "bridging-header.h"), ObjCpp("ITMyClientInterface+Private.mm"), - ObjCppHeaders("ITMyClientInterface+Private.h"), - Python("my_client_interface.py"), - PyCffi("pycffi_lib_build.py"), - CWrapper("cw__my_client_interface.cpp", "cw__my_client_interface.hpp"), - CWrapperHeaders("cw__my_client_interface.h"), - CppCli("MyClientInterface.hpp", "MyClientInterface.cpp") + ObjCppHeaders("ITMyClientInterface+Private.h") ), ( "all_datatypes", @@ -142,41 +96,7 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { ObjC("ITAllDatatypes.mm"), ObjCHeaders("ITAllDatatypes.h", "ITEnumData.h", "bridging-header.h"), ObjCpp("ITAllDatatypes+Private.mm"), - ObjCppHeaders("ITAllDatatypes+Private.h", "ITEnumData+Private.h"), - Python( - "all_datatypes.py", - "all_datatypes_helper.py", - "dh__list_bool.py", - "dh__map_int8_t_bool.py", - "dh__set_bool.py", - "enum_data.py" - ), - PyCffi(), - CWrapper( - "dh__all_datatypes.cpp", - "dh__all_datatypes.hpp", - "dh__list_bool.cpp", - "dh__list_bool.hpp", - "dh__map_int8_t_bool.cpp", - "dh__map_int8_t_bool.hpp", - "dh__set_bool.cpp", - "dh__set_bool.hpp", - "dh__enum_data.cpp", - "dh__enum_data.hpp" - ), - CWrapperHeaders( - "dh__all_datatypes.h", - "dh__list_bool.h", - "dh__map_int8_t_bool.h", - "dh__set_bool.h", - "dh__enum_data.h" - ), - CppCli( - "AllDatatypes.hpp", - "AllDatatypes.cpp", - "EnumData.cpp", - "EnumData.hpp" - ) + ObjCppHeaders("ITAllDatatypes+Private.h", "ITEnumData+Private.h") ), ( "using_custom_datatypes", @@ -192,22 +112,7 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { "bridging-header.h" ), ObjCpp("ITCustomDatatype+Private.mm", "ITOtherRecord+Private.mm"), - ObjCppHeaders("ITCustomDatatype+Private.h", "ITOtherRecord+Private.h"), - Python( - "custom_datatype.py", - "custom_datatype_helper.py", - "other_record.py", - "other_record_helper.py" - ), - PyCffi(), - CWrapper( - "dh__custom_datatype.cpp", - "dh__custom_datatype.hpp", - "dh__other_record.cpp", - "dh__other_record.hpp" - ), - CWrapperHeaders("dh__custom_datatype.h", "dh__other_record.h"), - CppCli("CustomDatatype.hpp", "CustomDatatype.cpp") + ObjCppHeaders("ITCustomDatatype+Private.h", "ITOtherRecord+Private.h") ) ) forAll(djinniTypes) { @@ -221,12 +126,7 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { objcFilenames: ObjC, objcHeaderFilenames: ObjCHeaders, objcppFilenames: ObjCpp, - objcppHeaderFilenames: ObjCppHeaders, - pythonFilenames: Python, - pyCffiFilenames: PyCffi, - cWrapperFilenames: CWrapper, - cWrapperHeaderFilenames: CWrapperHeaders, - cppcliFilenames: CppCli + objcppHeaderFilenames: ObjCppHeaders ) => it(s"should generate valid language bridges for `$idlFile`-types") { Given(s"`$idlFile.djinni`") @@ -282,35 +182,6 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { objcppHeaderFilenames ) - Then( - s"the expected files should be created for python: ${pythonFilenames.mkString(", ")}" - ) - assertFileContentEquals(idlFile, PY, pythonFilenames) - - Then( - s"the expected files should be created for cffi: ${pyCffiFilenames.mkString(", ")}" - ) - assertFileContentEquals(idlFile, CFFI, pyCffiFilenames) - - Then( - s"the expected source files should be created for c wrapper: ${cWrapperFilenames.mkString(", ")}" - ) - assertFileContentEquals(idlFile, CWRAPPER, cWrapperFilenames) - - Then( - s"the expected header files should be created for c wrapper: ${cWrapperHeaderFilenames.mkString(", ")}" - ) - assertFileContentEquals( - idlFile, - CWRAPPER_HEADERS, - cWrapperHeaderFilenames - ) - - Then( - s"the expected files should be created for C++/CLI: ${cppcliFilenames.mkString(", ")}" - ) - assertFileContentEquals(idlFile, CPPCLI, cppcliFilenames) - Then( "the file `generated-files.txt` should contain all generated files" ) @@ -334,9 +205,6 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { cpp = true, objc = false, java = false, - python = false, - cWrapper = false, - cppCLI = false, useNNHeader = true ) djinni(cmd) @@ -355,76 +223,6 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { ) } - it( - "should be able to generate C++/CLI outputs for interfaces with external dependencies" - ) { - val idlFile = "cppcli_extern_dependent_interface" - When(s"generating C++ language-bridges from `$idlFile.djinni`") - val cppcliFilenames = - CppCli("DependentInterface.hpp", "DependentInterface.cpp") - val cmd = djinniParams( - idlFile, - cpp = false, - objc = false, - java = false, - python = false, - cWrapper = false, - cppCLI = true, - useNNHeader = false - ) - djinni(cmd) - - Then( - s"the expected created C++/CLI files should be: ${cppcliFilenames.mkString(", ")}" - ) - assertFileContentEquals(idlFile, CPPCLI, cppcliFilenames) - - Then("the file `generated-files.txt` should contain all generated files") - assertFileContentEquals( - idlFile, - "", - List("generated-files.txt"), - s => Paths.get(s) - ) - } - - it( - "should be able to generate C++/CLI outputs for circular dependencies" - ) { - val idlFile = "cppcli_circular_dependent_interface" - When(s"generating C++ language-bridges from `$idlFile.djinni`") - val cppcliFilenames = CppCli( - "OneInterface.hpp", - "OneInterface.cpp", - "AnotherInterface.hpp", - "AnotherInterface.cpp" - ) - val cmd = djinniParams( - idlFile, - cpp = false, - objc = false, - java = false, - python = false, - cWrapper = false, - cppCLI = true, - useNNHeader = false - ) - djinni(cmd) - - Then( - s"the expected created C++/CLI files should be: ${cppcliFilenames.mkString(", ")}" - ) - assertFileContentEquals(idlFile, CPPCLI, cppcliFilenames) - - Then("the file `generated-files.txt` should contain all generated files") - assertFileContentEquals( - idlFile, - "", - List("generated-files.txt"), - s => Paths.get(s) - ) - } - it("should be able to generate C++ records without a default constructor") { val idlFile = "my_record_omit_default_ctor" When( @@ -436,9 +234,6 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { cpp = true, objc = false, java = false, - python = false, - cWrapper = false, - cppCLI = false, cppOmitDefaultRecordCtor = true ) djinni(cmd) @@ -457,41 +252,6 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { ) } - it( - "should be able to generate C++/CLI outputs with non-null pointers" - ) { - val idlFile = "cppcli_interface_nonnull" - When(s"generating C++ language-bridges from `$idlFile.djinni`") - val cppcliFilenames = CppCli( - "MyCppInterface.hpp", - "MyCppInterface.cpp" - ) - val cmd = djinniParams( - idlFile, - cpp = false, - objc = false, - java = false, - python = false, - cWrapper = false, - cppCLI = true, - useNNHeader = true - ) - djinni(cmd) - - Then( - s"the expected created C++/CLI files should be: ${cppcliFilenames.mkString(", ")}" - ) - assertFileContentEquals(idlFile, CPPCLI, cppcliFilenames) - - Then("the file `generated-files.txt` should contain all generated files") - assertFileContentEquals( - idlFile, - "", - List("generated-files.txt"), - s => Paths.get(s) - ) - } - it("should be able to only generate Java output") { val outputPath = "src/it/resources/result/only_java_out" When("calling the generator with just `--java-out`") @@ -553,9 +313,6 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { cpp = false, objc = true, java = false, - python = false, - cWrapper = false, - cppCLI = false, cppOmitDefaultRecordCtor = true ) djinni(cmd) @@ -569,35 +326,6 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { assertFileContentEquals(idlFile, OBJCPP_HEADERS, objcppHeaderFilenames) } - it( - "should be able to include C++/CLI generic type information for extern types" - ) { - Given( - "an IDL-file that uses a parameterized extern type that enables the C++/CLI option 'generics: true'" - ) - val idlFile = "extern_generics" - - When("generating the C++/CLI gluecode") - val cppcliFilenames = CppCli("MyRecord.hpp", "MyRecord.cpp") - val cmd = djinniParams( - idlFile, - cpp = false, - objc = false, - java = false, - python = false, - cWrapper = false, - cppCLI = true, - cppOmitDefaultRecordCtor = true - ) - - djinni(cmd) - - Then( - "the generic type parameters should be included in the C++/CLI type declarations" - ) - assertFileContentEquals(idlFile, CPPCLI, cppcliFilenames) - } - it( "should be able to include Java generic type information for extern types" ) { @@ -615,9 +343,6 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { cpp = false, objc = false, java = true, - python = false, - cWrapper = false, - cppCLI = false, cppOmitDefaultRecordCtor = true ) @@ -656,18 +381,6 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { assertFileExists(s"$outputPath/AllDatatypes+Private.mm") } - it("should be able to only generate C++/CLI output") { - val outputPath = "src/it/resources/result/only_cppcli_out" - When("calling the generator with just `--cppcli-out`") - val output = djinni( - s"--idl src/it/resources/all_datatypes.djinni --cppcli-out $outputPath" - ) - Then("the generator should successfully generate just C++/CLI output") - output should equal("Parsing...\nResolving...\nGenerating...\n") - assertFileExists(s"$outputPath/AllDatatypes.hpp") - assertFileExists(s"$outputPath/AllDatatypes.cpp") - } - it("should be able to only generate C++ output") { val outputPath = "src/it/resources/result/only_cpp_out" When("calling the generator with just `--cpp-out`") @@ -679,21 +392,6 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { assertFileExists(s"$outputPath/all_datatypes.hpp") } - it("should be able to only generate Python output") { - val outputPath = "src/it/resources/result/only_python_out" - When("calling the generator with just `--py-out`") - val output = djinni( - s"--idl src/it/resources/all_datatypes.djinni --py-out $outputPath" - ) - Then("the generator should successfully generate just python output") - output should equal("Parsing...\nResolving...\nGenerating...\n") - assertFileExists(s"$outputPath/all_datatypes.py") - assertFileExists(s"$outputPath/all_datatypes_helper.py") - assertFileExists(s"$outputPath/dh__list_bool.py") - assertFileExists(s"$outputPath/dh__map_int8_t_bool.py") - assertFileExists(s"$outputPath/dh__set_bool.py") - } - it("should be able to parse yaml files without all languages defined") { val outputPath = "src/it/resources/result/only_yaml_out" Given( @@ -784,9 +482,6 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { cpp = true, objc = false, java = false, - python = false, - cWrapper = false, - cppCLI = false, cppJsonSerialization = Some("nlohmann_json") ) djinni(cmd) @@ -858,9 +553,6 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { cpp = true, objc = false, java = false, - python = false, - cWrapper = false, - cppCLI = false, cppOmitDefaultRecordCtor = true ) @@ -888,9 +580,6 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { cpp = false, objc = false, java = true, - python = false, - cWrapper = false, - cppCLI = false, cppOmitDefaultRecordCtor = true ) @@ -922,9 +611,6 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { cpp = false, objc = true, java = false, - python = false, - cWrapper = false, - cppCLI = false, cppOmitDefaultRecordCtor = true ) @@ -971,9 +657,6 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen { cpp = true, objc = false, java = true, - python = false, - cWrapper = false, - cppCLI = false, cppOmitDefaultRecordCtor = false ) diff --git a/src/it/scala/djinni/IntegrationTest.scala b/src/it/scala/djinni/IntegrationTest.scala index 8db8d13a..a5f5e12e 100644 --- a/src/it/scala/djinni/IntegrationTest.scala +++ b/src/it/scala/djinni/IntegrationTest.scala @@ -23,11 +23,6 @@ class IntegrationTest extends AnyFunSpec { final val OBJC_HEADERS = "objc-headers" final val OBJCPP = "objcpp" final val OBJCPP_HEADERS = "objcpp-headers" - final val PY = "python" - final val CFFI = "cffi" - final val CWRAPPER = "cwrapper" - final val CWRAPPER_HEADERS = "cwrapper-headers" - final val CPPCLI = "cppcli" type Cpp = List[String] def Cpp(params: String*) = List(params: _*) @@ -47,16 +42,6 @@ class IntegrationTest extends AnyFunSpec { def ObjCpp(params: String*) = List(params: _*) type ObjCppHeaders = List[String] def ObjCppHeaders(params: String*) = List(params: _*) - type Python = List[String] - def Python(params: String*) = List(params: _*) - type PyCffi = List[String] - def PyCffi(params: String*) = List(params: _*) - type CWrapper = List[String] - def CWrapper(params: String*) = List(params: _*) - type CWrapperHeaders = List[String] - def CWrapperHeaders(params: String*) = List(params: _*) - type CppCli = List[String] - def CppCli(params: String*) = List(params: _*) /** Executes the djinni generator with the given parameters * @param parameters @@ -67,7 +52,21 @@ class IntegrationTest extends AnyFunSpec { def djinni(parameters: String): String = { val binExt = if (System.getProperty("os.name").startsWith("Windows")) ".bat" else "" - toUnixLineSeparator(s"target/bin/djinni${binExt} " + parameters !!) + val sbtBinary = "target/bin/djinni" + binExt + + if (new java.io.File(sbtBinary).isFile) { + // assume this is a sbt it:test. + // this expect that sbt assembly has been executed, and the executable is there + toUnixLineSeparator(sbtBinary + " " + parameters !!) + } else if (new java.io.File("bazel-bin/djinni").isFile) { + // bazel build, or anything else. Expect to find djinni in bazel-bin directory + toUnixLineSeparator("bazel-bin/djinni" + binExt + " " + parameters !!) + } else if (new java.io.File("djinni" + binExt).isFile) { + // fallback: djinni in current directory + toUnixLineSeparator("djinni" + binExt + " " + parameters !!) + } else { + fail("djinni executable not found") + } } /** Generates the command line parameters to pass to the djinni generator. @@ -84,12 +83,7 @@ class IntegrationTest extends AnyFunSpec { * Whether to generate Java output. Default: true. * @param objc * Whether to generate Objective C output. Default: true. - * @param python - * Whether to generate Python output. Default: true. - * @param cWrapper - * Whether to generate Python output. Default: true. - * @param cppCLI - * Whether to generate Python output. Default: true. + * * @param useNNHeader * Whether to use the nn.hpp header for non-null pointers. Default: false. * @param cppJsonSerialization @@ -105,9 +99,6 @@ class IntegrationTest extends AnyFunSpec { cpp: Boolean = true, java: Boolean = true, objc: Boolean = true, - python: Boolean = true, - cWrapper: Boolean = true, - cppCLI: Boolean = true, useNNHeader: Boolean = false, cppOmitDefaultRecordCtor: Boolean = false, cppJsonSerialization: Option[String] = None @@ -131,20 +122,7 @@ class IntegrationTest extends AnyFunSpec { cmd += s" --objcpp-out $baseOutputPath/$idl/$OBJCPP" cmd += s" --objcpp-header-out $baseOutputPath/$idl/$OBJCPP_HEADERS" } - if (python) { - cmd += s" --py-out $baseOutputPath/$idl/python" - cmd += s" --pycffi-out $baseOutputPath/$idl/cffi" - } - if (cWrapper) { - cmd += s" --c-wrapper-out $baseOutputPath/$idl/$CWRAPPER" - cmd += s" --c-wrapper-header-out $baseOutputPath/$idl/$CWRAPPER_HEADERS" - cmd += s" --c-wrapper-include-prefix ../$CWRAPPER_HEADERS/" - cmd += s" --c-wrapper-include-cpp-prefix ../$CPP_HEADERS/" - } - if (cppCLI) { - cmd += s" --cppcli-out $baseOutputPath/$idl/$CPPCLI" - cmd += s" --cppcli-include-cpp-prefix ../$CPP_HEADERS/" - } + if (useNNHeader) { cmd += " --cpp-nn-header nn.hpp" cmd += " --cpp-nn-type dropbox::oxygen::nn_shared_ptr" @@ -238,9 +216,13 @@ class IntegrationTest extends AnyFunSpec { ) { val directory = new Directory(new File(baseOutputPath)) if (directory.deleteRecursively()) { - System.console.printf( - "[info] Clean up old generated test output/files.\n" - ) + Option(System.console) match { + case Some(console) => + console.printf( + "[info] Clean up old generated test output/files.\n" + ) + case None => println("[info] Clean up old generated test output/files.") + } } } diff --git a/src/main/scala/djinni/CWrapperGenerator.scala b/src/main/scala/djinni/CWrapperGenerator.scala deleted file mode 100644 index 628b5eb9..00000000 --- a/src/main/scala/djinni/CWrapperGenerator.scala +++ /dev/null @@ -1,2443 +0,0 @@ -/** Copyright 2015 Dropbox, Inc. - * - * 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. - */ - -package djinni - -import djinni.ast._ -import djinni.generatorTools._ -import djinni.meta._ -import djinni.writer.IndentWriter - -import scala.collection.mutable - -class CWrapperGenerator(spec: Spec) extends Generator(spec) { - final val cWrapperBaseLibIncludePrefix = "djinni/cwrapper/" - - val marshal = new CWrapperMarshal(spec) - val cppMarshal = new CppMarshal(spec) - val dw = "djinni_this" - - def getCppDefArgs(m: Interface.Method, self: String): String = { - if (m.static || self == "") { - marshal.cArgDecl( - m.params.map(p => - cppMarshal.fqParamType(p.ty) + " " + idCpp.local(p.ident.name) - ) - ) - } else { - marshal.cArgDecl( - Seq[String](self) ++ - m.params.map(p => - cppMarshal.fqParamType(p.ty) + " " + idCpp.local(p.ident.name) - ) - ) - } - } - - def getDefArgs( - m: Interface.Method, - self: String, - forHeader: Boolean - ): String = { - if (m.static || self == "") { - marshal.cArgDecl( - m.params.map(p => - marshal.cParamType(p.ty, forHeader) + " " + idCpp.local(p.ident.name) - ) - ) - } else { - marshal.cArgDecl( - Seq[String](self) ++ - m.params.map(p => - marshal.cParamType(p.ty, forHeader) + " " + idCpp.local( - p.ident.name - ) - ) - ) - } - } - - def getCArgTypes( - m: Interface.Method, - self: String, - forHeader: Boolean - ): String = { - marshal.cArgDecl( - Seq(self) ++ m.params.map(p => marshal.cParamType(p.ty, forHeader)) - ) - } - - def getRecordTypes(r: Record, forHeader: Boolean): Seq[String] = { - r.fields.map(f => marshal.cParamType(f.ty, forHeader)) - } - - def getElementTypeRef(tm: MExpr, ident: Ident): TypeRef = { - val tref = TypeRef(TypeExpr(ident, Seq())) - tref.resolved = tm - return tref - } - - def getContainerElTypeRef(tm: MExpr, index: Int, ident: Ident): TypeRef = { - val tref = TypeRef(TypeExpr(ident, Seq())) - tref.resolved = tm.args(index) - return tref - } - - def declareGlobalGetter( - methodName: String, - ret: String, - cArgs: String, - className: String, - w: IndentWriter - ): Unit = { - val methodSignature = ret + p(" * ptr") + cArgs - - w.wl( - "static " + ret + " " + p( - " * " + marshal.callback(idCpp.method(className + methodName)) - ) + cArgs + ";" - ) - w.wl - w.wl( - "void " + idCpp.method(className + "_add_callback" + methodName) + p( - methodSignature - ) + " {" - ).nested { - w.wl(marshal.callback(idCpp.method(className + methodName)) + " = ptr;") - } - w.wl("}") - w.wl - } - - def declareGlobalGetterSignature( - methodName: String, - ret: String, - cArgs: String, - className: String, - w: IndentWriter - ): Unit = { - val methodSignature = ret + p(" * ptr") + cArgs - w.wl( - "void " + idCpp.method(className + "_add_callback" + methodName) + p( - methodSignature - ) + ";" - ) - } - - def writeWrapHandleAsUniquePointer( - tm: MExpr, - createMethod: String, - w: IndentWriter - ): Unit = { - w.wl( - "djinni::Handle" + t("DjinniObjectHandle") + " _handle(" + - createMethod + ", " + "& " + marshal.getReleaseMethodName(tm) + ");" - ) - } - - def declareObjectUniquePointerHandle( - tm: MExpr, - classAsMethodName: String, - w: IndentWriter - ): Unit = { - val createMethod = - marshal.callback(idCpp.method(classAsMethodName + "__create")) - writeWrapHandleAsUniquePointer(tm, createMethod + p(""), w) - } - - def getUniquePointerDeclarationIfNeeded( - elName: String, - elToFrom: String, - elTy: MExpr - ): String = { - val indentedElName = if (elName != "") " " + elName else elName - val decl = if (marshal.needsRAII(elTy)) { - if (marshal.canRAIIUseStandardUniquePtr(elTy)) { - // Optional Primitive don't need custom unique pointer deleters - "std::unique_ptr" + t( - marshal.removePointer(marshal.paramType(elTy)) - ) + indentedElName + p(elToFrom) - } else { - "djinni::Handle" + t( - marshal.removePointer(marshal.paramType(elTy)) - ) + indentedElName + p( - elToFrom + ", " + marshal.getReleaseMethodName(elTy) - ) - } - } else { - elToFrom - } - - return decl - } - - def declareUniquePointer( - elName: String, - elToFrom: String, - elTy: MExpr, - w: IndentWriter - ): Unit = { - val declaration = - getUniquePointerDeclarationIfNeeded(elName, elToFrom, elTy) - if (declaration != elToFrom) { // only if unique pointer was needed, write declaration - w.wl(declaration + ";") - } - } - - def raiiForElement(elToFrom: String, elTy: MExpr): String = { - getUniquePointerDeclarationIfNeeded("", elToFrom, elTy) - } - - def writeListToCpp( - tm: MExpr, - ident: Ident, - retType: String, - classAsMethodName: String, - w: IndentWriter - ): Unit = { - val elTyRef = getContainerElTypeRef(tm, 0, ident) - w.wl(retType + "_ret;") - w.wl( - "size_t size = " + marshal.callback( - idCpp.method(classAsMethodName) + idCpp.method("__get_size") + p( - "dh.get()" - ) + ";" - ) - ) - w.wl("_ret.reserve" + p("size") + ";") - w.wl - w.wl("for (int i = 0; i < size; i++) {").nested { - w.wl( - "_ret.push_back" + p( - marshal.convertTo( - raiiForElement( - marshal.callback( - idCpp.method(classAsMethodName) + idCpp - .method("__get_elem") + p("dh.get(), i") - ), - tm.args(0) - ), - elTyRef, - tempExpr = true - ) - ) + ";" - ) - } - w.wl("}") - w.wl - w.wl("return _ret;") - } - - def writeListFromCpp( - tm: MExpr, - ident: Ident, - retType: String, - classAsMethodName: String, - w: IndentWriter - ): Unit = { - val _ = retType // unused, TODO, check remove - val elTyRef = getContainerElTypeRef(tm, 0, ident) - val addToList = marshal.callback(idCpp.method(classAsMethodName + "__add")) - declareObjectUniquePointerHandle(tm, classAsMethodName, w) - - w.wl("size_t size = dc.size();") - w.wl("for (int i = 0; i < size; i++) {").nested { - if (marshal.needsRAII(elTyRef)) { - // separate taking ownership of memory and function call, when elements need RAII - w.wl("auto _el = " + marshal.convertFrom("dc[i]", elTyRef) + ";") - w.wl(addToList + p("_handle.get(), " + "_el.release()") + ";") - } else { - w.wl( - addToList + p( - "_handle.get(), " + marshal.convertFrom("dc[i]", elTyRef) - ) + ";" - ) - } - } - w.wl("}") - w.wl - w.wl("return _handle;") - - } - - def writeMapToCpp( - tm: MExpr, - ident: Ident, - retType: String, - className: String, - w: IndentWriter - ): Unit = { - val keyTyRef = getContainerElTypeRef(tm, 0, ident) - val valTyRef = getContainerElTypeRef(tm, 1, ident) - - w.wl(retType + "_ret;") - // Asking for size makes it easier to know when to stop asking for the next/ deciding what value would signal 'end of map' - w.wl( - "size_t size = " + marshal.callback( - idCpp.method(className) + idCpp.method("__get_size") + p( - "dh.get()" - ) + ";" - ) - ) - w.wl - w.wl("for (int i = 0; i < size; i++) {").nested { - w.wl( - "auto _key_c = " + raiiForElement( - marshal.callback( - idCpp.method(className) + idCpp.method("__next") + p("dh.get()") - ), - tm.args(0) - ) + "; // key that would potentially be surrounded by unique pointer" - ) - val key = - if (marshal.needsRAII(tm.args(0))) "_key_c.get()" - else "_key_c" // don't delete ownership - w.wl( - "auto _val = " + marshal.convertTo( - raiiForElement( - marshal.callback( - idCpp.method(className) + idCpp.method("__get_value") + p( - "dh.get(), " + key - ) - ), - tm.args(1) - ), - valTyRef, - tempExpr = true - ) + ";" - ) - w.wl - w.wl("auto _key = " + marshal.convertTo("_key_c", keyTyRef) + ";") - w.wl("_ret.emplace(std::move(_key), std::move(_val));") - } - w.wl("}") - w.wl - w.wl("return _ret;") - } - - def writeMapFromCpp( - tm: MExpr, - ident: Ident, - retType: String, - classAsMethodName: String, - w: IndentWriter - ): Unit = { - val _ = retType // unused, TODO, check remove - val addToMap = marshal.callback(idCpp.method(classAsMethodName + "__add")) - val keyTyRef = getContainerElTypeRef(tm, 0, ident) - val valTyRef = getContainerElTypeRef(tm, 1, ident) - - declareObjectUniquePointerHandle(tm, classAsMethodName, w) - w.wl("for (const auto & it : dc) {").nested { - val key = if (marshal.needsRAII(tm.args(0))) { - // separate taking ownership of memory and function call, when keys need RAII - w.wl("auto _key = " + marshal.convertFrom("it.first", keyTyRef) + ";") - "_key.release()" - } else marshal.convertFrom("it.first", keyTyRef) - - val value = if (marshal.needsRAII(tm.args(1))) { - // separate taking ownership of memory and function call, when values need RAII - w.wl("auto _val = " + marshal.convertFrom("it.second", valTyRef) + ";") - "_val.release()" - } else marshal.convertFrom("it.second", valTyRef) - - w.wl(addToMap + p("_handle.get(), " + key + ", " + value) + ";") - } - w.wl("}") - w.wl - w.wl("return _handle;") - - } - - def writeSetToCpp( - tm: MExpr, - ident: Ident, - retType: String, - className: String, - w: IndentWriter - ): Unit = { - val keyTyRef = getContainerElTypeRef(tm, 0, ident) - - w.wl(retType + "_ret;") - w.wl( - "size_t size = " + marshal.callback( - idCpp.method(className) + idCpp.method("__get_size") + p( - "dh.get()" - ) + ";" - ) - ) - w.wl - w.wl("for (int i = 0; i < size; i++) {").nested { - w.wl( - "auto _el = " + marshal.convertTo( - raiiForElement( - marshal.callback( - idCpp.method(className) + idCpp.method("__next") + p("dh.get()") - ), - tm.args(0) - ), - keyTyRef, - tempExpr = true - ) + ";" - ) - w.wl("_ret.insert(std::move(_el));") - } - w.wl("}") - w.wl - w.wl("return _ret;") - } - - def writeSetFromCpp( - tm: MExpr, - ident: Ident, - retType: String, - classAsMethodName: String, - w: IndentWriter - ): Unit = { - val _ = retType // unused, TODO, check remove - marshal.callback(idCpp.method(classAsMethodName + "__create")) - val addToMap = marshal.callback(idCpp.method(classAsMethodName + "__add")) - val keyTyRef = getContainerElTypeRef(tm, 0, ident) - declareObjectUniquePointerHandle(tm, classAsMethodName, w) - - w.wl("for (const auto & it : dc) {").nested { - val key_val = if (marshal.needsRAII(tm.args(0))) { - // separate taking ownership of memory and function call, when keys need RAII - w.wl("auto _key_val = " + marshal.convertFrom("it", keyTyRef) + ";") - "_key_val.release()" - } else marshal.convertFrom("it", keyTyRef) - - w.wl(addToMap + p("_handle.get(), " + key_val) + ";") - } - w.wl("}") - w.wl - w.wl("return _handle;") - } - - def declareGlobalGetters( - tm: MExpr, - ident: Ident, - retType: String, - className: String, - w: IndentWriter, - getName: String, - getType: String, - getReturnType: String, - addCArgs: String - ): Unit = { - val _ = (tm, ident, retType) // unused, TODO, check remove - val handle = "DjinniObjectHandle *" - var ret = "" - var cArgs = "" - if (getName != "") { - ret = getReturnType - cArgs = marshal.cArgDecl(Seq(handle, getType)) - declareGlobalGetter(getName, ret, cArgs, className, w) - } - - ret = "size_t" - cArgs = marshal.cArgDecl(Seq(handle)) - declareGlobalGetter("__get_size", ret, cArgs, className, w) - - ret = "DjinniObjectHandle *" - cArgs = marshal.cArgDecl(Seq()) - declareGlobalGetter("__create", ret, cArgs, className, w) - - ret = "void" - cArgs = marshal.cArgDecl(Seq(handle, addCArgs)) - declareGlobalGetter("__add", ret, cArgs, className, w) - } - - def declareGlobalGettersSignatures( - tm: MExpr, - ident: Ident, - retType: String, - className: String, - w: IndentWriter, - getName: String, - getType: String, - getReturnType: String, - addCArgs: String - ): Unit = { - val _ = (tm, ident, retType) // unused, TODO, check remove - val handle = "struct DjinniObjectHandle *" - var ret = "" - var cArgs = "" - if (getName != "") { - ret = getReturnType - cArgs = marshal.cArgDecl(Seq(handle, getType)) - declareGlobalGetterSignature(getName, ret, cArgs, className, w) - } - - ret = "size_t" - cArgs = marshal.cArgDecl(Seq(handle)) - declareGlobalGetterSignature("__get_size", ret, cArgs, className, w) - - ret = "struct DjinniObjectHandle *" - cArgs = marshal.cArgDecl(Seq()) - declareGlobalGetterSignature("__create", ret, cArgs, className, w) - - ret = "void" - cArgs = marshal.cArgDecl(Seq(handle, addCArgs)) - declareGlobalGetterSignature("__add", ret, cArgs, className, w) - } - - def writeObjectReleaseMethodSignature( - objectAsMethodName: String, - objectHandle: String, - w: IndentWriter - ): Unit = { - w.wl("void " + objectAsMethodName + "___delete" + p(objectHandle) + ";") - w.wl( - "void " + "optional_" + objectAsMethodName + "___delete" + p( - "struct DjinniOptionalObjectHandle *" - ) + ";" - ) - w.wl( - "void " + objectAsMethodName + "_add_callback_" + "__delete" + p( - "void(* ptr)" + p("struct " + marshal.djinniObjectHandle + " * ") - ) + ";" - ) - } - - def writeObjectReleaseMethods( - objectAsMethodName: String, - objectHandlePtr: String, - w: IndentWriter - ): Unit = { - // Callback for delete front-end object handle - w.wl( - "static void(*" + marshal.callback( - objectAsMethodName + "___delete" - ) + ")" + p(objectHandlePtr) + ";" - ) - w.wl( - "void " + objectAsMethodName + "_add_callback_" + "__delete" + p( - "void(* ptr)" + p(objectHandlePtr) - ) + " {" - ).nested { - w.wl(marshal.callback(objectAsMethodName + "___delete") + " = ptr;") - } - w.wl("}") - w.wl - // Function to call delete of record from front-end - var cArgs = marshal.cArgDecl(Seq(objectHandlePtr + " drh")) - w.wl("void " + objectAsMethodName + "___delete" + cArgs + " {").nested { - w.wl(marshal.callback(objectAsMethodName + "___delete") + p("drh") + ";") - } - w.wl("}") - cArgs = marshal.cArgDecl(Seq("DjinniOptionalObjectHandle * " + " drh")) - w.wl( - "void " + "optional_" + objectAsMethodName + "___delete" + cArgs + " {" - ).nested { - w.wl( - marshal.callback(objectAsMethodName + "___delete") + p( - p(objectHandlePtr) + " drh" - ) + ";" - ) - } - w.wl("}") - } - - def writeOptionalContainerFromCpp( - optHandle: String, - handle: String, - retType: String, - djinniWrapper: String, - deleteMethod: String, - w: IndentWriter - ): Unit = { - val _ = handle // unused, TODO, check remove - w.wl( - "djinni::Handle" + t(optHandle) + " " + djinniWrapper + "::fromCpp" + p( - spec.cppOptionalTemplate + t(retType) + " dc" - ) + " {" - ).nested { - w.wl("if (!dc) {").nested { - w.wl("return nullptr;") - } - w.wl("}") - w.wl( - "return " + "djinni::optionals::toOptionalHandle" + p( - djinniWrapper + "::fromCpp" + p( - "std::move(* dc)" - ) + ", " + deleteMethod - ) + ";" - ) - } - w.wl("}") - w.wl - } - - def writeOptionalContainerToCpp( - optHandle: String, - retTypeStr: String, - djinniWrapper: String, - reinterpret: String, - deleteMethod: String, - w: IndentWriter - ): Unit = { - val _ = reinterpret // unused, TODO, check remove - w.wl( - spec.cppOptionalTemplate + t(retTypeStr) + djinniWrapper + "::toCpp" + p( - "djinni::Handle" + t(optHandle) + " dh" - ) + " {" - ).nested { - w.wl(" if (dh) {").nested { - w.wl( - "return " + spec.cppOptionalTemplate + t(retTypeStr) + p( - djinniWrapper + "::toCpp" + p( - "djinni::optionals::fromOptionalHandle(std::move(dh), " + deleteMethod + ")" - ) - ) + ";" - ) - } - w.wl("}") - w.wl("return {};") - } - w.wl("}") - w.wl - } - - def writeContainerFromToCpp( - handle: String, - optHandle: String, - cppHandle: String, - cppOptHandle: String, - tm: MExpr, - retType: String, - w: IndentWriter - ): Unit = { - val _ = (handle, optHandle) // unused, TODO, check remove - w.wl( - "static " + "djinni::Handle" + t(cppHandle) + " fromCpp" + p( - cppMarshal.fqParamType(tm) + " dc" - ) + ";" - ) - w.wl( - "static " + retType + " toCpp" + p( - "djinni::Handle" + t(cppHandle) + " dh" - ) + ";" - ) - - w.wl( - "static " + "djinni::Handle" + t(cppOptHandle) + "fromCpp" + p( - spec.cppOptionalTemplate + t(retType) + " dc" - ) + ";" - ) - w.wl( - "static " + spec.cppOptionalTemplate + t(retType) + " toCpp" + p( - "djinni::Handle" + t(cppOptHandle) + " dh" - ) + ";" - ) - } - - def generateList( - tm: MExpr, - name: String, - className: String, - ident: Ident, - origin: String, - h: mutable.TreeSet[String], - hpp: mutable.TreeSet[String] - ): Unit = { - val _ = className // unused, TODO, check remove - // className is the composed idl named of the container type - val handle = "DjinniObjectHandle" - val handlePtr = handle + " *" - val optHandle = "DjinniOptionalObjectHandle" - val optHandlePtr = optHandle + " *" - val fileName = marshal.dh + name - val classAsMethodName = name - val djinniWrapper = "Djinni" + idCpp.ty(name) - - // typerefing to be able to use the cpp returnType function - val listTyRef = TypeRef(TypeExpr(ident, Seq())) - listTyRef.resolved = tm - val retType = cppMarshal.fqReturnType(Some(listTyRef)) - - var listElType = - marshal.cParamType(getContainerElTypeRef(tm, 0, ident), true) - - writeCHeader( - fileName, - origin, - "", - h, - true, - w => { - writeObjectReleaseMethodSignature(name, "struct " + handlePtr, w) - declareGlobalGettersSignatures( - tm, - ident, - retType, - classAsMethodName, - w, - "__get_elem", - "size_t", - listElType, - listElType - ) - } - ) - - listElType = marshal.cParamType(getContainerElTypeRef(tm, 0, ident), false) - writeContainerCppHeader( - fileName, - ident, - origin, - djinniWrapper, - handlePtr, - optHandlePtr, - handle, - optHandle, - tm, - retType - ) - - writeCFile( - fileName, - ident.name, - origin, - hpp, - true, - w => { - writeObjectReleaseMethods(name, handlePtr, w) - // declare global list methods (get size, get elem, create..) - declareGlobalGetters( - tm, - ident, - retType, - classAsMethodName, - w, - "__get_elem", - "size_t", - listElType, - listElType - ) - // List from cpp - w.wl( - "djinni::Handle" + t(handle) + " " + djinniWrapper + "::fromCpp" + p( - cppMarshal.fqParamType(tm) + " dc" - ) + " {" - ).nested { - writeListFromCpp(tm, ident, retType, classAsMethodName, w) - } - w.wl("}") - w.wl - // List to cpp - w.wl( - retType + " " + djinniWrapper + "::toCpp" + p( - "djinni::Handle" + t(handle) + " dh" - ) + " {" - ).nested { - writeListToCpp(tm, ident, retType, classAsMethodName, w) - } - w.wl("}") - w.wl - writeOptionalContainerFromCpp( - optHandle, - handle, - retType, - djinniWrapper, - "optional_" + marshal.getReleaseMethodName(tm), - w - ) - writeOptionalContainerToCpp( - optHandle, - retType, - djinniWrapper, - handlePtr, - marshal.getReleaseMethodName(tm), - w - ) - } - ) - } - - def generateMap( - tm: MExpr, - name: String, - className: String, - ident: Ident, - origin: String, - h: mutable.TreeSet[String], - hpp: mutable.TreeSet[String] - ): Unit = { - val _ = className // unused, TODO, check remove - // className is the composed idl named of the container type - val handle = "DjinniObjectHandle" - val handlePtr = "DjinniObjectHandle *" - val optHandle = "DjinniOptionalObjectHandle" - val optHandlePtr = "DjinniOptionalObjectHandle *" - val fileName = marshal.dh + name - val classAsMethodName = name - val djinniWrapper = "Djinni" + idCpp.ty(name) - - // typerefing to be able to use the cpp returnType function - val mapTyRef = TypeRef(TypeExpr(ident, Seq())) - mapTyRef.resolved = tm - val retType = cppMarshal.fqReturnType(Some(mapTyRef)) - - var keyType = marshal.cParamType(getContainerElTypeRef(tm, 0, ident), true) - var valType = marshal.cParamType(getContainerElTypeRef(tm, 1, ident), true) - - writeCHeader( - fileName, - origin, - "", - h, - true, - w => { - writeObjectReleaseMethodSignature(name, "struct " + handlePtr, w) - declareGlobalGettersSignatures( - tm, - ident, - retType, - classAsMethodName, - w, - "__get_value", - keyType, - valType, - keyType + ", " + valType - ) - - // __next - val ret = keyType - val cArgs = marshal.cArgDecl(Seq("struct " + handlePtr)) - declareGlobalGetterSignature("__next", ret, cArgs, classAsMethodName, w) - } - ) - - keyType = marshal.cParamType(getContainerElTypeRef(tm, 0, ident), false) - valType = marshal.cParamType(getContainerElTypeRef(tm, 1, ident), false) - writeContainerCppHeader( - fileName, - ident, - origin, - djinniWrapper, - handlePtr, - optHandlePtr, - handle, - optHandle, - tm, - retType - ) - - writeCFile( - fileName, - ident.name, - origin, - hpp, - true, - w => { - writeObjectReleaseMethods(name, handlePtr, w) - // declare global list methods (get size, get elem, create..) - declareGlobalGetters( - tm, - ident, - retType, - classAsMethodName, - w, - "__get_value", - keyType, - valType, - keyType + ", " + valType - ) - - // __next - val ret = keyType - val cArgs = marshal.cArgDecl(Seq(handlePtr)) - declareGlobalGetter("__next", ret, cArgs, classAsMethodName, w) - - // Map from cpp - w.wl( - "djinni::Handle" + t(handle) + " " + djinniWrapper + "::fromCpp" + p( - cppMarshal.fqParamType(tm) + " dc" - ) + " {" - ).nested { - writeMapFromCpp(tm, ident, retType, classAsMethodName, w) - } - w.wl("}") - w.wl - // Map to cpp - w.wl( - retType + " " + djinniWrapper + "::toCpp" + p( - "djinni::Handle" + t(handle) + " dh" - ) + " {" - ).nested { - writeMapToCpp(tm, ident, retType, classAsMethodName, w) - } - w.wl("}") - w.wl - - writeOptionalContainerFromCpp( - optHandle, - handle, - retType, - djinniWrapper, - "optional_" + marshal.getReleaseMethodName(tm), - w - ) - writeOptionalContainerToCpp( - optHandle, - retType, - djinniWrapper, - handlePtr, - marshal.getReleaseMethodName(tm), - w - ) - } - ) - - } - - def writeContainerCppHeader( - fileName: String, - ident: Ident, - origin: String, - djinniWrapper: String, - handlePtr: String, - optHandlePtr: String, - handle: String, - optHandle: String, - tm: MExpr, - retType: String - ): Unit = { - writeCppHeader( - fileName, - ident.name, - origin, - "", - true, - w => { - w.wl("struct " + djinniWrapper + " {").nested { - writeContainerFromToCpp( - handlePtr, - optHandlePtr, - handle, - optHandle, - tm, - retType, - w - ) - } - w.wl("};") - } - ) - } - - def generateSet( - tm: MExpr, - name: String, - className: String, - ident: Ident, - origin: String, - h: mutable.TreeSet[String], - hpp: mutable.TreeSet[String] - ): Unit = { - val _ = className // unused, TODO, check remove - // className is the composed idl named of the container type - val handle = "DjinniObjectHandle" - val handlePtr = "DjinniObjectHandle *" - val optHandle = "DjinniOptionalObjectHandle" - val optHandlePtr = "DjinniOptionalObjectHandle *" - val fileName = marshal.dh + name - val classAsMethodName = name - val djinniWrapper = "Djinni" + idCpp.ty(name) - - // typerefing to be able to use the cpp returnType function - val setTyRef = TypeRef(TypeExpr(ident, Seq())) - setTyRef.resolved = tm - val retType = cppMarshal.fqReturnType(Some(setTyRef)) - - var keyType = marshal.cParamType(getContainerElTypeRef(tm, 0, ident), true) - - writeCHeader( - fileName, - origin, - "", - h, - true, - w => { - writeObjectReleaseMethodSignature(name, "struct " + handlePtr, w) - declareGlobalGettersSignatures( - tm, - ident, - retType, - classAsMethodName, - w, - "", - "", - keyType, - keyType - ) - - // __next - val ret = keyType - val cArgs = marshal.cArgDecl(Seq("struct " + handlePtr)) - declareGlobalGetterSignature("__next", ret, cArgs, classAsMethodName, w) - } - ) - - keyType = marshal.cParamType(getContainerElTypeRef(tm, 0, ident), false) - writeContainerCppHeader( - fileName, - ident, - origin, - djinniWrapper, - handlePtr, - optHandlePtr, - handle, - optHandle, - tm, - retType - ) - - writeCFile( - fileName, - ident.name, - origin, - hpp, - true, - w => { - writeObjectReleaseMethods(name, handlePtr, w) - // declare global list methods (get size, get elem, create..) - declareGlobalGetters( - tm, - ident, - retType, - classAsMethodName, - w, - "", - "", - keyType, - keyType - ) - - // __next - val ret = keyType - val cArgs = marshal.cArgDecl(Seq(handlePtr)) - declareGlobalGetter("__next", ret, cArgs, classAsMethodName, w) - - // Set from cpp - w.wl( - "djinni::Handle" + t(handle) + " " + djinniWrapper + "::fromCpp" + p( - cppMarshal.fqParamType(tm) + " dc" - ) + " {" - ).nested { - writeSetFromCpp(tm, ident, retType, classAsMethodName, w) - } - w.wl("}") - w.wl - // Set to cpp - w.wl( - retType + " " + djinniWrapper + "::toCpp" + p( - "djinni::Handle" + t(handle) + " dh" - ) + " {" - ).nested { - writeSetToCpp(tm, ident, retType, classAsMethodName, w) - } - w.wl("}") - w.wl - writeOptionalContainerFromCpp( - optHandle, - handle, - retType, - djinniWrapper, - "optional_" + marshal.getReleaseMethodName(tm), - w - ) - writeOptionalContainerToCpp( - optHandle, - retType, - djinniWrapper, - handlePtr, - marshal.getReleaseMethodName(tm), - w - ) - } - ) - - } - - class CRefs(ident: Ident, origin: String) { - var hpp: mutable.TreeSet[String] = mutable.TreeSet[String]() - var h: mutable.TreeSet[String] = mutable.TreeSet[String]() - - def collect(ty: TypeRef, justCollect: Boolean): Unit = { - collect(ty.resolved, justCollect) - } - def collect(tm: MExpr, justCollect: Boolean): Unit = { - tm.args.foreach(t => collect(t, justCollect)) - collect(tm.base, justCollect) - - val name = marshal.getExprIdlName(tm) - val fileName = marshal.dh + name + ".hpp" - if (justCollect) { - if (tm.base == MList || tm.base == MSet || tm.base == MMap) { - hpp.add("#include " + q(fileName)) - } - } else { - val className = "struct Djinni" + idCpp.ty(marshal.getExprIdlName(tm)) - if ( - !Generator.writtenFiles.contains( - (marshal.dh + name + ".hpp").toLowerCase() - ) - ) { - Generator.writtenFiles.put(fileName.toLowerCase(), fileName) - tm.base match { - case MList => - generateList(tm, name, className, ident, origin, h, hpp) - case MMap => generateMap(tm, name, className, ident, origin, h, hpp) - case MSet => generateSet(tm, name, className, ident, origin, h, hpp) - case _ => - } - } - } - } - def collect(m: Meta, justCollect: Boolean): Unit = if (justCollect) - for (r <- marshal references (m, ident)) r match { - case ImportRef(arg) => - if (arg.endsWith(".hpp\"") || !arg.contains(".")) - hpp.add("#include " + arg + marshal.pythonCdefIgnore) - else h.add("#include " + arg) - case _ => - } - } - - def declareGlobalFunctionPointers( - ident: Ident, - cClassWrapper: String, - methods: Seq[Interface.Method], - w: IndentWriter - ): Unit = { - val _ = cClassWrapper // unused, TODO, check remove - for (m <- methods) { - val ret = marshal.cReturnType(m.ret, false) - val cArgs = getCArgTypes(m, marshal.djinniObjectHandle + " * ", false) - w.wl( - "static " + ret + "(*" + marshal.callback( - idCpp.method(ident.name) + "_" + idCpp.method(m.ident.name) - ) + ")" + cArgs + ";" - ) - } - // function to delete handler to front-end object - w.wl( - "static void(*" + marshal.callback( - idCpp.method(ident.name) + "___delete" - ) + ")" + p(marshal.djinniObjectHandle + " * ") + ";" - ) - } - - def declareGlobalRecordFieldGetters( - ident: Ident, - r: Record, - prefix: String, - number: Int, - w: IndentWriter - ): Unit = { - val recordAsMethodName = idCpp.method(ident.name) - var field_number = number - for (f <- r.fields) { - field_number += 1 - val f_id = prefix + field_number.toString() - - val ret = marshal.returnType(Some(f.ty)) - val cArgs = marshal.cArgDecl(Seq("DjinniRecordHandle *")) - declareGlobalGetter( - "_get_" + ident.name + "_f" + f_id, - ret, - cArgs, - recordAsMethodName, - w - ) - - } - val ret = "DjinniRecordHandle *" - val cArgs = marshal.cArgDecl(getRecordTypes(r, false)) - declareGlobalGetter( - "_create_" + recordAsMethodName, - ret, - cArgs, - recordAsMethodName, - w - ) - } - - def declareGlobalSignaturesRecordFieldGetters( - ident: Ident, - r: Record, - prefix: String, - number: Int, - w: IndentWriter - ): Unit = { - val recordAsMethodName = idCpp.method(ident.name) - var field_number = number - for (f <- r.fields) { - field_number += 1 - val f_id = prefix + field_number.toString() - - val ret = marshal.cReturnType(Some(f.ty), true) - val cArgs = marshal.cArgDecl(Seq("struct DjinniRecordHandle *")) - declareGlobalGetterSignature( - "_get_" + ident.name + "_f" + f_id, - ret, - cArgs, - recordAsMethodName, - w - ) - } - - // For creating record - var ret = "struct DjinniRecordHandle *" - var cArgs = marshal.cArgDecl(getRecordTypes(r, true)) - declareGlobalGetterSignature( - "_create_" + recordAsMethodName, - ret, - cArgs, - recordAsMethodName, - w - ) - // For releasing record - ret = "void" - cArgs = marshal.cArgDecl(Seq("struct DjinniRecordHandle *")) - declareGlobalGetterSignature("___delete", ret, cArgs, recordAsMethodName, w) - } - - def writeRecordToCpp( - ident: Ident, - r: Record, - prefix: String, - number: Int, - w: IndentWriter - ): IndentWriter = { - val recordAsFqClassType = withCppNs(idCpp.ty(ident.name)) - val recordAsMethodName = idCpp.method(ident.name) - var field_number = number - - // get ownership of record fields memory - for (f <- r.fields) { - field_number += 1 - val f_id = prefix + field_number.toString() - val methodName = - recordAsMethodName + "_" + "get_" + ident.name + "_f" + f_id - if (marshal.needsRAII(f.ty)) { - declareUniquePointer( - "_field_" + idCpp.method(f.ident.name), - marshal.callback(idCpp.method(methodName) + p("dh.get()")), - f.ty.resolved, - w - ) - } - } - w.wl - - field_number = number - w.wl("auto _aux = " + recordAsFqClassType + "(").nested { - val skipFirst = SkipFirst() - for (f <- r.fields) { - field_number += 1 - val f_id = prefix + field_number.toString() - val methodName = - recordAsMethodName + "_" + "get_" + ident.name + "_f" + f_id - - skipFirst { w.wl(",") } - if (marshal.needsRAII(f.ty)) { - w.w( - marshal.convertTo(" _field_" + idCpp.method(f.ident.name), f.ty) - ) // RAII done above - } else { - w.w( - marshal.convertTo( - marshal.callback(idCpp.method(methodName) + p("dh.get()")), - f.ty, - tempExpr = true - ) - ) - } - } - } - w.wl(");") - w.wl("return _aux;") - } - def writeRecordFromCpp( - ident: Ident, - r: Record, - prefix: String, - number: Int, - w: IndentWriter - ): IndentWriter = { - val _ = (prefix, number) // unused, TODO, check remove - val recordAsMethodName = idCpp.method(ident.name) - - for (f <- r.fields) { - if (marshal.needsRAII(f.ty)) { - w.wl( - "auto _field_" + idCpp.method(f.ident.name) + " = " + marshal - .convertFrom("dr." + f.ident.name, f.ty) + ";" - ) - } - } - w.wl - w.wl("djinni::Handle" + t("DjinniRecordHandle") + " _aux(").nested { - w.wl( - marshal.callback( - recordAsMethodName + idCpp.method("_create_") + recordAsMethodName - ) + "(" - ).nested { - val skipFirst = SkipFirst() - for (f <- r.fields) { - skipFirst { - w.wl(",") - } - if (marshal.needsRAII(f.ty)) { - w.w("_field_" + idCpp.method(f.ident.name) + ".release()") - } else - w.w(marshal.convertFrom("dr." + idCpp.local(f.ident.name), f.ty)) - - } - } - w.wl("),") - w.wl(recordAsMethodName + "___delete" + ");") - } - w.wl("return _aux;") - } - - def writeCFile( - fileName: String, - ident: String, - origin: String, - includes: Iterable[String], - create: Boolean, - f: IndentWriter => Unit - ): Unit = { - if (create) - createFile( - spec.cWrapperOutFolder.get, - fileName + ".cpp", - (w: IndentWriter) => { - w.wl("// AUTOGENERATED FILE - DO NOT MODIFY!") - w.wl("// This file was generated by Djinni from " + origin) - w.wl - // always include support library - w.wl("#include // for debugging") - w.wl("#include ") - w.wl( - "#include " + q( - cWrapperBaseLibIncludePrefix + "wrapper_marshal.hpp" - ) - ) - w.wl( - "#include " + q(spec.cWrapperIncludeCppPrefix + ident + ".hpp") - ) // include abstract cpp base class header - // Includes for Djinni Wrappers - if (includes.nonEmpty) { - w.wl - includes.foreach(i => { w.wl(marshal.removeComment(i)) }) - } - w.wl - } - ) - appendToFile( - spec.cWrapperOutFolder.get, - fileName + ".cpp", - (w: IndentWriter) => { - f(w) - } - ) - } - - def writeAsExternC(w: IndentWriter, f: IndentWriter => Unit): Unit = { - w.wl("#ifdef __cplusplus") - w.wl("extern \"C\" {") - w.wl("#endif") - w.wl - f(w) - w.wl - w.wl("#ifdef __cplusplus") - w.wl("}") - w.wl("#endif") - } - - def writeCHeader( - fileName: String, - origin: String, - cppClass: String, - includes: Iterable[String], - create: Boolean, - f: IndentWriter => Unit - ): Unit = { - val _ = cppClass // unused, TODO, check remove - if (create) - createFile( - spec.cWrapperHeaderOutFolder.get, - fileName + ".h", - (w: IndentWriter) => { - w.wl("// AUTOGENERATED FILE - DO NOT MODIFY!") - w.wl("// This file was generated by Djinni from " + origin) - w.wl - w.wl("#pragma once" + marshal.pythonCdefIgnore) - // Includes for referenced types - w.wl( - "#include " + marshal.pythonCdefIgnore - ) // seeing if 2 handles are equal needs this - if (includes.nonEmpty) { - w.wl - includes.foreach(w.wl) - } - } - ) - appendToFile( - spec.cWrapperHeaderOutFolder.get, - fileName + ".h", - (w: IndentWriter) => { - w.wl - f(w) - } - ) - } - - def writeCppHeader( - fileName: String, - ident: String, - origin: String, - cppClass: String, - create: Boolean, - f: IndentWriter => Unit - ): Unit = { - val _ = cppClass // unused, TODO, check remove - // hpp file contains definition of DjinniStruct wrapper over cpp shared_ptr - // meant to facilitate interuse of interfaces across files - if (create) - createFile( - spec.cWrapperOutFolder.get, - fileName + ".hpp", - (w: IndentWriter) => { - w.wl("// AUTOGENERATED FILE - DO NOT MODIFY!") - w.wl("// This file was generated by Djinni from " + origin) - w.wl - w.wl("#pragma once") - w.wl - w.wl("#include ") - w.wl("#include " + spec.cppOptionalHeader) - w.wl( - "#include " + q(spec.cWrapperIncludeCppPrefix + ident + ".hpp") - ) // include abstract cpp base class header - writeAsExternC( - w, - w => { - w.wl( - "#include " + q(spec.cWrapperIncludePrefix + fileName + ".h") - ) // include own header - } - ) - } - ) - appendToFile( - spec.cWrapperOutFolder.get, - fileName + ".hpp", - (w: IndentWriter) => { - f(w) - } - ) - } - - def writeMethodSignatures( - methods: Seq[Interface.Method], - forHeader: Boolean, - forCpp: Boolean, - cWrapper: String, - cMethodWrapper: String, - w: IndentWriter - ): Unit = { - val structCWrapper = if (cWrapper != "") "struct " + cWrapper else "" - val self = if (structCWrapper != "") structCWrapper + " * " + dw else "" - // C Wrapper method signatures for calling into cpp - for (m <- methods) { - val ret = - if (forCpp) cppMarshal.fqReturnType(m.ret) - else marshal.cReturnType(m.ret, forHeader) - - val params = - if (forCpp) getCppDefArgs(m, self) else getDefArgs(m, self, true) - w.wl( - ret + " " + cMethodWrapper + idCpp.method(m.ident.name) + params + ";" - ) - w.wl - } - } - - def writeGetWrappedObj( - ident: Ident, - w: IndentWriter, - className: String, - ext: Ext - ): Unit = { - w.wl( - "std::shared_ptr<" + withCppNs(className) + "> " + marshal.wrappedName( - className - ) + "::get" + p( - "djinni::WrapperRef" + t(marshal.wrappedName(className)) + " dw" - ) + " {" - ).nested { - w.wl("if (dw) {").nested { - w.wl("return dw->wrapped_obj;") - } - w.wl("}") - w.wl("return nullptr;") - } - w.wl("}") - w.wl - - if (ext.py) { - w.wl( - "void " + idCpp.method(ident.name) + "___delete" + p( - marshal.djinniObjectHandle + " * dh" - ) + " {" - ).nested { - // Only if we implement the interface in front-end, will there be a delete from front-end callback - w.wl( - marshal.callback(idCpp.method(ident.name) + "___delete") + p( - "dh" - ) + ";" - ) - } - w.wl("}") - } - - w.wl( - "void " + idCpp.method(ident.name) + "___wrapper_add_ref" + p( - marshal.wrappedName(className) + " * dh" - ) + " {" - ).nested { - w.wl("dh->ref_count.fetch_add(1);") - } - w.wl("}") - - w.wl( - "void " + idCpp.method(ident.name) + "___wrapper_dec_ref" + p( - marshal.wrappedName(className) + " * dh" - ) + " {" - ).nested { - w.wl("const size_t ref = dh->ref_count.fetch_sub(1);") - w.wl("if (ref == 1) {// value before sub is returned").nested { - w.wl("delete dh;") - } - w.wl("}") - } - w.wl("}") - - w.wl( - "djinni::Handle" + t(marshal.wrappedName(className)) + " " + marshal - .wrappedName(className) + "::wrap" + p( - "std::shared_ptr<" + withCppNs(className) + "> obj" - ) + " {" - ).nested { - w.wl("if (obj)").nested { - w.wl( - "return " + "djinni::Handle" + t(marshal.wrappedName(className)) + p( - "new " + marshal.wrappedName(className) + "{ std::move(obj) }, " + - idCpp.method(ident.name) + "___wrapper_dec_ref" - ) + ";" - ) - } - w.wl("return nullptr;") - } - w.wl("}") - w.wl - } - - def writeDjinniWrapper( - ident: Ident, - w: IndentWriter, - className: String - ): Unit = { - val _ = ident // unused, TODO, check remove - w.wl("struct " + marshal.wrappedName(className) + " final {").nested { - w.wl( - marshal.wrappedName(className) + p( - "std::shared_ptr" + t(withCppNs(className)) + "wo" - ) + ": wrapped_obj" + p("wo") + " {};" - ) - w.wl - w.wl( - "static std::shared_ptr" + t(withCppNs(className)) + " " + "get" + p( - "djinni::Handle" + t(marshal.wrappedName(className)) + " dw" - ) + ";" - ) - w.wl( - "static djinni::Handle" + t( - marshal.wrappedName(className) - ) + " wrap" + p( - "std::shared_ptr" + t(withCppNs(className)) + " obj" - ) + ";" - ) - w.wl - w.wl( - "const " + "std::shared_ptr" + t( - withCppNs(className) - ) + " " + "wrapped_obj;" - ) - w.wl("std::atomic ref_count {1};") - } - w.wl("};") - } - - def writeDjinniUnwrapperSignature( - cMethodWrapper: String, - cWrapper: String, - ext: Ext, - w: IndentWriter - ): Unit = { - if (ext.py) { - w.wl( - "void " + cMethodWrapper + "___delete(" + "struct " + marshal.djinniObjectHandle + " * " + dw + ");" - ) - } - w.wl( - "void " + idCpp.method(cMethodWrapper) + "___wrapper_dec_ref" + p( - "struct " + cWrapper + " * dh" - ) + ";" - ) - w.wl( - "void " + idCpp.method(cMethodWrapper) + "___wrapper_add_ref" + p( - "struct " + cWrapper + " * dh" - ) + ";" - ) - } - - def checkNonOptionals(m: Interface.Method, w: IndentWriter): Unit = { - m.params.map(arg => - if (arg.ty.resolved.base != MOptional) - w.wl("assert " + p(arg.ident.name + " != nullptr") + ";") - ) - } - - def writeMethodToCpp( - m: Interface.Method, - fctPrefix: String, - cWrapper: String, - cMethodWrapper: String, - w: IndentWriter - ): Unit = { - val ret = marshal.cReturnType(m.ret, false) - val args = m.params.map(p => - marshal.convertTo( - (if (marshal.needsRAII(p.ty.resolved)) "_" else "") + p.ident.name, - p.ty, - tempExpr = false - ) - ) // x - val fctCall = - fctPrefix + idCpp.method(m.ident.name) + marshal.cArgVals(args) - val returnStmt = - if (m.ret.isEmpty) fctCall + ";" - else - "return " + marshal.convertFrom( - fctCall, - m.ret.get, - tempExpr = true - ) + (if (marshal.needsRAII(m.ret.get)) ".release()" else "") + ";" - - val params = getDefArgs(m, cWrapper + " * " + dw, false) - w.wl( - ret + " " + cMethodWrapper + "_" + idCpp.method( - m.ident.name - ) + params + " {" - ).nested { - // take ownership of arguments memory when arguments come from front-end - m.params.foreach(p => - declareUniquePointer("_" + p.ident.name, p.ident.name, p.ty.resolved, w) - ) - w.wl("try {").nested { - w.wl(returnStmt) - } - val onExceptionReturn = if (m.ret.isDefined) "0" else "" - w.wl("} CW_TRANSLATE_EXCEPTIONS_RETURN" + p(onExceptionReturn) + ";") - } - w.wl("}") - } - - def writeMethodFromCpp( - ident: Ident, - m: Interface.Method, - cppClass: String, - handle: String, - w: IndentWriter - ): Unit = { - val ret = cppMarshal.fqReturnType(m.ret) - val args = marshal.cArgDecl( - m.params.map(p => - cppMarshal.fqParamType(p.ty) + " " + idCpp.local(p.ident.name) - ) - ) - val params = Seq(handle) ++ m.params.map(p => - if (marshal.needsRAII(p.ty.resolved)) - "_" + idCpp.local(p.ident.name) + ".release()" - else marshal.convertFrom(idCpp.local(p.ident.name), p.ty) - ) - - w.wl(ret + " " + cppClass + "::" + idCpp.method(m.ident.name) + args + " {") - .nested { - // take ownership of arguments memory when arguments come from front-end - m.params.foreach(p => - if (marshal.needsRAII(p.ty)) - w.wl( - "auto _" + p.ident.name + " = " + marshal - .convertFrom(p.ident.name, p.ty) + ";" - ) - ) - - val method_call = marshal.callback( - idCpp.method(ident.name) + "_" + idCpp.method(m.ident.name) - ) + marshal.cArgVals(params) - if (m.ret.isDefined) { - val method_call = marshal.callback( - idCpp.method(ident.name) + "_" + idCpp.method(m.ident.name) - ) + marshal.cArgVals(params) - w.wl( - "auto _ret = " + marshal.convertTo( - raiiForElement(method_call, m.ret.get.resolved), - m.ret.get, - tempExpr = true - ) + ";" - ) - w.wl("djinni::cw_throw_if_pending();") - w.wl("return _ret;") - } else { - w.wl(method_call + ";") - w.wl("djinni::cw_throw_if_pending();") - } - } - w.wl("}") - } - - def writeGetSetEqHandle( - djinniWrapper: String, - cMethodName: String, - cFrontEndProxy: String, - w: IndentWriter - ): Unit = { - - // Function to return handle around FrontEndProxy holding a front-end object - w.wl( - djinniWrapper + " * " + " make_proxy_object_from_handle_" + cMethodName + p( - marshal.djinniObjectHandle + " * " + "c_ptr" - ) + " {" - ).nested { - w.wl( - "return new " + djinniWrapper + "{" + "std::make_shared<" + cFrontEndProxy + ">(c_ptr)};" - ) - } - w.wl("}") - w.wl - // Function to return front-end object held via handle by front-end - w.wl( - marshal.djinniObjectHandle + " * " + "get_handle_from_proxy_object_" + cMethodName + p( - djinniWrapper + " * dw" - ) + " {" - ).nested { - w.wl( - cFrontEndProxy + " * " + "cast_ptr = dynamic_cast" + t( - cFrontEndProxy + " * " - ) + p("dw->wrapped_obj.get()") + ";" - ) - w.wl("if (!cast_ptr) { return nullptr; }") - w.wl("else return cast_ptr->get_m_obj_handle();") - } - w.wl("}") - w.wl - w.wl( - "bool " + "equal_handles_" + cMethodName + p( - djinniWrapper + " * dw1, " + - djinniWrapper + " * dw2" - ) + " {" - ).nested { - w.wl("return dw1->wrapped_obj == dw2->wrapped_obj;") - } - w.wl("}") - w.wl - } - - def writeGetSetEqHandleSignatures( - djinniWrapper: String, - cMethodName: String, - w: IndentWriter - ): IndentWriter = { - w.wl( - "struct " + djinniWrapper + " * " + " make_proxy_object_from_handle_" + cMethodName + p( - "struct " + marshal.djinniObjectHandle + " * " + "c_ptr" - ) + ";" - ) - w.wl( - "struct " + marshal.djinniObjectHandle + " * " + "get_handle_from_proxy_object_" + cMethodName + p( - "struct " + djinniWrapper + " * dw" - ) + ";" - ) - w.wl( - "bool " + "equal_handles_" + cMethodName + p( - "struct " + djinniWrapper + " * dw1, " + - "struct " + djinniWrapper + " * dw2" - ) + ";" - ) - w.wl - } - - def writeUnimplementableInterface( - ident: Ident, - origin: String, - cppClass: String, - refs: CRefs, - i: Interface - ): Unit = { - val cClassWrapper = "DjinniWrapper" + cppClass - - refs.hpp.add( - "#include " + q( - marshal.cw + ident.name + ".hpp" - ) + marshal.pythonCdefIgnore - ) // make sure own header included (for static) - - // C header for cdef - writeCHeader( - marshal.cw + ident.name, - origin, - cppClass, - refs.h, - true, - w => { - // Djinni Wrapper over cpp class - w.wl("struct " + marshal.wrappedName(cppClass) + ";") - writeDjinniUnwrapperSignature( - idCpp.method(ident.name), - cClassWrapper, - i.ext, - w - ) - } - ) - - // Cpp header for Djinni Wrapper signatures - writeCppHeader( - marshal.cw + ident.name, - ident.name, - origin, - cppClass, - true, - w => { - writeDjinniWrapper(ident, w, cppClass) - } - ) - - writeCFile( - marshal.cw + ident.name, - ident, - origin, - refs.hpp, - true, - w => { - writeGetWrappedObj(ident, w, cppClass, i.ext) - } - ) - } - - def writeCToCpp( - ident: Ident, - origin: String, - cppClass: String, - refs: CRefs, - i: Interface, - create: Boolean - ): Unit = { - val cClassWrapper = "DjinniWrapper" + cppClass - val cMethodWrapper = idCpp.method(marshal.cw + ident.name) - - refs.hpp.add( - "#include " + q( - marshal.cw + ident.name + ".hpp" - ) + marshal.pythonCdefIgnore - ) // make sure own header included (for static) - - // C header for cdef - writeCHeader( - marshal.cw + ident.name, - origin, - cppClass, - refs.h, - create, - w => { - if (create) { - // Djinni Wrapper over cpp class - w.wl("struct " + marshal.wrappedName(cppClass) + ";") - writeDjinniUnwrapperSignature( - idCpp.method(ident.name), - cClassWrapper, - i.ext, - w - ) - } - w.wl - writeMethodSignatures( - i.methods, - true, - false, - cClassWrapper, - cMethodWrapper + "_", - w - ) - } - ) - - // Cpp header for Djinni Wrapper signatures - writeCppHeader( - marshal.cw + ident.name, - ident.name, - origin, - cppClass, - create, - w => { - if (create) { // if not create then our writeCFromCpp function already created this wrapper - writeDjinniWrapper(ident, w, cppClass) - } - } - ) - - writeCFile( - marshal.cw + ident.name, - ident, - origin, - refs.hpp, - create, - w => { - if (create) { - writeGetWrappedObj(ident, w, cppClass, i.ext) - } - // Asbtract Class Implementation - // C Wrapper class methods calling into cpp - var skipFirst = SkipFirst() - for (m <- i.methods if !m.static) { - skipFirst { w.wl } - val fctPrefix = dw + "->" + "wrapped_obj" + "->" - writeMethodToCpp(m, fctPrefix, cClassWrapper, cMethodWrapper, w) - - } - - skipFirst = SkipFirst() - for (m <- i.methods if m.static) { - skipFirst { w.wl } - val fctPrefix = withCppNs(cppClass) + "::" - writeMethodToCpp(m, fctPrefix, cClassWrapper, cMethodWrapper, w) - } - } - ) - } - - def writeCFromCpp( - ident: Ident, - origin: String, - cppClass: String, - refs: CRefs, - i: Interface, - create: Boolean - ): Unit = { - val cMethodWrapper = idCpp.method(marshal.cw + ident.name) - val cClassWrapper = "DjinniWrapper" + idCpp.ty(ident.name) - val className = idCpp.ty(ident.name) - val classAsMethodName = idCpp.method(ident.name) - val cFrontEndProxy = idCpp.ty(ident.name) + "FrontEndProxy" - val handle = "m_obj_handle" - - refs.hpp.add( - "#include " + q(marshal.cw + ident.name + ".hpp") - ) // make sure own header included - - writeCHeader( - marshal.cw + ident.name, - origin, - cppClass, - refs.h, - create, - w => { - w.wl("struct " + marshal.wrappedName(cppClass) + ";") - writeDjinniUnwrapperSignature( - idCpp.method(ident.name), - cClassWrapper, - i.ext, - w - ) - w.wl - writeGetSetEqHandleSignatures(cClassWrapper, cMethodWrapper, w) - // Functions used to add callbacks - for (m <- i.methods) { - val ret = marshal.cReturnType(m.ret, true) - val cArgs = getCArgTypes( - m, - "struct " + marshal.djinniObjectHandle + " * ", - true - ) - val methodSignature = ret + "(* ptr)" + cArgs - w.wl( - "void " + classAsMethodName + "_add_callback_" + idCpp.method( - m.ident.name - ) + p(methodSignature) + ";" - ) - w.wl - } - w.wl( - "void " + classAsMethodName + "_add_callback_" + "__delete" + p( - "void(* ptr)" + p("struct " + marshal.djinniObjectHandle + " * ") - ) + ";" - ) - } - ) - - writeCppHeader( - marshal.cw + ident.name, - ident.name, - origin, - cppClass, - create, - w => { - writeDjinniWrapper( - ident, - w, - cppClass - ) // not per se needed but helpful for allowing general dynamic casts - w.wl - // FrontEndProxy Implementation - w.wl( - "class " + cFrontEndProxy + " final : public " + withCppNs( - className - ) + " {" - ).nested { - w.wl("public:").nested { - // Constructor - w.wl( - "explicit " + cFrontEndProxy + p( - marshal.djinniObjectHandle + " * " + "c_ptr" - ) + ";" - ) - // Destructor - w.wl("~" + cFrontEndProxy + "();") - // Handle Getter - w.wl(marshal.djinniObjectHandle + " * " + "get_m_obj_handle();") - w.wl - // Methods - writeMethodSignatures(i.methods, false, true, "", "", w) - } - w.wl("private:").nested { - w.wl(marshal.djinniObjectHandle + " * " + handle + ";") - } - } - w.wl("};") - } - ) - - writeCFile( - marshal.cw + ident.name, - ident, - origin, - refs.hpp, - create, - w => { - // Declare global handles to c-front-end function - declareGlobalFunctionPointers(ident, cClassWrapper, i.methods, w) - w.wl - writeGetWrappedObj(ident, w, cppClass, i.ext) - writeGetSetEqHandle(cClassWrapper, cMethodWrapper, cFrontEndProxy, w) - // Getter for front-end object handle - w.wl( - marshal.djinniObjectHandle + " * " + cFrontEndProxy + "::get_m_obj_handle() {" - ).nested { - w.wl("return m_obj_handle;") - } - w.wl("}") - w.wl - // Constructor from void* - w.wl( - cFrontEndProxy + "::" + cFrontEndProxy + p( - marshal.djinniObjectHandle + " * " + "c_ptr" - ) + " : " + handle + p("c_ptr") + " {}" - ) - w.wl - // Destructor - w.wl(cFrontEndProxy + "::~" + cFrontEndProxy + "() {").nested { - w.wl( - marshal.callback(idCpp.method(ident.name) + "___delete") + p( - handle - ) + ";" - ) - } - w.wl("}") - w.wl - // Function used to add callbacks - for (m <- i.methods) { - val ret = marshal.cReturnType(m.ret, false) - val cArgs = getCArgTypes(m, marshal.djinniObjectHandle + " * ", false) - val methodSignature = ret + "(* ptr)" + cArgs - w.wl( - "void " + classAsMethodName + "_add_callback_" + idCpp.method( - m.ident.name - ) + p(methodSignature) + " {" - ).nested { - w.wl( - marshal.callback( - idCpp.method(ident.name) + "_" + idCpp.method(m.ident.name) - ) + " = ptr;" - ) - } - w.wl("}") - w.wl - } - // Callback for delete front-end object handle - w.wl( - "void " + classAsMethodName + "_add_callback_" + "__delete" + p( - "void(* ptr)" + p(marshal.djinniObjectHandle + " * ") - ) + " {" - ).nested { - w.wl( - marshal.callback(idCpp.method(ident.name) + "___delete") + " = ptr;" - ) - } - w.wl("}") - w.wl - - val skipFirst = SkipFirst() - for (m <- i.methods) { - skipFirst { w.wl } - // TODO: raise exception or complain if method is static? - writeMethodFromCpp(ident, m, cFrontEndProxy, handle, w) - } - } - ) - } - - def generateInterface( - origin: String, - ident: Ident, - doc: Doc, - typeParams: Seq[TypeParam], - i: Interface - ): Unit = { - val cppClass = idCpp.ty(ident.name) - - val refs = new CRefs(ident, origin) - // first collect all references, don't write - i.methods.map(m => { - m.params.foreach(p => refs.collect(p.ty, true)) - m.ret.foreach(t => refs.collect(t, true)) - }) - i.consts.foreach(c => { - refs.collect(c.ty, true) - }) - // go through references and write - i.methods.map(m => { - m.params.foreach(p => refs.collect(p.ty, false)) - m.ret.foreach(t => refs.collect(t, false)) - }) - i.consts.foreach(c => { - refs.collect(c.ty, false) - }) - - if (i.ext.cpp && i.ext.py) { - writeCFromCpp(ident, origin, cppClass, refs, i, true) - writeCToCpp(ident, origin, cppClass, refs, i, false) - } else if (i.ext.cpp) { - writeCToCpp(ident, origin, cppClass, refs, i, true) - } else if (i.ext.py) { - writeCFromCpp(ident, origin, cppClass, refs, i, true) - } else { - // Write out only the pieces of code needed to compile usage sites, without the code to implement in either - // language. This ensures the code can compile for unused methods which reference types not used in front-end. - writeUnimplementableInterface(ident, origin, cppClass, refs, i) - } - } - - def generateEnum(origin: String, ident: Ident, doc: Doc, e: Enum): Unit = { - val refs = new CRefs(ident, origin) - writeCHeader(marshal.dh + ident.name, origin, "", refs.h, true, _ => {}) - - writeCppHeader( - marshal.dh + ident.name, - ident.name, - origin, - "", - true, - w => { - w.wl( - "int32_t int32_from_enum_" + idCpp.method(ident.name) + p( - spec.cppOptionalTemplate + t( - withCppNs(idCpp.enumType(ident.name)) - ) + " e" - ) + ";" - ) - w.wl( - "int32_t int32_from_enum_" + idCpp.method(ident.name) + p( - withCppNs(idCpp.enumType(ident.name)) + " e" - ) + ";" - ) - w.wl( - spec.cppOptionalTemplate + t(withCppNs(idCpp.enumType(ident.name))) + - " get_boxed_enum_" + idCpp.method(ident.name) + "_from_int32" + p( - "int32_t e" - ) + ";" - ) - } - ) - - writeCFile( - marshal.dh + ident.name, - ident, - origin, - refs.hpp, - true, - w => { - // Get int32 from boxed enum - w.wl( - "int32_t int32_from_enum_" + idCpp.method(ident.name) + p( - spec.cppOptionalTemplate + t( - withCppNs(idCpp.enumType(ident.name)) - ) + " e" - ) + " {" - ).nested { - w.wl("if (e) {").nested { - w.wl("return static_cast" + p("* e") + ";") - } - w.wl("}") - w.wl("return -1; // -1 to signal null boxed enum") - } - w.wl("}") - w.wl - // Get int32 from enum - w.wl( - "int32_t int32_from_enum_" + idCpp.method(ident.name) + p( - withCppNs(idCpp.enumType(ident.name)) + " e" - ) + " {" - ).nested { - w.wl("return static_cast" + p("e") + ";") - } - w.wl("}") - // Get boxed enum from int32 - w.wl( - spec.cppOptionalTemplate + t(withCppNs(idCpp.enumType(ident.name))) + - " get_boxed_enum_" + idCpp.method(ident.name) + "_from_int32" + p( - "int32_t e" - ) + " {" - ).nested { - w.wl("if (e == -1) { // to signal null enum").nested { - w.wl("return {};") - } - w.wl("}") - w.wl( - "return " + spec.cppOptionalTemplate + t( - withCppNs(idCpp.enumType(ident.name)) - ) + - p( - "static_cast" + t(withCppNs(idCpp.enumType(ident.name))) + p( - "e" - ) - ) + ";" - ) - } - w.wl("}") - } - ) - } - - def generateRecord( - origin: String, - ident: Ident, - doc: Doc, - params: Seq[TypeParam], - r: Record - ): Unit = { - val refs = new CRefs(ident, origin) - r.fields.map(f => refs.collect(f.ty, true)) - refs.hpp.add( - "#include " + q( - marshal.dh + ident.name + ".hpp" - ) + marshal.pythonCdefIgnore - ) - r.fields.map(f => refs.collect(f.ty, false)) - - val recordAsMethodName = idCpp.method(ident.name) - val recordName = "Djinni" + idCpp.ty(ident.name) - val recordHandle = "DjinniRecordHandle" - val optRecordHandle = "DjinniOptionalRecordHandle" - val cppRecordName = idCpp.ty(ident.name) - val fqCppRecordName = withCppNs(cppRecordName) - - writeCHeader( - marshal.dh + ident.name, - origin, - "", - refs.h, - true, - w => { - // record definition - w.wl("struct " + recordName + ";") - w.wl( - "void " + recordAsMethodName + "___delete" + p( - "struct " + recordHandle + " * " - ) + ";" - ) - w.wl( - "void " + "optional_" + recordAsMethodName + "___delete" + p( - "struct " + optRecordHandle + " * " - ) + ";" - ) - // global signatures for callbacks for getting record fields - declareGlobalSignaturesRecordFieldGetters(ident, r, "", 0, w) - } - ) - - writeCppHeader( - marshal.dh + ident.name, - ident.name, - origin, - "", - true, - w => { - w.wl("struct " + recordName + " {").nested { - // from cpp - w.wl( - "static " + "djinni::Handle" + t(recordHandle) + " fromCpp" + p( - "const " + fqCppRecordName + "&" + " dr" - ) + ";" - ) - // to cpp - w.wl( - "static " + fqCppRecordName + " " + "toCpp" + p( - "djinni::Handle" + t(recordHandle) + " dh" - ) + ";" - ) - - w.wl( - "static " + "djinni::Handle" + t(optRecordHandle) + " fromCpp" + p( - spec.cppOptionalTemplate + t(fqCppRecordName) + " dc" - ) + ";" - ) - w.wl( - "static " + spec.cppOptionalTemplate + t( - fqCppRecordName - ) + " toCpp" + p( - "djinni::Handle" + t(optRecordHandle) + " dh" - ) + ";" - ) - - } - w.wl("};") - } - ) - - writeCFile( - marshal.dh + ident.name, - ident, - origin, - refs.hpp, - true, - w => { - // Callback for delete front-end object handle - w.wl( - "static void(*" + marshal.callback( - recordAsMethodName + "___delete" - ) + ")" + p(recordHandle + " * ") + ";" - ) - - w.wl( - "void " + recordAsMethodName + "_add_callback_" + "__delete" + p( - "void(* ptr)" + p(recordHandle + " * ") - ) + " {" - ).nested { - w.wl( - marshal.callback(idCpp.method(ident.name) + "___delete") + " = ptr;" - ) - } - w.wl("}") - w.wl - // Function to call delete of record from front-end - var ret = "void" - var cArgs = marshal.cArgDecl(Seq("DjinniRecordHandle * drh")) - w.wl("void " + idCpp.method(ident.name + "___delete") + cArgs + " {") - .nested { - w.wl( - marshal.callback(idCpp.method(ident.name) + "___delete") + p( - "drh" - ) + ";" - ) - } - w.wl("}") - // Function to call delete of Optional record from front-end - ret = "void" - cArgs = marshal.cArgDecl(Seq("DjinniOptionalRecordHandle * drh")) - w.wl( - "void " + idCpp.method( - "optional_" + ident.name + "___delete" - ) + cArgs + " {" - ).nested { - w.wl( - marshal.callback(idCpp.method(ident.name) + "___delete") + p( - "(DjinniRecordHandle *) drh" - ) + "; // can't static cast, find better way" - ) - } - w.wl("}") - - // global callback pointers for getting record fields - declareGlobalRecordFieldGetters(ident, r, "", 0, w) - // from cpp - w.wl( - "djinni::Handle" + t( - recordHandle - ) + " " + recordName + "::fromCpp" + p( - "const " + fqCppRecordName + "&" + " dr" - ) + " {" - ).nested { - writeRecordFromCpp(ident, r, "", 0, w) - } - w.wl("}") - w.wl - // to cpp - w.wl( - fqCppRecordName + " " + recordName + "::toCpp" + p( - "djinni::Handle" + t(recordHandle) + " dh" - ) + " {" - ).nested { - writeRecordToCpp(ident, r, "", 0, w) - } - w.wl("}") - w.wl - - writeOptionalContainerFromCpp( - optRecordHandle, - recordHandle, - fqCppRecordName, - recordName, - "optional_" + recordAsMethodName + "___delete", - w - ) - writeOptionalContainerToCpp( - optRecordHandle, - fqCppRecordName, - recordName, - "DjinniRecordHandle *", - recordAsMethodName + "___delete", - w - ) - } - ) - } -} diff --git a/src/main/scala/djinni/CffiGenerator.scala b/src/main/scala/djinni/CffiGenerator.scala deleted file mode 100644 index 90271054..00000000 --- a/src/main/scala/djinni/CffiGenerator.scala +++ /dev/null @@ -1,115 +0,0 @@ -/** Copyright 2015 Dropbox, Inc. 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. - */ - -package djinni - -import djinni.ast._ -import djinni.generatorTools._ -import djinni.writer.IndentWriter - -class CffiGenerator(spec: Spec) extends Generator(spec) { - val marshal = new PythonMarshal(spec) - val cffi: String = spec.pycffiPackageName + "_cffi" - - def writeCffiFile( - ident: String, - origin: String, - f: IndentWriter => Unit - ): Unit = { - val _ = (ident, origin) // unused, TODO: remove - createFileOnce( - spec.pycffiOutFolder.get, - "pycffi_lib_build" + ".py", - (w: IndentWriter) => { - w.wl("# AUTOGENERATED FILE - DO NOT MODIFY!") - w.wl("# This file was generated by Djinni from " + spec.idlFileName) - w.wl - f(w) - } - ) - } - - override def generateInterface( - origin: String, - ident: Ident, - doc: Doc, - typeParams: Seq[TypeParam], - i: Interface - ): Unit = { - writeCffiFile( - "pycffi_lib_build.py", - origin, - w => { - w.wl("import sys") - w.wl("from cffi import FFI") - w.wl("from djinni.support import *") - w.wl("ffi = FFI()") - w.wl - // Paths relative to test-suite/pybuild - // TODO: raise exception if not at least 2 arguments? - w.wl("args = sys.argv[1:]") - w.wl( - "cdef_headers = sort_by_import_order(clean_headers_for(args, 'python_cdef_ignore'))" - ) - w.wl( - "setsource_headers = sort_by_import_order(clean_headers_for(args, 'python_setsource_ignore'))" - ) - w.wl - - w.wl("f = open('clean_headers.h', 'w')") - w.wl("f.write(setsource_headers)") - w.wl("f.close()") - w.wl - w.wl( - "ffi.set_source('" + cffi + "', '''#include \"clean_headers.h\"'''," - ).nested { - w.w("runtime_library_dirs=['.']") - if (!spec.pycffiDynamicLibList.isEmpty) { - w.wl(",") - w.w("libraries=['" + spec.pycffiDynamicLibList + "']") - } - w.wl(")") - } - w.wl - w.wl("ffi.cdef(\"typedef _Bool bool;\"\n + cdef_headers)") - w.wl - w.wl("if __name__ == '__main__':").nested { - w.wl("ffi.compile()") - } - w.wl - } - ) - - } - - override def generateRecord( - origin: String, - ident: Ident, - doc: Doc, - params: Seq[TypeParam], - r: Record - ): Unit = { - // Not needed - } - - override def generateEnum( - origin: String, - ident: Ident, - doc: Doc, - e: Enum - ): Unit = { - // Not needed - } -} diff --git a/src/main/scala/djinni/CppCliGenerator.scala b/src/main/scala/djinni/CppCliGenerator.scala deleted file mode 100644 index 36aea632..00000000 --- a/src/main/scala/djinni/CppCliGenerator.scala +++ /dev/null @@ -1,840 +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. - */ - -package djinni - -import djinni.ast.Record.DerivingType -import djinni.ast._ -import djinni.generatorTools._ -import djinni.meta._ -import djinni.writer.IndentWriter - -import scala.collection.mutable - -class CppCliGenerator(spec: Spec) extends Generator(spec) { - final val cppCliBaseLibIncludePrefix = "djinni/cppcli/" - - val marshal = new CppCliMarshal(spec) - val cppMarshal = new CppMarshal(spec) - - class CppCliRefs(name: String) { - val hpp = new mutable.TreeSet[String]() - val hppFwds = new mutable.TreeSet[String]() - val cpp = new mutable.TreeSet[String]() - val cppPrefix: String = spec.cppCliIncludeCppPrefix - - hpp.add( - "#include " + q( - cppPrefix + spec.cppFileIdentStyle(name) + "." + spec.cppHeaderExt - ) - ) - - def find(ty: TypeRef, forwardDeclareOnly: Boolean): Unit = { - find(ty.resolved, forwardDeclareOnly) - } - def find(tm: MExpr, forwardDeclareOnly: Boolean): Unit = { - tm.args.foreach(x => find(x, forwardDeclareOnly)) - find(tm.base, forwardDeclareOnly) - } - def find(m: Meta, forwardDeclareOnly: Boolean): Unit = for ( - r <- marshal.references(m, name, forwardDeclareOnly) - ) addRefs(r) - - private def addRefs(r: SymbolReference) = r match { - case ImportRef(arg) => hpp.add("#include " + arg) // TODO add to `cpp` - case DeclRef(decl, Some(spec.cppCliNamespace)) => hppFwds.add(decl) - case DeclRef(_, _) => - } - } - - def withCppCliNs(namespace: String, t: String): String = - withNs(Some(namespace), t) - - val writeCppCliCppFile - : (String, String, Iterable[String], IndentWriter => Unit) => Unit = - writeCppFileGeneric( - spec.cppCliOutFolder.get, - spec.cppCliNamespace, - spec.cppCliIdentStyle.file, - "" - ) _ - - def writeCppCliHppFile( - name: String, - origin: String, - includes: Iterable[String], - fwds: Iterable[String], - f: IndentWriter => Unit, - f2: IndentWriter => Unit = _ => {} - ): Unit = - writeHppFileGeneric( - spec.cppCliOutFolder.get, - spec.cppCliNamespace, - spec.cppCliIdentStyle.file - )(name, origin, includes, fwds, f, f2) - - def generateConstants( - w: IndentWriter, - ident: Ident, - r: Record, - consts: Seq[Const] - ): Unit = { - def writeCppCliLiteral(ty: TypeRef, v: Any) = { - v match { - case l: Long if List("long", "long?").contains(marshal.fieldType(ty)) => - w.w(l.toString + "L") - case l: Long => w.w(l.toString) - case d: Double if marshal.fieldType(ty).equals("float") => - w.w(d.toString + "F") - case d: Double if marshal.fieldType(ty).equals("float?") => - w.w(d.toString + "F") - case d: Double => w.w(d.toString) - case b: Boolean => w.w(if (b) "true" else "false") - case s: String => w.w(s) - case e: EnumValue => w.w(s"${marshal.typename(ty)}::${idCs.enum(e)}") - case v: ConstRef => w.w(idCs.const(v)) - case z: Map[_, _] => { // Value is record - val recordMdef = ty.resolved.base.asInstanceOf[MDef] - val record = recordMdef.body.asInstanceOf[Record] - val vMap = z.asInstanceOf[Map[String, Any]] - w.wl(s"gcnew ${marshal.typename(ty, needsHandle = false)}(") - w.increase() - // Use exact sequence - val skipFirst = SkipFirst() - for (f <- record.fields) { - skipFirst { - w.wl(",") - } - writeCppCliConst(w, f.ty, vMap.apply(f.ident.name)) - w.w(" /* " + idCs.field(f.ident) + " */ ") - } - w.w(")") - w.decrease() - } - } - } - def writeCppCliConst(w: IndentWriter, ty: TypeRef, v: Any): Unit = - ty.resolved.base match { - case MOptional if ty.resolved.args.head.base != MString => - w.w(marshal.typename(ty, needsHandle = false) + "(") - writeCppCliLiteral(ty, v) - w.w(")") - case _ => writeCppCliLiteral(ty, v) - } - def isInitOnly(c: Const) = c.ty.resolved.base match { - case _: MPrimitive => false - case _ => true - } - - for (c <- consts) { - w.wl - writeDoc(w, c.doc) - val fieldType = marshal.fieldType(c.ty) - val fieldIdent = idCs.const(c.ident) - if (isInitOnly(c)) { - w.wl(s"static initonly $fieldType $fieldIdent;") - } else { - w.w(s"literal $fieldType $fieldIdent = ") - writeCppCliConst(w, c.ty, c.value) - w.wl(";") - } - } - - val initOnlyConsts = consts.filter(c => isInitOnly(c)) - if (initOnlyConsts.nonEmpty) { - w.wl - val self = marshal.typename(ident, r) - w.w(s"static $self()").braced { - initOnlyConsts.foreach(c => { - w.w(s"${idCs.const(c.ident)} = ") - writeCppCliConst(w, c.ty, c.value) - w.wl(";") - }) - } - } - } - - override def generateEnum( - origin: String, - ident: Ident, - doc: Doc, - e: Enum - ): Unit = { - val refs = new CppCliRefs(ident.name) - - writeCppCliHppFile( - ident, - origin, - refs.hpp, - refs.hppFwds, - w => { - writeDoc(w, doc) - if (e.flags) w.wl("[System::Flags]") - w.w(s"public enum class ${marshal.typename(ident, e)}").bracedSemi { - writeEnumOptionNone(w, e, idCs.enum(_)) - writeEnumOptions(w, e, idCs.enum(_)) - writeEnumOptionAll(w, e, idCs.enum(_)) - } - } - ) - - writeCppCliCppFile( - ident, - origin, - refs.hpp, - w => { - w.wl("// Empty... making sure the symbols get included in the build.") - } - ) - } - - override def generateRecord( - origin: String, - ident: Ident, - doc: Doc, - params: Seq[TypeParam], - r: Record - ): Unit = { - val refs = new CppCliRefs(ident.name) - refs.find(MString, false) // for: String^ ToString(); - r.fields.foreach(f => refs.find(f.ty, false)) - r.consts.foreach(c => refs.find(c.ty, false)) - - def call(f: Field) = { - f.ty.resolved.base match { - case _: MPrimitive => "." - case MOptional => "." - case MDate => "." - case e: MExtern => if (e.cs.reference.get) "->" else "." - case _ => "->" - } - } - - val self = marshal.typename(ident, r) - val cppSelf = cppMarshal.fqTypename(ident, r) - - val fieldNamesInScope = r.fields.map(f => idCs.property(f.ident)) - - writeCppCliHppFile( - ident, - origin, - refs.hpp, - refs.hppFwds, - w => { - writeDoc(w, doc) - - val interfaces = scala.collection.mutable.ArrayBuffer[String]() - if (r.derivingTypes.contains(DerivingType.Ord)) - interfaces += s"System::IComparable<$self^>" - if (r.derivingTypes.contains(DerivingType.Eq)) - interfaces += s"System::IEquatable<$self^>" - val inheritanceList = - if (interfaces.isEmpty) "" else interfaces.mkString(" : ", ", ", "") - - w.wl("[System::Serializable]") - w.w(s"public ref class $self$inheritanceList").bracedSemi { - w.wlOutdent("public:") - - generateConstants(w, ident, r, r.consts) - - // Properties. - for (f <- r.fields) { - w.wl - val retType = - s"${marshal.fqFieldType(f.ty.resolved, fieldNamesInScope)}" - w.wl(s"property $retType ${idCs.property(f.ident)}").braced { - w.wl(s"$retType get();") - } - } - - // Constructor. - if (r.fields.nonEmpty) { - w.wl - writeAlignedCall( - w, - self + "(", - r.fields, - ")", - f => - marshal.fqFieldType( - f.ty.resolved, - fieldNamesInScope - ) + " " + idCs.local(f.ident) - ) - w.wl(";") - } - - w.wl - w.wl(s"System::String^ ToString() override;") - - if (r.derivingTypes.contains(DerivingType.Eq)) { - w.wl - w.wl(s"virtual bool Equals($self^ other);") - w.wl("bool Equals(System::Object^ obj) override;") - w.wl("int GetHashCode() override;") - } - - if (r.derivingTypes.contains(DerivingType.Ord)) { - w.wl - w.w(s"virtual int CompareTo($self^ other);") - } - - w.wl - w.wlOutdent("internal:") - w.wl(s"using CppType = $cppSelf;") - w.wl(s"using CsType = $self^;") - w.wl - w.wl(s"static CppType ToCpp(CsType cs);") - w.wl(s"static CsType FromCpp(const CppType& cpp);") - - w.wl - w.wlOutdent("private:") - - // Field definitions. - for (f <- r.fields) { - writeDoc(w, f.doc) - w.wl( - s"${marshal.fqFieldType(f.ty.resolved, fieldNamesInScope)} ${idCs - .field(f.ident)};" - ) - } - } - } - ) - - refs.cpp.add("#include " + q(cppCliBaseLibIncludePrefix + "Marshal.hpp")) - refs.cpp.add("#include ") - - writeCppCliCppFile( - ident, - origin, - refs.cpp, - w => { - // Constructor. - if (r.fields.nonEmpty) { - writeAlignedCall( - w, - self + "::" + self + "(", - r.fields, - ")", - f => - marshal.fqFieldType(f.ty.resolved, fieldNamesInScope) + " " + idCs - .local(f.ident) - ) - w.wl - val init = - (f: Field) => idCs.field(f.ident) + "(" + idCs.local(f.ident) + ")" - w.wl(": " + init(r.fields.head)) - r.fields.tail.map(f => ", " + init(f)).foreach(w.wl) - w.wl("{}") - } - - // Properties. - for (f <- r.fields) { - w.wl - val retType = s"${marshal.fieldType(f.ty)}" - w.wl(s"$retType $self::${idCs.property(f.ident)}::get()").braced { - w.wl(s"return ${idCs.field(f.ident)};") - } - } - - w.wl - w.wl(s"System::String^ $self::ToString()").braced { - val placeholders = - r.fields.view.zipWithIndex.map { case (field, index) => - s"${idCs.property(field.ident)}{$index}" - } - val formatStr = placeholders.mkString(s"$self {{", ", ", "}}") - val call = "return System::String::Format(" - w.w(s"""$call"$formatStr"""") - r.fields.foreach(f => { - w.wl(",") - w.w(" " * call.length + idCs.property(f.ident)) - }) - w.wl(");") - } - - if (r.derivingTypes.contains(DerivingType.Eq)) { - w.wl - w.w(s"bool $self::Equals($self^ other)").braced { - w.wl("if (ReferenceEquals(nullptr, other)) return false;") - w.wl("if (ReferenceEquals(this, other)) return true;") - w.wl( - r.fields - .map(f => { - val property = idCs.property(f.ident) - f.ty.resolved.base match { - case _: MPrimitive => s"$property == other->$property" - case _ => s"$property${call(f)}Equals(other->$property)" - } - }) - .mkString("return ", " && ", ";") - ) - } - - w.wl - w.w(s"bool $self::Equals(System::Object^ obj)").braced { - w.wl("if (ReferenceEquals(nullptr, obj)) return false;") - w.wl("if (ReferenceEquals(this, obj)) return true;") - w.wl(s"return obj->GetType() == GetType() && Equals(($self^) obj);") - } - - w.wl - w.w(s"int $self::GetHashCode()").braced { - w.wl( - s"auto hashCode = ${idCs.property(r.fields.head.ident)}${call(r.fields.head)}GetHashCode();" - ) - for (f <- r.fields.tail) { - w.wl( - s"hashCode = (hashCode * 397) ^ ${idCs.property(f.ident)}${call(f)}GetHashCode();" - ) - } - w.wl("return hashCode;") - } - } - - if (r.derivingTypes.contains(DerivingType.Ord)) { - def compare(f: Field): String = { - val property = idCs.property(f.ident) - f.ty.resolved.base match { - case MString => - s"System::String::Compare($property, other->$property, System::StringComparison::Ordinal)" - case _ => s"$property${call(f)}CompareTo(other->$property)" - } - } - w.wl - w.w(s"int $self::CompareTo($self^ other)").braced { - w.wl("if (ReferenceEquals(this, other)) return 0;") - w.wl("if (ReferenceEquals(nullptr, other)) return 1;") - for (f <- r.fields.dropRight(1)) { - val local = idCs.local(f.ident) + "Comparison" - w.wl(s"auto $local = ${compare(f)};") - w.wl(s"if ($local != 0) return $local;") - } - w.wl(s"return ${compare(r.fields.last)};") - } - } - - // To/From C++ - val CppType = s"$self::CppType" - val CsType = s"$self::CsType" - w.wl - w.wl(s"$CppType $self::ToCpp($CsType cs)").braced { - w.wl("ASSERT(cs != nullptr);") - writeAlignedCall( - w, - "return {", - r.fields, - "}", - f => marshal.toCpp(f.ty, "cs->" + idCs.property(f.ident)) - ) - w.wl(";") - } - w.wl - w.wl(s"$CsType $self::FromCpp(const $CppType& cpp)").braced { - writeAlignedCall( - w, - s"return gcnew $self(", - r.fields, - ")", - f => marshal.fromCpp(f.ty, "cpp." + idCpp.field(f.ident)) - ) - w.wl(";") - } - } - ) - } - - def nnCheck(expr: String): String = - spec.cppNnCheckExpression.fold(expr)(check => s"$check($expr)") - - override def generateInterface( - origin: String, - ident: Ident, - doc: Doc, - typeParams: Seq[TypeParam], - i: Interface - ): Unit = { - val refs = new CppCliRefs(ident.name) - i.methods.foreach(m => { - m.params.foreach(p => refs.find(p.ty, true)) - m.ret.foreach(x => refs.find(x, true)) - }) - i.consts.map(c => { - refs.find(c.ty, true) - }) - - val self = marshal.typename(ident, i) - val cppSelf = cppMarshal.fqTypename(ident, i) - - spec.cppNnHeader match { - case Some(nnHdr) => - refs.hpp.add("#include " + q(nnHdr)) - case _ => - } - - refs.hpp.add("#include ") - - val methodNamesInScope = i.methods.map(m => idCs.method(m.ident)) - - writeCppCliHppFile( - ident, - origin, - refs.hpp, - refs.hppFwds, - w => { - writeDoc(w, doc) - w.w(s"public ref class $self abstract").bracedSemi { - w.wlOutdent("public:") - val skipFirst = new SkipFirst - i.methods.foreach(m => { - skipFirst { w.wl } - writeDoc(w, m.doc) - val staticVirtual = if (m.static) "static " else "virtual " - val params = m.params.map(p => { - marshal.paramType(p.ty, methodNamesInScope) + " " + idCs - .local(p.ident) - }) - val abstrct = if (!m.static) " abstract" else "" - // Protect against conflicts with the class name. - val origMethodName = idCs.method(m.ident) - val methodName = - if (self == origMethodName) "Do" + origMethodName - else origMethodName - w.wl( - staticVirtual + marshal.returnType( - m.ret - ) + " " + methodName + params.mkString("(", ", ", s")$abstrct;") - ) - }) - - w.wl - w.wlOutdent("internal:") - spec.cppNnType match { - case Some(nnPtr) => - w.wl(s"using CppType = $nnPtr<$cppSelf>;") - w.wl(s"using CppOptType = std::shared_ptr<$cppSelf>;") - case _ => - w.wl(s"using CppType = std::shared_ptr<$cppSelf>;") - w.wl(s"using CppOptType = std::shared_ptr<$cppSelf>;") - } - w.wl(s"using CsType = $self^;") - w.wl - w.wl(s"static CppType ToCpp(CsType cs);") - w.wl(s"static CsType FromCppOpt(const CppOptType& cpp);") - w.wl( - s"static CsType FromCpp(const CppType& cpp) { return FromCppOpt(cpp); }" - ) - } - } - ) - - refs.cpp.add("#include " + q(cppCliBaseLibIncludePrefix + "Marshal.hpp")) - refs.cpp.add("#include " + q(cppCliBaseLibIncludePrefix + "Error.hpp")) - refs.cpp.add( - "#include " + q(cppCliBaseLibIncludePrefix + "WrapperCache.hpp") - ) - i.methods.foreach(m => { - m.params.foreach(p => { - def include(tm: MExpr): Unit = tm.base match { - case MMap => - tm.args.foreach(a => include(a)) - case d: MDef => - refs.cpp.add( - "#include " + q( - spec.cppIncludePrefix + spec.cppFileIdentStyle( - d.name - ) + "." + spec.cppHeaderExt - ) - ) - case _ => - } - include(p.ty.resolved) - }) - }) - - writeCppCliCppFile( - ident, - origin, - refs.cpp, - w => { - i.methods - .filter(m => m.static) - .foreach(m => { - val params = m.params.map(p => { - marshal.paramType(p.ty, methodNamesInScope) + " " + idCs - .local(p.ident) - }) - // Protect against conflicts with the class name. - val origMethodName = idCs.method(m.ident) - val methodName = - if (self == origMethodName) "Do" + origMethodName - else origMethodName - w.w( - marshal.returnType(m.ret) + s" $self::$methodName" + params - .mkString("(", ", ", ")") - ).braced { - w.w("try").bracedEnd(" DJINNI_TRANSLATE_EXCEPTIONS()") { - // TODO Check non-optional params for null - val ret = m.ret.fold("")(_ => "auto cs_result = ") - val call = ret + cppSelf + "::" + idCpp.method(m.ident) + "(" - writeAlignedCall( - w, - call, - m.params, - ")", - p => marshal.toCpp(p.ty, idCs.local(p.ident.name)) - ) - - w.wl(";") - m.ret.fold(())(r => - w.wl(s"return ${marshal.fromCpp(r, "cs_result")};") - ) - } - m.ret.fold(())(r => - w.wl( - s"return ${dummyConstant(r)}; // Unreachable! (Silencing compiler warnings.)" - ) - ) - } - w.wl - }) - - val cppProxySelf = self + "CppProxy" - val csProxySelf = self + "CsProxy" - - if (i.ext.cpp) { - w.w(s"ref class $cppProxySelf : public $self").bracedSemi { - w.wl(s"using CppType = std::shared_ptr<$cppSelf>;") - w.wl("using HandleType = ::djinni::CppProxyCache::Handle;") - w.wlOutdent("public:") - w.wl( - s"$cppProxySelf(const CppType& cppRef) : _cppRefHandle(new HandleType(cppRef)) {}" - ) - i.methods - .filter(m => !m.static) - .foreach(m => { - w.wl - val ret = marshal.returnType(m.ret, methodNamesInScope) - val params = m.params.map(p => { - marshal.paramType(p.ty, methodNamesInScope) + " " + idCs - .local(p.ident) - }) - // Protect against conflicts with the class name. - val origMethodName = idCs.method(m.ident) - val methodName = - if (self == origMethodName) "Do" + origMethodName - else origMethodName - w.w( - s"$ret $methodName" + params.mkString("(", ", ", ") override") - ).braced { - w.w("try").bracedEnd(" DJINNI_TRANSLATE_EXCEPTIONS()") { - // TODO Check non-optional params for null - val ret = m.ret.fold("")(_ => "auto cs_result = ") - val call = ret + "_cppRefHandle->get()->" + idCpp - .method(m.ident) + "(" - writeAlignedCall( - w, - call, - m.params, - ")", - p => marshal.toCpp(p.ty, idCs.local(p.ident.name)) - ) - - w.wl(";") - m.ret.fold(())(r => - w.wl(s"return ${marshal.fromCpp(r, "cs_result")};") - ) - } - m.ret.fold(())(r => - w.wl( - s"return ${dummyConstant(r)}; // Unreachable! (Silencing compiler warnings.)" - ) - ) - } - }) - w.wl - w.w("CppType djinni_private_get_proxied_cpp_object()").braced { - w.wl("return _cppRefHandle->get();") - } - w.wl - w.wlOutdent("private:") - w.wl(s"AutoPtr _cppRefHandle;") - } - w.wl - } - - if (i.ext.cppcli) { - w.w(s"class $csProxySelf : public $cppSelf").bracedSemi { - w.wl( - s"using CsType = ${withCppCliNs(spec.cppCliNamespace, self)}^;" - ) - w.wl(s"using CsRefType = ::djinni::CsRef;") - w.wl( - "using HandleType = ::djinni::CsProxyCache::Handle<::djinni::CsRef>;" - ) - w.wlOutdent("public:") - w.wl( - s"$csProxySelf(CsRefType cs) : m_djinni_private_proxy_handle(std::move(cs)) {}" - ) - w.wl( - s"$csProxySelf(const ::djinni::CsRef& ptr) : $csProxySelf(CsRefType(dynamic_cast(ptr.get()))) {}" - ) - for (m <- i.methods) { - w.wl - val ret = cppMarshal.fqReturnType(m.ret) - val params = m.params.map(p => - cppMarshal.fqParamType(p.ty) + " " + idCpp.local(p.ident) - ) - w.wl( - s"$ret ${idCpp.method(m.ident)}${params.mkString("(", ", ", ")")} override" - ).braced { - val ret = m.ret.fold("")(_ => "auto cs_result = ") - val call = - s"djinni_private_get_proxied_cs_object()->${idCs.method(m.ident)}(" - writeAlignedCall( - w, - ret + call, - m.params, - ")", - p => s"${marshal.fromCpp(p.ty, idCpp.local(p.ident))}" - ) - w.wl(";") - m.ret.fold(())(ty => { - w.wl("// TODO check cs_result for null") - w.wl(s"return ${marshal.toCpp(ty, "cs_result")};") - }) - } - } - w.wl - w.w("CsType djinni_private_get_proxied_cs_object()").braced { - w.wl("return m_djinni_private_proxy_handle.get().get();") - } - w.wl - w.wlOutdent("private:") - w.wl("HandleType m_djinni_private_proxy_handle;") - } - w.wl - } - - // To/From C++ - val CppType = s"$self::CppType" - val CppOptType = s"$self::CppOptType" - val CsType = s"$self::CsType" - w.wl(s"$CppType $self::ToCpp($CsType cs)").braced { - // Handle null - w.w("if (!cs)").braced { - if (spec.cppNnType.isEmpty) { - w.wl("return nullptr;") - } else { - w.wl( - s"""throw gcnew System::Exception("$self::ToCpp requires non-nil object.");""" - ) - } - } - if (i.ext.cpp && !i.ext.cppcli) { - // C++ only. In this case we *must* unwrap a proxy object - the dynamic_cast will - // throw bad_cast if we gave it something of the wrong type. - w.wl( - s"return ${nnCheck(s"dynamic_cast<$cppProxySelf^>(cs)->djinni_private_get_proxied_cpp_object()")};" - ) - } else if (i.ext.cpp || i.ext.cppcli) { - // C# only, or C# and C++. - if (i.ext.cpp) { - // If it could be implemented in C++, we might have to unwrap a proxy object. - w.wl(s"if (auto cs_ref = dynamic_cast<$cppProxySelf^>(cs))") - .braced { - w.wl( - s"return ${nnCheck("cs_ref->djinni_private_get_proxied_cpp_object()")};" - ) - } - } - w.wl( - s"return ${nnCheck(s"::djinni::get_cs_proxy<$csProxySelf>(cs)")};" - ) - } else { - // Neither C# nor C++. Unusable, but generate compilable code. - w.wl( - "DJINNI_UNIMPLEMENTED(\"Interface not implementable in any language.\");" - ) - } - } - w.wl - w.wl(s"$CsType $self::FromCppOpt(const $CppOptType& cpp)").braced { - w.w("if (!cpp)").braced { - w.wl("return nullptr;") - } - if (i.ext.cppcli && !i.ext.cpp) { - // C# only. In this case we *must* unwrap a proxy object - the dynamic_cast will - // throw bad_cast if we gave it something of the wrong type. - w.wl( - s"return dynamic_cast<$csProxySelf*>(cpp.get())->djinni_private_get_proxied_cs_object();" - ) - } else if (i.ext.cppcli || i.ext.cpp) { - // C++ only, or C++ and C#. - if (i.ext.cppcli) { - // If it could be implemented in C#, we might have to unwrap a proxy object. - w.w(s"if (auto cpp_ptr = dynamic_cast<$csProxySelf*>(cpp.get()))") - .braced { - w.wl( - "return cpp_ptr->djinni_private_get_proxied_cs_object();" - ) - } - } - w.wl(s"return ::djinni::get_cpp_proxy<$cppProxySelf^>(cpp);") - } else { - // Neither C# nor C++. Unusable, but generate compilable code. - w.wl( - "DJINNI_UNIMPLEMENTED(\"Interface not implementable in any language.\");" - ) - } - } - } - ) - } - - private def dummyConstant(ret: TypeRef): String = { - val typeStr = marshal.typename(ret) - ret.resolved.base match { - case p: MPrimitive => - p.cppCliName match { - case "double" => "0.0" - case _ => "0" - } - case d: MDef => - d.defType match { - case DEnum => s"($typeStr)0" - case _ => "nullptr" - } - case MDate => typeStr + "()" - case MOptional => - ret.resolved.args.head.base match { - case _: MPrimitive => typeStr + "()" - case MDate => typeStr + "()" - case d: MDef => - d.defType match { - case DEnum => typeStr + "()" - case _ => "nullptr" - } - case e: MExtern => - if (e.cs.reference.get) "nullptr" else typeStr + "()" - case _ => "nullptr" - } - case e: MExtern => - if (e.cs.reference.get) "nullptr" else typeStr + "()" - case _ => "nullptr" - } - } -} diff --git a/src/main/scala/djinni/CppCliMarshal.scala b/src/main/scala/djinni/CppCliMarshal.scala deleted file mode 100644 index 0b524fdb..00000000 --- a/src/main/scala/djinni/CppCliMarshal.scala +++ /dev/null @@ -1,278 +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. - */ - -package djinni - -import djinni.ast._ -import djinni.generatorTools._ -import djinni.meta._ - -class CppCliMarshal(spec: Spec) extends Marshal(spec) { - private val cppMarshal = new CppMarshal(spec) - - override def typename(tm: meta.MExpr): String = - toCppCliType(tm, None, Seq(), needsHandle = true) - def typename(ty: TypeRef, needsHandle: Boolean): String = - toCppCliType(ty, None, Seq(), needsHandle) - def typename(name: String, ty: TypeDef): String = { - val _ = ty // unused, TODO: remove - idCs.ty(name) - } - - override def fqTypename(tm: meta.MExpr): String = - toCppCliType(tm, Some(spec.cppCliNamespace), Seq(), needsHandle = true) - - override def paramType(tm: meta.MExpr): String = typename(tm) - def paramType(tm: MExpr, scopeSymbols: Seq[String]): String = - toCppCliType(tm, None, scopeSymbols, needsHandle = true) - def paramType(ty: TypeRef, scopeSymbols: Seq[String]): String = - paramType(ty.resolved, scopeSymbols) - - override def fqParamType(tm: meta.MExpr): String = paramType(tm) - - override def returnType(ret: Option[TypeRef]): String = returnType(ret, Seq()) - def returnType(ret: Option[TypeRef], scopeSymbols: Seq[String]): String = - ret.fold("void")(toCppCliType(_, None, scopeSymbols)) - - override def fqReturnType(ret: Option[TypeRef]): String = - throw new AssertionError("not applicable") - - override def fieldType(tm: meta.MExpr): String = typename(tm) - - override def fqFieldType(tm: meta.MExpr): String = throw new AssertionError( - "not applicable" - ) - def fqFieldType(tm: meta.MExpr, scopeSymbols: Seq[String]): String = - toCppCliType(tm, None, scopeSymbols, needsHandle = true) - - def helperClass(name: String): String = idCpp.ty(name) - private def helperClass(tm: MExpr): String = - helperName(tm) + helperTemplates(tm) - - override def toCpp(tm: MExpr, expr: String): String = { - s"${helperClass(tm)}::ToCpp($expr)" - } - - override def fromCpp(tm: MExpr, expr: String): String = { - s"${helperClass(tm)}::FromCpp($expr)" - } - - def include(ident: String, isExtendedRecord: Boolean = false): String = { - val _ = isExtendedRecord // unused, TODO: remove - q(spec.cppCliIdentStyle.file(ident) + "." + spec.cppHeaderExt) - } - - def isReference(td: TypeDecl): Boolean = td.body match { - case _: Interface => true - case _: Record => true - case _: Enum => false - } - - def references( - m: Meta, - exclude: String, - forwardDeclareOnly: Boolean - ): Seq[SymbolReference] = m match { - case d: MDef => - d.body match { - case _: Interface => - if (d.name != exclude) { - if (forwardDeclareOnly) { - List( - ImportRef(include(d.name)), - // TODO: Only add reference if two classes reference each other - DeclRef( - s"ref class ${typename(d.name, d.body)};", - Some(spec.cppCliNamespace) - ) - ) - } else { - List(ImportRef(include(d.name))) - } - } else { - List() - } - case _ => - if (d.name != exclude) { - List(ImportRef(include(d.name))) - } else { - List() - } - } - case e: MExtern => - List(ImportRef(e.cs.header.get)) - case _ => List() - } - - private def toCppCliType( - ty: TypeRef, - namespace: Option[String] = None, - scopeSymbols: Seq[String] = Seq(), - needsHandle: Boolean = true - ): String = - toCppCliType(ty.resolved, namespace, scopeSymbols, needsHandle) - - private def toCppCliType( - tm: MExpr, - namespace: Option[String], - scopeSymbols: Seq[String], - needsHandle: Boolean - ): String = { - def withNamespace(name: String): String = { - // If an unqualified symbol needs to have its namespace added, this code assumes that the - // namespace is the one that's defined for generated types (spec.cppNamespace). - // This seems like a safe assumption for the C++ generator as it doesn't make much use of - // other global names, but might need to be refined to cover other types in the future. - val ns = namespace match { - case Some(ns) => Some(ns) - case None => - if (scopeSymbols.contains(name)) - Some(spec.cppCliNamespace.replace(".", "::")) - else None - } - withNs(ns, name) - } - def handle(o: Meta) = { - if (needsHandle) { - o match { - case _: MPrimitive => "" - case d: MDef => - d.defType match { - case DEnum => "" - case _ => "^" - } - case MOptional => "" - case MDate => "" - case e: MExtern => if (e.cs.reference.get) "^" else "" - case _ => "^" - } - } else "" - } - def expr(tm: MExpr): String = { - val args = - if (tm.args.isEmpty) "" - else tm.args.map((tm: MExpr) => expr(tm)).mkString("<", ", ", ">") - tm.base match { - case MOptional => - assert(tm.args.size == 1) - val arg = tm.args.head - arg.base match { - case _: MPrimitive => "System::Nullable" + args - case MDate => "System::Nullable" + args - case d: MDef => - d.defType match { - case DEnum => "System::Nullable" + args - case _ => expr(arg) - } - case e: MExtern => - if (e.cs.reference.get) { - expr(arg) - } else { - "System::Nullable" + args - } - case _ => expr(arg) - } - case e: MExtern => - if (e.cs.generic.get) - withNamespace(e.cs.typename.get) + args + handle(e) - else - withNamespace(e.cs.typename.get) - case o => - val base = o match { - case p: MPrimitive => p.cppCliName - case MString => "System::String" - case MDate => "System::DateTime" - case MBinary => "array" - case MList => "System::Collections::Generic::List" - case MSet => "System::Collections::Generic::HashSet" - case MMap => "System::Collections::Generic::Dictionary" - case d: MDef => withNamespace(idCs.ty(d.name)) - case p: MParam => idCs.typeParam(p.name) - case MOptional => - throw new AssertionError( - "optional should have been special cased" - ) - case _: MExtern => - throw new AssertionError( - "optional should have been special cased" - ) - } - base + args + handle(o) - } - } - expr(tm) - } - - def helperName(tm: MExpr): String = tm.base match { - case d: MDef => - d.defType match { - case DEnum => - withNs( - Some("djinni"), - s"Enum<${cppMarshal.fqTypename(tm)}, ${fqTypename(tm)}>" - ) - case _ => - withNs( - Some(spec.cppCliNamespace.replace(".", "::")), - helperClass(d.name) - ) - } - case e: MExtern => e.cs.translator.get - case o => - withNs( - Some("djinni"), - o match { - case p: MPrimitive => - p.idlName match { - case "i8" => "I8" - case "i16" => "I16" - case "i32" => "I32" - case "i64" => "I64" - case "f32" => "F32" - case "f64" => "F64" - case "bool" => "Bool" - } - case MOptional => "Optional" - case MBinary => "Binary" - case MDate => "Date" - case MString => if (spec.cppUseWideStrings) "WString" else "String" - case MList => "List" - case MSet => "Set" - case MMap => "Map" - case _: MDef => throw new AssertionError("unreachable") - case _: MExtern => throw new AssertionError("unreachable") - case _: MParam => throw new AssertionError("not applicable") - } - ) - } - - private def helperTemplates(tm: MExpr): String = { - def f() = if (tm.args.isEmpty) "" - else tm.args.map(helperClass).mkString("<", ", ", ">") - tm.base match { - case MOptional => - assert(tm.args.size == 1) - val argHelperClass = helperClass(tm.args.head) - s"<${spec.cppOptionalTemplate}, $argHelperClass>" - case MList | MSet => - assert(tm.args.size == 1) - f() - case MMap => - assert(tm.args.size == 2) - f() - case _ => f() - } - } -} diff --git a/src/main/scala/djinni/JavaMarshal.scala b/src/main/scala/djinni/JavaMarshal.scala index 2c56b7e8..9c70d6a5 100644 --- a/src/main/scala/djinni/JavaMarshal.scala +++ b/src/main/scala/djinni/JavaMarshal.scala @@ -103,9 +103,9 @@ class JavaMarshal(spec: Spec) extends Marshal(spec) { } def isEnumFlags(m: Meta): Boolean = m match { - case MDef(_, _, _, Enum(_, true)) => true - case MExtern(_, _, _, Enum(_, true), _, _, _, _, _, _) => true - case _ => false + case MDef(_, _, _, Enum(_, true)) => true + case MExtern(_, _, _, Enum(_, true), _, _, _, _, _) => true + case _ => false } def isEnumFlags(tm: MExpr): Boolean = tm.base match { case MOptional => isEnumFlags(tm.args.head) diff --git a/src/main/scala/djinni/Main.scala b/src/main/scala/djinni/Main.scala index a667588c..c784be70 100644 --- a/src/main/scala/djinni/Main.scala +++ b/src/main/scala/djinni/Main.scala @@ -87,26 +87,12 @@ object Main { var objcFileIdentStyleOptional: Option[IdentConverter] = None var objcStrictProtocol: Boolean = true var objcppNamespace: String = "djinni_generated" - var cppCliOutFolder: Option[File] = None - var cppCliIdentStyle = IdentStyle.csDefault - var cppCliNamespace: String = "" - var cppCliIncludeCppPrefix: String = "" var inFileListPath: Option[File] = None var outFileListPath: Option[File] = None var skipGeneration: Boolean = false var yamlOutFolder: Option[File] = None var yamlOutFile: Option[String] = None var yamlPrefix: String = "" - var pyOutFolder: Option[File] = None - var pyIdentStyle = IdentStyle.pythonDefault - var cWrapperOutFolder: Option[File] = None - var cWrapperHeaderOutFolderOptional: Option[File] = None - var cWrapperIncludePrefix: String = "" - var cWrapperIncludeCppPrefix: String = "" - var pycffiPackageName: String = "" - var pycffiDynamicLibList: String = "" - var pycffiOutFolder: Option[File] = None - var pyImportPrefix: String = "" var cppJsonSerialization: Option[String] = None val argParser: OptionParser[Unit] = new scopt.OptionParser[Unit]("djinni") { @@ -436,76 +422,6 @@ object Main { .foreach(objcppNamespace = _) .text("The namespace name to use for generated Objective-C++ classes.") - note("\nPython") - opt[File]("py-out") - .valueName("") - .foreach(x => pyOutFolder = Some(x)) - .text( - "The output folder for Python files (Generator disabled if unspecified)." - ) - opt[File]("pycffi-out") - .valueName("") - .foreach(x => pycffiOutFolder = Some(x)) - .text( - "The output folder for PyCFFI files (Generator disabled if unspecified)." - ) - opt[String]("pycffi-package-name") - .valueName("...") - .foreach(x => pycffiPackageName = x) - .text("The package name to use for the generated PyCFFI classes.") - opt[String]("pycffi-dynamic-lib-list") - .valueName("...") - .foreach(x => pycffiDynamicLibList = x) - .text("The names of the dynamic libraries to be linked with PyCFFI.") - opt[String]("py-import-prefix") - .valueName("") - .foreach(pyImportPrefix = _) - .text( - "The import prefix used within python generated files (default: \"\")" - ) - note("\nC wrapper") - opt[File]("c-wrapper-out") - .valueName("") - .foreach(x => cWrapperOutFolder = Some(x)) - .text( - "The output folder for C wrapper files (Generator disabled if unspecified)." - ) - opt[File]("c-wrapper-header-out") - .valueName("") - .foreach(x => cWrapperHeaderOutFolderOptional = Some(x)) - .text( - "The output folder for C wrapper header files (default: the same as --c-wrapper-out)." - ) - opt[String]("c-wrapper-include-prefix") - .valueName("") - .foreach(x => cWrapperIncludePrefix = x) - .text( - "The prefix for #includes of C wrapper header files from C wrapper C++ files." - ) - opt[String]("c-wrapper-include-cpp-prefix") - .valueName("") - .foreach(x => cWrapperIncludeCppPrefix = x) - .text( - "The prefix for #includes of C++ header files from C wrapper C++ files." - ) - - note("\nC++/CLI") - opt[File]("cppcli-out") - .valueName("") - .foreach(x => cppCliOutFolder = Some(x)) - .text( - "The output folder for C++/CLI files (Generator disabled if unspecified)." - ) - opt[String]("cppcli-namespace") - .valueName("...") - .foreach(cppCliNamespace = _) - .text("The namespace name to use for generated C++/CLI classes.") - opt[String]("cppcli-include-cpp-prefix") - .valueName("") - .foreach(x => cppCliIncludeCppPrefix = x) - .text( - "The prefix for #include of the main C++ header files from C++/CLI files." - ) note("\nYaml Generation") opt[File]("yaml-out") .valueName("") @@ -649,90 +565,6 @@ object Main { "FooBar", c => { objcFileIdentStyleOptional = Some(c) } ) - - note("\nPython options:") - identStyle( - "ident-py-type", - "foo_bar", - c => { pyIdentStyle = pyIdentStyle.copy(ty = c) } - ) - identStyle( - "ident-py-class-name", - "FooBar", - c => { pyIdentStyle = pyIdentStyle.copy(className = c) } - ) - identStyle( - "ident-py-type-param", - "foo_bar", - c => { pyIdentStyle = pyIdentStyle.copy(typeParam = c) } - ) - identStyle( - "ident-py-method", - "foo_bar", - c => { pyIdentStyle = pyIdentStyle.copy(method = c) } - ) - identStyle( - "ident-py-field", - "foo_bar", - c => { pyIdentStyle = pyIdentStyle.copy(field = c) } - ) - identStyle( - "ident-py-local", - "foo_bar", - c => { pyIdentStyle = pyIdentStyle.copy(local = c) } - ) - identStyle( - "ident-py-enum", - "Foo_Bar", - c => { pyIdentStyle = pyIdentStyle.copy(enum = c) } - ) - identStyle( - "ident-py-const", - "FOO_BAR", - c => { pyIdentStyle = pyIdentStyle.copy(const = c) } - ) - - note("\nC++/CLI options:") - identStyle( - "ident-cppcli-type", - "FooBar", - c => { cppCliIdentStyle = cppCliIdentStyle.copy(ty = c) } - ) - identStyle( - "ident-cppcli-type-param", - "FooBar", - c => { cppCliIdentStyle = cppCliIdentStyle.copy(typeParam = c) } - ) - identStyle( - "ident-cppcli-property", - "FooBar", - c => { cppCliIdentStyle = cppCliIdentStyle.copy(property = c) } - ) - identStyle( - "ident-cppcli-method", - "FooBar", - c => { cppCliIdentStyle = cppCliIdentStyle.copy(method = c) } - ) - identStyle( - "ident-cppcli-local", - "fooBar", - c => { cppCliIdentStyle = cppCliIdentStyle.copy(local = c) } - ) - identStyle( - "ident-cppcli-enum", - "FooBar", - c => { cppCliIdentStyle = cppCliIdentStyle.copy(enum = c) } - ) - identStyle( - "ident-cppcli-const", - "FooBar", - c => { cppCliIdentStyle = cppCliIdentStyle.copy(const = c) } - ) - identStyle( - "ident-cppcli-file", - "FooBar", - c => { cppCliIdentStyle = cppCliIdentStyle.copy(file = c) } - ) } if (argParser.parse(args, ()).isEmpty) { @@ -752,10 +584,6 @@ object Main { val objcppHeaderOutFolder = if (objcppHeaderOutFolderOptional.isDefined) objcppHeaderOutFolderOptional else objcppOutFolder - val cWrapperHeaderOutFolder = - if (cWrapperHeaderOutFolderOptional.isDefined) - cWrapperHeaderOutFolderOptional - else cWrapperOutFolder val jniClassIdentStyle = jniClassIdentStyleOptional.getOrElse(cppIdentStyle.ty) jniBaseLibClassIdentStyleOptional.getOrElse(jniClassIdentStyle) @@ -828,8 +656,7 @@ object Main { objcOutRequired = objcOutFolder.isDefined, objcppOutRequired = objcppOutFolder.isDefined, javaOutRequired = javaOutFolder.isDefined, - jniOutRequired = jniOutFolder.isDefined, - cppCliOutRequired = cppCliOutFolder.isDefined + jniOutRequired = jniOutFolder.isDefined ) match { case Some(err) => System.err.println(err) @@ -915,10 +742,6 @@ object Main { objcppIncludeObjcPrefix, objcppNamespace, objcSwiftBridgingHeaderWriter, - cppCliOutFolder, - cppCliIdentStyle, - cppCliNamespace, - cppCliIncludeCppPrefix, objcSwiftBridgingHeaderName, objcClosedEnums, objcStrictProtocol, @@ -927,17 +750,7 @@ object Main { yamlOutFolder, yamlOutFile, yamlPrefix, - pyOutFolder, - pyIdentStyle, - pycffiOutFolder, - pycffiPackageName, - pycffiDynamicLibList, idlFile.getName(), - cWrapperOutFolder, - cWrapperHeaderOutFolder, - cWrapperIncludePrefix, - cWrapperIncludeCppPrefix, - pyImportPrefix, cppJsonSerialization ) diff --git a/src/main/scala/djinni/Marshal.scala b/src/main/scala/djinni/Marshal.scala index 52e46507..fc571179 100644 --- a/src/main/scala/djinni/Marshal.scala +++ b/src/main/scala/djinni/Marshal.scala @@ -47,8 +47,6 @@ abstract class Marshal(spec: Spec) { protected val idCpp = spec.cppIdentStyle protected val idJava = spec.javaIdentStyle protected val idObjc = spec.objcIdentStyle - protected val idPython = spec.pyIdentStyle - protected val idCs = spec.cppCliIdentStyle protected def withNs(namespace: Option[String], t: String): String = namespace match { diff --git a/src/main/scala/djinni/PythonGenerator.scala b/src/main/scala/djinni/PythonGenerator.scala deleted file mode 100644 index 543df861..00000000 --- a/src/main/scala/djinni/PythonGenerator.scala +++ /dev/null @@ -1,1681 +0,0 @@ -/** Copyright 2015 Dropbox, Inc. - * - * 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. - */ - -package djinni - -import djinni.ast.Record.DerivingType -import djinni.ast._ -import djinni.generatorTools._ -import djinni.meta._ -import djinni.writer.IndentWriter - -import scala.collection.mutable -import scala.math.pow - -class PythonGenerator(spec: Spec) extends Generator(spec) { - val lib = "lib" // internal library name (from PyCFFIlib_cffi import lib) - val marshal = new PythonMarshal(spec) - val cMarshal = new CWrapperMarshal(spec) - - def getRecordArguments(r: Record, self: String): Seq[String] = { - if (self != "") Seq(self) ++ r.fields.map(f => idPython.local(f.ident.name)) - else r.fields.map(f => idPython.local(f.ident.name)) - } - - def getRecordTypes(r: Record): Seq[String] = { - r.fields.map(f => cMarshal.cParamType(f.ty, forHeader = true)) - } - - // Override since Python doesn't share the C-style comment syntax. - override def writeDoc(w: IndentWriter, doc: Doc): Unit = { - doc.lines.foreach(l => w.wl(s"#$l")) - } - - // Use docstrings rather than comments when available. - def writeDocString( - w: IndentWriter, - doc: Doc, - docLists: Seq[IndentWriter => Unit] = Seq() - ): Boolean = { - if (doc.lines.isEmpty && docLists.isEmpty) { - return false - } - if (doc.lines.length == 1 && docLists.isEmpty) { - w.wl(s"""\"\"\"${doc.lines.head} \"\"\"""") - } else { - w.wl("\"\"\"") - doc.lines.foreach(l => w.wl(s"$l")) - docLists.foreach(docList => docList(w)) - w.wl("\"\"\"") - } - true - } - - def writeDocList( - w: IndentWriter, - name: String, - docItems: IndentWriter => Unit - ): Unit = { - w.wl(name) - w.nested { - docItems(w) - } - } - - def writeDocListItem( - w: IndentWriter, - name: String, - lines: Seq[String] - ): Unit = { - if (lines.isEmpty) { - w.wl(s"${name}") - } else { - w.wl(s"${name}: ${lines.head.trim}") - w.nested { - lines.tail.foreach(l => { - w.wl(l) - }) - } - } - } - - def writeDocConstantsList(w: IndentWriter, consts: Seq[Const]): Unit = { - writeDocList( - w, - "Constants", - { w => - consts.foreach(c => { - writeDocListItem(w, idPython.const(c.ident), c.doc.lines) - }) - } - ) - } - - def writeDocFieldsList(w: IndentWriter, fields: Seq[Field]): Unit = { - writeDocList( - w, - "Fields", - { w => - fields.foreach(f => { - writeDocListItem(w, idPython.field(f.ident), f.doc.lines) - }) - } - ) - } - - def writeDocEnumOptionsList( - w: IndentWriter, - options: Seq[Enum.Option] - ): Unit = { - writeDocList( - w, - "Members", - { w => - options.foreach(o => { - writeDocListItem(w, idPython.enum(o.ident), o.doc.lines) - }) - } - ) - } - - def writeGetterCallback( - methodName: String, - ret: String, - cArgs: String, - defArgs: String, - w: IndentWriter, - f: IndentWriter => Unit - ): Unit = { - w.wl("@ffi.callback" + "(\"" + ret + cArgs + "\")") - w.wl("def " + methodName + defArgs + ":").nested { - f(w) - } - w.wl - } - - def getContainerElTyRef(tm: MExpr, index: Int, ident: Ident): TypeRef = { - val elTyRef = TypeRef(TypeExpr(ident, Seq())) - elTyRef.resolved = tm.args(index) - elTyRef - } - - def getElTyRef(tm: MExpr, ident: Ident): TypeRef = { - val elTyRef = TypeRef(TypeExpr(ident, Seq())) - elTyRef.resolved = tm - elTyRef - } - - def writeReleaseCallback(className: String, w: IndentWriter): Unit = { - // Function to release handler to python object - w.wl( - "@ffi.callback(\"void(" + "struct " + cMarshal.djinniObjectHandle + " * " + ")\")" - ) - w.wl("def __delete" + p("c_ptr") + ":").nested { - w.wl("assert c_ptr in " + className + ".c_data_set") - w.wl(className + ".c_data_set.remove(c_ptr)") - } - w.wl - } - - def writeGettersCallbacks( - tm: MExpr, - ident: Ident, - name: String, - className: String, - w: IndentWriter, - self: String, - keyToPy: String, - keyAssert: String, - getName: String, - getRetTyRef: TypeRef, - getRetType: String, - getType: String, - getCall: String, - elIndex: String, - elTyRef: TypeRef, - getSizeCall: String, - createName: String, - addElemCall: String, - toAddDefArgs: String, - toAddCArgs: String, - extraAddCallback: String, - extraCallBackImpl: IndentWriter => Unit - ): Unit = { - val _ = (tm, ident, elTyRef) // unused, TODO: remove - // GET ELEMENT/ GET VALUE - var ret = getRetType - var defArgs = Seq("cself, " + elIndex).mkString("(", ", ", ")") - var cArgs = - Seq("struct DjinniObjectHandle *", getType).mkString("(", ", ", ")") - if (getName != "") { - writeGetterCallback( - getName, - ret, - cArgs, - defArgs, - w, - w => { - if (keyToPy != "") w.wl(keyToPy) - if (keyAssert != "") w.wl(keyAssert) - writeReturnFromCallback(self, getRetTyRef, getCall, w) - } - ) - } - - // GET SIZE - ret = "size_t" - defArgs = Seq("cself").mkString("(", ", ", ")") - cArgs = Seq("struct DjinniObjectHandle *").mkString("(", ", ", ")") - writeGetterCallback( - "__get_size", - ret, - cArgs, - defArgs, - w, - w => { - w.wl("return " + getSizeCall) - } - ) - - // CREATE - ret = "struct DjinniObjectHandle *" - defArgs = Seq("").mkString("(", ", ", ")") - cArgs = Seq("").mkString("(", ", ", ")") - writeGetterCallback( - "__create", - ret, - cArgs, - defArgs, - w, - w => { - w.wl("c_ptr = ffi.new_handle" + p(createName)) - w.wl(className + ".c_data_set.add(c_ptr)") - w.wl("return ffi.cast(\"struct DjinniObjectHandle *\", c_ptr)") - } - ) - - // ADD TO - ret = "void" - defArgs = Seq("cself, " + toAddDefArgs).mkString("(", ", ", ")") - cArgs = - Seq("struct DjinniObjectHandle *", toAddCArgs).mkString("(", ", ", ")") - writeGetterCallback( - "__add", - ret, - cArgs, - defArgs, - w, - w => { - w.wl(addElemCall) - } - ) - - // RELEASE - writeReleaseCallback(className, w) - extraCallBackImpl(w) - - // Function to add callback on cpp side - w.wl("@staticmethod") - w.wl("def _add_callbacks():").nested { - if (getName != "") { - w.wl( - "lib." + name + "_add_callback" + getName + p( - className + "." + getName - ) - ) - } - // release method callback added - w.wl( - "lib." + name + "_add_callback_" + "__delete" + p( - className + "." + "__delete" - ) - ) - w.wl( - "lib." + name + "_add_callback" + "__get_size" + p( - className + "." + "__get_size" - ) - ) - w.wl( - "lib." + name + "_add_callback" + "__create" + p( - className + "." + "__create" - ) - ) - w.wl( - "lib." + name + "_add_callback" + "__add" + p(className + "." + "__add") - ) - if (extraAddCallback != "") w.wl(extraAddCallback) - } - w.wl - } - - def writeChecksForContainer( - tm: MExpr, - exclude: String, - w: IndentWriter - ): Unit = { - val className = marshal.getClassHoldingCDataSet(tm) - if (className != "" && className != exclude) { - w.wl(marshal.getClassHoldingCDataSet(tm) + ".check_c_data_set_empty()") - } - - tm.base match { - case MList => - writeChecksForContainer(tm.args.head, exclude, w) - case MSet | MMap => { - writeChecksForContainer(tm.args.head, exclude, w) - if (tm.base == MMap) writeChecksForContainer(tm.args(1), exclude, w) - } - case _ => - } - } - - def generateContainer( - tm: MExpr, - isOpt: Boolean, - fileName: String, - classAsMethodName: String, - ident: Ident, - origin: String, - python: mutable.TreeSet[String] - ): Unit = { - val _ = classAsMethodName // unused, TODO: remove - val helperClass = idPython.className(fileName) + "Helper" - val proxyName = idPython.className(fileName) + "Proxy" - val next = - if (tm.base == MList) "" - else { - if (isOpt) "next(CPyObjectProxy.toPyIterOpt(cself))" - else "next(CPyObjectProxy.toPyIter(cself))" - } - - writePythonFile( - marshal.dh + fileName, - origin, - python, - includeCffiLib = true, - w => { - w.wl("class " + helperClass + ":").nested { - w.wl("c_data_set = MultiSet()") - w.wl - w.wl("@staticmethod") - w.wl("def check_c_data_set_empty():").nested { - w.wl("assert len" + p(helperClass + ".c_data_set") + " == 0") - writeChecksForContainer(tm, helperClass, w) - } - w.wl - tm.base match { - case MList => - val elTyref = getContainerElTyRef(tm, 0, ident) - val elTy = cMarshal.cReturnType(Some(elTyref), forHeader = true) - - writeGettersCallbacks( - tm, - ident, - fileName, - helperClass, - w, - "CPyObject.toPy(cself)", - "", - "", - "__get_elem", - elTyref, - elTy, - "size_t", - "CPyObject.toPy(" + "None" + ", " + "cself)[index]", - "index", - elTyref, - "len(CPyObject.toPy(" + "None" + ", " + "cself))", - "list()", - "CPyObject.toPy(" + "None" + ", " + "cself).append(" + marshal - .convertTo("el", elTyref) + ")", - "el", - elTy, - "", - _ => {} - ) - case MMap => - val keyTyRef = getContainerElTyRef(tm, 0, ident) - val keyTy = cMarshal.cReturnType(Some(keyTyRef), forHeader = true) - val valTyref = getContainerElTyRef(tm, 1, ident) - val valTy = cMarshal.cReturnType(Some(valTyref), forHeader = true) - val keyToPy = - "pyKey = " + marshal.convertToRelease("key", keyTyRef) - val keyAssert = "assert pyKey is not None" - - writeGettersCallbacks( - tm, - ident, - fileName, - helperClass, - w, - "CPyObjectProxy.toPyObj(cself)", - keyToPy, - (if (keyTyRef.resolved.base != MOptional) keyAssert else ""), - "__get_value", - valTyref, - valTy, - keyTy, - "CPyObjectProxy.toPyObj(" + "None" + ", " + "cself)[pyKey]", - "key", - keyTyRef, - "len(CPyObjectProxy.toPyObj(" + "None" + ", " + "cself))", - proxyName + p("dict()"), - "CPyObjectProxy.toPyObj(" + "None" + ", " + "cself)[" + marshal - .convertTo("key", keyTyRef) + "] = " + marshal - .convertTo("value", valTyref), - "key, value", - keyTy + ", " + valTy, - "lib." + fileName + "_add_callback" + "__next" + p( - helperClass + "." + "__next" - ), - w => { - // NEXT in iteration - val ret = keyTy - val defArgs = Seq("cself").mkString("(", ", ", ")") - val cArgs = - Seq("struct DjinniObjectHandle *").mkString("(", ", ", ")") - writeGetterCallback( - "__next", - ret, - cArgs, - defArgs, - w, - w => { - writeReturnFromCallback( - "CPyObjectProxy.toPyObj(None, cself)", - keyTyRef, - next, - w - ) - } - ) - } - ) - - // change function get elem with get key and write function to get elem - case MSet => - val keyTyRef = getContainerElTyRef(tm, 0, ident) - val keyTy = cMarshal.cReturnType(Some(keyTyRef), forHeader = true) - - writeGettersCallbacks( - tm, - ident, - fileName, - helperClass, - w, - "CPyObjectProxy.toPyObj(cself)", - "", - "", - "", - keyTyRef, - keyTy, - "size_t", - "CPyObjectProxy.toPyObj(" + "None" + ", " + "cself)[index]", - "index", - keyTyRef, - "len(CPyObjectProxy.toPyObj(" + "None" + ", " + "cself))", - proxyName + p("set()"), - "CPyObjectProxy.toPyObj(" + "None" + ", " + "cself).add(" + marshal - .convertTo("el", keyTyRef) + ")", - "el", - keyTy, - "lib." + fileName + "_add_callback" + "__next" + p( - helperClass + "." + "__next" - ), - w => { - // NEXT in iteration - val ret = keyTy - val defArgs = Seq("cself").mkString("(", ", ", ")") - val cArgs = - Seq("struct DjinniObjectHandle *").mkString("(", ", ", ")") - - writeGetterCallback( - "__next", - ret, - cArgs, - defArgs, - w, - w => { - writeReturnFromCallback( - "CPyObjectProxy.toPyObj(None, cself)", - keyTyRef, - next, - w - ) - } - ) - } - ) - - case _ => - } - } - w.wl(helperClass + "._add_callbacks()") - w.wl - if (tm.base == MSet || tm.base == MMap) { - w.wl("class " + proxyName + ":").nested { - w.wl("def iter(d):").nested { - w.wl("for k in d:").nested { - w.wl("yield k") - } - } - w.wl - w.wl("def __init__(self, py_obj):").nested { - w.wl("self._py_obj = py_obj") - w.wl("if py_obj is not None:").nested { - w.wl("self._py_iter = iter(py_obj)") - } - w.wl("else:").nested { - w.wl("self._py_iter = None") - } - } - } - } - } - ) - } - - // for map and set have proxy map and set that can hold on to metadata like iterator - - class PythonRefs(ident: Ident, origin: String) { - var python: mutable.TreeSet[String] = mutable.TreeSet[String]() - - def collect(ty: TypeRef, justCollect: Boolean): Unit = { - collect(ty.resolved, justCollect, isOpt = false) - } - def collect(tm: MExpr, justCollect: Boolean, isOpt: Boolean): Unit = { - tm.args.foreach(t => collect(t, justCollect, isOpt)) - collect(tm.base, justCollect) - - val idlName = marshal.getExprIdlName(tm) - val fileName = idlName - - tm.base match { - case MList | MSet | MMap => { - if (justCollect) { - if (tm.base == MList) - python.add( - "from " + spec.pyImportPrefix + marshal.dh + fileName + " import " + idPython - .className(fileName) + "Helper" - ) - else { - python.add( - "from " + spec.pyImportPrefix + marshal.dh + fileName + " import " + idPython - .className(fileName) + "Helper" - ) - python.add( - "from " + spec.pyImportPrefix + marshal.dh + fileName + " import " + idPython - .className(fileName) + "Proxy" - ) - } - } else { - if ( - !Generator.writtenFiles.contains((idlName + ".py").toLowerCase()) - ) { - Generator.writtenFiles.put(fileName.toLowerCase(), fileName) - generateContainer( - tm, - isOpt, - fileName, - idlName, - ident, - origin, - marshal.referencesForContainer(tm, idlName) - ) - } - } - } - case MOptional => - tm.args.head.base match { - case m @ (MPrimitive(_, _, _, _, _, _, _, _, _, _) | MDate) => { - python.add( - "from djinni.pycffi_marshal import CPyBoxed" + idPython - .className(m.asInstanceOf[MOpaque].idlName) - ) - } - case _ => collect(tm.args.head, justCollect, isOpt = true) - } - case _ => - } - } - def collect(m: Meta, justCollect: Boolean): Unit = if (justCollect) - for (r <- marshal references (m, ident.name)) r match { - case ImportRef(arg) => - python.add(arg) - case _ => - } - } - - def getCArgTypes(m: Interface.Method, self: String): String = { - (Seq(self) ++ m.params.map(p => - cMarshal.cParamType(p.ty, forHeader = true) - )).mkString("(", ", ", ")") - } - - def getDefArgs(m: Interface.Method, self: String): String = { - if (m.static) { - m.params.map(p => idPython.local(p.ident.name)).mkString("(", ", ", ")") - } else { - (Seq(self) ++ m.params.map(p => idPython.local(p.ident.name))) - .mkString("(", ", ", ")") - } - } - - def getLibArgsFrom(m: Interface.Method, pythonClass: String): String = { - if (m.static || pythonClass == "") { - m.params - .map(p => marshal.releaseRAII(marshal.pyName(p.ident.name, p.ty), p.ty)) - .mkString("(", ", ", ")") - } else { - (Seq("self._cpp_impl") ++ m.params.map(p => - marshal.releaseRAII(marshal.pyName(p.ident.name, p.ty), p.ty) - )).mkString("(", ", ", ")") - } - } - - def getLibArgsTo(m: Interface.Method, pythonClass: String): String = { - val _ = pythonClass // unused, TODO: remove - m.params - .map(p => marshal.convertTo(p.ident.name, p.ty)) - .mkString("(", ", ", ")") - } - - def writePythonFile( - ident: String, - origin: String, - refs: Iterable[String], - includeCffiLib: Boolean, - f: IndentWriter => Unit - ): Unit = { - createFileOnce( - spec.pyOutFolder.get, - idPython.ty(ident) + ".py", - (w: IndentWriter) => { - w.wl("# AUTOGENERATED FILE - DO NOT MODIFY!") - w.wl("# This file was generated by Djinni from " + origin) - w.wl - w.wl( - "from djinni.support import MultiSet # default imported in all files" - ) - w.wl( - "from djinni.exception import CPyException # default imported in all files" - ) - - var condensed_refs = Iterable[String]() - var support_lib_refs = "" - val prefix_len = "from djinni.pycffi_marshal import ".length - refs.foreach(r => { - if (r.startsWith("from djinni.pycffi_marshal import ")) { - if (support_lib_refs == "") support_lib_refs = r - else support_lib_refs += ", " + r.slice(prefix_len, r.length) - } else { - condensed_refs = condensed_refs ++ Seq(r) - } - }) - - w.wl(support_lib_refs) - if (condensed_refs.nonEmpty) { - w.wl - condensed_refs.foreach(w.wl) - } - - if (includeCffiLib) { - val cffi = spec.pycffiPackageName + "_cffi" - w.wl("from " + cffi + " import ffi, lib") - w.wl - } - w.wl( - "from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception" - ) - w.wl - f(w) - } - ) - } - - def checkNonOptionals(m: Interface.Method, w: IndentWriter): Unit = { - m.params.map(arg => - if (arg.ty.resolved.base != MOptional) - w.wl("assert " + arg.ident.name + " is not None ") - ) - } - - def processPackedArgs( - m: Interface.Method, - withStmts: mutable.ArrayBuffer[String] - ): Unit = { - val args = mutable.ArrayBuffer( - m.params.filter((p: Field) => marshal.isPacked(p.ty)): _* - ) - if (args.nonEmpty) { - withStmts.appendAll(args.map(arg => { - val argName = idPython.local(arg.ident.name) // .name? - val pyArgName = idPython.local(marshal.pyName(arg.ident.name, arg.ty)) - - marshal.getPacked(arg, argName, pyArgName) - })) - } - } - - def writeWithStmts(withStmts: Seq[String], w: IndentWriter)( - f: => Unit - ): Unit = { - if (withStmts.nonEmpty) { - val len = withStmts.length - - if (len == 1) { - w.wl("with " + withStmts.head + ":") - } else { - w.wl("with " + withStmts.head + ",\\") - // extra nesting for 2nd..last with - w.nestedN(2) { - val middle = withStmts.slice(1, len - 1) - middle.map(s => { - w.wl(s + ",\\") - }) - w.wl(withStmts(len - 1) + ":") - } - } - w.nested(f) - } else { - f - } - } - - def writeDeclStmts(declStmts: Seq[String], w: IndentWriter): Unit = { - declStmts.map(s => w.wl(s)) - } - - def checkForExceptionFromPython( - libcall: IndentWriter => Unit, - returnNotVoid: Boolean, - w: IndentWriter - ): Unit = { - w.wl("try:").nested { - libcall(w) - } - w.wl("except Exception as _djinni_py_e:").nested { - w.wl("CPyException.setExceptionFromPy" + p("_djinni_py_e")) - if (returnNotVoid) { - w.wl("return ffi.NULL") - } - } - } - - def writeReturnFromCallback( - self: String, - ret: TypeRef, - libCall: String, - w: IndentWriter - ): Unit = { - val _ = self // unused, TODO: remove - val returnStmt: String = ret.resolved.base match { - case MString | MBinary => - checkForExceptionFromPython( - w => { - w.wl("with " + marshal.convertFrom(libCall, ret) + " as py_obj:") - .nested { - w.wl("_ret = " + marshal.releaseRAII("py_obj", ret)) - w.wl("assert _ret != ffi.NULL") - w.wl("return _ret") - } - }, - returnNotVoid = true, - w - ) - return - case MOptional => { - val optTy = ret.resolved.args.head - optTy.base match { - case MSet | MMap => - checkForExceptionFromPython( - w => { - w.wl("return " + marshal.convertFrom(libCall, ret)) - }, - returnNotVoid = true, - w - ) - case MString | MBinary => - checkForExceptionFromPython( - w => { - w.wl( - "with " + marshal.convertFrom(libCall, ret) + " as py_obj:" - ).nested { - w.wl( - "return " + marshal - .releaseRAII("py_obj", optTy, isOpt = true) - ) // here - } - }, - returnNotVoid = true, - w - ) - case MPrimitive(_, _, _, _, _, _, _, _, _, _) | MDate => - checkForExceptionFromPython( - w => { - w.wl( - "with " + marshal.convertFrom(libCall, ret) + " as py_obj:" - ).nested { - w.wl("return " + marshal.releaseRAII("py_obj", ret)) // here - } - }, - returnNotVoid = true, - w - ) - case _ => - checkForExceptionFromPython( - w => { - w.wl("return " + marshal.convertFrom(libCall, ret)) - }, - returnNotVoid = true, - w - ) - } - // for optionals we don't need asserts of non-None, so we return here - return - } - case d: MDef => - d.defType match { - case DEnum => - checkForExceptionFromPython( - w => { - w.wl("_ret = " + marshal.convertFrom(libCall, ret)) - w.wl("assert _ret != -1") - w.wl("return _ret") - }, - returnNotVoid = true, - w - ) - return - case _ => "_ret = " + marshal.convertFrom(libCall, ret) - } - case _ => "_ret = " + marshal.convertFrom(libCall, ret) - } - - checkForExceptionFromPython( - w => { - w.wl(returnStmt) - if (!marshal.isPrimitive(ret)) { - w.wl("assert _ret != ffi.NULL") - } - w.wl("return _ret") - - }, - returnNotVoid = true, - w - ) - } - - def checkForExceptionFromCpp(ret: String, w: IndentWriter): Unit = { - w.wl("CPyException.toPyCheckAndRaise" + p(ret)) - } - - def writeCppProxyMethod( - m: Interface.Method, - cMethodWrapper: String, - pythonClass: String, - w: IndentWriter - ): Unit = { - val defArgs = getDefArgs(m, "self") - if (m.static) { - w.wl("@staticmethod") - } - w.wl("def " + m.ident.name + defArgs + ":").nested { - val withStmts = mutable.ArrayBuffer[String]() - processPackedArgs(m, withStmts) - // check that if python promised to send as arguments non optionals then they are not None - // checkNonOptionals(m, w) - writeWithStmts(withStmts.toSeq, w) { - val libArgs = getLibArgsFrom(m, pythonClass) - val libCall = lib + "." + cMethodWrapper + "_" + m.ident.name + libArgs - if (m.ret.isEmpty) { - w.wl(libCall) - checkForExceptionFromCpp("ffi.NULL", w) - } else { - w.wl("_ret_c = " + libCall) - checkForExceptionFromCpp("_ret_c", w) - w.wl("_ret = " + marshal.convertTo("_ret_c", m.ret.get)) - // Check that if C promised to return a non-optional it is not None - if (m.ret.get.resolved.base != MOptional) { - m.ret.get.resolved.base match { - case d: MDef => - d.defType match { - case DEnum => - w.wl("assert _ret.value != -1") - case _ => w.wl("assert _ret is not None") - } - case _ => w.wl("assert _ret is not None") - } - } - - w.wl("return _ret") - } - } - } - } - - def writeCallbackMethod( - m: Interface.Method, - pythonClass: String, - w: IndentWriter - ): Unit = { - // Should I throw an exception if the method is declared static? - val defArgs = getDefArgs(m, "cself") - val cArgs = getCArgTypes(m, "struct " + cMarshal.djinniObjectHandle + " * ") - val ret = cMarshal.cReturnType(m.ret, forHeader = true) - w.wl("@ffi.callback" + "(\"" + ret + cArgs + "\")") - w.wl("def " + m.ident.name + defArgs + ":").nested { - // check that if C promised non-optionals as arguments to callback, they are not None - val libArgs = getLibArgsTo(m, "") - val libCall = - pythonClass + "Helper.selfToPy(cself)." + m.ident.name + libArgs - if (m.ret.isDefined) { - writeReturnFromCallback( - pythonClass + "Helper.selfToPy(cself)", - m.ret.get, - libCall, - w - ) - } else { - checkForExceptionFromPython( - w => { w.wl(libCall) }, - returnNotVoid = false, - w - ) - } - } - } - - def writeCppProxyClass( - pythonClass: String, - cMethodWrapper: String, - methods: Seq[Interface.Method], - w: IndentWriter - ): Unit = { - val proxyClass = pythonClass + "CppProxy" - // Proxy Class Definition - w.wl("class " + proxyClass + p(pythonClass) + ":").nested { - // Init and Del methods - w.wl("def __init__(self, proxy):").nested { - w.wl("self._is_cpp_proxy = True") - w.wl("self._cpp_impl" + " = proxy") - } - w.wl("def __del__(self):").nested { - w.wl("if not lib:").nested { - w.wl("return") - } - w.wl(lib + "." + cMethodWrapper + "___wrapper_dec_ref(self._cpp_impl)") - } - w.wl - - // Method implementations, calling into C code via ccfi library - for (m <- methods) { - writeCppProxyMethod(m, cMarshal.cw + cMethodWrapper, pythonClass, w) - w.wl - } - } - } - def writeHelperMethodsForCppImplementedInterface( - ident: String, - ext: Ext, - w: IndentWriter - ): Unit = { - val helperClass = idPython.className(ident) + "Helper" - val proxyClass = idPython.className(ident) + "CppProxy" - // Static method to wrap as object of this class - w.wl("@staticmethod") - w.wl("def toPy(obj):").nested { - w.wl("if obj == ffi.NULL:").nested { - w.wl("return None") - } - if (ext.py) { - w.wl( - "# Python Objects can be returned without being wrapped in proxies" - ) - w.wl( - "py_handle = lib.get_handle_from_proxy_object_" + cMarshal.cw + idPython - .method(ident) + p("obj") - ) - w.wl("if py_handle:").nested { - w.wl("assert py_handle in " + helperClass + ".c_data_set") - w.wl("aux = ffi.from_handle(ffi.cast(\"void * \", py_handle))") - w.wl( - "lib." + idPython.method(ident) + "___wrapper_dec_ref" + p("obj") - ) - w.wl("return aux") - } - } - - w.wl("return " + proxyClass + p("obj")) - } - w.wl - } - - def writeCallbacksHelperClass( - ident: Ident, - pythonClass: String, - methods: Seq[Interface.Method], - ext: Ext, - w: IndentWriter - ): Unit = { - val _ = ext // unused, TODO, check remove - val proxyClass = pythonClass + "CallbacksHelper" - val helperClass = pythonClass + "Helper" - val classNameAsMethod = idPython.method(ident.name) - // Proxy Class Definition - w.wl("class " + proxyClass + "():").nested { - // Method implementations, calling into C code via ccfi library - for (m <- methods) { - writeCallbackMethod(m, pythonClass, w) - w.wl - } - - // Function to release handler to python object - writeReleaseCallback(helperClass, w) - - // Function to add callback on cpp side - w.wl("@staticmethod") - w.wl("def _add_callbacks():").nested { - for (m <- methods.sortBy(x => x.ident.name)) { - w.wl( - "lib." + classNameAsMethod + "_add_callback_" + idPython - .method(m.ident.name) + p(proxyClass + "." + m.ident.name) - ) - } - w.wl - // release method callback added - w.wl( - "lib." + classNameAsMethod + "_add_callback_" + "__delete" + p( - proxyClass + "." + "__delete" - ) - ) - w.wl - } - - } - w.wl(proxyClass + "._add_callbacks()") - w.wl - } - - def writeHelperMethodsForPythonImplementedInterface( - ident: String, - methods: Seq[Interface.Method], - ext: Ext, - w: IndentWriter - ): Unit = { - val helperClass = idPython.className(ident) + "Helper" - val cppProxyClass = idPython.className(ident) + "CppProxy" - w.wl("@staticmethod") - w.wl("def selfToPy(obj):").nested { - w.wl("assert obj in " + helperClass + ".c_data_set") - w.wl("return ffi.from_handle(ffi.cast(\"void * \",obj))") - } - w.wl - - // Helper function for having this interface as argument - w.wl("@staticmethod") - w.wl("def fromPy(py_obj):").nested { - w.wl("if py_obj is None:").nested { - w.wl("return" + " ffi.NULL") - } - // check whether cpp implementation given (then no need to wrap as pyproxy) - if (ext.cpp) { - w.wl("if isinstance(py_obj, " + cppProxyClass + "):").nested { - w.wl( - "lib." + idPython - .method(ident) + "___wrapper_add_ref(py_obj._cpp_impl)" - ) - w.wl("return py_obj._cpp_impl") - w.wl - } - } - - w.wl("py_proxy = " + p("py_obj")) - // check wheter object implements all needed functions - for (m <- methods) { - w.wl( - "if not hasattr" + p( - "py_obj, " + q(idPython.method(m.ident.name)) - ) + ":" - ).nested { - w.wl("raise TypeError") - } - } - w.wl - w.wl("bare_c_ptr = ffi.new_handle(py_proxy)") - w.wl(helperClass + ".c_data_set.add(bare_c_ptr)") - w.wl( - "wrapped_c_ptr = lib.make_proxy_object_from_handle_" + cMarshal.cw + idPython - .method(ident) + p("bare_c_ptr") - ) - w.wl("return wrapped_c_ptr") - } - } - - def writeNonRecursiveConst( - w: IndentWriter, - ty: TypeRef, - v: Any, - selfName: String - ): Unit = { - val _ = ty // used, TODO, check remove - v match { - case l: Long => w.w(l.toString) - case d: Double => w.w(d.toString) - case b: Boolean => w.w(if (b) "True" else "False") - case s: String => w.w(s) - case _: EnumValue => throw new NotImplementedError() - case v: ConstRef => w.w(selfName + "." + idPython.const(v)) - } - } - - def generateNonRecursiveConstants( - w: IndentWriter, - consts: Seq[Const], - selfName: String, - genRecord: Boolean - ): Unit = { - val _ = genRecord // unused, TODO, check remove - for (c <- consts) { - if (!c.value.isInstanceOf[Map[_, _]]) { // is not a record - w.w(idPython.const(c.ident) + " = ") - writeNonRecursiveConst(w, c.ty, c.value, selfName) - w.wl - } - } - } - - def generateRecursiveConstants( - w: IndentWriter, - consts: Seq[Const], - selfName: String - ): Unit = { - def writeRecursiveConst( - w: IndentWriter, - cName: String, - ty: TypeRef, - v: Any, - selfName: String - ): Unit = v match { - case z: Map[_, _] => { // Value is record - val recordMdef = ty.resolved.base.asInstanceOf[MDef] - val record = recordMdef.body.asInstanceOf[Record] - val vMap = z.asInstanceOf[Map[String, Any]] - val recordClassName = idPython.className(recordMdef.name) - w.wl( - selfName + "." + idPython.const(cName) + " = " + recordClassName + "(" - ) - w.increase() - // Use exact sequence - val skipFirst = SkipFirst() - for (f <- record.fields) { - skipFirst { w.wl(",") } - writeRecursiveConst( - w, - cName, - f.ty, - vMap.apply(f.ident.name), - selfName - ) - } - w.decrease() - w.w(")") - w.wl - } - case _ => writeNonRecursiveConst(w, ty, v, selfName) - } - - for (c <- consts) { - if (c.value.isInstanceOf[Map[_, _]]) { // is a record - writeRecursiveConst(w, c.ident, c.ty, c.value, selfName) - w.wl - } - } - } - - override def generateInterface( - origin: String, - ident: Ident, - doc: Doc, - typeParams: Seq[TypeParam], - i: Interface - ): Unit = { - val pythonClass = idPython.className(ident.name) - val cMethodWrapper = idPython.method(ident.name) - val refs = new PythonRefs(ident, origin) - i.consts.map(c => { - refs.collect(c.ty, justCollect = true) - }) - i.methods.map(m => { - m.params.foreach(p => refs.collect(p.ty, justCollect = true)) - m.ret.foreach(t => refs.collect(t, justCollect = true)) - }) - i.methods.map(m => { - m.params.foreach(p => refs.collect(p.ty, justCollect = false)) - m.ret.foreach(t => refs.collect(t, justCollect = false)) - }) - refs.python.add("from abc import ABCMeta, abstractmethod") - refs.python.add("from future.utils import with_metaclass") - - writePythonFile( - ident, - origin, - refs.python, - includeCffiLib = true, - w => { - // Asbtract Class Definition - w.wl("class " + pythonClass + "(with_metaclass(ABCMeta)):").nested { - val docConsts = - if (!i.consts.exists(!_.doc.lines.isEmpty)) Seq() - else - Seq({ w: IndentWriter => - writeDocConstantsList(w, i.consts) - }) - if (writeDocString(w, doc, docConsts)) { w.wl } - - if (i.consts.nonEmpty) { - generateNonRecursiveConstants( - w, - i.consts, - idPython.className(ident.name), - genRecord = true - ) - w.wl - } - for (m <- i.methods if !m.static) { - w.wl("@abstractmethod") - w.wl( - "def " + idPython - .method(m.ident.name) + getDefArgs(m, "self") + ":" - ).nested { - writeDocString(w, m.doc) - w.wl("raise NotImplementedError") - } - w.wl - } - if (i.ext.cpp) { // static methods only exist one way - val proxyClass = pythonClass + "CppProxy" - for (m <- i.methods if m.static) { - val defArgs = getDefArgs(m, "self") - w.wl("@staticmethod") - w.wl("def " + idPython.method(m.ident.name) + defArgs + ":") - .nested { - writeDocString(w, m.doc) - if (m.ret.isDefined) { - w.wl( - "return " + proxyClass + "." + idPython - .method(m.ident.name) + defArgs - ) - } else { - w.wl( - proxyClass + "." + idPython.method(m.ident.name) + defArgs - ) - } - } - } - } - } - w.wl - // Recursive constants, such as records, might reference the interface class that is currently definied - // They are added as properties on the class, after the class definition to avoid 'incomplete type' errors - if (i.consts.nonEmpty) { - generateRecursiveConstants( - w, - i.consts, - idPython.className(ident.name) - ) - w.wl - } - if (i.ext.cpp && i.ext.py) { - writeCppProxyClass(pythonClass, cMethodWrapper, i.methods, w) - writeCallbacksHelperClass(ident, pythonClass, i.methods, i.ext, w) - w.wl("class " + pythonClass + "Helper" + ":").nested { - w.wl("c_data_set = MultiSet()") - writeHelperMethodsForCppImplementedInterface(ident.name, i.ext, w) - writeHelperMethodsForPythonImplementedInterface( - ident.name, - i.methods, - i.ext, - w - ) - } - } else if (i.ext.cpp) { - writeCppProxyClass(pythonClass, cMethodWrapper, i.methods, w) - w.wl("class " + pythonClass + "Helper" + ":").nested { - w.wl("c_data_set = MultiSet()") - writeHelperMethodsForCppImplementedInterface(ident.name, i.ext, w) - } - } else if (i.ext.py) { - writeCallbacksHelperClass(ident, pythonClass, i.methods, i.ext, w) - w.wl("class " + pythonClass + "Helper" + ":").nested { - w.wl("c_data_set = MultiSet()") - writeHelperMethodsForCppImplementedInterface(ident.name, i.ext, w) - writeHelperMethodsForPythonImplementedInterface( - ident.name, - i.methods, - i.ext, - w - ) - } - } - } - ) - } - - def writeRecordCallbacks( - ident: Ident, - r: Record, - number: Int, - callbackNames: mutable.Set[String], - w: IndentWriter - ): IndentWriter = { - val recordAsMethod = idPython.method(ident.name) - var field_number = number - for (f <- r.fields) { - field_number += 1 - val f_id = field_number.toString() - - val ret = cMarshal.cReturnType(Some(f.ty), forHeader = true) - val defArgs = Seq("cself").mkString("(", ", ", ")") - val cArgs = Seq("struct DjinniRecordHandle *").mkString("(", ", ", ")") - val methodName = "get_" + ident.name + "_f" + f_id - callbackNames.add(methodName) - - w.wl("@ffi.callback" + "(\"" + ret + cArgs + "\")") - w.wl("def " + methodName + defArgs + ":").nested { - val libCall = "CPyRecord.toPy" + p("None" + ", cself") + "." + idPython - .local(f.ident.name) - writeReturnFromCallback( - "CPyRecord.toPy" + p("None" + ", cself"), - f.ty, - libCall, - w - ) - } - w.wl - } - - // Callback to allow creating a Python Record from C - w.wl( - "@ffi.callback" + p( - q( - "struct DjinniRecordHandle *" + getRecordTypes(r) - .mkString("(", ",", ")") - ) - ) - ) - w.wl( - "def " + "create_" + recordAsMethod + getRecordArguments(r, "") - .mkString("(", ",", ")") + ":" - ).nested { - writeRecordToFromCb(ident, r, "", 0, w) - } - callbackNames.add("create_" + recordAsMethod) - w.wl - - val recordAsClassName = idPython.className(ident.name) - w.wl("@ffi.callback" + p(q("void " + p("struct DjinniRecordHandle *")))) - w.wl("def " + "__delete" + p("dh") + ":").nested { - w.wl("assert dh in " + recordAsClassName + ".c_data_set") - w.wl(recordAsClassName + ".c_data_set.remove(dh)") - } - callbackNames.add("__delete") - w.wl - } - - def writeRecordToFromCb( - ident: Ident, - r: Record, - prefix: String, - number: Int, - w: IndentWriter - ): IndentWriter = { - val _ = (prefix, number) // unused, TODO, check remove - val recordClassName = idPython.className(ident.name) - val skipFirst = SkipFirst() - w.wl("py_rec = " + recordClassName + "(").nested { - for (f <- r.fields) { - skipFirst { w.wl(",") } - - w.w(marshal.convertTo(f.ident.name, f.ty)) - } - } - w.wl(")") - w.wl( - "return CPyRecord.fromPy(" + recordClassName + ".c_data_set, py_rec) #to do: can be optional?" - ) - } - - def cmpRecordFields( - fieldName: String, - cmpOp: String, - needsParens: Boolean - ): String = { - if (needsParens) { - "self." + fieldName + cmpOp + p("other." + fieldName) - } else { - "self." + fieldName + cmpOp + "other." + fieldName - } - } - - def writeRecordDerivings(r: Record, w: IndentWriter): Unit = { - // EQUAL - if (r.derivingTypes.contains(DerivingType.Eq)) { - w.wl("def " + "__eq__" + "(self, other):").nested { - w.w("return ") - val skipFirst = SkipFirst() - for (f <- r.fields) { - skipFirst { w.wl(" and \\") } - val isPrimitive = marshal.isPrimitive(f.ty) - w.w( - cmpRecordFields( - f.ident.name, - if (isPrimitive) "==" else ".__eq__", - !isPrimitive - ) - ) - } - } - w.wl - } - - if (r.derivingTypes.contains(DerivingType.Ord)) { - // LESS THAN - w.wl("def " + "__lt__" + "(self, other):").nested { - for (f <- r.fields) { - val isPrimitive = marshal.isPrimitive(f.ty) - w.wl( - "if " + cmpRecordFields( - f.ident.name, - if (isPrimitive) "<" else ".__lt__", - !isPrimitive - ) + ":" - ).nested { - w.wl("return True") - } - w.wl( - "if " + cmpRecordFields( - f.ident.name, - if (isPrimitive) ">" else ".__gt__", - !isPrimitive - ) + ":" - ).nested { - w.wl("return False") - } - } - w.wl("return False") - } - // LESS THAN OR EQUAL - w.wl("def " + "__le__" + "(self, other):").nested { - w.wl("return not other.__lt__(self)") - } - // GREATER THAN OR EQUAL - w.wl("def " + "__ge__" + "(self, other):").nested { - w.wl("return not self.__lt__(other)") - } - // GREATER THAN - w.wl("def " + "__gt__" + "(self, other):").nested { - w.wl("return other.__lt__(self)") - } - } - - // HASH CODE - w.wl("def __hash__(self):").nested { - w.wl("# Pick an arbitrary non-zero starting value") - w.wl("hash_code = 17") - for (f <- r.fields) { // TODO: should we check that if f is a record it has derivings? we don't in Java - w.wl( - "hash_code = hash_code * 31 + self." + f.ident.name + ".__hash__()" - ) - } - w.wl("return hash_code") - } - } - - override def generateRecord( - origin: String, - ident: Ident, - doc: Doc, - params: Seq[TypeParam], - r: Record - ): Unit = { - val recordClassName = idPython.className(ident.name) - val recordAsMethod = idPython.method(ident.name) - val refs = new PythonRefs(ident, origin) - refs.python.add("from djinni.pycffi_marshal import CPyRecord") - r.fields.foreach(f => refs.collect(f.ty, justCollect = true)) - r.fields.foreach(f => refs.collect(f.ty, justCollect = false)) - r.consts.foreach(c => refs.collect(c.ty, justCollect = true)) - - writePythonFile( - ident.name + (if (r.ext.py) "_base" else ""), - origin, - refs.python, - includeCffiLib = true, - w => { - // Record Definition - w.wl("class " + recordClassName + (if (r.ext.py) "Base" else "") + ":") - .nested { - val docLists = mutable.ArrayBuffer[IndentWriter => Unit]() - if (r.fields.exists(_.doc.lines.nonEmpty)) - docLists += { w: IndentWriter => writeDocFieldsList(w, r.fields) } - if (r.consts.exists(_.doc.lines.nonEmpty)) - docLists += { w: IndentWriter => - writeDocConstantsList(w, r.consts) - } - if (writeDocString(w, doc, docLists.toSeq)) { w.wl } - - w.wl("c_data_set = MultiSet()") - w.wl - w.wl("@staticmethod") - w.wl("def check_c_data_set_empty():").nested { - w.wl("assert len" + p(recordClassName + ".c_data_set") + " == 0") - r.fields.map(f => - if (marshal.getClassHoldingCDataSet(f.ty.resolved) != "") { - w.wl( - marshal.getClassHoldingCDataSet( - f.ty.resolved - ) + ".check_c_data_set_empty()" - ) - } - ) - } - w.wl - if (r.consts.nonEmpty) { - generateNonRecursiveConstants( - w, - r.consts, - recordClassName, - genRecord = false - ) - w.wl - } - // TODO: figure out if we should have default intitializations for members of record - // r.fields.map(f => w.wl("#" + marshal.privateClassMember(idPython.local(f.ident.name)) + " = could have default initializer")) - // Derivings - if (r.derivingTypes.nonEmpty) { - w.wl("# Record deriving types") - writeRecordDerivings(r, w) - } - w.wl - // Constructor - w.wl( - "def __init__" + getRecordArguments(r, "self") - .mkString("(", ", ", ")") + ":" - ).nested { - r.fields.foreach(f => - w.wl( - "self." + idPython.local(f.ident.name) + " = " + idPython - .local(f.ident.name) - ) - ) - if (r.fields.isEmpty) { w.wl("pass") } - } - } - w.wl - // Const record object of type equal to current record type must be defined after class definition - if (r.consts.nonEmpty) { - generateRecursiveConstants(w, r.consts, recordClassName) - w.wl - } - } - ) - - writePythonFile( - ident.name + "_helper", - origin, - refs.python, - includeCffiLib = true, - w => { - w.wl( - "from " + spec.pyImportPrefix + ident.name + " import " + recordClassName - ) - w.wl - w.wl("class " + recordClassName + "Helper" + ":").nested { - w.wl("@staticmethod") - w.wl("def release(c_ptr):").nested { - w.wl("assert c_ptr in c_data_set") - w.wl("c_data_set.remove(ffi.cast(\"void*\", c_ptr))") - } - w.wl - // Callbacks to pass every record field to C, and to allow creating record from C - val callbackNames = mutable.SortedSet[String]() - writeRecordCallbacks(ident, r, 0, callbackNames, w) - - // Function to give C access to callbacks - w.wl("@staticmethod") - w.wl("def _add_callbacks():").nested { - for (cb <- callbackNames) { - w.wl( - "lib." + recordAsMethod + "_add_callback_" + idPython - .method(cb) + p(recordClassName + "Helper" + "." + cb) - ) - } - } - } - w.wl - // Recursive constants, such as records, might reference the record class that is currently definied - // They are added as properties on the class, after the class definition to avoid 'incomplete type' errors - if (r.consts.nonEmpty) { - generateRecursiveConstants(w, r.consts, recordClassName) - w.wl - } - // Send callback pointers to C - w.wl(recordClassName + "Helper" + "._add_callbacks()") - w.wl - } - ) - - } - - override def generateEnum( - origin: String, - ident: Ident, - doc: Doc, - e: Enum - ): Unit = { - val enumClassName = idPython.className(ident.name) - val refs = new PythonRefs(ident, origin) - writePythonFile( - ident, - origin, - refs.python, - includeCffiLib = false, - w => { - val flagOrEnum = if (e.flags) "IntFlag" else "IntEnum" - w.wl(s"from enum import $flagOrEnum") - w.wl - w.wl("class " + enumClassName + p(flagOrEnum) + ":").nested { - if (writeDocString(w, doc)) { w.wl } - - writeEnumOptionNone(w, e) - writeEnumOptions(w, e) - writeEnumOptionAll(w, e) - } - } - ) - } - - def writeEnumOptionNone(w: IndentWriter, e: Enum): Unit = { - for ( - o <- e.options.find(_.specialFlag.contains(Enum.SpecialFlag.NoFlags)) - ) { - writeDocString(w, o.doc) - w.wl(s"${idPython.enum(o.ident.name)} = 0") - } - } - - def writeEnumOptions(w: IndentWriter, e: Enum): Unit = { - var shift = 0 - for (o <- normalEnumOptions(e)) { - writeDocString(w, o.doc) - w.wl( - s"${idPython.enum(o.ident.name)} = ${if (e.flags) 1 << shift else shift}" - ) - shift += 1 - } - } - - def writeEnumOptionAll(w: IndentWriter, e: Enum): Unit = { - for ( - o <- e.options.find(_.specialFlag.contains(Enum.SpecialFlag.AllFlags)) - ) { - writeDocString(w, o.doc) - w.wl( - s"${idPython.enum(o.ident.name)} = ${pow(2, normalEnumOptions(e).size).toInt - 1}" - ) - } - } -} diff --git a/src/main/scala/djinni/PythonMarshal.scala b/src/main/scala/djinni/PythonMarshal.scala deleted file mode 100644 index 0a2206dc..00000000 --- a/src/main/scala/djinni/PythonMarshal.scala +++ /dev/null @@ -1,491 +0,0 @@ -/** Copyright 2015 Dropbox, Inc. - * - * 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. - */ - -package djinni - -import djinni.ast._ -import djinni.generatorTools._ -import djinni.meta._ - -import scala.collection.mutable - -// Python does not have explicit types, must see if needed, currently returnType and toPythonType used -class PythonMarshal(spec: Spec) extends Marshal(spec) { - val cMarshal = new CWrapperMarshal(spec) - // prefix for py files containing helpers for structured types - val dh = "dh__" - - override def typename(tm: MExpr): String = toPythonType(tm) - @SuppressWarnings(Array("unused")) - def typename(name: String, ty: TypeDef): String = { - val _ = (name, ty) // unused, TODO, check remove - throw new NotImplementedError() // idPython.ty(name) - } - - override def fqTypename(tm: MExpr): String = throw new NotImplementedError() - @SuppressWarnings(Array("unused")) - def fqTypename(name: String, ty: TypeDef): String = { - val _ = (name, ty) // unused, TODO, check remove - throw new NotImplementedError() - } - - override def paramType(tm: MExpr): String = typename(tm) - override def fqParamType(tm: MExpr): String = throw new NotImplementedError() - - override def returnType(ret: Option[TypeRef]): String = - ret.fold("void")(ty => toPythonType(ty.resolved)) - override def fqReturnType(ret: Option[TypeRef]): String = - throw new NotImplementedError() - - override def fieldType(tm: MExpr): String = typename(tm) - override def fqFieldType(tm: MExpr): String = fqTypename(tm) - -// override def toCpp(tm: MExpr, expr: String): String = throw new AssertionError("direct python to cpp conversion not possible") -// override def fromCpp(tm: MExpr, expr: String): String = throw new AssertionError("direct cpp to python conversion not possible") - - def references(m: Meta, exclude: String): Seq[SymbolReference] = m match { - case d: MDef => { - val className = idPython.className(d.name) - if (idPython.local(d.name) != idPython.local(exclude)) { - d.defType match { - case DInterface => - List( - ImportRef( - "from " + spec.pyImportPrefix + idPython.local( - d.name - ) + " import " + className - ), - ImportRef( - "from " + spec.pyImportPrefix + idPython.local( - d.name - ) + " import " + className + "Helper" - ) - ) - case DRecord => - List( - ImportRef("from djinni.pycffi_marshal import CPyRecord"), - ImportRef( - "from " + spec.pyImportPrefix + idPython.local( - d.name - ) + " import " + className - ), - ImportRef( - "from " + spec.pyImportPrefix + idPython.local( - d.name - ) + "_helper" + " import " + className + "Helper" - ) - ) - case DEnum => - List( - ImportRef("from djinni.pycffi_marshal import CPyEnum"), - ImportRef( - "from " + spec.pyImportPrefix + idPython.local( - d.name - ) + " import " + className - ) - ) - } - } else List() - } - case _: MPrimitive => - List(ImportRef("from djinni.pycffi_marshal import CPyPrimitive")) - case MString => - List(ImportRef("from djinni.pycffi_marshal import CPyString")) - case MBinary => - List(ImportRef("from djinni.pycffi_marshal import CPyBinary")) - case MDate => List(ImportRef("from djinni.pycffi_marshal import CPyDate")) - case MList => List(ImportRef("from djinni.pycffi_marshal import CPyObject")) - case MSet | MMap => - List( - ImportRef("from djinni.pycffi_marshal import CPyObject, CPyObjectProxy") - ) - case _: MExtern => List() // TODO: implement e: MExtern - case _ => List() - } - - def getExprIdlName(tm: MExpr): String = toPythonType(tm) - def referencesForContainer( - tm: MExpr, - exclude: String - ): mutable.TreeSet[String] = { - val refs = mutable.TreeSet[String]() - def getRef(tm: MExpr): Unit = { - val idlName = toPythonType(tm) - tm.base match { - case MOptional => { - tm.args.head.base match { - case m @ (MPrimitive(_, _, _, _, _, _, _, _, _, _) | MDate) => { - refs.add( - "from djinni.pycffi_marshal import CPyBoxed" + idPython - .className(m.asInstanceOf[MOpaque].idlName) - ) - } - case _ => getRef(tm.args.head) - } - } - case MList => { - refs.add("from djinni.pycffi_marshal import CPyObject") - if (idPython.className(idlName) != idPython.className(exclude)) { - refs.add( - "from " + spec.pyImportPrefix + dh + idlName + " import " + idPython - .className(idlName) + "Helper" - ) - } - getRef(tm.args.head) - } - case MSet | MMap => { - refs.add( - "from djinni.pycffi_marshal import CPyObject, CPyObjectProxy" - ) - if (idPython.className(idlName) != idPython.className(exclude)) { - refs.add( - "from " + spec.pyImportPrefix + dh + idlName + " import " + idPython - .className(idlName) + "Helper" - ) - refs.add( - "from " + spec.pyImportPrefix + dh + idlName + " import " + idPython - .className(idlName) + "Proxy" - ) - } - getRef(tm.args.head) - if (tm.base == MMap) getRef(tm.args(1)) - } - case d: MDef => - d.defType match { - case DInterface => - refs.add( - "from " + spec.pyImportPrefix + idPython.local( - d.name - ) + " import " + idPython.className(d.name) + "Helper" - ) - case DRecord => - refs.add( - "from " + spec.pyImportPrefix + idPython.local( - d.name - ) + " import " + idPython.className(d.name) - ) - refs.add("from djinni.pycffi_marshal import CPyRecord") - case DEnum => - refs.add( - "from " + spec.pyImportPrefix + idPython.local( - d.name - ) + " import " + idPython.className(d.name) - ) - refs.add("from djinni.pycffi_marshal import CPyEnum") - } - case _: MPrimitive => - refs.add("from djinni.pycffi_marshal import CPyPrimitive") - case MString => refs.add("from djinni.pycffi_marshal import CPyString") - case MBinary => refs.add("from djinni.pycffi_marshal import CPyBinary") - case MDate => refs.add("from djinni.pycffi_marshal import CPyDate") - case _ => - } - } - - getRef(tm) - return refs - } - - // see if this works wutg getIdlName - private def toPythonType(tm: MExpr): String = { - def base(m: Meta): String = m match { - case p: MPrimitive => p.cName - case MString => "string" - case MBinary => "binary" - case MDate => "date" - case MList => "list" - case MSet => "set" - case MMap => "map" - case MOptional => - tm.args.head.base match { - case MPrimitive(_, _, _, _, _, _, _, _, _, _) | MDate => "boxed" - case _ => "optional" - } - case d: MDef => - d.defType match { - case DInterface => "interface_" + d.name - case DRecord => "record_" + d.name - case DEnum => "enum_" + d.name - } - case _: MExtern => "extern" // TODO: implement e: MExtern - case _ => throw new NotImplementedError() - } - def expr(tm: MExpr): String = { - val baseTy = base(tm.base) - baseTy match { - case "boxed" | "optional" => baseTy + "_" + toPythonType(tm.args.head) - // for list, set, map we return the name of the helper - case "list" | "set" => - idPython.local( - baseTy + (if (tm.args.isEmpty) "" - else "_" + toPythonType(tm.args.head)) - ) - case "map" => - idPython.local( - baseTy + (if (tm.args.isEmpty) "" - else - "_" + toPythonType(tm.args.head)) + "_" + toPythonType( - tm.args(1) - ) - ) - case _ => - baseTy + (if (tm.args.isEmpty) "" - else tm.args.map(expr).mkString("<", ", ", ">")) - } - } - expr(tm) - } - - def isPrimitive(ty: TypeRef): Boolean = ty.resolved.base match { - case _: MPrimitive => true - case _ => false - } - - // TODO: pyName, isPacked and getPacked have been removed on a different branch (keep them removed when rebasing) - def pyName(name: String, ty: MExpr): String = ty.base match { - case MString => "pys_" + name - case MBinary => "pybin_" + name - case _ => name - - } - def pyName(name: String, ty: TypeRef): String = ty.resolved.base match { - case MOptional => - if (isPacked(ty)) "pyopt_" + name - else name - case _ => pyName(name, ty.resolved) - } - - def isPacked(ty: MExpr): Boolean = ty.base match { - case MString | MBinary => true - case _ => false - - } - def isPacked(ty: TypeRef): Boolean = ty.resolved.base match { - case MOptional => - ty.resolved.args.head.base match { - case MPrimitive(_, _, _, _, _, _, _, _, _, _) | MDate => true - case MString | MBinary => true - case _ => false - } - case _: MExtern => false // TODO: implement e: MExtern - case _ => isPacked(ty.resolved) - } - - // TODO: replace with 1 case here of convert fromo + as .. - def getPacked( - arg: MExpr, - isOpt: Boolean, - argName: String, - pyArgName: String - ): String = { - val opt_s = if (isOpt) "Opt" else "" - arg.base match { - case MString => - "CPyString.fromPy" + opt_s + p(argName) + " as " + pyArgName - case MBinary => - "CPyBinary.fromPy" + opt_s + p(argName) + " as " + pyArgName - case _ => throw new NotImplementedError() - } - } - def getPacked(arg: Field, argName: String, pyArgName: String): String = { - arg.ty.resolved.base match { - case MOptional => { - arg.ty.resolved.args.head.base match { - case MPrimitive(_, _, _, _, _, _, _, _, _, _) | MDate => - val idlName = - arg.ty.resolved.args.head.base.asInstanceOf[MOpaque].idlName - "CPyBoxed" + idPython.className(idlName) + ".fromPyOpt" + p( - argName - ) + " as " + pyArgName - case _ => - getPacked( - arg.ty.resolved.args.head, - isOpt = true, - argName, - pyArgName - ) - } - } - case _: MExtern => argName // TODO: implement e: MExtern - case _ => getPacked(arg.ty.resolved, isOpt = false, argName, pyArgName) - } - } - - def getClassHoldingCDataSet(tm: MExpr): String = tm.base match { - case MList | MSet | MMap => - idPython.className(getExprIdlName(tm)) + "Helper" - case d: MDef => idPython.className(d.name) - case _ => "" - } - - // from Python names - def fromRAII(name: String, ty: MExpr, isOpt: Boolean): String = { - ty.base match { - case MString => idPython.method(name + ".get_djinni_string()") - case MBinary => idPython.method(name + ".get_djinni_binary()") - case MOptional => convertFrom(name, ty, true) - case _: MExtern => name // TODO: implement e: MExtern - case _ => convertFrom(name, ty, isOpt) - } - } - def fromRAII(name: String, ty: TypeRef): String = ty.resolved.base match { - case MOptional => { - ty.resolved.args.head.base match { - case MPrimitive(_, _, _, _, _, _, _, _, _, _) | MDate => - idPython.method(name + ".get_djinni_boxed" + "()") - case _ => fromRAII(name, ty.resolved.args.head, isOpt = true) - } - } - case _: MExtern => name // TODO: implement e: MExtern - case _ => fromRAII(name, ty.resolved, isOpt = false) - } - - def releaseRAII(name: String, ty: MExpr, isOpt: Boolean): String = { - ty.base match { - case MString => idPython.method(name + ".release_djinni_string()") - case MBinary => idPython.method(name + ".release_djinni_binary()") - case _: MExtern => name // TODO: implement e: MExtern - case _ => - fromRAII( - name, - ty, - isOpt - ) // nothing else needs to be released yet, the asserts for empty c_data_sets would fail otherwise - - } - } - def releaseRAII(name: String, ty: TypeRef): String = ty.resolved.base match { - case MOptional => - ty.resolved.args.head.base match { - case MPrimitive(_, _, _, _, _, _, _, _, _, _) | MDate => - idPython.method(name + ".release_djinni_boxed" + "()") - case _ => releaseRAII(name, ty.resolved.args.head, isOpt = true) - } - case _: MExtern => name // TODO: implement e: MExtern - case _ => releaseRAII(name, ty.resolved, isOpt = false) - } - - // Get to data from within C structure - def convertTo(name: String, ty: TypeRef): String = - convertTo(name, ty.resolved, false) - def convertTo(name: String, ty: MExpr, isOpt: Boolean): String = { - val local = idPython.local(name) - val idlName = idPython.className(getExprIdlName(ty)) - val opt_s = if (isOpt) "Opt" else "" - - ty.base match { - case _: MPrimitive => "CPyPrimitive.toPy" + p(local) - case MString | MBinary | MDate => - "CPy" + idlName + ".toPy" + opt_s + p(local) - case MList => - "CPyObject.toPy" + opt_s + p( - idlName + "Helper" + ".c_data_set" + ", " + local - ) - case MMap | MSet => - "CPyObjectProxy.toPyObj" + opt_s + p( - idlName + "Helper" + ".c_data_set" + ", " + local - ) - case d: MDef => - d.defType match { - case DInterface => - idPython.className(d.name) + "Helper" + ".toPy" + p(local) - case DRecord => - "CPyRecord.toPy" + opt_s + p( - idPython.className(d.name) + ".c_data_set" + ", " + name - ) // TODO different in that it does not .local, why would it - case DEnum => - "CPyEnum.toPy" + opt_s + p(idPython.className(d.name) + ", " + name) - } - case MOptional => { - ty.args.head.base match { - case MPrimitive(_, _, _, _, _, _, _, _, _, _) | MDate => - val idlName = ty.args.head.base.asInstanceOf[MOpaque].idlName - "CPyBoxed" + idPython.className(idlName) + ".toPyOpt" + p(local) - case _ => convertTo(name, ty.args.head, isOpt = true) - } - } - case _: MExtern => name // TODO: implement e: MExtern - case _ => name - } - } - - // to avoid with blocks in strings and binaries toPy - def convertToRelease(name: String, ty: TypeRef): String = - convertToRelease(name, ty.resolved) - def convertToRelease(name: String, ty: MExpr): String = { - val local = idPython.local(name) - val idlName = idPython.className(getExprIdlName(ty)) - ty.base match { - case MString | MBinary => - "CPy" + idlName + ".toPyWithoutTakingOwnership" + p(local) - case MOptional => - ty.args.head.base match { - case m @ (MPrimitive(_, _, _, _, _, _, _, _, _, _) | MDate) => - val idlName = m.asInstanceOf[MOpaque].idlName - "CPyBoxed" + idPython.className( - idlName - ) + ".toPyOptWithoutTakingOwnership" + p(local) - case MString | MBinary => convertToRelease(name, ty.args.head) - case _ => convertTo(name, ty, isOpt = false) - } - case _: MExtern => name // TODO: implement e: MExtern - case _ => convertTo(name, ty, isOpt = false) - } - } - - def convertFrom(name: String, ty: TypeRef): String = - convertFrom(name, ty.resolved, isOpt = false) - def convertFrom(name: String, ty: MExpr, isOpt: Boolean): String = { - val local = idPython.local(name) - val idlName = idPython.className(getExprIdlName(ty)) - val opt_s = if (isOpt) "Opt" else "" - - ty.base match { - case _: MPrimitive => "CPyPrimitive.fromPy" + p(local) - case MString | MBinary | MDate => - "CPy" + idlName + ".fromPy" + opt_s + p(local) - case MList => - "CPyObject.fromPy" + opt_s + p( - idlName + "Helper" + ".c_data_set, " + local - ) - case MMap | MSet => - "CPyObjectProxy.fromPy" + opt_s + p( - idlName + "Helper" + ".c_data_set, " + idlName + "Proxy" + p(local) - ) - case d: MDef => - d.defType match { - case DInterface => - idPython.className(d.name) + "Helper" + ".fromPy(" + local + ")" - case DRecord => - "CPyRecord.fromPy" + opt_s + p( - idPython.className(d.name) + ".c_data_set, " + local - ) - case DEnum => "CPyEnum.fromPy" + opt_s + p(local) - } - case MOptional => { - ty.args.head.base match { - case MPrimitive(_, _, _, _, _, _, _, _, _, _) | MDate => - val idlName = ty.args.head.base.asInstanceOf[MOpaque].idlName - "CPyBoxed" + idPython.className(idlName) + ".fromPyOpt" + p(local) - case _ => convertFrom(name, ty.args.head, isOpt = true) - } - } - case _: MExtern => name // TODO: implement e: MExtern - case _ => name - } - } - - def privateClassMember(s: String): String = "_" + s // private class member -} diff --git a/src/main/scala/djinni/YamlGenerator.scala b/src/main/scala/djinni/YamlGenerator.scala index 187f19b8..b1a52c3d 100644 --- a/src/main/scala/djinni/YamlGenerator.scala +++ b/src/main/scala/djinni/YamlGenerator.scala @@ -16,7 +16,6 @@ class YamlGenerator(spec: Spec) extends Generator(spec) { val objcppMarshal = new ObjcppMarshal(spec) val javaMarshal = new JavaMarshal(spec) val jniMarshal = new JNIMarshal(spec) - val cppCliMarshal = new CppCliMarshal(spec) case class QuotedString( str: String @@ -75,7 +74,6 @@ class YamlGenerator(spec: Spec) extends Generator(spec) { w.wl("objcpp:").nested { write(w, objcpp(td)) } w.wl("java:").nested { write(w, java(td)) } w.wl("jni:").nested { write(w, jni(td)) } - w.wl("cs:").nested { write(w, cs(td)) } } private def write(w: IndentWriter, m: Map[String, Any]): Unit = { @@ -181,13 +179,6 @@ class YamlGenerator(spec: Spec) extends Generator(spec) { "typeSignature" -> QuotedString(jniMarshal.fqTypename(td.ident, td.body)) ) - private def cs(td: TypeDecl) = Map[String, Any]( - "translator" -> QuotedString(cppCliMarshal.helperName(mexpr(td))), - "header" -> QuotedString(cppCliMarshal.include(td.ident)), - "typename" -> cppCliMarshal.fqParamType(mexpr(td)), - "reference" -> cppCliMarshal.isReference(td) - ) - // TODO: there has to be a way to do all this without the MExpr/Meta conversions? private def mexpr(td: TypeDecl) = MExpr(meta(td), List()) @@ -250,8 +241,7 @@ object YamlGenerator { objcOutRequired: Boolean, objcppOutRequired: Boolean, javaOutRequired: Boolean, - jniOutRequired: Boolean, - cppCliOutRequired: Boolean + jniOutRequired: Boolean ): MExtern = MExtern( td.ident.name.stripPrefix( td.properties("prefix").toString @@ -344,31 +334,6 @@ object YamlGenerator { "typeSignature", _.toString ) - ), - MExtern.Cs( - nested( - td, - isRequired = cppCliOutRequired, - "cs", - "translator", - _.toString - ), - nested(td, isRequired = cppCliOutRequired, "cs", "header", _.toString), - nested(td, isRequired = cppCliOutRequired, "cs", "typename", _.toString), - nested( - td, - isRequired = cppCliOutRequired, - "cs", - "reference", - _.asInstanceOf[Boolean] - ), - nested( - td, - false, - "cs", - "generic", - _.asInstanceOf[Boolean] - ) orElse Option.apply[Boolean](false) ) ) diff --git a/src/main/scala/djinni/generator.scala b/src/main/scala/djinni/generator.scala index eed2053f..42e58e97 100644 --- a/src/main/scala/djinni/generator.scala +++ b/src/main/scala/djinni/generator.scala @@ -79,10 +79,6 @@ package object generatorTools { objcppIncludeObjcPrefix: String, objcppNamespace: String, objcSwiftBridgingHeaderWriter: Option[Writer], - cppCliOutFolder: Option[File], - cppCliIdentStyle: CppCliIdentStyle, - cppCliNamespace: String, - cppCliIncludeCppPrefix: String, objcSwiftBridgingHeaderName: Option[String], objcClosedEnums: Boolean, objcStrictProtocol: Boolean, @@ -91,17 +87,7 @@ package object generatorTools { yamlOutFolder: Option[File], yamlOutFile: Option[String], yamlPrefix: String, - pyOutFolder: Option[File], - pyIdentStyle: PythonIdentStyle, - pycffiOutFolder: Option[File], - pycffiPackageName: String, - pycffiDynamicLibList: String, idlFileName: String, - cWrapperOutFolder: Option[File], - cWrapperHeaderOutFolder: Option[File], - cWrapperIncludePrefix: String, - cWrapperIncludeCppPrefix: String, - pyImportPrefix: String, cppJsonSerialization: Option[String] ) @@ -147,28 +133,6 @@ package object generatorTools { const: IdentConverter ) - case class PythonIdentStyle( - ty: IdentConverter, - className: IdentConverter, - typeParam: IdentConverter, - method: IdentConverter, - field: IdentConverter, - local: IdentConverter, - enum: IdentConverter, - const: IdentConverter - ) - case class CppCliIdentStyle( - ty: IdentConverter, - typeParam: IdentConverter, - property: IdentConverter, - method: IdentConverter, - field: IdentConverter, - local: IdentConverter, - enum: IdentConverter, - const: IdentConverter, - file: IdentConverter - ) - object IdentStyle { val camelUpper: String => String = (s: String) => s.split('_').map(firstUpper).mkString @@ -212,28 +176,6 @@ package object generatorTools { enum = camelUpper, const = camelUpper ) - val pythonDefault: PythonIdentStyle = PythonIdentStyle( - ty = underLower, - className = camelUpper, - typeParam = underLower, - method = underLower, - field = underLower, - local = underLower, - enum = underUpper, - const = underCaps - ) - - val csDefault: CppCliIdentStyle = CppCliIdentStyle( - ty = camelUpper, - typeParam = camelUpper, - property = camelUpper, - method = camelUpper, - field = prefix("_", camelLower), - local = camelLower, - enum = camelUpper, - const = camelUpper, - file = camelUpper - ) val styles: Map[String, String => String] = Map( "FooBar" -> camelUpper, @@ -372,37 +314,12 @@ package object generatorTools { new SwiftBridgingHeaderGenerator(spec).generate(idl) } } - if (spec.cppCliOutFolder.isDefined) { - if (!spec.skipGeneration) { - createFolder("C++/CLI", spec.cppCliOutFolder.get) - } - new CppCliGenerator(spec).generate(idl) - } if (spec.yamlOutFolder.isDefined) { if (!spec.skipGeneration) { createFolder("YAML", spec.yamlOutFolder.get) } new YamlGenerator(spec).generate(idl) } - if (spec.pyOutFolder.isDefined) { - if (!spec.skipGeneration) { - createFolder("Python", spec.pyOutFolder.get) - } - new PythonGenerator(spec).generate(idl) - } - if (spec.cWrapperOutFolder.isDefined) { - if (!spec.skipGeneration) { - createFolder("C", spec.cWrapperOutFolder.get) - createFolder("C header", spec.cWrapperHeaderOutFolder.get) - } - new CWrapperGenerator(spec).generate(idl) - } - if (spec.pycffiOutFolder.isDefined) { - if (!spec.skipGeneration) { - createFolder("Cffi", spec.pycffiOutFolder.get) - } - new CffiGenerator(spec).generate(idl) - } None } catch { case GenerateException(message) => Some(message) @@ -528,8 +445,6 @@ abstract class Generator(spec: Spec) { val idCpp = spec.cppIdentStyle val idJava = spec.javaIdentStyle val idObjc = spec.objcIdentStyle - val idPython = spec.pyIdentStyle - val idCs = spec.cppCliIdentStyle def wrapNamespace( w: IndentWriter, diff --git a/src/main/scala/djinni/meta.scala b/src/main/scala/djinni/meta.scala index b8752d5c..0a16c65a 100644 --- a/src/main/scala/djinni/meta.scala +++ b/src/main/scala/djinni/meta.scala @@ -43,8 +43,7 @@ package object meta { objc: MExtern.Objc, objcpp: MExtern.Objcpp, java: MExtern.Java, - jni: MExtern.Jni, - cs: MExtern.Cs + jni: MExtern.Jni ) extends Meta object MExtern { // These hold the information marshals need to interface with existing types correctly @@ -101,17 +100,6 @@ package object meta { String ] // The mangled Java type signature (e.g. "Ljava/lang/String;") ) - case class Cs( - translator: Option[ - String - ], // C++ typename containing ToCpp/FromCpp methods - header: Option[String], // Where to find the translator class - typename: Option[String], - reference: Option[Boolean], - generic: Option[ - Boolean - ] // Set to false to exclude type arguments from the C++/CLI typename. This is false by default. Useful if template arguments are only used in C++. - ) } abstract sealed class MOpaque extends Meta { val idlName: String } diff --git a/src/main/scala/djinni/resolver.scala b/src/main/scala/djinni/resolver.scala index 6eac5aad..5cd47ca2 100644 --- a/src/main/scala/djinni/resolver.scala +++ b/src/main/scala/djinni/resolver.scala @@ -35,8 +35,7 @@ package object resolver { objcOutRequired: Boolean, objcppOutRequired: Boolean, javaOutRequired: Boolean, - jniOutRequired: Boolean, - cppCliOutRequired: Boolean + jniOutRequired: Boolean ): Option[Error] = { try { @@ -76,8 +75,7 @@ package object resolver { objcOutRequired = objcOutRequired, objcppOutRequired = objcppOutRequired, javaOutRequired = javaOutRequired, - jniOutRequired = jniOutRequired, - cppCliOutRequired = cppCliOutRequired + jniOutRequired = jniOutRequired ) } )