TITANIUM_FUNCTION(TableView, insertRowBefore) { TITANIUM_LOG_WARN("TableView.insertRowBefore is not implemented yet"); if (arguments.size() < 3) { return get_context().CreateUndefined(); } else if (arguments.size() >= 3) { const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsNumber()); const auto _1 = arguments.at(1); TITANIUM_ASSERT(_1.IsObject()); const auto _2 = arguments.at(2); //TITANIUM_ASSERT(_2.IsTableViewAnimationProperties()); const double index = static_cast<double>(_0); const auto row = static_cast<JSObject>(_1); const auto animation = static_cast<JSObject>(_2); // insertRowBefore(index, row, animation); } else if (arguments.size() >= 2) { const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsNumber()); const auto _1 = arguments.at(1); TITANIUM_ASSERT(_1.IsObject()); const double index = static_cast<double>(_0); const auto row = static_cast<JSObject>(_1); // insertRowBefore(index, row); } else if (arguments.size() >= 1) { const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsNumber()); const double index = static_cast<double>(_0); // insertRowBefore(index); } return get_context().CreateUndefined(); }
TITANIUM_FUNCTION(ListView, scrollToItem) { const auto js_context = this_object.get_context(); if (arguments.size() >= 2) { JSObject animation = js_context.CreateObject(); const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsNumber()); const auto _1 = arguments.at(1); TITANIUM_ASSERT(_1.IsNumber()); const auto sectionIndex = static_cast<uint32_t>(_0); const auto itemIndex = static_cast<uint32_t>(_1); if (arguments.size() >= 3) { const auto _3 = arguments.at(2); if (_3.IsObject()) { animation = listviewAnimationProperties_ctor__.CallAsConstructor({_3}); } } scrollToItem(sectionIndex, itemIndex, animation.GetPrivate<ListViewAnimationProperties>()); } return this_object.get_context().CreateUndefined(); }
TITANIUM_FUNCTION(TableView, updateSection) { TITANIUM_LOG_WARN("TableView.updateSection is not implemented yet"); if (arguments.size() < 3) { return get_context().CreateUndefined(); } else if (arguments.size() >= 3) { const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsNumber()); const auto _1 = arguments.at(1); //TITANIUM_ASSERT(_1.IsTitanium.UI.TableViewSection()); const auto _2 = arguments.at(2); //TITANIUM_ASSERT(_2.IsTableViewAnimationProperties()); const double index = static_cast<double>(_0); const auto section = static_cast<JSObject>(_1); const auto animation = static_cast<JSObject>(_2); // updateSection(index, section, animation); } else if (arguments.size() >= 2) { const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsNumber()); const auto _1 = arguments.at(1); //TITANIUM_ASSERT(_1.IsTitanium.UI.TableViewSection()); const double index = static_cast<double>(_0); const auto section = static_cast<JSObject>(_1); // updateSection(index, section); } else if (arguments.size() >= 1) { const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsNumber()); const double index = static_cast<double>(_0); // updateSection(index); } return get_context().CreateUndefined(); }
void TableViewRow::ensureRowLabel() { if (title__ == nullptr) { const auto Titanium_property = get_context().get_global_object().GetProperty("Titanium"); TITANIUM_ASSERT(Titanium_property.IsObject()); const auto Titanium = static_cast<JSObject>(Titanium_property); const auto UI_property = Titanium.GetProperty("UI"); TITANIUM_ASSERT(UI_property.IsObject()); const auto UI = static_cast<JSObject>(UI_property); const auto Label_property = UI.GetProperty("Label"); TITANIUM_ASSERT(Label_property.IsObject()); auto Label = static_cast<JSObject>(Label_property); const auto label = Label.CallAsConstructor(); title__ = label.GetPrivate<TitaniumWindows::UI::Label>(); title__->set_text(""); title__->getViewLayoutDelegate()->set_left("0"); EnsureRowComponentWidth(title__->getViewLayoutDelegate<WindowsViewLayoutDelegate>()->getComponent()); add(label); } }
TITANIUM_FUNCTION(ListView, replaceSectionAt) { const auto js_context = this_object.get_context(); if (arguments.size() >= 2) { JSObject animation = js_context.CreateObject(); std::vector<std::shared_ptr<ListSection>> sections; const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsNumber()); const auto sectionIndex = static_cast<uint32_t>(_0); const auto _1 = arguments.at(1); TITANIUM_ASSERT(_1.IsObject()); const auto js_sections = static_cast<JSObject>(_1); if (js_sections.IsArray()) { sections = static_cast<JSArray>(js_sections).GetPrivateItems<ListSection>(); } else { sections.push_back(js_sections.GetPrivate<ListSection>()); } if (arguments.size() >= 3) { const auto _2 = arguments.at(2); if (_2.IsObject()) { animation = listviewAnimationProperties_ctor__.CallAsConstructor({_2}); } } replaceSectionAt(sectionIndex, sections, animation.GetPrivate<ListViewAnimationProperties>()); } return this_object.get_context().CreateUndefined(); }
TITANIUM_FUNCTION(ListSection, replaceItemsAt) { const auto js_context = this_object.get_context(); if (arguments.size() >= 3) { const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsNumber()); const auto _1 = arguments.at(1); TITANIUM_ASSERT(_1.IsNumber()); const auto _2 = arguments.at(2); TITANIUM_ASSERT(_2.IsObject()); JSObject animation = js_context.CreateObject(); const auto index = static_cast<std::uint32_t>(_0); const auto count = static_cast<std::uint32_t>(_1); const auto dataItems = js_to_ListDataItem_array(static_cast<JSObject>(_2)); if (arguments.size() >= 4) { const auto _3 = arguments.at(3); if (_3.IsObject()) { animation = listviewAnimationProperties_ctor__.CallAsConstructor({ _3 }); } } replaceItemsAt(index, count, dataItems, animation.GetPrivate<ListViewAnimationProperties>()); } return get_context().CreateUndefined(); }
TITANIUM_FUNCTION(SocketModule, createUDP) { TITANIUM_LOG_DEBUG("SocketModule::createUDP: "); ENSURE_OPTIONAL_OBJECT_AT_INDEX(parameters, 0); JSValue Titanium_property = get_context().get_global_object().GetProperty("Titanium"); TITANIUM_ASSERT(Titanium_property.IsObject()); // precondition JSObject Titanium = static_cast<JSObject>(Titanium_property); JSValue Network_property = Titanium.GetProperty("Network"); TITANIUM_ASSERT(Network_property.IsObject()); // precondition JSObject Network = static_cast<JSObject>(Network_property); JSValue Socket_property = Network.GetProperty("Socket"); TITANIUM_ASSERT(Socket_property.IsObject()); // precondition JSObject Socket = static_cast<JSObject>(Socket_property); JSValue UDP_property = Socket.GetProperty("UDP"); TITANIUM_ASSERT(UDP_property.IsObject()); // precondition JSObject UDP = static_cast<JSObject>(UDP_property); auto udp = UDP.CallAsConstructor(); applyProperties(parameters, udp); return udp; }
TITANIUM_FUNCTION(View, setLocation) { TITANIUM_ASSERT(arguments.size() == 1); auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsObject()); setLocation(js_to_MapLocationTypev2(static_cast<JSObject>(_0))); return get_context().CreateUndefined(); }
TITANIUM_FUNCTION(View, zoom) { TITANIUM_ASSERT(arguments.size() == 1); auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsNumber()); zoom(static_cast<uint32_t>(_0)); return get_context().CreateUndefined(); }
TITANIUM_FUNCTION(View, removeRoute) { TITANIUM_ASSERT(arguments.size() == 1); auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsObject()); removeRoute(static_cast<JSObject>(_0).GetPrivate<Route>()); return get_context().CreateUndefined(); }
TITANIUM_FUNCTION(View, selectAnnotation) { TITANIUM_ASSERT(arguments.size() == 1); auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsObject()); selectAnnotation(static_cast<JSObject>(_0).GetPrivate<Annotation>()); return get_context().CreateUndefined(); }
TITANIUM_FUNCTION(View, showAnnotations) { TITANIUM_ASSERT(arguments.size() > 0); auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsObject()); const auto _0Obj = static_cast<JSObject>(_0); TITANIUM_ASSERT(_0Obj.IsArray()); const auto annotations = static_cast<JSArray>(_0Obj); showAnnotations(annotations.GetPrivateItems<Annotation>()); return get_context().CreateUndefined(); }
TITANIUM_FUNCTION(View, animateCamera) { if (arguments.size() > 1) { auto _0 = arguments.at(0); auto _1 = arguments.at(1); TITANIUM_ASSERT(_0.IsObject()); TITANIUM_ASSERT(_1.IsObject()); auto callback = static_cast<JSObject>(_1); animateCamera(js_to_CameraAnimationParams(static_cast<JSObject>(_0)), callback); } return get_context().CreateUndefined(); }
JSValue GlobalObject::requireBuiltinModule(const JSContext& js_context, const std::string& moduleId) { if (moduleId == "ti.map") { JSValue Titanium_property = js_context.get_global_object().GetProperty("Titanium"); TITANIUM_ASSERT(Titanium_property.IsObject()); // precondition JSObject Titanium = static_cast<JSObject>(Titanium_property); JSValue Map_property = Titanium.GetProperty("Map"); TITANIUM_ASSERT(Map_property.IsObject()); // precondition return Map_property; } return js_context.CreateUndefined(); }
TITANIUM_PROPERTY_SETTER(Animation, transform) { TITANIUM_ASSERT(argument.IsObject()); const auto object = static_cast<JSObject>(argument); set_transform(object.GetPrivate<Titanium::UI::TwoDMatrix>()); return true; }
TITANIUM_PROPERTY_SETTER(View, region) { TITANIUM_ASSERT(argument.IsObject()); const auto region = static_cast<JSObject>(argument); set_region(js_to_MapRegionTypev2(region)); return true; }
TITANIUM_PROPERTY_SETTER(Animation, view) { TITANIUM_ASSERT(argument.IsObject()); const auto object = static_cast<JSObject>(argument); set_view(object.GetPrivate<Titanium::UI::View>()); return true; }
TITANIUM_PROPERTY_SETTER(Animation, duration) { TITANIUM_ASSERT(argument.IsNumber()); const auto duration = std::chrono::milliseconds(static_cast<std::chrono::milliseconds::rep>(static_cast<std::uint32_t>(argument))); set_duration(duration); return true; }
TITANIUM_FUNCTION(File, write) { const auto js_context = this_object.get_context(); if (arguments.size() < 1) { return js_context.CreateUndefined(); } const auto _0 = arguments.at(0); const auto _1 = arguments.size() < 2 ? js_context.CreateBoolean(false) : arguments.at(1); TITANIUM_ASSERT(_1.IsBoolean()); const auto append = static_cast<bool>(_1); if (_0.IsString()) { return js_context.CreateBoolean(write(static_cast<std::string>(arguments.at(0)), append)); } else if (_0.IsObject()) { const auto js_object = static_cast<JSObject>(_0); const auto blob = js_object.GetPrivate<Titanium::Blob>(); const auto file = js_object.GetPrivate<File>(); if (blob != nullptr) { return js_context.CreateBoolean(write(blob, append)); } else if (file != nullptr) { return js_context.CreateBoolean(write(file, append)); } } return js_context.CreateNull(); }
TITANIUM_FUNCTION(UIModule, create2DMatrix) { ENSURE_OPTIONAL_OBJECT_AT_INDEX(parameters, 0); // FIXME Macros didn't work because identifiers can't start with digits! JSValue Titanium_property = this_object.get_context().get_global_object().GetProperty("Titanium"); TITANIUM_ASSERT(Titanium_property.IsObject()); JSObject Titanium = static_cast<JSObject>(Titanium_property); JSValue UI_property = Titanium.GetProperty("UI"); TITANIUM_ASSERT(UI_property.IsObject()); JSObject UI = static_cast<JSObject>(UI_property); JSValue TwoDMatrix_property = UI.GetProperty("2DMatrix"); TITANIUM_ASSERT(TwoDMatrix_property.IsObject()); JSObject TwoDMatrix = static_cast<JSObject>(TwoDMatrix_property); auto TwoDMatrix_obj = TwoDMatrix.CallAsConstructor(parameters); Titanium::Module::applyProperties(parameters, TwoDMatrix_obj); return TwoDMatrix_obj; }
TITANIUM_FUNCTION(Module, removeEventListener) { ENSURE_STRING_AT_INDEX(name, 0); ENSURE_OBJECT_AT_INDEX(callback, 1); TITANIUM_ASSERT(callback.IsFunction()); removeEventListener(name, callback, this_object); return get_context().CreateUndefined(); }
TITANIUM_FUNCTION(ListView, setMarker) { if (arguments.size() >= 1) { const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsObject()); setMarker(js_to_ListViewMarkerProps(static_cast<JSObject>(_0))); } return this_object.get_context().CreateUndefined(); }
void ListSection::fireListSectionEvent(const std::string& event_name, const std::uint32_t& index, const std::uint32_t& itemCount, const std::uint32_t& affectedRows) { const auto js_listview = get_object().GetProperty("listview"); if (!js_listview.IsObject()) { return; } const auto listview = static_cast<JSObject>(js_listview).GetPrivate<ListView>(); TITANIUM_ASSERT(listview); listview->fireListSectionEvent(event_name, get_object().GetPrivate<ListSection>(), index, itemCount, affectedRows); }
TITANIUM_FUNCTION(ListSection, getItemAt) { if (arguments.size() >= 1) { const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsNumber()); const auto itemIndex = static_cast<std::uint32_t>(_0); return ListDataItem_to_js(get_context(), getItemAt(itemIndex)); } return get_context().CreateUndefined(); }
void ListSection::setViewForSectionItem(const std::uint32_t& itemIndex, const std::shared_ptr<View>& view) { TITANIUM_ASSERT(items__.size() > itemIndex); TITANIUM_LOG_DEBUG("ListSectin::setViewForSectionItem at ", itemIndex, " ", view.get(), " for ", this); auto item = items__.at(itemIndex); item.view = view; items__.at(itemIndex) = item; }
TITANIUM_FUNCTION(TableView, appendRow) { if (arguments.size() >= 2) { const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsObject()); const auto _1 = arguments.at(1); TITANIUM_ASSERT(_1.IsObject()); const auto row = static_cast<JSObject>(_0); const auto animation = static_cast<JSObject>(_1); appendRow(row.GetPrivate<TableViewRow>(), animation.GetPrivate<TableViewAnimationProperties>()); } else if (arguments.size() >= 1) { const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsObject()); const auto row = static_cast<JSObject>(_0); const auto animation = get_context().CreateObject(); appendRow(row.GetPrivate<TableViewRow>(), animation.GetPrivate<TableViewAnimationProperties>()); } return get_context().CreateUndefined(); }
TITANIUM_PROPERTY_SETTER(TableView, data) { TITANIUM_ASSERT(argument.IsObject()); auto data_obj = static_cast<JSObject>(argument); TITANIUM_ASSERT(data_obj.IsArray()); auto data = static_cast<std::vector<JSValue>>(static_cast<JSArray>(data_obj)); auto animation = get_context().CreateObject(); std::vector<JSObject> tableObjects; for (uint32_t i=0;i<data.size();i++) { auto tableObject = static_cast<JSObject>(data[i]); tableObjects.push_back(tableObject); } setData(tableObjects, animation.GetPrivate<TableViewAnimationProperties>()); return false; }
TITANIUM_FUNCTION(File, copy) { if (arguments.size() == 0) { return get_context().CreateUndefined(); } const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsString()); const auto destinationPath = static_cast<std::string>(_0); return get_context().CreateBoolean(copy(destinationPath)); }
TITANIUM_FUNCTION(File, rename) { if (arguments.size() == 0) { return get_context().CreateUndefined(); } const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsString()); const auto newname = static_cast<std::string>(_0); return get_context().CreateBoolean(rename(newname)); }
TITANIUM_FUNCTION(WebView, setData) { if (arguments.size() >= 1) { const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsObject()); const auto data = _0; // TODO Convert JSObject(Ti.Blob or Ti.File) to std::vector<std::uint8_t> // setData(data); } return get_context().CreateUndefined(); }