bool ClassPreferencesDialog::run(Builder &builder, ClassNodeDrawOptions &options) { Dialog dlg(GTK_DIALOG(gtk_dialog_new())); dlg.addButton(GUI_CANCEL, GTK_RESPONSE_CANCEL); dlg.addButton(GUI_OK, GTK_RESPONSE_OK); // Steal the options, then put them back. GtkWidget *optionsBox = builder.getWidget("ClassesOptionsBox"); Gui::reparentWidget(optionsBox, GTK_CONTAINER(dlg.getContentArea())); for(auto const &opt : PrefOptions) { bool active = *(reinterpret_cast<unsigned char *>(&options) + (opt.offset)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON( Builder::getBuilder()->getWidget(opt.widgetName)), active); } bool ok = dlg.run(); if(ok) { for(auto const &opt : PrefOptions) { bool active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( Builder::getBuilder()->getWidget(opt.widgetName))); *(reinterpret_cast<unsigned char *>(&options) + (opt.offset)) = active; } } Gui::reparentWidget(optionsBox, GTK_CONTAINER(builder.getWidget("OptionsNotebook"))); dlg.destroy(); return ok; }
void ClassDiagramView::displayDrawContextMenu(guint button, guint32 acttime, gpointer data) { GdkEventButton *event = static_cast<GdkEventButton*>(data); ClassNode *node = getNode(static_cast<int>(event->x), static_cast<int>(event->y)); OovStringRef const nodeMenus[] = { "GotoClassMenuitem", "ClassPreferencesMenuitem", "AddSelectedMenuitem", "AddStandardMenuitem", "AddAllMenuitem", "AddSuperclassesMenuitem", "AddSubclassesMenuitem", "AddMembersUsingMenuitem", "AddMemberUsersMenuitem", "AddTemplateMenuItem", "AddFuncParamsUsingMenuitem", "AddFuncParamUsersMenuitem", "AddFuncBodyVarUsingMenuitem", "AddFuncBodyVarUsersMenuitem", "RemoveClassMenuitem", "ViewSourceMenuitem" }; Builder *builder = Builder::getBuilder(); for(size_t i=0; i<sizeof(nodeMenus)/sizeof(nodeMenus[i]); i++) { gtk_widget_set_sensitive(builder->getWidget( nodeMenus[i]), node != nullptr); } GtkMenu *menu = builder->getMenu("DrawClassPopupMenu"); gtk_menu_popup(menu, nullptr, nullptr, nullptr, nullptr, button, acttime); gStartPosInfo.set(static_cast<int>(event->x), static_cast<int>(event->y)); }
int main(int, char* []) { Builder b; // build an object with attribute names "b", "a", "l", "name" b(Value(ValueType::Object))("b", Value(12))("a", Value(true))( "l", Value(ValueType::Array))(Value(1))(Value(2))(Value(3))()( "name", Value("Gustav"))(); // a Slice is a lightweight accessor for a VPack value Slice s(b.start()); // now dump the Slice into an outfile Options dumperOptions; dumperOptions.prettyPrint = true; // this is our output file try { std::ofstream ofs("prettified.json", std::ofstream::out); OutputFileStreamSink sink(&ofs); Dumper::dump(s, &sink); std::cout << "successfully wrote JSON to outfile 'prettified.json'" << std::endl; } catch (std::exception const& ex) { std::cout << "could not write outfile 'prettified.json': " << ex.what() << std::endl; } }
void ParseRegion(Builder& target) { static const char MARKER_NORTH_AMERICA[] = "Sony Computer Entertainment Inc. for North America area"; static const char MARKER_JAPAN[] = "Sony Computer Entertainment Inc. for Japan area"; static const char MARKER_EUROPE[] = "Sony Computer Entertainment Inc. for Europe area"; Stream.Seek(0x4c); const auto marker = Stream.ReadCString(60); if (marker == MARKER_NORTH_AMERICA) { target.SetRegion("North America", 60); } else if (marker == MARKER_JAPAN) { target.SetRegion("Japan", 60); } else if (marker == MARKER_EUROPE) { target.SetRegion("Europe", 50); } else { target.SetRegion(marker.to_string(), 0); } Dbg("Marker: %s", marker); }
void Settings::set_to_gui (Builder &builder, int i) { const char *glade_name = settings[i].glade_name; if (!glade_name) return; switch (settings[i].type) { case T_BOOL: { Gtk::CheckButton *check = NULL; builder->get_widget (glade_name, check); if (!check) std::cerr << "Missing boolean config item " << glade_name << "\n"; else check->set_active (*PTR_BOOL(this, i)); break; } case T_INT: case T_FLOAT: { Gtk::Widget *w = NULL; builder->get_widget (glade_name, w); if (!w) { std::cerr << "Missing user interface item " << glade_name << "\n"; break; } Gtk::SpinButton *spin = dynamic_cast<Gtk::SpinButton *>(w); if (spin) { if (settings[i].type == T_INT) spin->set_value (*PTR_INT(this, i)); else spin->set_value (*PTR_FLOAT(this, i)); break; } Gtk::Range *range = dynamic_cast<Gtk::Range *>(w); if (range) { if (settings[i].type == T_INT) range->set_value (*PTR_INT(this, i)); else range->set_value (*PTR_FLOAT(this, i)); } break; } case T_STRING: { Gtk::Entry *e = NULL; builder->get_widget (glade_name, e); if (!e) { std::cerr << "Missing user interface item " << glade_name << "\n"; break; } e->set_text(*PTR_STRING(this, i)); break; } case T_COLOUR_MEMBER: break; // Ignore, Colour members are special default: std::cerr << "corrupt setting type\n"; break; } }
Map* Loader::loadMap(const QString& filename) { QFile file(filename); if (!file.open(QIODevice::ReadOnly)) { qDebug() << "could not open file " << filename; return nullptr; } QXmlSimpleReader xmlReader; Builder builder; XmlHandler* handler = new XmlHandler(&builder); QXmlInputSource* source = new QXmlInputSource(&file); xmlReader.setContentHandler(handler); xmlReader.setErrorHandler(handler); bool ok = xmlReader.parse(source); Map* map = builder.map(); map->setFilename(filename); delete handler; return map; }
void construct() { std::cout << "\tDirector::construct()\n"; builder_->createNewProduct(); builder_->buildPartA(); builder_->buildPartB(); }
Builder Collection::extract(Slice const& slice, int64_t from, int64_t to) { Builder b; b.openArray(); int64_t length = static_cast<int64_t>(slice.length()); int64_t skip = from; int64_t limit = to; if (limit < 0) { limit = length + limit - skip; } if (limit > 0) { ArrayIterator it(slice); while (it.valid()) { if (skip > 0) { --skip; } else { b.add(it.value()); if (--limit == 0) { break; } } it.next(); } } b.close(); return b; }
Formats::Chiptune::Container::Ptr Parse(const Binary::Container& rawData, Builder& target) { if (!FastCheck(rawData)) { return Formats::Chiptune::Container::Ptr(); } const Binary::TypedContainer& data(rawData); const Header& header = *data.GetField<Header>(0); //workaround for some emulators const std::size_t offset = (header.Version == INT_BEGIN) ? offsetof(Header, Version) : sizeof(header); std::size_t restSize = rawData.Size() - offset; const uint8_t* bdata = data.GetField<uint8_t>(offset); //detect as much chunks as possible, in despite of real format issues while (restSize) { const uint_t reg = *bdata; ++bdata; --restSize; if (INT_BEGIN == reg) { target.AddChunks(1); } else if (INT_SKIP == reg) { if (restSize < 1) { ++restSize;//put byte back break; } target.AddChunks(4 * *bdata); ++bdata; --restSize; } else if (MUS_END == reg) { break; } else if (reg <= 15) //register { if (restSize < 1) { ++restSize;//put byte back break; } target.SetRegister(reg, *bdata); ++bdata; --restSize; } else { ++restSize;//put byte back break; } } const std::size_t usedSize = rawData.Size() - restSize; const Binary::Container::Ptr subData = rawData.GetSubcontainer(0, usedSize); return CreateCalculatingCrcContainer(subData, offset, usedSize - offset); }
Car* get_car() { Car *car = new Car(); car->body = build->buildBody(); car->engine = build->buildEngine(); car->wheels = build->buildWheels(); return car; }
int main () { Builder b; SemanticGraph::TranslationUnit& tu (*b.build ()); delete &tu; }
//----------- void CameraHead::init(int cameraID, const Payload& payload, Builder& gui) { this->init(cameraID, payload); this->gui = &gui; gui.add(this->camera, "Camera " + ofToString(this->getCameraID())); this->panelPinC = gui.add(this->getDecoder().getProjectorInCamera(), "Projector in Camera " + ofToString( this->getCameraID() )); this->panelCinP = gui.add(this->getDecoder().getCameraInProjector(), "Camera " + ofToString( this->getCameraID() ) + " in Projector"); gui.add( this->getDecoder().getCaptures() ); }
int main() { Builder b; //b.makeFactorial(); //b.makeFibonacci(); b.makeEuklides(); return 0; }
VertexHandle addVertex(Vector3 const & pos) { VertexHandle ref = builder->add_vertex(typename Mesh::Point_3(pos.x(), pos.y(), pos.z())); if (builder->error()) throw Error("IncrementalCGALMeshBuilder: Error adding vertex"); vertex_indices->insert(typename VertexIndexMap::value_type(&(*ref), next_index)); next_index++; return ref; }
Builder Collection::concat(Slice const& slice1, Slice const& slice2) { Builder b; b.openArray(); appendArray(b, slice1); appendArray(b, slice2); b.close(); return b; }
template<typename Builder> typename Builder::Object IOMarkerPayload::preparePayloadImp(Builder& b) { typename Builder::RootedObject data(b.context(), b.CreateObject()); prepareCommonProps("io", b, data); b.DefineProperty(data, "source", mSource); return data; }
typename Builder::Object ProfilerMarkerImagePayload::preparePayloadImp(Builder& b) { typename Builder::RootedObject data(b.context(), b.CreateObject()); prepareCommonProps("innerHTML", b, data); // TODO: Finish me //b.DefineProperty(data, "innerHTML", "<img src=''/>"); return data; }
int main( int argc, char* argv[] ) { Builder* b = new ConcreteBuilder(); Director* d = new Director(b); d->Construct(); b->GetProduct(); return 0; }
Tensor::UP build1DTensor(Builder &builder) { Builder::Dimension dimX = builder.defineDimension("x", 3); builder.addLabel(dimX, 0).addCell(10). addLabel(dimX, 1).addCell(11). addLabel(dimX, 2).addCell(12); return builder.build(); }
void ParseBuffer(uint_t count, Stream& source, Builder& target) { const std::size_t bufSize = source.GetBufferSize(); Dump buf(bufSize); std::size_t cursor = 0; uint_t flag = 0x40; //dX_flag while (count) { //dX_next flag <<= 1; if ((flag & 0xff) == 0) { flag = source.ReadByte(); flag = (flag << 1) | 1; } if ((flag & 0x100) != 0) { flag &= 0xff; uint_t counter = source.ReadCounter(); std::size_t srcPtr = source.ReadBackRef(); Require(count >= counter); Require(srcPtr < bufSize); count -= counter; while (counter--) { buf[cursor++] = buf[srcPtr++]; if (cursor >= bufSize) { target.AddValues(buf); cursor -= bufSize; } if (srcPtr >= bufSize) { srcPtr -= bufSize; } } } else { //dX_chr --count; buf[cursor++] = source.ReadByte(); if (cursor >= bufSize) { target.AddValues(buf); cursor -= bufSize; } } } if (cursor) { buf.resize(cursor); target.AddValues(buf); } }
int main(int argc, char *argv[]) { boost::program_options::options_description options_description("Builder usage"); options_description.add_options() ("help", "Display this message") ("version", "Displays version number") ("input-path,i", boost::program_options::value<std::string>(), "Path to directory with sources") ("output-path,o", boost::program_options::value<std::string>(), "Path to output directory (repository)") ("extension-path,e", boost::program_options::value<std::string>(), "Path to extensions directory") ("clear-output,c", "Clear output directory (repository) before build") ("settings,s", boost::program_options::value<std::string>(), "Path to configuration file for sc-memory") ("auto-formats,f", "Enable automatic formats info generation") ("show-filenames,v", "Enable processing filnames printing"); boost::program_options::variables_map vm; boost::program_options::store(boost::program_options::command_line_parser(argc, argv).options(options_description).run(), vm); boost::program_options::notify(vm); if (vm.count("help") || !vm.count("input-path") || !vm.count("output-path")) { std::cout << options_description; return 0; } BuilderParams params; params.clearOutput = false; params.autoFormatInfo = false; if (vm.count("input-path")) params.inputPath = vm["input-path"].as<std::string>(); if (vm.count("output-path")) params.outputPath = vm["output-path"].as<std::string>(); if (vm.count("extension-path")) params.extensionsPath = vm["extension-path"].as<std::string>(); if (vm.count("clear-output")) params.clearOutput = true; if (vm.count("auto-formats")) params.autoFormatInfo = true; if (vm.count("settings")) params.configFile = vm["settings"].as<std::string>(); if (vm.count("show-filenames")) params.showFileNames = true; Builder builder; builder.initialize(); builder.run(params); return builder.hasErrors() ? EXIT_SUCCESS : EXIT_FAILURE; }
void Reader::construct(PersistenceAttribute list[], int num) { for (int i = 0; i < num; i++) if (list[i].type == File) _builder->configureFile(list[i].value); else if (list[i].type == Queue) _builder->configureQueue(list[i].value); else if (list[i].type == Pathway) _builder->configurePathway(list[i].value); }
void Reader::construct(PersistenceAttribute list[], int num) { for (int i = 0; i< num; ++i) { if (list[i].type == File) { _builder->configureFile(list[i].value); } else if (list[i].type == Queue) { _builder->configureQueue(list[i].value); } } }
static void ParseSubchunk(const SubChunkHeader& hdr, Builder& target) { switch (hdr.ID) { case SubChunkHeader::SongName: target.SetTitle(hdr.GetString()); break; case SubChunkHeader::GameName: target.SetGame(hdr.GetString()); break; case SubChunkHeader::ArtistName: target.SetArtist(hdr.GetString()); break; case SubChunkHeader::DumperName: target.SetDumper(hdr.GetString()); break; case SubChunkHeader::Date: target.SetDumpDate(DateFromInteger(hdr.GetInteger())); break; case SubChunkHeader::Comments: target.SetComment(hdr.GetString()); break; case SubChunkHeader::IntroductionLength: target.SetIntro(hdr.GetTicks()); break; case SubChunkHeader::LoopLength: target.SetLoop(hdr.GetTicks()); break; case SubChunkHeader::FadeLength: target.SetFade(hdr.GetTicks()); break; default: break; } }
void AssemblyTree::rebuild_assembly_tree() { // Clear the current tree. clear(); m_assembly_instances.clear(); Statistics statistics; // Collect all assembly instances of the scene. AABBVector assembly_instance_bboxes; collect_assembly_instances(assembly_instance_bboxes); RENDERER_LOG_INFO( "building assembly tree (%s %s)...", pretty_int(m_assembly_instances.size()).c_str(), plural(m_assembly_instances.size(), "assembly instance").c_str()); // Create the partitioner. typedef bvh::SAHPartitioner<AABBVector> Partitioner; Partitioner partitioner( assembly_instance_bboxes, AssemblyTreeMaxLeafSize, AssemblyTreeInteriorNodeTraversalCost, AssemblyTreeTriangleIntersectionCost); // Build the assembly tree. typedef bvh::Builder<AssemblyTree, Partitioner> Builder; Builder builder; builder.build<DefaultWallclockTimer>(*this, partitioner, m_assembly_instances.size(), AssemblyTreeMaxLeafSize); statistics.insert_time("build time", builder.get_build_time()); statistics.merge(bvh::TreeStatistics<AssemblyTree>(*this, AABB3d(m_scene.compute_bbox()))); if (!m_assembly_instances.empty()) { const vector<size_t>& ordering = partitioner.get_item_ordering(); assert(m_assembly_instances.size() == ordering.size()); // Reorder the assembly instances according to the tree ordering. vector<const AssemblyInstance*> temp_assembly_instances(ordering.size()); small_item_reorder( &m_assembly_instances[0], &temp_assembly_instances[0], &ordering[0], ordering.size()); // Store assembly instances in the tree leaves whenever possible. store_assembly_instances_in_leaves(statistics); } // Print assembly tree statistics. RENDERER_LOG_DEBUG("%s", StatisticsVector::make( "assembly tree statistics", statistics).to_string().c_str()); }
Formats::Chiptune::Container::Ptr Parse(const Binary::Container& data, Builder& target) { if (!FastCheck(data)) { return Formats::Chiptune::Container::Ptr(); } try { Binary::InputStream stream(data); stream.ReadField<SignatureType>(); target.SetTitle(DecodeString(stream.ReadCString(MAX_STRING_SIZE))); target.SetAuthor(DecodeString(stream.ReadCString(MAX_STRING_SIZE))); target.SetComment(DecodeString(stream.ReadCString(MAX_COMMENT_SIZE))); const std::size_t fixedOffset = stream.GetPosition(); std::size_t totalFrames = 0; for (;;) { const uint8_t val = stream.ReadField<uint8_t>(); if (val == FINISH) { break; } switch (val) { case BEGIN_FRAME: ++totalFrames; target.BeginFrames(1); break; case SKIP_FRAMES: { const uint_t frames = 3 + stream.ReadField<uint8_t>(); totalFrames += frames; target.BeginFrames(frames); } break; case SELECT_SECOND_CHIP: target.SelectChip(1); break; case SELECT_FIRST_CHIP: target.SelectChip(0); break; case LOOP_MARKER: target.SetLoop(); break; default: target.SetRegister(val, stream.ReadField<uint8_t>()); break; } } Require(totalFrames >= MIN_FRAMES); const std::size_t usedSize = stream.GetPosition(); const auto subData = stream.GetReadData(); return CreateCalculatingCrcContainer(subData, fixedOffset, usedSize - fixedOffset); } catch (const std::exception&) { return Formats::Chiptune::Container::Ptr(); } }
void TextProcessorTester::testExtensionSubtable() { Builder builder; /* Test with an unmatching glyph. */ testSubstitution(builder.createExtension(LookupType::sSingle, builder.createSingleSubst({ 1 }, 100)), { 0 }, { 0 }); /* Test with a matching glyph.*/ testSubstitution(builder.createExtension(LookupType::sSingle, builder.createSingleSubst({ 1 }, 100)), { 1 }, { 101 }); }
void Node::rebuildVecBuf() const { if (_vecBufDirty) { // Dirty vector buffer Builder tmp; tmp.openArray(); for (auto const& i : _value) { tmp.add(Slice(i.data())); } tmp.close(); _vecBuf = *tmp.steal(); _vecBufDirty = false; } }
int main(int, char* []) { // create an object with a few members Builder b; b(Value(ValueType::Object)); b.add("foo", Value(42)); b.add("bar", Value("some string value")); b.add("baz", Value(ValueType::Object)); b.add("qux", Value(true)); b.add("bart", Value("this is a string")); b.close(); b.add("quux", Value(12345)); b.close(); // a Slice is a lightweight accessor for a VPack value Slice s(b.start()); // now fetch the string in the object's "bar" attribute if (s.hasKey("bar")) { Slice bar(s.get("bar")); std::cout << "'bar' attribute value has type: " << bar.type() << std::endl; } // fetch non-existing attribute "quetzal" Slice quetzal(s.get("quetzal")); // note: this returns a slice of type None std::cout << "'quetzal' attribute value has type: " << quetzal.type() << std::endl; std::cout << "'quetzal' attribute is None: " << std::boolalpha << quetzal.isNone() << std::endl; // fetch subattribute "baz.qux" Slice qux(s.get(std::vector<std::string>({"baz", "qux"}))); std::cout << "'baz'.'qux' attribute has type: " << qux.type() << std::endl; std::cout << "'baz'.'qux' attribute has bool value: " << std::boolalpha << qux.getBoolean() << std::endl; std::cout << "Complete value of 'baz' is: " << s.get("baz").toJson() << std::endl; // fetch non-existing subattribute "bark.foobar" Slice foobar(s.get(std::vector<std::string>({"bark", "foobar"}))); std::cout << "'bark'.'foobar' attribute is None: " << std::boolalpha << foobar.isNone() << std::endl; // check if subattribute "baz"."bart" does exist if (s.hasKey(std::vector<std::string>({"baz", "bart"}))) { // access subattribute using operator syntax std::cout << "'baz'.'bart' attribute has type: " << s["baz"]["bart"].type() << std::endl; std::cout << "'baz'.'bart' attribute has value: '" << s["baz"]["bart"].copyString() << "'" << std::endl; } }
/** * Add padding to buffer (if needed) to align data properly. * * This calculates how many padding bytes are needed and adds * as many zero bytes to the buffer. It also adds this number * to the size of the current item (if the "self" param is * true) and recursively to all the parent items. * * @param self If true add number of padding bytes to size * of current item. Size is always added to * parent item (if any). * */ void add_padding(bool self = false) { const auto padding = osmium::memory::align_bytes - (size() % osmium::memory::align_bytes); if (padding != osmium::memory::align_bytes) { std::fill_n(m_buffer.reserve_space(padding), padding, 0); if (self) { add_size(padding); } else if (m_parent) { m_parent->add_size(padding); assert(m_parent->size() % osmium::memory::align_bytes == 0); } } }