JSObject RouteDescription_to_js(const JSContext& js_context, const RouteDescription& config) { auto object = js_context.CreateObject(); std::vector<JSValue> js_inputs; for (const auto v : config.inputs) { js_inputs.push_back(js_context.CreateNumber(static_cast<std::uint32_t>(v))); } std::vector<JSValue> js_outputs; for (const auto v : config.outputs) { js_outputs.push_back(js_context.CreateNumber(static_cast<std::uint32_t>(v))); } object.SetProperty("inputs", js_context.CreateArray(js_inputs)); object.SetProperty("outputs", js_context.CreateArray(js_outputs)); return object; }
JSObject Emails_to_js(const JSContext& js_context, const Emails& emails) { auto object = js_context.CreateObject(); std::vector<JSValue> js_home; for (const auto email : emails.home) { js_home.push_back(js_context.CreateString(email)); } object.SetProperty("home", js_context.CreateArray(js_home)); std::vector<JSValue> js_work; for (const auto email : emails.work) { js_work.push_back(js_context.CreateString(email)); } object.SetProperty("work", js_context.CreateArray(js_work)); std::vector<JSValue> js_other; for (const auto email : emails.other) { js_other.push_back(js_context.CreateString(email)); } object.SetProperty("other", js_context.CreateArray(js_other)); return object; };
JSObject PushNotificationConfig_to_js(const JSContext& js_context, const PushNotificationConfig& config) { auto object = js_context.CreateObject(); object.SetProperty("callback", config.callback); object.SetProperty("error", config.error); object.SetProperty("success", config.success); std::vector<JSValue> js_types; for (const auto t : config.types) { js_types.push_back(js_context.CreateNumber(Titanium::Network::Constants::to_underlying_type(t))); } object.SetProperty("types", js_context.CreateArray(js_types)); return object; }
JSObject ShowContactsParams_to_js(const JSContext& js_context, const ShowContactsParams& dict) { auto object = js_context.CreateObject(); object.SetProperty("animated", js_context.CreateBoolean(dict.animated)); object.SetProperty("cancel", dict.callbacks.cancel); std::vector<JSValue> js_fields; for (const auto f : dict.fields) { js_fields.push_back(js_context.CreateString(f)); } object.SetProperty("fields", js_context.CreateArray(js_fields)); object.SetProperty("selectedPerson", dict.callbacks.selectedPerson); object.SetProperty("selectedProperty", dict.callbacks.selectedProperty); return object; };