Skip to content

Commit

Permalink
feat: Try CarSwift experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Aug 12, 2024
1 parent 0dd6322 commit db05f1f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class HybridSwiftKotlinTestObject : HybridSwiftKotlinTestObjectSpec {

func simpleFunc() throws {
// do nothing

var car: margelo.nitro.image.CarSwift? = nil
car!.year = 55.0
}

func addNumbers(a: Double, b: Double) throws -> Double {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif

#include <NitroModules/NitroDefines.hpp>

// Forward declaration of `Powertrain` to properly resolve imports.
namespace margelo::nitro::image { enum class Powertrain; }
// Forward declaration of `Person` to properly resolve imports.
Expand All @@ -40,6 +42,19 @@ namespace margelo::nitro::image {
explicit Car(double year, std::string make, std::string model, double power, Powertrain powertrain, std::optional<Person> driver): year(year), make(make), model(model), power(power), powertrain(powertrain), driver(driver) {}
};

struct CarSwift {
private:
Car _car;

public:
double getYear() const SWIFT_COMPUTED_PROPERTY {
return _car.year;
}
void setYear(double newValue) SWIFT_COMPUTED_PROPERTY {
_car.year = newValue;
}
};

} // namespace margelo::nitro::image

namespace margelo::nitro {
Expand Down

0 comments on commit db05f1f

Please sign in to comment.