From 628a47a745a48bf06845678840ffb6b2dcd1dba5 Mon Sep 17 00:00:00 2001 From: SnapCI Date: Fri, 6 Jun 2025 10:42:37 -0700 Subject: [PATCH 1/2] Update file names --- src/source/ComposerGenerator.scala | 38 +++--- src/source/ast.scala | 2 +- ...DataRef_composer.cpp => DataRef_valdi.cpp} | 4 +- ...DataRef_composer.hpp => DataRef_valdi.hpp} | 10 +- ...taView_composer.hpp => DataView_valdi.hpp} | 10 +- .../{Future_composer.hpp => Future_valdi.hpp} | 10 +- ...Outcome_composer.hpp => Outcome_valdi.hpp} | 14 +-- .../{djinni_composer.cpp => djinni_valdi.cpp} | 14 +-- .../{djinni_composer.hpp => djinni_valdi.hpp} | 118 +++++++++--------- support-lib/dataref.yaml | 4 +- support-lib/dataview.yaml | 4 +- support-lib/future.yaml | 4 +- support-lib/outcome.yaml | 4 +- 13 files changed, 118 insertions(+), 118 deletions(-) rename support-lib/composer/{DataRef_composer.cpp => DataRef_valdi.cpp} (98%) rename support-lib/composer/{DataRef_composer.hpp => DataRef_valdi.hpp} (80%) rename support-lib/composer/{DataView_composer.hpp => DataView_valdi.hpp} (86%) rename support-lib/composer/{Future_composer.hpp => Future_valdi.hpp} (95%) rename support-lib/composer/{Outcome_composer.hpp => Outcome_valdi.hpp} (84%) rename support-lib/composer/{djinni_composer.cpp => djinni_valdi.cpp} (87%) rename support-lib/composer/{djinni_composer.hpp => djinni_valdi.hpp} (86%) diff --git a/src/source/ComposerGenerator.scala b/src/source/ComposerGenerator.scala index 81ec1935..4b3b13ea 100644 --- a/src/source/ComposerGenerator.scala +++ b/src/source/ComposerGenerator.scala @@ -34,7 +34,7 @@ class ComposerGenerator(spec: Spec) extends Generator(spec) { val nameParts = jsClass.split("""\.""") val ns = nameParts.dropRight(1).mkString(".") val cls = nameParts.takeRight(1).last - return Seq(ns, cls).map( e=> s"""djinni::composer::CTS{"$e"}""").mkString(", ") + return Seq(ns, cls).map( e=> s"""djinni::valdi::CTS{"$e"}""").mkString(", ") } class ComposerRefs(name: String, cppPrefixOverride: Option[String]=None) { @@ -44,7 +44,7 @@ class ComposerGenerator(spec: Spec) extends Generator(spec) { val cppPrefix = cppPrefixOverride.getOrElse(spec.composerIncludeCppPrefix) hpp.add("#include " + q(cppPrefix + spec.cppFileIdentStyle(name) + "." + spec.cppHeaderExt)) - hpp.add("#include " + q(spec.composerBaseLibIncludePrefix + "djinni_composer.hpp")) + hpp.add("#include " + q(spec.composerBaseLibIncludePrefix + "djinni_valdi.hpp")) spec.cppNnHeader match { case Some(nnHdr) => hpp.add("#include " + nnHdr) case _ => @@ -78,7 +78,7 @@ class ComposerGenerator(spec: Spec) extends Generator(spec) { def helperName(tm: MExpr): String = tm.base match { case d: MDef => withNs(Some(helperNamespace()), helperClass(d.name)) case e: MExtern => e.composer.translator - case o => withNs(Some("djinni::composer"), o match { + case o => withNs(Some("djinni::valdi"), o match { case p: MPrimitive => p.idlName match { case "i8" => "I8" case "i16" => "I16" @@ -174,7 +174,7 @@ class ComposerGenerator(spec: Spec) extends Generator(spec) { // val fullyQualifiedName = withWasmNamespace(idJs.ty(ident)) val fullyQualifiedName = idJs.ty(ident) writeHppFileGeneric(spec.composerOutFolder.get, helperNamespace(), composerFilenameStyle)(ident.name, origin, refs.hpp, Nil, (w => { - w.wl(s"using $helper = ::djinni::composer::Enum<$cls>;") + w.wl(s"using $helper = ::djinni::valdi::Enum<$cls>;") }), (w => {})) } @@ -189,11 +189,11 @@ class ComposerGenerator(spec: Spec) extends Generator(spec) { writeHppFileGeneric(spec.composerOutFolder.get, helperNamespace(), composerFilenameStyle)(ident.name, origin, refs.hpp, Nil, (w => { w.wl(s"struct $helper").bracedSemi { w.wl(s"using CppType = $cls;") - w.wl("using ComposerType = Composer:: Value;") + w.wl("using ValdiType = Composer:: Value;") w.wl(s"using Boxed = $helper;") w.wl - w.wl("static CppType toCpp(const ComposerType& v);") - w.wl("static ComposerType fromCpp(const CppType& c);") + w.wl("static CppType toCpp(const ValdiType& v);") + w.wl("static ValdiType fromCpp(const CppType& c);") w.wl w.wl("static const Composer::ValueSchema& schema() noexcept;") } @@ -201,7 +201,7 @@ class ComposerGenerator(spec: Spec) extends Generator(spec) { writeCppFileGeneric(spec.composerOutFolder.get, helperNamespace(), composerFilenameStyle, spec.composerIncludePrefix) (ident.name, origin, refs.cpp, (w => { w.wl("using namespace Composer;") w.wl - w.w(s"auto $helper::toCpp(const ComposerType& v) -> CppType").braced { + w.w(s"auto $helper::toCpp(const ValdiType& v) -> CppType").braced { w.wl("auto o = v.getTypedObjectRef();") var nextIdx = 0; writeAlignedCall(w, "return {", r.fields, "}", f => { @@ -211,7 +211,7 @@ class ComposerGenerator(spec: Spec) extends Generator(spec) { }) w.wl(";") } - w.w(s"auto $helper::fromCpp(const CppType& c) -> ComposerType").braced { + w.w(s"auto $helper::fromCpp(const CppType& c) -> ValdiType").braced { w.wl("auto o = ValueTypedObject::make(schema().getClassRef(),").bracedEnd(");"){ for (f <- r.fields) { w.wl(s"${helperClass(f.ty.resolved)}::Boxed::fromCpp(${cppMarshal.maybeMove("c." + idCpp.field(f.ident), f.ty)}),") @@ -245,7 +245,7 @@ class ComposerGenerator(spec: Spec) extends Generator(spec) { val cls = withNs(Some(spec.cppNamespace), idCpp.ty(ident)) val helper = helperClass(ident) writeHppFileGeneric(spec.composerOutFolder.get, helperNamespace(), composerFilenameStyle)(ident.name, origin, refs.hpp, Nil, (w => { - w.w(s"struct $helper : ::djinni::composer::JsInterface<$cls, $helper>").bracedSemi { + w.w(s"struct $helper : ::djinni::valdi::JsInterface<$cls, $helper>").bracedSemi { w.wl("static void registerSchema(bool resolve) noexcept;") w.wl("static const Composer::ValueSchema& schemaRef() noexcept;") w.wl("static const Composer::ValueSchema& schema() noexcept;") @@ -257,8 +257,8 @@ class ComposerGenerator(spec: Spec) extends Generator(spec) { // js proxy if (i.ext.js) { - w.w(s"struct ComposerProxy: $cls, ::djinni::composer::ComposerProxyBase").bracedSemi { - w.wl("ComposerProxy(Composer::Ref js) : ComposerProxyBase(js) {}") + w.w(s"struct ValdiProxy: $cls, ::djinni::valdi::ValdiProxyBase").bracedSemi { + w.wl("ValdiProxy(Composer::Ref js) : ValdiProxyBase(js) {}") for (m <- i.methods.filter(m => !m.static)) { w.w(s"${cppMarshal.fqReturnType(m.ret)} ${idCpp.method(m.ident)}(") w.w(m.params.map(p => { @@ -320,10 +320,10 @@ class ComposerGenerator(spec: Spec) extends Generator(spec) { w.w(s"Ref $helper::toComposer(const CppOptType& c)").braced{ w.w("auto o = ValueTypedObject::make(schema().getClassRef(),").bracedEnd(");") { for (m <- i.methods.filter(m => !m.static)) { - w.wl(s"""djinni::composer::tsFunc<${exceptionHandlingTraits(m)}>(std::bind(shim::${idCpp.method(m.ident)}, c, _1)),""") + w.wl(s"""djinni::valdi::tsFunc<${exceptionHandlingTraits(m)}>(std::bind(shim::${idCpp.method(m.ident)}, c, _1)),""") } } - w.wl("return makeShared>(o, c);") + w.wl("return makeShared>(o, c);") } } //value schema @@ -345,7 +345,7 @@ class ComposerGenerator(spec: Spec) extends Generator(spec) { w.wl(s"${t}::registerSchema(resolve);") } w.wl("static bool flag[2] = {false, false};") - w.wl("if (std::exchange(flag[resolve ? 1 : 0], true) == false) { djinni::composer::registerSchemaImpl(unresolvedSchema(), resolve); }") + w.wl("if (std::exchange(flag[resolve ? 1 : 0], true) == false) { djinni::valdi::registerSchemaImpl(unresolvedSchema(), resolve); }") } // type reference w.w(s"const ValueSchema& $helper::schemaRef() noexcept").braced { @@ -353,14 +353,14 @@ class ComposerGenerator(spec: Spec) extends Generator(spec) { w.wl("return ref;") } w.w(s"const ValueSchema& $helper::schema() noexcept").braced { - w.wl(s"static auto schema = djinni::composer::getResolvedSchema<$helper>(schemaName());") + w.wl(s"static auto schema = djinni::valdi::getResolvedSchema<$helper>(schemaName());") w.wl("return schema;") } // js proxy if (i.ext.js) { var idx = 0 for (m <- i.methods.filter(m => !m.static)) { - w.w(s"${cppMarshal.fqReturnType(m.ret)} $helper::ComposerProxy::${idCpp.method(m.ident)}(") + w.w(s"${cppMarshal.fqReturnType(m.ret)} $helper::ValdiProxy::${idCpp.method(m.ident)}(") w.w(m.params.map(p => { s"${cppMarshal.fqParamType(p.ty)} ${idCpp.local(p.ident)}" }).mkString(",")) @@ -395,10 +395,10 @@ class ComposerGenerator(spec: Spec) extends Generator(spec) { } } } - w.wl(s"auto staticSchema = djinni::composer::resolveSchema(unresolvedStaticSchema, [] { registerSchema(false); registerSchema(true);} );") + w.wl(s"auto staticSchema = djinni::valdi::resolveSchema(unresolvedStaticSchema, [] { registerSchema(false); registerSchema(true);} );") w.w(s"""(*m)[STRING_LITERAL("${idJs.ty(ident)}")] = Value(ValueTypedObject::make(staticSchema.getClassRef(),""").bracedEnd("));") { for (m <- staticMethods) { - w.wl(s"""djinni::composer::tsFunc<${exceptionHandlingTraits(m)}>(shim::${idCpp.method(m.ident)}),""") + w.wl(s"""djinni::valdi::tsFunc<${exceptionHandlingTraits(m)}>(shim::${idCpp.method(m.ident)}),""") } } } diff --git a/src/source/ast.scala b/src/source/ast.scala index 62e3d699..fa42f098 100644 --- a/src/source/ast.scala +++ b/src/source/ast.scala @@ -51,7 +51,7 @@ case class InternTypeDecl(override val ident: Ident, override val params: Seq[Ty case class ExternTypeDecl(override val ident: Ident, override val params: Seq[TypeParam], override val body: TypeDef, properties: Map[String, Any], override val origin: String) extends TypeDecl case class ProtobufTypeDecl(override val ident: Ident, override val params: Seq[TypeParam], override val body: TypeDef, override val origin: String) extends TypeDecl -// `Ext.js` is shared by both wasm and composer +// `Ext.js` is shared by both wasm and valdi case class Ext(java: Boolean, cpp: Boolean, objc: Boolean, js: Boolean) { def any(): Boolean = { java || cpp || objc || js diff --git a/support-lib/composer/DataRef_composer.cpp b/support-lib/composer/DataRef_valdi.cpp similarity index 98% rename from support-lib/composer/DataRef_composer.cpp rename to support-lib/composer/DataRef_valdi.cpp index 64a12a3c..32ea53f2 100644 --- a/support-lib/composer/DataRef_composer.cpp +++ b/support-lib/composer/DataRef_valdi.cpp @@ -15,10 +15,10 @@ */ #include "../cpp/DataRef.hpp" -#include "DataRef_composer.hpp" +#include "DataRef_valdi.hpp" #include -namespace djinni::composer { +namespace djinni::valdi { struct ComposerDataObject: Composer::ComposerObject { COMPOSER_CLASS_HEADER(ComposerDataObject); diff --git a/support-lib/composer/DataRef_composer.hpp b/support-lib/composer/DataRef_valdi.hpp similarity index 80% rename from support-lib/composer/DataRef_composer.hpp rename to support-lib/composer/DataRef_valdi.hpp index 2abf0509..c004f5cb 100644 --- a/support-lib/composer/DataRef_composer.hpp +++ b/support-lib/composer/DataRef_valdi.hpp @@ -16,18 +16,18 @@ #pragma once -#include "djinni_composer.hpp" +#include "djinni_valdi.hpp" #include "../cpp/DataRef.hpp" -namespace djinni::composer { +namespace djinni::valdi { struct NativeDataRef { using CppType = DataRef; - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = NativeDataRef; - static CppType toCpp(const ComposerType& v); - static ComposerType fromCpp(const CppType& c); + static CppType toCpp(const ValdiType& v); + static ValdiType fromCpp(const CppType& c); static const Composer::ValueSchema& schema(); }; diff --git a/support-lib/composer/DataView_composer.hpp b/support-lib/composer/DataView_valdi.hpp similarity index 86% rename from support-lib/composer/DataView_composer.hpp rename to support-lib/composer/DataView_valdi.hpp index 3b7a85fa..81bce314 100644 --- a/support-lib/composer/DataView_composer.hpp +++ b/support-lib/composer/DataView_valdi.hpp @@ -16,23 +16,23 @@ #pragma once -#include "djinni_composer.hpp" +#include "djinni_valdi.hpp" #include "../cpp/DataView.hpp" -namespace djinni::composer { +namespace djinni::valdi { struct NativeDataView { using CppType = DataView; - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = NativeDataView; - static CppType toCpp(const ComposerType& v) { + static CppType toCpp(const ValdiType& v) { auto arr = v.getTypedArrayRef(); const auto& buf = arr->getBuffer(); return DataView(buf.data(), buf.size()); } - static ComposerType fromCpp(const CppType& c) { + static ValdiType fromCpp(const CppType& c) { Composer::BytesView buf(nullptr, c.buf(), c.len()); auto arr = Composer::makeShared(Composer::kDefaultTypedArrayType, buf); return Composer::Value(arr); diff --git a/support-lib/composer/Future_composer.hpp b/support-lib/composer/Future_valdi.hpp similarity index 95% rename from support-lib/composer/Future_composer.hpp rename to support-lib/composer/Future_valdi.hpp index 2f53a355..304b8af7 100644 --- a/support-lib/composer/Future_composer.hpp +++ b/support-lib/composer/Future_valdi.hpp @@ -16,11 +16,11 @@ #pragma once -#include "djinni_composer.hpp" +#include "djinni_valdi.hpp" #include "../cpp/Future.hpp" #include "composer_core/cpp/Utils/ResolvablePromise.hpp" -namespace djinni::composer { +namespace djinni::valdi { template class FutureAdaptor @@ -29,13 +29,13 @@ class FutureAdaptor public: using CppType = Future; - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = FutureAdaptor; using NativePromiseType = Promise; - static CppType toCpp(ComposerType o) + static CppType toCpp(ValdiType o) { auto composerPromise = castOrNull(o.getComposerObject()); auto cppPromise = Composer::makeShared>(); @@ -54,7 +54,7 @@ class FutureAdaptor return cppFuture; } - static ComposerType fromCpp(CppType c) + static ValdiType fromCpp(CppType c) { auto composerPromise = Composer::makeShared(); c.then([composerPromise] (Future f) { diff --git a/support-lib/composer/Outcome_composer.hpp b/support-lib/composer/Outcome_valdi.hpp similarity index 84% rename from support-lib/composer/Outcome_composer.hpp rename to support-lib/composer/Outcome_valdi.hpp index 642c5569..020be76e 100644 --- a/support-lib/composer/Outcome_composer.hpp +++ b/support-lib/composer/Outcome_valdi.hpp @@ -16,24 +16,24 @@ #pragma once -#include "djinni_composer.hpp" +#include "djinni_valdi.hpp" #include "../cpp/expected.hpp" -namespace djinni::composer { +namespace djinni::valdi { template class Outcome { using ResultCppType = typename RESULT::CppType; using ErrorCppType = typename ERROR::CppType; - using ResultComposerType = typename RESULT::Boxed::ComposerType; - using ErrorComposerType = typename ERROR::Boxed::ComposerType; + using ResultValdiType = typename RESULT::Boxed::ValdiType; + using ErrorValdiType = typename ERROR::Boxed::ValdiType; public: using CppType = expected; - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = Outcome; - static CppType toCpp(ComposerType v) + static CppType toCpp(ValdiType v) { auto outcomeCpp = castOrNull(v.getComposerObject()); if (outcomeCpp->error.isUndefined()) { @@ -43,7 +43,7 @@ class Outcome } } - static ComposerType fromCpp(const CppType& c) + static ValdiType fromCpp(const CppType& c) { auto outcomeCpp = Composer::makeShared(); if (c.has_value()) { diff --git a/support-lib/composer/djinni_composer.cpp b/support-lib/composer/djinni_valdi.cpp similarity index 87% rename from support-lib/composer/djinni_composer.cpp rename to support-lib/composer/djinni_valdi.cpp index 30c4cae5..a713ba8d 100644 --- a/support-lib/composer/djinni_composer.cpp +++ b/support-lib/composer/djinni_valdi.cpp @@ -14,15 +14,15 @@ * limitations under the License. */ -#include "djinni_composer.hpp" +#include "djinni_valdi.hpp" #include "composer_core/cpp/Utils/ValueTypedArray.hpp" -namespace djinni::composer { +namespace djinni::valdi { using namespace Composer; -std::unordered_map> jsProxyCache; +std::unordered_map> jsProxyCache; std::unordered_map cppProxyCache; std::mutex jsProxyCacheMutex; std::mutex cppProxyCacheMutex; @@ -54,13 +54,13 @@ void registerSchemaImpl(const ValueSchema& schema, bool resolve) noexcept { } } -Binary::CppType Binary::toCpp(const Binary::ComposerType& v) noexcept { +Binary::CppType Binary::toCpp(const Binary::ValdiType& v) noexcept { auto a = v.getTypedArrayRef(); auto buffer = a->getBuffer(); return CppType(buffer.begin(), buffer.end()); } -Binary::ComposerType Binary::fromCpp(const Binary::CppType& c) noexcept { +Binary::ValdiType Binary::fromCpp(const Binary::CppType& c) noexcept { auto bytes = makeShared(); bytes->assignData(c.data(), c.size()); auto va = makeShared(TypedArrayType::Uint8Array, bytes); @@ -72,12 +72,12 @@ const ValueSchema& Binary::schema() noexcept { return schema; } -Date::CppType Date::toCpp(const Date::ComposerType& v) noexcept { +Date::CppType Date::toCpp(const Date::ValdiType& v) noexcept { auto millisecondsSinceEpoch = std::chrono::milliseconds(static_cast(v.toDouble())); return CppType(std::chrono::duration_cast(millisecondsSinceEpoch)); } -Date::ComposerType Date::fromCpp(const Date::CppType& c) noexcept { +Date::ValdiType Date::fromCpp(const Date::CppType& c) noexcept { auto millisecondsSinceEpoch = std::chrono::duration_cast(c.time_since_epoch()); return Composer::Value(static_cast(millisecondsSinceEpoch.count())); } diff --git a/support-lib/composer/djinni_composer.hpp b/support-lib/composer/djinni_valdi.hpp similarity index 86% rename from support-lib/composer/djinni_composer.hpp rename to support-lib/composer/djinni_valdi.hpp index 79c42800..d1d5d04d 100644 --- a/support-lib/composer/djinni_composer.hpp +++ b/support-lib/composer/djinni_valdi.hpp @@ -40,7 +40,7 @@ #include #include -namespace djinni::composer { +namespace djinni::valdi { // -------- Helper functions and classes class JsException : public std::runtime_error { @@ -117,15 +117,15 @@ template class Primitive { public: using CppType = T; - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = Primitive; - static CppType toCpp(const ComposerType& v) noexcept { + static CppType toCpp(const ValdiType& v) noexcept { return static_cast(v.to()); } - static ComposerType fromCpp(const CppType& c) noexcept { - return ComposerType(static_cast(c)); + static ValdiType fromCpp(const CppType& c) noexcept { + return ValdiType(static_cast(c)); } static const Composer::ValueSchema& schema() noexcept { static auto schema = Composer::ValueSchema::primitiveType(); @@ -151,11 +151,11 @@ class WString { using Utf16Converter = std::wstring_convert>; public: using CppType = std::wstring; - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = WString; - static CppType toCpp(const ComposerType& v) { + static CppType toCpp(const ValdiType& v) { if (v.isInternedString()) { auto utf8str = v.toStringBox().toStringView(); return Utf8Converter{}.from_bytes(utf8str.data(), utf8str.data() + utf8str.size()); @@ -170,8 +170,8 @@ class WString { } } } - static ComposerType fromCpp(const CppType& c) { - return ComposerType(Utf8Converter{}.to_bytes(c)); + static ValdiType fromCpp(const CppType& c) { + return ValdiType(Utf8Converter{}.to_bytes(c)); } static const Composer::ValueSchema& schema() noexcept { static auto schema = Composer::ValueSchema::string(); @@ -183,22 +183,22 @@ class WString { class Binary { public: using CppType = std::vector; - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = Binary; - static CppType toCpp(const ComposerType& j) noexcept; - static ComposerType fromCpp(const CppType& c) noexcept; + static CppType toCpp(const ValdiType& j) noexcept; + static ValdiType fromCpp(const CppType& c) noexcept; static const Composer::ValueSchema& schema() noexcept ; }; class Date { public: using CppType = std::chrono::system_clock::time_point; - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = Date; - static CppType toCpp(const ComposerType& v) noexcept; - static ComposerType fromCpp(const CppType& c) noexcept; + static CppType toCpp(const ValdiType& v) noexcept; + static ValdiType fromCpp(const CppType& c) noexcept; static const Composer::ValueSchema& schema() noexcept; }; @@ -209,24 +209,24 @@ struct Optional { template static typename C::CppOptType opt_type(typename C::CppOptType*); using CppType = decltype(opt_type(nullptr)); - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = Optional; - static CppType toCpp(const ComposerType& j) { + static CppType toCpp(const ValdiType& j) { if (j.isUndefined() || j.isNull()) { return CppType{}; } else { return T::Boxed::toCpp(j); } } - static ComposerType fromCpp(const OptionalType& c) { + static ValdiType fromCpp(const OptionalType& c) { return c ? T::Boxed::fromCpp(*c) : Composer::Value::undefined(); } - static ComposerType fromCpp(OptionalType&& c) { + static ValdiType fromCpp(OptionalType&& c) { return c ? T::Boxed::fromCpp(std::move(*c)) : Composer::Value::undefined(); } template - static ComposerType fromCpp(const typename C::CppOptType& cppOpt) { + static ValdiType fromCpp(const typename C::CppOptType& cppOpt) { return T::Boxed::fromCppOpt(cppOpt); } static const Composer::ValueSchema& schema() noexcept { @@ -238,11 +238,11 @@ struct Optional { template class List { using ECppType = typename T::CppType; - using EComposerType = typename T::Boxed::ComposerType; + using EValdiType = typename T::Boxed::ValdiType; public: using CppType = std::vector; - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = List; static const Composer::ValueSchema& schema() noexcept { @@ -250,7 +250,7 @@ class List { return schema; } - static CppType toCpp(const ComposerType& v) { + static CppType toCpp(const ValdiType& v) { CppType c; const auto* a = v.getArray(); if (a != nullptr) { @@ -261,7 +261,7 @@ class List { } return c; } - static ComposerType fromCpp(const CppType& c) { + static ValdiType fromCpp(const CppType& c) { auto newArray = Composer::ValueArray::make(c.size()); for (size_t i = 0; i < c.size(); ++i) { (*newArray)[i] = T::Boxed::fromCpp(c[i]); @@ -273,13 +273,13 @@ class List { template class Set { using ECppType = typename T::CppType; - using EComposerType = typename T::Boxed::ComposerType; + using EValdiType = typename T::Boxed::ValdiType; public: using CppType = std::unordered_set; - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = Set; - static CppType toCpp(const ComposerType& v) { + static CppType toCpp(const ValdiType& v) { auto es6set = castOrNull(v.getComposerObject()); CppType cppSet; for (auto i = es6set->entries.begin(); i != es6set->entries.end(); i++) { @@ -287,7 +287,7 @@ class Set { } return cppSet; } - static ComposerType fromCpp(const CppType& c) { + static ValdiType fromCpp(const CppType& c) { auto es6set = Composer::makeShared(); for (const auto& k: c) { es6set->entries.push_back(T::fromCpp(k)); @@ -304,14 +304,14 @@ template class Map { using CppKeyType = typename Key::CppType; using CppValueType = typename Value::CppType; - using ComposerKeyType = typename Key::Boxed::ComposerType; - using ComposerValueType = typename Value::Boxed::ComposerType; + using ComposerKeyType = typename Key::Boxed::ValdiType; + using ComposerValueType = typename Value::Boxed::ValdiType; public: using CppType = std::unordered_map; - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = Map; - static CppType toCpp(const ComposerType& v) { + static CppType toCpp(const ValdiType& v) { auto es6map = castOrNull(v.getComposerObject()); CppType cppMap; for (auto i = es6map->entries.begin(); i != es6map->entries.end();) { @@ -321,7 +321,7 @@ class Map { } return cppMap; } - static ComposerType fromCpp(const CppType& c) { + static ValdiType fromCpp(const CppType& c) { auto es6Map = Composer::makeShared(); for (const auto& [k, v]: c) { es6Map->entries.push_back(Key::fromCpp(k)); @@ -338,7 +338,7 @@ class Map { class Void { public: using CppType = void; - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = Void; static const Composer::ValueSchema& schema() noexcept { static auto schema = Composer::ValueSchema::untyped(); @@ -354,10 +354,10 @@ template class Protobuf { public: using CppType = CppProto; - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = Protobuf; - static CppType toCpp(ComposerType v) + static CppType toCpp(ValdiType v) { auto array = v.getTypedArrayRef(); auto buffer = array->getBuffer(); @@ -366,7 +366,7 @@ class Protobuf { return ret; } - static ComposerType fromCpp(const CppType& c) + static ValdiType fromCpp(const CppType& c) { std::vector cbuf(c.ByteSizeLong()); c.SerializeToArray(cbuf.data(), static_cast(cbuf.size())); @@ -386,13 +386,13 @@ class Protobuf { template struct Array { using CppType = std::vector; - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = Array; - static CppType toCpp(const ComposerType& v) { + static CppType toCpp(const ValdiType& v) { return List::toCpp(v); } - static ComposerType fromCpp(const CppType& c) { + static ValdiType fromCpp(const CppType& c) { return List::fromCpp(c); } @@ -404,11 +404,11 @@ struct Array { template > struct PrimitiveArray { using CppType = std::vector; - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = PrimitiveArray; using CppElemType = typename T::CppType; - static CppType toCpp(const ComposerType& v) noexcept { + static CppType toCpp(const ValdiType& v) noexcept { auto arr = v.getTypedArrayRef(); const auto* bytes = arr->getBuffer().data(); const auto byteSize = arr->getBuffer().size(); @@ -416,7 +416,7 @@ struct PrimitiveArray { const auto typedSize = byteSize / sizeof(CppElemType); return CppType(typedData, typedData + typedSize); } - static ComposerType fromCpp(const CppType& c) noexcept { + static ValdiType fromCpp(const CppType& c) noexcept { auto bytes = Composer::makeShared(); bytes->assignData(reinterpret_cast(c.data()), c.size() * sizeof(CppElemType)); auto arr = Composer::makeShared(U::getArrayType(), bytes); @@ -463,26 +463,26 @@ struct Array : PrimitiveArray { }; // -------- Interface support -using ComposerProxyId = uint32_t; +using ValdiProxyId = uint32_t; struct CppProxyCacheEntry { Composer::Weak ref; int count; }; -class ComposerProxyBase; -extern std::unordered_map> jsProxyCache; +class ValdiProxyBase; +extern std::unordered_map> jsProxyCache; extern std::unordered_map cppProxyCache; extern std::mutex jsProxyCacheMutex; extern std::mutex cppProxyCacheMutex; -class ComposerProxyBase { +class ValdiProxyBase { protected: Composer::Ref _js; std::vector> _methods; public: - ComposerProxyBase(Composer::Ref js) + ValdiProxyBase(Composer::Ref js) : _js(js), _methods(_js->getTypedObject()->getPropertiesSize()) {} - virtual ~ComposerProxyBase() { + virtual ~ValdiProxyBase() { std::lock_guard lk(jsProxyCacheMutex); jsProxyCache.erase(_js->getId()); } @@ -536,17 +536,17 @@ class JsInterface { public: using CppType = std::shared_ptr; using CppOptType = std::shared_ptr; - using ComposerType = Composer::Value; + using ValdiType = Composer::Value; using Boxed = Self; - static CppType toCpp(const ComposerType& v) { + static CppType toCpp(const ValdiType& v) { return _fromJs(v); } - static ComposerType fromCppOpt(const CppOptType& c) { + static ValdiType fromCppOpt(const CppOptType& c) { return {_toJs(c)}; } - static ComposerType fromCpp(const CppType& c) { - ::djinni::composer::checkForNull(c.get(), typeid(Self).name()); + static ValdiType fromCpp(const CppType& c) { + ::djinni::valdi::checkForNull(c.get(), typeid(Self).name()); return fromCppOpt(c); } @@ -559,23 +559,23 @@ class JsInterface { } }; template - struct GetOrCreateJsProxy> { + struct GetOrCreateJsProxy> { std::shared_ptr operator()(const Composer::Value& js) noexcept { auto proxy = js.getTypedProxyObjectRef(); auto obj = proxy->getTypedObject(); std::lock_guard lk(jsProxyCacheMutex); // check prsence of proxy id in js object - ComposerProxyId id = proxy->getId(); + ValdiProxyId id = proxy->getId(); auto i = jsProxyCache.find(id); if (i != jsProxyCache.end()) { auto strongProxyRef = i->second.lock(); if (strongProxyRef != nullptr) { - return std::dynamic_pointer_cast(strongProxyRef); + return std::dynamic_pointer_cast(strongProxyRef); } } // not found or cache entry expired // create new js proxy and store it in cache - auto newproxy = std::make_shared(proxy); + auto newproxy = std::make_shared(proxy); jsProxyCache.emplace(id, newproxy); return newproxy; } @@ -634,7 +634,7 @@ class JsInterface { if (c == nullptr) { // null object return Composer::Value::undefined(); - } else if (auto* p = dynamic_cast(c.get())) { + } else if (auto* p = dynamic_cast(c.get())) { // unwrap existing js proxy return Composer::Value(p->getProxy()); } else { diff --git a/support-lib/dataref.yaml b/support-lib/dataref.yaml index 9b404575..1513ee67 100644 --- a/support-lib/dataref.yaml +++ b/support-lib/dataref.yaml @@ -34,5 +34,5 @@ ts: typename: 'Uint8Array' module: '' composer: - translator: '::djinni::composer::NativeDataRef' - header: '"$DataRef_composer.hpp"' + translator: '::djinni::valdi::NativeDataRef' + header: '"$DataRef_valdi.hpp"' diff --git a/support-lib/dataview.yaml b/support-lib/dataview.yaml index 6edc19f7..7ba4fc94 100644 --- a/support-lib/dataview.yaml +++ b/support-lib/dataview.yaml @@ -34,5 +34,5 @@ ts: typename: 'Uint8Array' module: '' composer: - translator: '::djinni::composer::NativeDataView' - header: '"$DataView_composer.hpp"' + translator: '::djinni::valdi::NativeDataView' + header: '"$DataView_valdi.hpp"' diff --git a/support-lib/future.yaml b/support-lib/future.yaml index b2c922ac..521c754b 100644 --- a/support-lib/future.yaml +++ b/support-lib/future.yaml @@ -37,5 +37,5 @@ ts: module: '' generic: true composer: - translator: '::djinni::composer::FutureAdaptor' - header: '"$Future_composer.hpp"' + translator: '::djinni::valdi::FutureAdaptor' + header: '"$Future_valdi.hpp"' diff --git a/support-lib/outcome.yaml b/support-lib/outcome.yaml index 5d859d7f..295ac13c 100644 --- a/support-lib/outcome.yaml +++ b/support-lib/outcome.yaml @@ -37,5 +37,5 @@ ts: module: '@djinni_support/Outcome' generic: true composer: - translator: '::djinni::composer::Outcome' - header: '"$Outcome_composer.hpp"' + translator: '::djinni::valdi::Outcome' + header: '"$Outcome_valdi.hpp"' From 2ab1c04628edbfa0794743c661c811f15a452a2c Mon Sep 17 00:00:00 2001 From: SnapCI Date: Fri, 6 Jun 2025 17:46:53 -0700 Subject: [PATCH 2/2] All good --- src/source/ComposerGenerator.scala | 4 +- support-lib/composer/djinni_valdi.hpp | 140 +++----------------------- 2 files changed, 17 insertions(+), 127 deletions(-) diff --git a/src/source/ComposerGenerator.scala b/src/source/ComposerGenerator.scala index 855f4964..f8475e5e 100644 --- a/src/source/ComposerGenerator.scala +++ b/src/source/ComposerGenerator.scala @@ -189,7 +189,7 @@ class ComposerGenerator(spec: Spec) extends Generator(spec) { writeHppFileGeneric(spec.composerOutFolder.get, helperNamespace(), composerFilenameStyle)(ident.name, origin, refs.hpp, Nil, (w => { w.wl(s"struct $helper").bracedSemi { w.wl(s"using CppType = $cls;") - w.wl("using ValdiType = Valid:: Value;") + w.wl("using ValdiType = Valdi:: Value;") w.wl(s"using Boxed = $helper;") w.wl w.wl("static CppType toCpp(const ValdiType& v);") @@ -257,7 +257,7 @@ class ComposerGenerator(spec: Spec) extends Generator(spec) { // js proxy if (i.ext.js) { - w.w(s"struct ValdiProxy: $cls, ::djinni::composer::ValdiProxyBase").bracedSemi { + w.w(s"struct ValdiProxy: $cls, ::djinni::valdi::ValdiProxyBase").bracedSemi { w.wl("ValdiProxy(Valdi::Ref js) : ValdiProxyBase(js) {}") for (m <- i.methods.filter(m => !m.static)) { w.w(s"${cppMarshal.fqReturnType(m.ret)} ${idCpp.method(m.ident)}(") diff --git a/support-lib/composer/djinni_valdi.hpp b/support-lib/composer/djinni_valdi.hpp index 8e28794c..62168b77 100644 --- a/support-lib/composer/djinni_valdi.hpp +++ b/support-lib/composer/djinni_valdi.hpp @@ -117,11 +117,7 @@ template class Primitive { public: using CppType = T; -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp - using ValdiType = Composer::Value; -======= - using ComposerType = Valdi::Value; ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp + using ValdiType = Valdi::Value; using Boxed = Primitive; @@ -155,11 +151,7 @@ class WString { using Utf16Converter = std::wstring_convert>; public: using CppType = std::wstring; -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp - using ValdiType = Composer::Value; -======= - using ComposerType = Valdi::Value; ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp + using ValdiType = Valdi::Value; using Boxed = WString; @@ -191,41 +183,23 @@ class WString { class Binary { public: using CppType = std::vector; -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp - using ValdiType = Composer::Value; + using ValdiType = Valdi::Value; using Boxed = Binary; static CppType toCpp(const ValdiType& j) noexcept; static ValdiType fromCpp(const CppType& c) noexcept; - static const Composer::ValueSchema& schema() noexcept ; -======= - using ComposerType = Valdi::Value; - using Boxed = Binary; - - static CppType toCpp(const ComposerType& j) noexcept; - static ComposerType fromCpp(const CppType& c) noexcept; static const Valdi::ValueSchema& schema() noexcept ; ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp }; class Date { public: using CppType = std::chrono::system_clock::time_point; -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp - using ValdiType = Composer::Value; + using ValdiType = Valdi::Value; using Boxed = Date; static CppType toCpp(const ValdiType& v) noexcept; static ValdiType fromCpp(const CppType& c) noexcept; - static const Composer::ValueSchema& schema() noexcept; -======= - using ComposerType = Valdi::Value; - using Boxed = Date; - - static CppType toCpp(const ComposerType& v) noexcept; - static ComposerType fromCpp(const CppType& c) noexcept; static const Valdi::ValueSchema& schema() noexcept; ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp }; template class OptionalType, class T> @@ -235,11 +209,7 @@ struct Optional { template static typename C::CppOptType opt_type(typename C::CppOptType*); using CppType = decltype(opt_type(nullptr)); -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp - using ValdiType = Composer::Value; -======= - using ComposerType = Valdi::Value; ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp + using ValdiType = Valdi::Value; using Boxed = Optional; static CppType toCpp(const ValdiType& j) { @@ -249,19 +219,11 @@ struct Optional { return T::Boxed::toCpp(j); } } -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp static ValdiType fromCpp(const OptionalType& c) { - return c ? T::Boxed::fromCpp(*c) : Composer::Value::undefined(); - } - static ValdiType fromCpp(OptionalType&& c) { - return c ? T::Boxed::fromCpp(std::move(*c)) : Composer::Value::undefined(); -======= - static ComposerType fromCpp(const OptionalType& c) { return c ? T::Boxed::fromCpp(*c) : Valdi::Value::undefined(); } - static ComposerType fromCpp(OptionalType&& c) { + static ValdiType fromCpp(OptionalType&& c) { return c ? T::Boxed::fromCpp(std::move(*c)) : Valdi::Value::undefined(); ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp } template static ValdiType fromCpp(const typename C::CppOptType& cppOpt) { @@ -280,11 +242,7 @@ class List { public: using CppType = std::vector; -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp - using ValdiType = Composer::Value; -======= - using ComposerType = Valdi::Value; ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp + using ValdiType = Valdi::Value; using Boxed = List; static const Valdi::ValueSchema& schema() noexcept { @@ -303,13 +261,8 @@ class List { } return c; } -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp static ValdiType fromCpp(const CppType& c) { - auto newArray = Composer::ValueArray::make(c.size()); -======= - static ComposerType fromCpp(const CppType& c) { auto newArray = Valdi::ValueArray::make(c.size()); ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp for (size_t i = 0; i < c.size(); ++i) { (*newArray)[i] = T::Boxed::fromCpp(c[i]); } @@ -323,32 +276,19 @@ class Set { using EValdiType = typename T::Boxed::ValdiType; public: using CppType = std::unordered_set; -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp - using ValdiType = Composer::Value; + using ValdiType = Valdi::Value; using Boxed = Set; static CppType toCpp(const ValdiType& v) { - auto es6set = castOrNull(v.getComposerObject()); -======= - using ComposerType = Valdi::Value; - using Boxed = Set; - - static CppType toCpp(const ComposerType& v) { auto es6set = castOrNull(v.getComposerObject()); ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp CppType cppSet; for (auto i = es6set->entries.begin(); i != es6set->entries.end(); i++) { cppSet.insert(T::toCpp(*i)); } return cppSet; } -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp static ValdiType fromCpp(const CppType& c) { - auto es6set = Composer::makeShared(); -======= - static ComposerType fromCpp(const CppType& c) { auto es6set = Valdi::makeShared(); ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp for (const auto& k: c) { es6set->entries.push_back(T::fromCpp(k)); } @@ -369,17 +309,10 @@ class Map { public: using CppType = std::unordered_map; -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp - using ValdiType = Composer::Value; + using ValdiType = Valdi::Value; using Boxed = Map; static CppType toCpp(const ValdiType& v) { - auto es6map = castOrNull(v.getComposerObject()); -======= - using ComposerType = Valdi::Value; - using Boxed = Map; - static CppType toCpp(const ComposerType& v) { auto es6map = castOrNull(v.getComposerObject()); ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp CppType cppMap; for (auto i = es6map->entries.begin(); i != es6map->entries.end();) { auto k = Key::toCpp(*i++); @@ -388,13 +321,8 @@ class Map { } return cppMap; } -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp static ValdiType fromCpp(const CppType& c) { - auto es6Map = Composer::makeShared(); -======= - static ComposerType fromCpp(const CppType& c) { auto es6Map = Valdi::makeShared(); ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp for (const auto& [k, v]: c) { es6Map->entries.push_back(Key::fromCpp(k)); es6Map->entries.push_back(Value::fromCpp(v)); @@ -410,11 +338,7 @@ class Map { class Void { public: using CppType = void; -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp - using ValdiType = Composer::Value; -======= - using ComposerType = Valdi::Value; ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp + using ValdiType = Valdi::Value; using Boxed = Void; static const Valdi::ValueSchema& schema() noexcept { static auto schema = Valdi::ValueSchema::untyped(); @@ -430,11 +354,7 @@ template class Protobuf { public: using CppType = CppProto; -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp - using ValdiType = Composer::Value; -======= - using ComposerType = Valdi::Value; ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp + using ValdiType = Valdi::Value; using Boxed = Protobuf; static CppType toCpp(ValdiType v) @@ -466,11 +386,7 @@ class Protobuf { template struct Array { using CppType = std::vector; -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp - using ValdiType = Composer::Value; -======= - using ComposerType = Valdi::Value; ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp + using ValdiType = Valdi::Value; using Boxed = Array; static CppType toCpp(const ValdiType& v) { @@ -488,11 +404,7 @@ struct Array { template > struct PrimitiveArray { using CppType = std::vector; -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp - using ValdiType = Composer::Value; -======= - using ComposerType = Valdi::Value; ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp + using ValdiType = Valdi::Value; using Boxed = PrimitiveArray; using CppElemType = typename T::CppType; @@ -504,19 +416,11 @@ struct PrimitiveArray { const auto typedSize = byteSize / sizeof(CppElemType); return CppType(typedData, typedData + typedSize); } -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp static ValdiType fromCpp(const CppType& c) noexcept { - auto bytes = Composer::makeShared(); - bytes->assignData(reinterpret_cast(c.data()), c.size() * sizeof(CppElemType)); - auto arr = Composer::makeShared(U::getArrayType(), bytes); - return Composer::Value(arr); -======= - static ComposerType fromCpp(const CppType& c) noexcept { auto bytes = Valdi::makeShared(); bytes->assignData(reinterpret_cast(c.data()), c.size() * sizeof(CppElemType)); auto arr = Valdi::makeShared(U::getArrayType(), bytes); return Valdi::Value(arr); ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp } static const Valdi::ValueSchema& schema() noexcept { static auto schema = Valdi::ValueSchema::valueTypedArray(); @@ -632,11 +536,7 @@ class JsInterface { public: using CppType = std::shared_ptr; using CppOptType = std::shared_ptr; -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp - using ValdiType = Composer::Value; -======= - using ComposerType = Valdi::Value; ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp + using ValdiType = Valdi::Value; using Boxed = Self; static CppType toCpp(const ValdiType& v) { @@ -659,13 +559,8 @@ class JsInterface { } }; template -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp struct GetOrCreateJsProxy> { - std::shared_ptr operator()(const Composer::Value& js) noexcept { -======= - struct GetOrCreateJsProxy> { std::shared_ptr operator()(const Valdi::Value& js) noexcept { ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp auto proxy = js.getTypedProxyObjectRef(); auto obj = proxy->getTypedObject(); std::lock_guard lk(jsProxyCacheMutex); @@ -738,13 +633,8 @@ class JsInterface { static Valdi::Value _toJs(const std::shared_ptr& c) { if (c == nullptr) { // null object -<<<<<<< HEAD:support-lib/composer/djinni_valdi.hpp - return Composer::Value::undefined(); - } else if (auto* p = dynamic_cast(c.get())) { -======= return Valdi::Value::undefined(); - } else if (auto* p = dynamic_cast(c.get())) { ->>>>>>> 6b4988062380a5d79032ba022d25363e2f6e30bc:support-lib/composer/djinni_composer.hpp + } else if (auto* p = dynamic_cast(c.get())) { // unwrap existing js proxy return Valdi::Value(p->getProxy()); } else {