JSObject CameraMediaItemType_to_js(const JSContext& js_context, const CameraMediaItemType& config) { auto object = js_context.CreateObject(); object.SetProperty("code", js_context.CreateNumber(config.code)); object.SetProperty("cropRect", Titanium::UI::Dimension_to_js(js_context, config.cropRect)); object.SetProperty("error", js_context.CreateString(config.error)); if (config.media != nullptr) { object.SetProperty("media", config.media->get_object()); } object.SetProperty("mediaType", js_context.CreateNumber(static_cast<std::uint32_t>(config.mediaType))); object.SetProperty("success", js_context.CreateBoolean(config.success)); 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 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; };