//------------------------------do_new----------------------------------------- void Parse::do_new() { kill_dead_locals(); bool will_link; ciInstanceKlass* klass = iter().get_klass(will_link)->as_instance_klass(); assert(will_link, "_new: typeflow responsibility"); // Should initialize, or throw an InstantiationError? if (!klass->is_initialized() && !klass->is_being_initialized() || klass->is_abstract() || klass->is_interface() || klass->name() == ciSymbol::java_lang_Class() || iter().is_unresolved_klass()) { uncommon_trap(Deoptimization::Reason_uninitialized, Deoptimization::Action_reinterpret, klass); return; } if (klass->is_being_initialized()) { emit_guard_for_new(klass); } Node* kls = makecon(TypeKlassPtr::make(klass)); Node* obj = new_instance(kls); // Push resultant oop onto stack push(obj); // Keep track of whether opportunities exist for StringBuilder // optimizations. if (OptimizeStringConcat && (klass == C->env()->StringBuilder_klass() || klass == C->env()->StringBuffer_klass())) { C->set_has_stringbuilder(true); } }
fruitapp::cursor::instance_sequence_unique_ptr fruitapp::cursor::manager::create_instances( fruitlib::scenic::optional_parent const &_parent) { fruitapp::cursor::instance_sequence_unique_ptr new_instance( fcppt::make_unique_ptr<fruitapp::cursor::instance_sequence>( *this, _parent)); fruitapp::cursor::instance_sequence * const new_instance_ptr = &*new_instance; instance_sequences_.insert( new_instance_ptr); for( auto const cursor : cursors_ ) new_instance->cursor_discover( *cursor); return new_instance; }
void Effect::update() { if(!running) return; // Check if we need to spawn another instance if((repeat_delay != 0) && (last_instanced + repeat_delay*1000.0 < QDateTime::currentMSecsSinceEpoch())){ // repeat_delay = 0 means we spawn only one instance new_instance(); } // Delete instances that lasted their full duration if(duration != 0){ // Duration = 0 means the effect stays there until its stoped for(auto i = instances.begin(); i != instances.end(); ++i){ if(((*i)->time_started + (int64_t)(duration*1000)) < QDateTime::currentMSecsSinceEpoch()){ i = instances.erase(i); } } } // Update instance positions if(follow){ for(auto &i: instances){ i->move(parent_pony->pos() + i->offset); } } }
//------------------------------do_new----------------------------------------- void Parse::do_new() { kill_dead_locals(); // The allocator will coalesce int->oop copies away. See comment in // coalesce.cpp about how this works. It depends critically on the exact // code shape produced here, so if you are changing this code shape // make sure the GC info for the heap-top is correct in and around the // slow-path call. bool will_link; ciInstanceKlass* klass = iter().get_klass(will_link)->as_instance_klass(); assert(will_link, "_new: typeflow responsibility"); // Should initialize, or throw an InstantiationError? if (!klass->is_initialized() || klass->is_abstract() || klass->is_interface() || klass->name() == ciSymbol::java_lang_Class()) { uncommon_trap(Deoptimization::Reason_uninitialized, Deoptimization::Action_reinterpret, klass); return; } Node* obj = new_instance(klass); // Push resultant oop onto stack push(obj); }
/* ** Creates a new game. First we create a new instance. If thhis function returns ** NULL, it means we've hit max players so we send a reject message and return ** non-zero to the server so it can log accordingly. After this, we generate a ** (pseduo) random code if none was supplied on initial execution. ** Finally we create a thread and pass it the StateInfo to work with. */ int create_game(int sock_id, char *ip4, char *correct, StateInfo *state_info) { // The thread ID will be set by pthread_create later. Instance *new_game = new_instance(state_info, sock_id, ip4, (pthread_t)-1); if (new_game == NULL) { // Error message currently hardcoded prepended with 0. // TODO this should be more extensible. send(sock_id, reject_message, OUTGOING_MSG_LEN, 0); close(sock_id); return -1; // blah do more errno or something? } if (correct == NULL) { new_game->code = get_random_code(); } else { new_game->code = correct; } // Write initial information to log upon client connection. char log_buf[LOG_MSG_LEN]; sprintf(log_buf, "(%s)(%d) Client connected.\n", ip4, sock_id); write_log(log_buf); sprintf(log_buf, "(0.0.0.0) Server secret = \"%s\".\n", new_game->code); write_log(log_buf); // Create the new thread and pass in the StateInfo. // We will relocate the appropriate instance inside the thread. pthread_create(&new_game->t, NULL, run_instance, state_info); return 0; }
FilterInstance *Filter::apply(Layer *lay) { FilterInstance *instance = new_instance(); if (apply(lay, instance)) return instance; delete instance; return NULL; }
void Effect::start() { running = true; // Add the first effect instance new_instance(); if(ConfigWindow::getSetting<bool>("general/debug")) { qDebug() << "Pony:"<<parent_pony->name<<"effect:"<< name <<"started."; } }
static value_t new_instance_of_string(runtime_t *runtime, value_t type) { value_t factories = ROOT(runtime, plankton_factories); value_t factory = get_id_hash_map_at(factories, type); if (in_family(ofFactory, factory)) { value_t new_instance_wrapper = get_factory_new_instance(factory); void *new_instance_ptr = get_void_p_value(new_instance_wrapper); factory_new_instance_t *new_instance = (factory_new_instance_t*) (intptr_t) new_instance_ptr; return new_instance(runtime); } else { return new_heap_seed(runtime, type, nothing()); } }
T2 Singleton_impl< T1, T2, T3 >::get_instance() { static Static_data static_data_; if(0 == static_data_.instance_.get()) { Guard_t guard(static_data_.lock_); if(0 == static_data_.instance_.get()) { Pointer_t new_instance(new T1()); if(0 != new_instance.get()) { std::swap(static_data_.instance_, new_instance); } } } return static_data_.instance_; }
u4 MemoryDataArray::new_array(int *a_size, u1 *a_type, Class *ref) { MemoryData *m ; if(a_type[0] != TYPE_ARRAY) { printf("Error not array type %c: mem_data_array.new_array",a_type[0]); exit(0); } m = new MemoryData; data[size] = m; size++; m->type = TYPE_ARRAY; m->array_type = a_type[1]; m->data_index = new int[ a_size[0] ]; m->data_count = a_size[0]; m->data_length = make_array_index(m); m->data = new u4[m->data_length]; if(a_type[1] == TYPE_CLASS) { if(ref == NULL) { printf("Error class ref null %s: mem_data_array.new_array\n",a_type); exit(0); } for(u4 i=0; i<m->data_count; i++) { m->data[i] = new_instance(ref); } } //#define TEST_NEW_ARRAY #ifdef TEST_NEW_ARRAY printf("TEST_NEW_ARRAY: mem_data_array\n"); printf("instance addr %p\n", m); printf("count %d\n",m->data_count); printf("size %d type %c\n", a_size[0], a_type[1]); printf("\n"); #endif if(a_type[1] == TYPE_ARRAY) { for(u4 i=0;i<m->data_count; i++) { m->data[i] = new_array(a_size+1, a_type+1, ref); #ifdef TEST_NEW_ARRAY printf("add get [%d] %08X",i,m->data[i]); #endif } } return (u4)m; }
void LIRGenerator::do_NewInstance(NewInstance* x) { #ifndef PRODUCT if (PrintNotLoaded && !x->klass()->is_loaded()) { tty->print_cr(" ###class not loaded at new bci %d", x->printable_bci()); } #endif CodeEmitInfo* info = state_for(x, x->state()); LIR_Opr reg = result_register_for(x->type()); LIR_Opr klass_reg = new_register(objectType); new_instance(reg, x->klass(), FrameMap::rcx_oop_opr, FrameMap::rdi_oop_opr, FrameMap::rsi_oop_opr, LIR_OprFact::illegalOpr, FrameMap::rdx_oop_opr, info); LIR_Opr result = rlock_result(x); __ move(reg, result); }
void LIRGenerator::do_NewInstance(NewInstance* x) { // This instruction can be deoptimized in the slow path : use // O0 as result register. const LIR_Opr reg = result_register_for(x->type()); if (PrintNotLoaded && !x->klass()->is_loaded()) { tty->print_cr(" ###class not loaded at new bci %d", x->bci()); } CodeEmitInfo* info = state_for(x, x->state()); LIR_Opr tmp1 = FrameMap::G1_oop_opr; LIR_Opr tmp2 = FrameMap::G3_oop_opr; LIR_Opr tmp3 = FrameMap::G4_oop_opr; LIR_Opr tmp4 = FrameMap::O1_oop_opr; LIR_Opr klass_reg = FrameMap::G5_oop_opr; new_instance(reg, x->klass(), tmp1, tmp2, tmp3, tmp4, klass_reg, info); LIR_Opr result = rlock_result(x); __ move(reg, result); }
int main(int argc, char* argv[]) { int validity_code = check_input_validity(argc, argv); if (validity_code) { print_usage(argv[0]); return validity_code; } download_instance* thz = new_instance(argc, argv); int ret_code = run_instance(thz); tear_down_instance(thz); return ret_code; }
// here the plugin creates an instance of our CPlugin object which // will be associated with this newly created plugin instance and // will do all the neccessary job NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char *argn[], char *argv[], NPSavedData * saved) { if (instance == NULL) return NPERR_INVALID_INSTANCE_ERROR; NPError rv = NPERR_NO_ERROR; printf("NPP_New called\n"); CPlugin *pPlugin = new CPlugin(instance); if (pPlugin == NULL) return NPERR_OUT_OF_MEMORY_ERROR; instance->pdata = (void *) pPlugin; pPlugin->mode = mode; pPlugin->mimetype = g_strdup(pluginType); pPlugin->mInstance = instance; new_instance(pPlugin, argc, argn, argv); return rv; }
int ipclite_client_create(ipclite **c, const char *msg, int flags) { ipclite_client *client; int pip[2]; if(! c) return IPCLITE_ERR_INV; if(pipe2(pip, O_NONBLOCK) == -1) { return IPCLITE_ERR_PIP; } if(! (client = new_instance(ipclite_client))) { close(pip[0]); close(pip[1]); return IPCLITE_ERR_OOM; } client->base.type = IPCLITE_CLIENT; client->base.msg = ((msg && *msg) ? strdup(msg) : NULL); client->base.handler = NULL; client->base.ud = NULL; client->base.master = -1; client->base.path[0] = '\0'; ipclite_port_init(&client->port, -1); client->port_state = client->port.state; client->peer = -1; client->notify[0] = pip[0]; client->notify[1] = pip[1]; pthread_mutex_init(&client->lock, NULL); pthread_cond_init(&client->cond, NULL); client->worker_started = 0; client->quit = 0; FD_ZERO(&client->rd); FD_ZERO(&client->wr); FD_SET(pip[0], &client->rd); client->max_fd = pip[0] + 1; pthread_mutex_init(&client->rd_lock, NULL); pthread_cond_init(&client->rd_cond, NULL); client->rd_quit = 0; client->rd_started = 0; list_init(&client->rd_queue); list_init(&client->req_queue); pthread_mutex_init(&client->wait_lock, NULL); pthread_cond_init(&client->wait_cond, NULL); client->wait_cnt = 0; list_init(&client->wait_queue); *c = (ipclite *)client; return IPCLITE_ERR_OK; }
match_t<IRInstruction, std::tuple<match_t<IRInstruction> > > new_instance() { return new_instance(any<IRInstruction>()); }
object uniform_type_info::deserialize(deserializer* from) const { auto ptr = new_instance(); deserialize(ptr, from); return {ptr, this}; }
object uniform_type_info::create() const { return {new_instance(), this}; }
// constructor MyWindow::MyWindow(int w, int h) : red_active(false), red_set(*(new Polygon_set)), blue_set(*(new Polygon_set)), res_set(*(new Polygon_set)) { widget = new CGAL::Qt_widget(this); //Constructs a widget which is a child of this window /* Sets the central widget for this main window to w. * The central widget is surrounded by the left, top, right and bottom dock areas. * The menu bar is above the top dock area */ setCentralWidget(widget); file_name= QString::null; //create a timer for checking if somthing changed QTimer *timer = new QTimer( this ); // constructs a timer whose parent is this window connect( timer, SIGNAL(timeout()), this, SLOT(timer_done()) ); // connects the timer to the window timer->start( 200, FALSE ); // Starts the timer with a msec milliseconds timeout // file menu QPopupMenu * file = new QPopupMenu( this ); menuBar()->insertItem( "&File", file ); file->insertItem("&New", this, SLOT(new_instance()), CTRL+Key_N); file->insertItem("New &Window", this, SLOT(new_window()), CTRL+Key_W); file->insertSeparator(); file->insertItem("&Open Linear Polygon file", this, SLOT(open_linear_polygon_file()),CTRL+Key_O); file->insertItem("&Open DXF file", this, SLOT(open_dxf_file()),CTRL+Key_D); file->insertSeparator(); //file->insertItem("&Save",this ,SLOT(save_file()),CTRL+Key_S); //file->insertItem("&Save as",this ,SLOT(save_file_as())); file->insertSeparator(); file->insertItem("Print", widget, SLOT(print_to_ps()), CTRL+Key_P); file->insertSeparator(); file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X ); file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q ); // help menu QPopupMenu * help = new QPopupMenu( this ); menuBar()->insertItem( "&Help", help ); help->insertItem("How To", this, SLOT(howto()), Key_F1); help->insertSeparator(); help->insertItem("&About", this, SLOT(about()), CTRL+Key_A ); help->insertItem("About &Qt", this, SLOT(aboutQt()) ); //the standard toolbar stoolbar = new CGAL::Qt_widget_standard_toolbar (widget, this, "ST"); radiotoolbar = new QToolBar(this, "polygon type"); blue_pgn = new QRadioButton ("Blue", radiotoolbar); blue_pgn->toggle(); red_pgn = new QRadioButton("Red", radiotoolbar); radio_group = new QVButtonGroup(this,"Radios"); radio_group->insert(blue_pgn); radio_group->insert(red_pgn); radio_group->setRadioButtonExclusive(true); connect(blue_pgn, SIGNAL(toggled (bool)), this, SLOT(radio_selected())); connect(red_pgn, SIGNAL(toggled (bool)), this, SLOT(radio_selected())); //layers //widget->attach(&testlayer); //the new tools toolbar newtoolbar = new Tools_toolbar(widget, this); // voronoi toolbar bops_toolbar = new QToolBar(this, "Boolean operations"); QIconSet set0(QPixmap( (const char**)intersection_xpm ), QPixmap( (const char**)intersection_xpm )); intersection_but = new QToolButton(bops_toolbar, "Boolean operations"); intersection_but->setAutoRaise(TRUE); intersection_but->setIconSet(set0); intersection_but->setTextLabel("Intersection "); connect(intersection_but,SIGNAL(pressed()), this, SLOT(perform_intersection())); QIconSet set1(QPixmap( (const char**)union_xpm ), QPixmap( (const char**)union_xpm )); bops_toolbar->addSeparator(); union_but = new QToolButton(bops_toolbar, "Boolean operations"); union_but->setAutoRaise(TRUE); union_but->setIconSet(set1); union_but->setTextLabel("Union "); connect(union_but,SIGNAL(pressed()), this, SLOT(perform_union())); QIconSet set2(QPixmap( (const char**)diff_PQ_xpm ), QPixmap( (const char**)diff_PQ_xpm )); bops_toolbar->addSeparator(); diff_but2 = new QToolButton(bops_toolbar, "Boolean operations"); diff_but2->setAutoRaise(TRUE); diff_but2->setIconSet(set2); diff_but2->setTextLabel("Difference between Blue and Red"); connect(diff_but2, SIGNAL(pressed()), this, SLOT(perform_diff2())); QIconSet set3(QPixmap( (const char**)diff_QP_xpm ), QPixmap( (const char**)diff_QP_xpm )); bops_toolbar->addSeparator(); diff_but = new QToolButton(bops_toolbar, "Boolean operations"); diff_but->setAutoRaise(TRUE); diff_but->setIconSet(set3); diff_but->setTextLabel("Difference between Red and Blue"); connect(diff_but, SIGNAL(pressed()), this, SLOT(perform_diff())); QIconSet set4(QPixmap( (const char**)symm_diff_xpm ), QPixmap( (const char**)symm_diff_xpm )); bops_toolbar->addSeparator(); symm_diff_but = new QToolButton(bops_toolbar, "Boolean operations"); symm_diff_but->setAutoRaise(TRUE); symm_diff_but->setIconSet(set4); symm_diff_but->setTextLabel("Symmetric Difference "); connect(symm_diff_but, SIGNAL(pressed()), this, SLOT(perform_symm_diff())); QIconSet set12(QPixmap( (const char**)mink_sum_xpm ), QPixmap( (const char**)mink_sum_xpm )); bops_toolbar->addSeparator(); mink_sum_but = new QToolButton(bops_toolbar, "Boolean operations"); mink_sum_but->setAutoRaise(TRUE); mink_sum_but->setIconSet(set12); mink_sum_but->setTextLabel("Minkowski Sum "); connect(mink_sum_but, SIGNAL(pressed()), this, SLOT(perform_mink_sum())); QIconSet set5(QPixmap( (const char**)comp_P_xpm ), QPixmap( (const char**)comp_P_xpm )); bops_toolbar->addSeparator(); blue_complement_but = new QToolButton(bops_toolbar, "Boolean operations"); blue_complement_but->setAutoRaise(TRUE); blue_complement_but->setIconSet(set5); blue_complement_but->setTextLabel("Blue Complement "); connect(blue_complement_but, SIGNAL(pressed()), this, SLOT(perform_blue_complement())); QIconSet set6(QPixmap( (const char**)comp_Q_xpm ), QPixmap( (const char**)comp_Q_xpm )); bops_toolbar->addSeparator(); red_complement_but = new QToolButton(bops_toolbar, "Boolean operations"); red_complement_but->setAutoRaise(TRUE); red_complement_but->setIconSet(set6); red_complement_but->setTextLabel("Red Complement "); connect(red_complement_but, SIGNAL(pressed()), this, SLOT(perform_red_complement())); QIconSet set7(QPixmap( (const char**)make_P_xpm ), QPixmap( (const char**)make_P_xpm )); bops_toolbar->addSeparator(); make_res_blue_but = new QToolButton(bops_toolbar, "Boolean operations"); make_res_blue_but->setAutoRaise(TRUE); make_res_blue_but->setIconSet(set7); make_res_blue_but->setTextLabel("Make Result Blue"); connect(make_res_blue_but,SIGNAL(pressed()), this, SLOT(make_res_blue())); QIconSet set8(QPixmap( (const char**)make_Q_xpm ), QPixmap( (const char**)make_Q_xpm )); bops_toolbar->addSeparator(); make_res_red_but = new QToolButton(bops_toolbar, "Boolean operations"); make_res_red_but->setAutoRaise(TRUE); make_res_red_but->setIconSet(set8); make_res_red_but->setTextLabel("Make Result Red"); connect(make_res_red_but,SIGNAL(pressed()), this, SLOT(make_res_red())); QIconSet set9(QPixmap( (const char**)refresh_xpm ), QPixmap( (const char**)refresh_xpm )); bops_toolbar->addSeparator(); refresh_but = new QToolButton(bops_toolbar, "Boolean operations"); refresh_but->setAutoRaise(TRUE); refresh_but->setIconSet(set9); refresh_but->setTextLabel("Refresh "); connect(refresh_but,SIGNAL(pressed()), this, SLOT(refresh())); QIconSet set10(QPixmap( (const char**)del_P_xpm ), QPixmap( (const char**)del_P_xpm )); bops_toolbar->addSeparator(); delete_blue_but = new QToolButton(bops_toolbar, "Boolean operations"); delete_blue_but->setAutoRaise(TRUE); delete_blue_but->setIconSet(set10); delete_blue_but->setTextLabel("Delete Blue Polygons"); connect(delete_blue_but,SIGNAL(pressed()), this, SLOT(delete_blue_polygons())); QIconSet set11(QPixmap( (const char**)del_Q_xpm ), QPixmap( (const char**)del_Q_xpm )); bops_toolbar->addSeparator(); delete_red_but = new QToolButton(bops_toolbar, "Boolean operations"); delete_red_but->setAutoRaise(TRUE); delete_red_but->setIconSet(set11); delete_red_but->setTextLabel("Delete Red Polygons"); connect(delete_red_but,SIGNAL(pressed()), this, SLOT(delete_red_polygons())); *widget << CGAL::LineWidth(2) << CGAL::BackgroundColor (CGAL::BLACK); resize(w,h); widget->set_window(-1, 1, -1, 1); widget->setMouseTracking(TRUE); //connect the widget to the main function that receives the objects connect(widget, SIGNAL(new_cgal_object(CGAL::Object)), this, SLOT(get_new_object(CGAL::Object))); //application flag stuff old_state = 0; current_state = 1; red_active = false; red_set.clear(); blue_set.clear(); res_set.clear(); }