void g (int a) { f0(); x.f0(); f0(a); /* { dg-error "too many arguments to function 'f0'" } */ x.f0(a); /* { dg-error "too many arguments to function 'x.f0'" } */ f0(a, a); /* { dg-error "too many arguments to function 'f0'" } */ x.f0(a, a); /* { dg-error "too many arguments to function 'x.f0'" } */ f1(); /* { dg-error "too few arguments to function 'f1'" } */ x.f1(); /* { dg-error "too few arguments to function 'x.f1'" } */ f1(a); x.f1(a); f1(a, a); /* { dg-error "too many arguments to function 'f1'" } */ x.f1(a, a); /* { dg-error "too many arguments to function 'x.f1'" } */ f1v(); /* { dg-error "too few arguments to function 'f1v'" } */ x.f1v(); /* { dg-error "too few arguments to function 'x.f1v'" } */ f1v(a); x.f1v(a); f1v(a, a); x.f1v(a, a); f2(a); /* { dg-error "too few arguments to function 'f2'" } */ x.f2(a); /* { dg-error "too few arguments to function 'x.f2'" } */ f2(a, a); x.f2(a, a); f2(a, a, a); /* { dg-error "too many arguments to function 'f2'" } */ x.f2(a, a, a); /* { dg-error "too many arguments to function 'x.f2'" } */ f2v(a); /* { dg-error "too few arguments to function 'f2v'" } */ x.f2v(a); /* { dg-error "too few arguments to function 'x.f2v'" } */ f2v(a, a); x.f2v(a, a); f2v(a, a, a); x.f2v(a, a, a); }
void Message::innerDisplay(std::string name, struct netField *message) { uint8_t field= 0; struct netField *nf= message; if (hasSub) { while( nf->type != MP_END) { field++; switch(nf->type) { case MP_ARRAYFIXED: case MP_ARRAY_VAR_SMALL: case MP_ARRAY_VAR_LARGE: case MP_OPTIONAL: { uint32_t addr; if (inSection(&secRdata, nf->refTypeDef)) addr= f2v(&secRdata, nf->refTypeDef); else addr= f2v(&secData, nf->refTypeDef); std::stringstream ss; ss << name << '_' << std::hex << (uint32_t)field; innerDisplay(ss.str(), (struct netField *)addr); } break; default: break; } nf++; } } std::cout << "struct netFieldI " << name << "[] = {" << std::endl; decodeFields(name, message); }
int main(int argc, char *argv[]) { bfd *tmp_bfd = NULL; bfd_byte *p; uint32_t *call; uint32_t *rcv; uint32_t *snd; uint8_t rcvCount; uint8_t sndCount; uint32_t *scan; MessageMap msgs; if (argc < 2) { printf("Specify filename\n"); exit(1); } tmp_bfd = bfd_openr (argv[1], NULL); if (tmp_bfd == NULL) { printf ("Error openning file"); exit(1); } //check if the file is in format if (!bfd_check_format (tmp_bfd, bfd_object)) { if (bfd_get_error () != bfd_error_file_ambiguously_recognized) { printf("Incompatible format\n"); exit(1); } } secText.sec = bfd_get_section_by_name(tmp_bfd, ".text"); bfd_malloc_and_get_section(tmp_bfd, secText.sec, &secText.data); secRdata.sec = bfd_get_section_by_name(tmp_bfd, ".rdata"); if (!secRdata.sec) { printf("Failed to get section\n"); exit(10); } if (!bfd_malloc_and_get_section(tmp_bfd, secRdata.sec, &secRdata.data)) { printf("Alloc error\n"); exit(10); } secData.sec = bfd_get_section_by_name(tmp_bfd, ".data"); if (!secData.sec) { printf("Failed to get section\n"); exit(10); } if (!bfd_malloc_and_get_section(tmp_bfd, secData.sec, &secData.data)) { printf("Alloc error\n"); exit(10); } /* 406060: 68 40 6f 0e 01 push $0x10e6f40 406065: 6a 06 push $0x6 406067: 68 38 6f 0e 01 push $0x10e6f38 40606c: 6a 02 push $0x2 40606e: 33 d2 xor %edx,%edx 406070: 33 c9 xor %ecx,%ecx 406072: e8 e9 16 5e 00 call 0x9e7760 */ for(p= secText.data; p < secText.data+bfd_section_size(tmp_bfd, secText.sec); p++) { if ( p< secText.data+bfd_section_size(tmp_bfd, secText.sec)-22 && isMsgRegister(p, &rcv, &rcvCount, &snd, &sndCount, &call) ) { uint8_t i; bfd_vma dest; scan= NULL; if (rcvCount) { if (inSection(&secRdata, (bfd_vma)rcv)) rcv= (uint32_t *)f2v(&secRdata, (uint32_t)rcv); else rcv= (uint32_t *)f2v(&secData, (uint32_t)rcv); scan= rcv; } if (sndCount) { if (inSection(&secRdata, (bfd_vma)snd)) snd= (uint32_t *)f2v(&secRdata, (uint32_t)snd); else snd= (uint32_t *)f2v(&secData, (uint32_t)snd); scan= snd; } char *text= NULL; char *clitext= NULL; if (scan) { for(uint32_t *cp = scan-0x200; cp < scan; cp++) { char *p; if ((p=strstr((char *)cp, ".cpp")) == NULL) continue; while(*p != '\\') p--; text= &p[1]; if (strstr(text, "Cli")) clitext= text; } if (!text) { printf("Name missing\n"); exit(1); } } #if 0 if (clitext) text= clitext; #endif if (rcvCount) { rcvCount *= 2; for(i=0; i< rcvCount; i++) { if ( !(i%2) && !inSection(&secData, rcv[i]) && !inSection(&secRdata, rcv[i])) { //printf("Not in (r)data section\n"); goto next; } if ( (i%2) && !inSection(&secText, rcv[i])) { //printf("Not in text section 0x%p\n", rcv[i]); goto next; } } for(i=0; i< rcvCount; i+=2) { struct netField *nf= (struct netField *) f2v(&secData, rcv[i]); msgs.insert( MessageEntry(call, Message(text,nf, true) )); } } if (sndCount) { for(i=0; i< sndCount; i++) { if ( !inSection(&secData, snd[i])) goto next; } for(i=0; i< sndCount; i++) { struct netField *nf= (struct netField *) f2v(&secData, snd[i]); msgs.insert( MessageEntry(call, Message(text,nf, false) )); } } } next:; } std::cout << "#ifndef PACKETS_H\n" << "#define PACKETS_H\n" << "#include \"netfield.hpp\"\n" << std::endl; for(MessageMap::iterator m = msgs.begin(); m != msgs.end(); ++m) { Message msg = m->second; msg.display(); } // Server Messages uint32_t *oldcall= NULL; for(MessageMap::iterator m = msgs.begin(); m != msgs.end(); ++m) { uint32_t *call = m->first; Message msg = m->second; if (!msg.isServer) continue; if (oldcall != call) { if (oldcall) std::cout << "\tNULL" << "};\n\n"; std::cout << "struct netFieldI *serverMsgPack_" << msg.getBasicName() << "[] = {" << std::endl; oldcall = call; } std::cout << "\t" << msg.getName() << "," << std::endl; } std::cout << "\tNULL\n" <<"};\n\n" << std::endl; // Client Messages oldcall= NULL; for(MessageMap::iterator m = msgs.begin(); m != msgs.end(); ++m) { uint32_t *call = m->first; Message msg = m->second; if (msg.isServer) continue; if (oldcall != call) { if (oldcall) std::cout << "\tNULL" << "};\n\n"; std::cout << "struct netFieldI *clientMsgPack_" << msg.getBasicName() << "[] = {" << std::endl; oldcall = call; } std::cout << "\t" << msg.getName() << "," << std::endl; } std::cout << "\tNULL\n" <<"};\n\n" << "#endif" << std::endl; return 0; }
SettingsFrame::SettingsFrame(CreatorFrame* parent, trance_pb::System& system) : wxFrame{parent, wxID_ANY, "System settings", wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN} , _system{system} , _parent{parent} { auto panel = new wxPanel{this}; auto sizer = new wxBoxSizer{wxVERTICAL}; auto top = new wxBoxSizer{wxHORIZONTAL}; auto bottom = new wxBoxSizer{wxHORIZONTAL}; auto left = new wxStaticBoxSizer{wxVERTICAL, panel, "Memory"}; auto right = new wxStaticBoxSizer{wxVERTICAL, panel, "Rendering"}; auto right_mode = new wxBoxSizer{wxHORIZONTAL}; _monitor = new wxRadioButton{panel, wxID_ANY, "Monitor", wxDefaultPosition, wxDefaultSize, wxRB_GROUP}; _oculus = new wxRadioButton{panel, wxID_ANY, "Oculus Rift"}; _openvr = new wxRadioButton{panel, wxID_ANY, "SteamVR"}; _enable_vsync = new wxCheckBox{panel, wxID_ANY, "Enable VSync"}; _image_cache_size = new wxSpinCtrl{panel, wxID_ANY}; _animation_buffer_size = new wxSpinCtrl{panel, wxID_ANY}; _font_cache_size = new wxSpinCtrl{panel, wxID_ANY}; _draw_depth = new wxSlider{panel, wxID_ANY, f2v(_system.draw_depth().draw_depth()), 0, 8, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_VALUE_LABEL}; _eye_spacing = new wxSpinCtrlDouble{panel, wxID_ANY}; auto button_ok = new wxButton{panel, wxID_ANY, "OK"}; auto button_cancel = new wxButton{panel, wxID_ANY, "Cancel"}; _button_apply = new wxButton{panel, wxID_ANY, "Apply"}; _monitor->SetToolTip(MONITOR_TOOLTIP); _oculus->SetToolTip(OCULUS_TOOLTIP); _openvr->SetToolTip(OPENVR_TOOLTIP); if (system.renderer() == trance_pb::System::OPENVR) { _openvr->SetValue(true); } else if (system.renderer() == trance_pb::System::OCULUS) { _oculus->SetValue(true); } else { _monitor->SetValue(true); _eye_spacing->Disable(); } _enable_vsync->SetToolTip(VSYNC_TOOLTIP); _enable_vsync->SetValue(_system.enable_vsync()); _image_cache_size->SetToolTip(IMAGE_CACHE_SIZE_TOOLTIP); _image_cache_size->SetRange(16, 1024); _image_cache_size->SetValue(_system.image_cache_size()); _animation_buffer_size->SetToolTip(ANIMATION_BUFFER_SIZE_TOOLTIP); _animation_buffer_size->SetRange(8, 512); _animation_buffer_size->SetValue(_system.animation_buffer_size()); _font_cache_size->SetToolTip(FONT_CACHE_SIZE_TOOLTIP); _font_cache_size->SetRange(2, 256); _font_cache_size->SetValue(_system.font_cache_size()); _draw_depth->SetToolTip(DRAW_DEPTH_TOOLTIP); _eye_spacing->SetToolTip(EYE_SPACING_TOOLTIP); _eye_spacing->SetRange(-1., 1.); _eye_spacing->SetIncrement(1. / 128); _eye_spacing->SetValue(_system.eye_spacing().eye_spacing()); sizer->Add(top, 1, wxEXPAND, 0); sizer->Add(bottom, 0, wxEXPAND, 0); top->Add(left, 1, wxALL | wxEXPAND, DEFAULT_BORDER); top->Add(right, 1, wxALL | wxEXPAND, DEFAULT_BORDER); wxStaticText* label = nullptr; label = new wxStaticText{panel, wxID_ANY, "Image cache size:"}; label->SetToolTip(IMAGE_CACHE_SIZE_TOOLTIP); left->Add(label, 0, wxALL, DEFAULT_BORDER); left->Add(_image_cache_size, 0, wxALL | wxEXPAND, DEFAULT_BORDER); label = new wxStaticText{panel, wxID_ANY, "Animation buffer size:"}; label->SetToolTip(ANIMATION_BUFFER_SIZE_TOOLTIP); left->Add(label, 0, wxALL, DEFAULT_BORDER); left->Add(_animation_buffer_size, 0, wxALL | wxEXPAND, DEFAULT_BORDER); label = new wxStaticText{panel, wxID_ANY, "Font cache size:"}; label->SetToolTip(IMAGE_CACHE_SIZE_TOOLTIP); left->Add(label, 0, wxALL, DEFAULT_BORDER); left->Add(_font_cache_size, 0, wxALL | wxEXPAND, DEFAULT_BORDER); label = new wxStaticText{panel, wxID_ANY, "Rendering mode:"}; right->Add(right_mode, 0, wxALL | wxEXPAND, DEFAULT_BORDER); right_mode->Add(_monitor, 1, wxALL, DEFAULT_BORDER); right_mode->Add(_oculus, 1, wxALL, DEFAULT_BORDER); right_mode->Add(_openvr, 1, wxALL, DEFAULT_BORDER); right->Add(_enable_vsync, 0, wxALL, DEFAULT_BORDER); label = new wxStaticText{panel, wxID_ANY, "Draw depth:"}; label->SetToolTip(DRAW_DEPTH_TOOLTIP); right->Add(label, 0, wxALL, DEFAULT_BORDER); right->Add(_draw_depth, 0, wxALL | wxEXPAND, DEFAULT_BORDER); _eye_spacing_label = new wxStaticText{panel, wxID_ANY, "Eye spacing (in VR):"}; _eye_spacing_label->SetToolTip(EYE_SPACING_TOOLTIP); right->Add(_eye_spacing_label, 0, wxALL, DEFAULT_BORDER); right->Add(_eye_spacing, 0, wxALL | wxEXPAND, DEFAULT_BORDER); bottom->Add(button_ok, 1, wxALL, DEFAULT_BORDER); bottom->Add(button_cancel, 1, wxALL, DEFAULT_BORDER); bottom->Add(_button_apply, 1, wxALL, DEFAULT_BORDER); _eye_spacing_label->Enable(!_monitor->GetValue()); _eye_spacing->Enable(!_monitor->GetValue()); _button_apply->Enable(false); panel->SetSizer(sizer); SetClientSize(sizer->GetMinSize()); CentreOnParent(); Show(true); auto changed = [&](wxCommandEvent&) { Changed(); }; Bind(wxEVT_RADIOBUTTON, changed); Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, changed); Bind(wxEVT_SLIDER, changed); Bind(wxEVT_SPINCTRL, changed); Bind(wxEVT_SPINCTRLDOUBLE, changed); button_ok->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [&](wxCommandEvent&) { Apply(); Close(); }); button_cancel->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [&](wxCommandEvent&) { Close(); }); _button_apply->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [&](wxCommandEvent&) { Apply(); }); Bind(wxEVT_CLOSE_WINDOW, [&](wxCloseEvent& event) { _parent->SettingsClosed(); Destroy(); }); }