From 7feaf082296c13793cdbd79e3cbe3e5bc952ed25 Mon Sep 17 00:00:00 2001 From: Zach Nehrenberg Date: Wed, 20 Dec 2023 16:44:05 -0800 Subject: [PATCH] Update readme --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 83290c6f..f5ec4690 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ verify the build and binary from the command line. - DataView for copy free data passing - DateRef for copy free data passing with ownership - Generating string names for C++ enums + - Omit optional parameters from record constructors - Bug fixes ## Using new features @@ -341,6 +342,35 @@ The C++ `Future` type has optional support for coroutines. If coroutines are availble (eg. compiling with C++20 or C++17 with -fcoroutines-ts), then you can use `co_await` on future objects. +## Omitting Optionals from Record Constructors +- By default, optionals will be omitted from the constructor in Djinni +- The Djinni code generator will generate two constructors for a record with optionals: one with all values and one with optionals omitted. This will minimize code disruption +- Optional behavior will be able to be switched via a usage flag for each platform. +- A new [deriving method](https://github.com/dropbox/djinni#derived-methods) specifier will be implemented so that individual records can still require all parameters + +### Compiler Flags +The following compiler flags will require optionals in constructors for C++/ObjC/Java: +``` +--cpp-constructor-require-optionals +--java-constructor-require-optionals +--objc-constructor-require-optionals +``` + +### Deriving Record +Any record can be made to have all parameters be required by specifying it as a `req` deriving record: +``` +MyClass = record { + required: string; + optional: optional; +} deriving(req) +``` + +### Omitting Convenience Constructors +Extra convenience constructors which require all parameters can be removed from optional ObjC records with a new compiler flag: +``` +--objc-omit-full-convenience-constructor +``` + ## FAQ Q. Do I need to use Bazel to build my project?