varargs protected void setup_messages(string name, mixed up_dest, mixed down_dest) { string dirs; if(up_dest) add_method("ascend",up_dest); if(down_dest) add_method("descend",down_dest); if (up_dest) { if (down_dest) dirs = "up and down"; else dirs = "upwards"; } else { if( down_dest ) dirs = "downwards"; else dirs = "nowhere"; } if (query_plural()) add_id_no_plural(name); else add_id( name ); set_long(sprintf("The %s %s %s", name, query_plural()?"lead":"leads", dirs) ); set_in_room_desc(sprintf("There %s %s here, leading %s.", query_plural()?"are ":"is a ", name, dirs) ); }
ResoundSession::ResoundSession(CLIOptions options) : Resound::OSCManager(options.oscPort_.c_str()), options_(options) { // setup ladspa hosting ladspaHost = new LadspaHost(); // diskstream threads pthread_mutex_init (&diskstreamThreadLock_, NULL); pthread_cond_init(&diskstreamThreadReady_, NULL); // registering some factories register_behaviour_factory("diskstream", Diskstream::factory); register_behaviour_factory("livestream", Livestream::factory); register_behaviour_factory("att", AttBehaviour::factory); register_behaviour_factory("mpc", MultipointCrossfadeBehaviour::factory); register_behaviour_factory("chase", ChaseBehaviour::factory); register_behaviour_factory("amppan", AmpPanBehaviour::factory); register_behaviour_factory("gain", GainInsertBehaviour::factory); register_behaviour_factory("ringmod", RingmodInsertBehaviour::factory); register_behaviour_factory("ladspa", LADSPABehaviour::factory); init("resoundnv-session"); ///activate jack ports cannot be connected until active start(); // register transport osc parameters add_method("/resound/t1/play","i", ResoundSession::lo_play, this); add_method("/resound/t1/stop","i", ResoundSession::lo_stop, this); add_method("/resound/t1/seek","i", ResoundSession::lo_seek, this); }
static int new_obj(lua_State *lstate) { dev_stop(); lua_newtable(lstate); set_value(lstate, "card"); set_userdata(lstate, "intern", (void *)&unit); add_method(lstate, "capture", capture); add_method(lstate, "stop", lua_stop); add_fader_methods(lstate); return 1; }
static void parse_methods(const char *p) { const compress_t *c; for (;;) { if (p == NULL || p[0] == 0) usage(argv0,-1,1); else if ((c = find_method(p)) != NULL) add_method(c->id); else if (m_strcmp(p,"all") == 0 || m_strcmp(p,"avail") == 0) add_all_methods(1,M_LAST_COMPRESSOR); else if (m_strcmp(p,"ALL") == 0) { add_all_methods(1,M_LAST_COMPRESSOR); add_all_methods(9721,9729); add_all_methods(9781,9789); } else if (m_strcmp(p,"lzo") == 0) add_all_methods(1,M_MEMCPY); else if (m_strcmp(p,"bench") == 0) add_methods(benchmark_methods); else if (m_strcmp(p,"m1") == 0) add_methods(x1_methods); else if (m_strcmp(p,"m99") == 0) add_methods(x99_methods); else if (m_strcmp(p,"m999") == 0) add_methods(x999_methods); else if (m_strcmp(p,"1x999") == 0) add_all_methods(9721,9729); else if (m_strcmp(p,"1y999") == 0) add_all_methods(9821,9829); #if defined(ALG_ZLIB) else if (m_strcmp(p,"zlib") == 0) add_all_methods(M_ZLIB_8_1,M_ZLIB_8_9); #endif #if defined(MFX) # include "maint/t_opt_m.ch" #endif else if (m_strisdigit(p)) add_method(atoi(p)); else { printf("%s: invalid method '%s'\n\n",argv0,p); exit(EXIT_USAGE); } while (*p && *p != ',') p++; while (*p == ',') p++; if (*p == 0) return; } }
int flac_feed(lua_State *lstate) { lua_newtable(lstate); set_value(lstate, "mount"); set_value(lstate, "port"); set_value(lstate, "host"); set_userdata(lstate, "intern", alloc_flac_feed()); add_method(lstate, "play", play_flac); add_method(lstate, "stop", stop_feed); add_fader_methods(lstate); return 1; }
static void add_method(reachable_method_stack_t** s, reachable_type_t* t, const char* name, ast_t* typeargs) { reachable_method_name_t* n = reach_method_name(t, name); if(n == NULL) { n = POOL_ALLOC(reachable_method_name_t); n->name = name; reachable_methods_init(&n->r_methods, 0); reachable_method_names_put(&t->methods, n); } add_rmethod(s, t, n, typeargs); // Add to subtypes if we're an interface or trait. ast_t* def = (ast_t*)ast_data(t->type); switch(ast_id(def)) { case TK_INTERFACE: case TK_TRAIT: { size_t i = HASHMAP_BEGIN; reachable_type_t* t2; while((t2 = reachable_type_cache_next(&t->subtypes, &i)) != NULL) add_method(s, t2, name, typeargs); break; } default: {} } }
static void reachable_method(reachable_method_stack_t** s, reachable_types_t* r, uint32_t* next_type_id, ast_t* type, const char* name, ast_t* typeargs) { switch(ast_id(type)) { case TK_NOMINAL: { reachable_type_t* t = add_type(s, r, next_type_id, type); add_method(s, t, name, typeargs); break; } case TK_UNIONTYPE: case TK_ISECTTYPE: { ast_t* child = ast_child(type); while(child != NULL) { ast_t* find = lookup_try(NULL, NULL, child, name); if(find != NULL) reachable_method(s, r, next_type_id, child, name, typeargs); child = ast_sibling(child); } break; } default: assert(0); } }
// Process the given provided method for the given entity. // The method passed should be reified already and will be freed by this // function. static bool provided_method(ast_t* entity, ast_t* reified_method, ast_t* raw_method, ast_t** last_method) { assert(entity != NULL); assert(reified_method != NULL); assert(last_method != NULL); const char* entity_name = ast_name(ast_child(entity)); if(ast_id(reified_method) == TK_BE || ast_id(reified_method) == TK_NEW) { // Modify return type to the inheritting type ast_t* ret_type = ast_childidx(reified_method, 4); assert(ast_id(ret_type) == TK_NOMINAL); const char* pkg_name = package_name(ast_nearest(entity, TK_PACKAGE)); ast_set_name(ast_childidx(ret_type, 0), pkg_name); ast_set_name(ast_childidx(ret_type, 1), entity_name); } // Ignore docstring ast_t* doc = ast_childidx(reified_method, 7); if(ast_id(doc) == TK_STRING) { ast_set_name(doc, ""); ast_setid(doc, TK_NONE); } // Check for existing method of the same name const char* name = ast_name(ast_childidx(reified_method, 1)); assert(name != NULL); ast_t* existing = ast_get(entity, name, NULL); if(existing != NULL && is_field(existing)) { ast_error(existing, "field '%s' clashes with provided method", name); ast_error(raw_method, "method is defined here"); ast_free_unattached(reified_method); return false; } existing = add_method(entity, existing, reified_method, last_method); if(existing == NULL) { ast_free_unattached(reified_method); return false; } method_t* info = (method_t*)ast_data(existing); assert(info != NULL); if(!record_default_body(reified_method, raw_method, info)) ast_free_unattached(reified_method); return true; }
static void add_all_methods(int first, int last) { int m; for (m = first; m <= last; m++) if (info(m,NULL) != NULL) add_method(m); }
void record_disqualified_method(Method* m) { // If not in the set, add it as disqualified. If it's already in the set, // then set the state to disqualified no matter what the previous state was. if (!contains_method(m)) { add_method(m, DISQUALIFIED); } else { disqualify_method(m); } }
void record_qualified_method(Method* m) { // If the method already exists in the set as qualified, this operation is // redundant. If it already exists as disqualified, then we leave it as // disqualfied. Thus we only add to the set if it's not already in the // set. if (!contains_method(m)) { add_method(m, QUALIFIED); } }
// Process the given provided method for the given entity. // The method passed should be reified already and will be freed by this // function. static bool provided_method(pass_opt_t* opt, ast_t* entity, ast_t* reified_method, ast_t* raw_method, ast_t** last_method) { assert(entity != NULL); assert(reified_method != NULL); assert(last_method != NULL); AST_GET_CHILDREN(reified_method, cap, id, typeparams, params, result, can_error, body, doc); if(ast_id(reified_method) == TK_BE || ast_id(reified_method) == TK_NEW) { // Modify return type to the inheriting type ast_t* this_type = type_for_this(opt, entity, ast_id(cap), TK_EPHEMERAL, true); ast_replace(&result, this_type); } // Ignore docstring if(ast_id(doc) == TK_STRING) { ast_set_name(doc, ""); ast_setid(doc, TK_NONE); } // Check for existing method of the same name const char* name = ast_name(id); assert(name != NULL); ast_t* existing = ast_get(entity, name, NULL); if(existing != NULL && is_field(existing)) { ast_error(existing, "field '%s' clashes with provided method", name); ast_error(raw_method, "method is defined here"); ast_free_unattached(reified_method); return false; } existing = add_method(entity, existing, reified_method, last_method); if(existing == NULL) { ast_free_unattached(reified_method); return false; } method_t* info = (method_t*)ast_data(existing); assert(info != NULL); if(!record_default_body(reified_method, raw_method, info)) ast_free_unattached(reified_method); return true; }
void relocate_method(DexMethod* method, DexType* to_type) { auto from_cls = type_class(method->get_class()); auto to_cls = type_class(to_type); from_cls->remove_method(method); DexMethodSpec spec; spec.cls = to_type; method->change(spec, true /* rename on collision */, true /* update deobfuscated name */); to_cls->add_method(method); }
static void add_special(reachable_method_stack_t** s, reachable_type_t* t, ast_t* type, const char* special) { special = stringtab(special); ast_t* find = lookup_try(NULL, NULL, type, special); if(find != NULL) { add_method(s, t, special, NULL); ast_free_unattached(find); } }
static int new_obj(lua_State *lstate) { GEN *gen; lua_Number duration, gain; char gentype[64]; duration = -1.0; gain = 1.0; strcpy(gentype, lua_tostring(lstate, -2)); lua_remove(lstate, -2); getnumber(lstate, "duration", &duration); getnumber(lstate, "gain", &gain); gen = (GEN *)malloc(sizeof(GEN)); gen->data = NULL; gen->init = NULL; gen->generate = NULL; gen->phase = 0.0; if (strcmp(gentype, "fm") == 0) { fm_init(lstate, gen); gen->generate = fm_generate; } else if (strcmp(gentype, "sine") == 0) { sine_init(lstate, gen); gen->generate = sine_generate; } else if (strcmp(gentype, "white") == 0) { gen->generate = white_generate; } lua_pop(lstate, 1); lua_newtable(lstate); init_fader(&(gen->unit.fader), gain); gen->running = 0; lua_pushstring(lstate, "intern"); lua_pushlightuserdata(lstate, (void *)gen); lua_settable(lstate, -3); add_method(lstate, "play", gen_play); add_fader_methods(lstate); add_method(lstate, "stop", gen_stop); gen->final_frame = duration * jack_sr; gen->pos = 0; return 1; }
DexClass* create_class(const DexType* type, const DexType* super_type, const std::string& pkg_name, std::vector<DexField*> fields, const TypeSet& interfaces, bool with_default_ctor, DexAccessFlags access) { DexType* t = const_cast<DexType*>(type); always_assert(!pkg_name.empty()); auto name = std::string(type->get_name()->c_str()); name = pkg_name + "/" + name.substr(1); t->set_name(DexString::make_string(name)); // Create class. ClassCreator creator(t); creator.set_access(access); always_assert(super_type != nullptr); creator.set_super(const_cast<DexType*>(super_type)); for (const auto& itf : interfaces) { creator.add_interface(const_cast<DexType*>(itf)); } for (const auto& field : fields) { creator.add_field(field); } auto cls = creator.create(); // Keeping type-erasure generated classes from being renamed. cls->rstate.set_keep_name(); if (!with_default_ctor) { return cls; } // Create ctor. auto super_ctors = type_class(super_type)->get_ctors(); for (auto super_ctor : super_ctors) { auto mc = new MethodCreator(t, DexString::make_string("<init>"), super_ctor->get_proto(), ACC_PUBLIC | ACC_CONSTRUCTOR); // Call to super.<init> std::vector<Location> args; size_t args_size = super_ctor->get_proto()->get_args()->size(); for (size_t arg_loc = 0; arg_loc < args_size + 1; ++arg_loc) { args.push_back(mc->get_local(arg_loc)); } auto mb = mc->get_main_block(); mb->invoke(OPCODE_INVOKE_DIRECT, super_ctor, args); mb->ret_void(); auto ctor = mc->create(); TRACE(TERA, 4, " default ctor created %s\n", SHOW(ctor)); cls->add_method(ctor); } return cls; }
void attach_method(STATE, CallFrame* call_frame, Object* recv, Symbol* name, CompiledMethod* method) { if(Module* mod = try_as<Module>(recv)) { StaticScope* ss = StaticScope::create(state); ss->module(state, mod); ss->parent(state, method->scope()); method->scope(state, ss); } else { /* Push the current scope down. */ method->scope(state, call_frame->static_scope()); } add_method(state, call_frame, recv->metaclass(state), name, method); }
static void add_methods_to_type(reachable_method_stack_t** s, reachable_type_t* from, reachable_type_t* to) { size_t i = HASHMAP_BEGIN; reachable_method_name_t* n; while((n = reachable_method_names_next(&from->methods, &i)) != NULL) { size_t j = HASHMAP_BEGIN; reachable_method_t* m; while((m = reachable_methods_next(&n->r_methods, &j)) != NULL) add_method(s, to, n->name, m->typeargs); } }
void setup() { set_relations("on"); set_adj("ugly"); set_id("horse"); set_long("Damn, the horse is ugly!"); add_relation("on",VERY_LARGE*2); set_default_relation("on"); // So people will see: Sitting on the horse you see Rust... // set_primary_verb("sitting"); set_in_room_desc("There is an ugly horse here."); set_get_on_msg("$N $vget onto the ugly horse.\n"); set_get_off_msg("$N $vdismount from the ugly horse.\n"); // We could opt for simple messages, and uncomment these // 2 lines, but we can also go for more complex msgs (see below). set_arrival_msg("$N $vtrot off.\n"); set_departure_msg("$N $vtrot in.\n"); add_method("mount", this_object()); add_method("dismount", (: environment(this_object()) :) ); }
static void add_node(Env* env, rtable nodes, rtable methods, Node* node, WorkList& work, KeyMap& keys, uint32_t threshold) { // We haven't exited this method yet, so its stats won't be accurate if(node->method()->timer.started()) return; rinteger key = env->integer_new(node->id()); rarray tbl = env->array_new(5); env->table_store(nodes, key, tbl); robject meth_key = add_method(env, methods, node->method(), keys); env->array_set(tbl, 0, meth_key); env->array_set(tbl, 1, env->integer_new(node->total())); env->array_set(tbl, 2, env->integer_new(node->called())); int count = node->count_sub_nodes(); env->array_set(tbl, 3, env->integer_new(count)); rarray ary = env->array_new(count); int idx = 0; Node* sub = node->sub_nodes(); while(sub) { if(sub->total() >= threshold) { env->array_set(ary, idx++, env->integer_new(sub->id())); work.push_back(sub); } sub = sub->sibling(); } env->array_set(tbl, 4, ary); }
SEXP init_java(SEXP classpath) { JavaVMInitArgs initArgs; initArgs.version = JNI_VERSION_1_4; JavaVMOption options[2]; std::string classpath_optstr = "-Djava.class.path="; classpath_optstr += CHAR(STRING_ELT(classpath,0)); // these lines require explicit casts to cast away const-ness. I'm trusting // Java won't be modifying the options strings. options[0].optionString = (char*)classpath_optstr.c_str(); options[1].optionString = (char*)"-Djava.version=1.5"; initArgs.options=options; initArgs.nOptions = 2; //jint JNI_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize *nVMs); // See if there's a pre-existing VM, and use it if so. Only the first VM returned // is used. jsize numvms; JavaVM *existing_vm; JNI_GetCreatedJavaVMs(&existing_vm, 1, &numvms); if(numvms > 0) existing_vm->AttachCurrentThread((void**)&env, NULL); else JNI_CreateJavaVM(&jvm, (void**)&env, (void*)&initArgs); add_class("RDirectBufferData", "edu/stanford/math/plex/RDirectBufferData"); add_method("RDirectBufferData", "<init>", "(ILjava/nio/ByteBuffer;)V"); add_class("RipsStream", "edu/stanford/math/plex/RipsStream"); add_method("RipsStream", "<init>", "(DDILedu/stanford/math/plex/PointData;)V"); add_class("Persistence","edu/stanford/math/plex/Persistence"); add_method("Persistence", "<init>", "()V"); add_method("Persistence","computeIntervals", "(Ledu/stanford/math/plex/SimplexStream;)[Ledu/stanford/math/plex/PersistenceInterval$Float;"); add_class("PersistenceInterval.Float","edu/stanford/math/plex/PersistenceInterval$Float"); add_method("PersistenceInterval.Float", "<init>", "()V"); add_method("PersistenceInterval.Float", "2<init>", "(IDD)V"); add_class("LazyWitnessStream", "edu/stanford/math/plex/LazyWitnessStream"); add_method("LazyWitnessStream", "<init>", "(DIDI[ILedu/stanford/math/plex/PointData;)V"); add_class("WitnessStream", "edu/stanford/math/plex/WitnessStream"); add_method("WitnessStream", "<s>makeRandomLandmarks", "(Ledu/stanford/math/plex/PointData;I)[I"); add_method("WitnessStream", "<s>estimateRmax", "(Ledu/stanford/math/plex/PointData;[I)D"); add_class("Plex", "edu/stanford/math/plex/Plex"); add_method("Plex", "<s>FilterInfinite", "([Ledu/stanford/math/plex/PersistenceInterval;)Ledu/stanford/math/plex/Plex$BettiNumbers;"); add_class("Plex.BettiNumbers", "edu/stanford/math/plex/Plex$BettiNumbers"); add_method("Plex.BettiNumbers", "toString", "()Ljava/lang/String;"); add_class("ExplicitStream", "edu/stanford/math/plex/ExplicitStream"); add_method("ExplicitStream", "<init>", "()V"); add_method("ExplicitStream", "open", "()V"); add_method("ExplicitStream", "close", "()V"); add_method("ExplicitStream", "add", "([ID)V"); add_method("ExplicitStream", "remove", "([I)V"); add_class("EuclideanArrayData", "edu/stanford/math/plex/EuclideanArrayData"); add_method("EuclideanArrayData", "<init>", "([DI)V"); add_method("EuclideanArrayData", "2<init>", "(II)V"); p = env->NewObject(cl["Persistence"], fn["Persistence.<init>"]); return(R_NilValue); }
void node::import_methods(const method_info *info) { for (int k = 0; info[k].name; k++) { add_method(&info[k]); } }
// class constructor Resound::PerformanceView::PerformanceView(wxWindow* parent) : wxScrolledWindow(parent, wxID_ANY, wxPoint(0,0), wxSize(320,240)), OSCManager(ResoundClient::get_instance().get_client_port().c_str()) { // insert your code here wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *upperTierSizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer *lowerTierSizer = new wxBoxSizer( wxHORIZONTAL ); Resound::MasterFader* temp; // temporary, for storing MasterFaders in fader array. int fId = 0; int n, g; for(n = 0; n < 4; n++) // create top row of MasterFaders { wxBoxSizer* grp = new wxBoxSizer(wxHORIZONTAL); for(g = 0; g < 4; g++) { temp = new Resound::MasterFader(this,fId++, 7); // create new MasterFader // register with OSC /// NOTE this is in two blocks see below std::stringstream s; s << "/fader/" << fId; add_method(s.str(),"f",Resound::PerformanceView::lo_cb_att, (void*)temp); /// end of block OSC masterFaderArray.push_back(temp); // store in array grp->Add(temp, wxSizerFlags(1).Align(0).Border(wxALL,1)); // add to GUI }void on_select_preset(wxCommandEvent& evt); upperTierSizer->Add(grp, wxSizerFlags(1).Align(0).Border(wxALL,5)); } for(n = 0; n < 4; n++) // create bottom row of MasterFaders { wxBoxSizer* grp = new wxBoxSizer(wxHORIZONTAL); for(g = 0; g < 4; g++) { temp = new Resound::MasterFader(this,fId++, 10); // create new MasterFader // register with OSC /// NOTE this is in two blocks see above std::stringstream s; s << "/fader/" << fId; add_method(s.str(),"f",Resound::PerformanceView::lo_cb_att, (void*)temp); ///// end of block OSC masterFaderArray.push_back(temp); // store in array grp->Add(temp, wxSizerFlags(1).Align(0).Border(wxALL,1)); // add to GUI } lowerTierSizer->Add(grp, wxSizerFlags(1).Align(0).Border(wxALL,5)); } m_presetCombo = new wxComboBox(this, PRESET_COMBO, _("1:")); for(int n = 0; n < Resound::MAX_PRESETS; n++){ m_presetCombo->Append(wxString::Format(_("%d:"),n)); } topSizer->Add(m_presetCombo); topSizer->Add(new wxButton(this, PRESET_BUTTON, _("Store Preset"))); topSizer->Add(upperTierSizer); topSizer->Add(lowerTierSizer); SetSizer(topSizer); //topSizer->SetSizeHints(this); // set size hints to honour minimum size topSizer->Layout(); }
std::string connection_base::add_method( const method& m ) { std::string nn = create_method_id(); add_method( nn, m ); return nn; }
void maybe_add_lambda_conv_op (tree type) { bool nested = (cfun != NULL); bool nested_def = decl_function_context (TYPE_MAIN_DECL (type)); tree callop = lambda_function (type); if (LAMBDA_EXPR_CAPTURE_LIST (CLASSTYPE_LAMBDA_EXPR (type)) != NULL_TREE) return; if (processing_template_decl) return; bool const generic_lambda_p = (DECL_TEMPLATE_INFO (callop) && DECL_TEMPLATE_RESULT (DECL_TI_TEMPLATE (callop)) == callop); if (!generic_lambda_p && DECL_INITIAL (callop) == NULL_TREE) { /* If the op() wasn't instantiated due to errors, give up. */ gcc_assert (errorcount || sorrycount); return; } /* Non-template conversion operators are defined directly with build_call_a and using DIRECT_ARGVEC for arguments (including 'this'). Templates are deferred and the CALL is built in-place. In the case of a deduced return call op, the decltype expression, DECLTYPE_CALL, used as a substitute for the return type is also built in-place. The arguments of DECLTYPE_CALL in the return expression may differ in flags from those in the body CALL. In particular, parameter pack expansions are marked PACK_EXPANSION_LOCAL_P in the body CALL, but not in DECLTYPE_CALL. */ vec<tree, va_gc> *direct_argvec = 0; tree decltype_call = 0, call = 0; tree fn_result = TREE_TYPE (TREE_TYPE (callop)); if (generic_lambda_p) { /* Prepare the dependent member call for the static member function '_FUN' and, potentially, prepare another call to be used in a decltype return expression for a deduced return call op to allow for simple implementation of the conversion operator. */ tree instance = build_nop (type, null_pointer_node); tree objfn = build_min (COMPONENT_REF, NULL_TREE, instance, DECL_NAME (callop), NULL_TREE); int nargs = list_length (DECL_ARGUMENTS (callop)) - 1; call = prepare_op_call (objfn, nargs); if (type_uses_auto (fn_result)) decltype_call = prepare_op_call (objfn, nargs); } else { direct_argvec = make_tree_vector (); direct_argvec->quick_push (build1 (NOP_EXPR, TREE_TYPE (DECL_ARGUMENTS (callop)), null_pointer_node)); } /* Copy CALLOP's argument list (as per 'copy_list') as FN_ARGS in order to declare the static member function "_FUN" below. For each arg append to DIRECT_ARGVEC (for the non-template case) or populate the pre-allocated call args (for the template case). If a parameter pack is found, expand it, flagging it as PACK_EXPANSION_LOCAL_P for the body call. */ tree fn_args = NULL_TREE; { int ix = 0; tree src = DECL_CHAIN (DECL_ARGUMENTS (callop)); tree tgt; while (src) { tree new_node = copy_node (src); if (!fn_args) fn_args = tgt = new_node; else { TREE_CHAIN (tgt) = new_node; tgt = new_node; } mark_exp_read (tgt); if (generic_lambda_p) { if (DECL_PACK_P (tgt)) { tree a = make_pack_expansion (tgt); if (decltype_call) CALL_EXPR_ARG (decltype_call, ix) = copy_node (a); PACK_EXPANSION_LOCAL_P (a) = true; CALL_EXPR_ARG (call, ix) = a; } else { tree a = convert_from_reference (tgt); CALL_EXPR_ARG (call, ix) = a; if (decltype_call) CALL_EXPR_ARG (decltype_call, ix) = copy_node (a); } ++ix; } else vec_safe_push (direct_argvec, tgt); src = TREE_CHAIN (src); } } if (generic_lambda_p) { if (decltype_call) { ++processing_template_decl; fn_result = finish_decltype_type (decltype_call, /*id_expression_or_member_access_p=*/false, tf_warning_or_error); --processing_template_decl; } } else call = build_call_a (callop, direct_argvec->length (), direct_argvec->address ()); CALL_FROM_THUNK_P (call) = 1; tree stattype = build_function_type (fn_result, FUNCTION_ARG_CHAIN (callop)); /* First build up the conversion op. */ tree rettype = build_pointer_type (stattype); tree name = mangle_conv_op_name_for_type (rettype); tree thistype = cp_build_qualified_type (type, TYPE_QUAL_CONST); tree fntype = build_method_type_directly (thistype, rettype, void_list_node); tree convfn = build_lang_decl (FUNCTION_DECL, name, fntype); tree fn = convfn; DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (callop); if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn && DECL_ALIGN (fn) < 2 * BITS_PER_UNIT) DECL_ALIGN (fn) = 2 * BITS_PER_UNIT; SET_OVERLOADED_OPERATOR_CODE (fn, TYPE_EXPR); grokclassfn (type, fn, NO_SPECIAL); set_linkage_according_to_type (type, fn); rest_of_decl_compilation (fn, toplevel_bindings_p (), at_eof); DECL_IN_AGGR_P (fn) = 1; DECL_ARTIFICIAL (fn) = 1; DECL_NOT_REALLY_EXTERN (fn) = 1; DECL_DECLARED_INLINE_P (fn) = 1; DECL_ARGUMENTS (fn) = build_this_parm (fntype, TYPE_QUAL_CONST); if (nested_def) DECL_INTERFACE_KNOWN (fn) = 1; if (generic_lambda_p) fn = add_inherited_template_parms (fn, DECL_TI_TEMPLATE (callop)); add_method (type, fn, NULL_TREE); /* Generic thunk code fails for varargs; we'll complain in mark_used if the conversion op is used. */ if (varargs_function_p (callop)) { DECL_DELETED_FN (fn) = 1; return; } /* Now build up the thunk to be returned. */ name = get_identifier ("_FUN"); tree statfn = build_lang_decl (FUNCTION_DECL, name, stattype); fn = statfn; DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (callop); if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn && DECL_ALIGN (fn) < 2 * BITS_PER_UNIT) DECL_ALIGN (fn) = 2 * BITS_PER_UNIT; grokclassfn (type, fn, NO_SPECIAL); set_linkage_according_to_type (type, fn); rest_of_decl_compilation (fn, toplevel_bindings_p (), at_eof); DECL_IN_AGGR_P (fn) = 1; DECL_ARTIFICIAL (fn) = 1; DECL_NOT_REALLY_EXTERN (fn) = 1; DECL_DECLARED_INLINE_P (fn) = 1; DECL_STATIC_FUNCTION_P (fn) = 1; DECL_ARGUMENTS (fn) = fn_args; for (tree arg = fn_args; arg; arg = DECL_CHAIN (arg)) { /* Avoid duplicate -Wshadow warnings. */ DECL_NAME (arg) = NULL_TREE; DECL_CONTEXT (arg) = fn; } if (nested_def) DECL_INTERFACE_KNOWN (fn) = 1; if (generic_lambda_p) fn = add_inherited_template_parms (fn, DECL_TI_TEMPLATE (callop)); add_method (type, fn, NULL_TREE); if (nested) push_function_context (); else /* Still increment function_depth so that we don't GC in the middle of an expression. */ ++function_depth; /* Generate the body of the thunk. */ start_preparsed_function (statfn, NULL_TREE, SF_PRE_PARSED | SF_INCLASS_INLINE); if (DECL_ONE_ONLY (statfn)) { /* Put the thunk in the same comdat group as the call op. */ cgraph_node::get_create (statfn)->add_to_same_comdat_group (cgraph_node::get_create (callop)); } tree body = begin_function_body (); tree compound_stmt = begin_compound_stmt (0); if (!generic_lambda_p) { set_flags_from_callee (call); if (MAYBE_CLASS_TYPE_P (TREE_TYPE (call))) call = build_cplus_new (TREE_TYPE (call), call, tf_warning_or_error); } call = convert_from_reference (call); finish_return_stmt (call); finish_compound_stmt (compound_stmt); finish_function_body (body); fn = finish_function (/*inline*/2); if (!generic_lambda_p) expand_or_defer_fn (fn); /* Generate the body of the conversion op. */ start_preparsed_function (convfn, NULL_TREE, SF_PRE_PARSED | SF_INCLASS_INLINE); body = begin_function_body (); compound_stmt = begin_compound_stmt (0); /* decl_needed_p needs to see that it's used. */ TREE_USED (statfn) = 1; finish_return_stmt (decay_conversion (statfn, tf_warning_or_error)); finish_compound_stmt (compound_stmt); finish_function_body (body); fn = finish_function (/*inline*/2); if (!generic_lambda_p) expand_or_defer_fn (fn); if (nested) pop_function_context (); else --function_depth; }
int main(int argc, char *argv[]) { int r = EXIT_OK; int i, ii; int m; time_t t_total; #if defined(__EMX__) _response(&argc,&argv); _wildcard(&argc,&argv); #endif if (argv[0]) argv0 = argv[0]; align_mem(); (void) my_clock(); printf("\nLZO real-time data compression library (v%s, %s).\n", LZO_VERSION_STRING, LZO_VERSION_DATE); printf("Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer\n\n"); if (lzo_init() != LZO_E_OK) { printf("lzo_init() failed !!!\n"); exit(EXIT_LZO_INIT); } if (argc < 2) usage(argv0,-1,0); i = get_options(argc,argv); if (methods_n == 0) add_method(default_method); if (methods_n > 1 && opt_read_from_stdin) { printf("%s: cannot use multiple methods and '-@'\n", argv0); exit(EXIT_USAGE); } if (opt_block_size < 16) opt_block_size = 16; if (opt_block_size > MAX_BLOCK_SIZE) opt_block_size = MAX_BLOCK_SIZE; dict_len = 0; #ifndef USE_DICT opt_dict = 0; #else if (opt_dict) { opt_optimize_compressed_data = 0; if (opt_dictionary_file) { read_dict(opt_dictionary_file); if (opt_max_dict_len > 0 && dict_len > (lzo_uint) opt_max_dict_len) dict_len = opt_max_dict_len; if (dict_len > 0) printf("Using dictionary '%s', %ld bytes, ID 0x%08lx.\n", opt_dictionary_file, (long) dict_len, (long) dict_adler32); } if (dict_len <= 0) { init_default_dict(); if (opt_max_dict_len > 0 && dict_len > (lzo_uint) opt_max_dict_len) dict_len = opt_max_dict_len; printf("Using default dictionary, %ld bytes, ID 0x%08lx.\n", (long) dict_len, (long) dict_adler32); } if (opt_max_dict_len == -1) printf("Dictionary size will be adjusted to file size.\n"); else if (opt_max_dict_len <= 0) printf("Dictionary size will be adjusted to file size.\n"); } #endif t_total = time(NULL); (void) my_clock(); ii = i; for (m = 0; m < methods_n && r == EXIT_OK; m++) { int method = methods[m]; i = ii; if (i >= argc && opt_calgary_corpus_path == NULL && !opt_read_from_stdin) usage(argv0,-1,0); if (m == 0 && opt_verbose >= 1) printf("%lu block-size\n\n", (long) opt_block_size); if (!info(method,NULL)) info(method,stdout); #ifdef USE_CORPUS if (opt_calgary_corpus_path != NULL) r = do_corpus(calgary_corpus,method,opt_calgary_corpus_path, opt_c_loops,opt_d_loops); else #endif { for ( ; i < argc && r == EXIT_OK; i++) { r = do_file(method,argv[i],opt_c_loops,opt_d_loops,NULL,NULL); if (r == EXIT_FILE) /* ignore file errors */ r = EXIT_OK; } if (opt_read_from_stdin) { char buf[512], *p; while (r == EXIT_OK && fgets(buf,sizeof(buf)-1,stdin) != NULL) { buf[sizeof(buf)-1] = 0; p = buf + strlen(buf); while (p > buf && is_space(p[-1])) *--p = 0; p = buf; while (*p && is_space(*p)) p++; if (*p) r = do_file(method,p,opt_c_loops,opt_d_loops,NULL,NULL); if (r == EXIT_FILE) /* ignore file errors */ r = EXIT_OK; } opt_read_from_stdin = 0; } } } t_total = time(NULL) - t_total; if (opt_totals) print_totals(); if (opt_execution_time || (methods_n > 1 && opt_verbose >= 1)) printf("\n%s: execution time: %lu seconds\n", argv0, (long) t_total); if (r != EXIT_OK) printf("\n%s: exit code: %d\n", argv0, r); return r; }
// light_xyPad Ctor OSCRoller(int x,int y,int w,int h, char* l) : Fl_Roller(x,y,w,h,l) { host = "SC-bassControl"; port = "7700"; osco = new OSCoutput( host, port ); add_method(); }
int main( int argc, char** argv ) { #ifdef WIN32 BOOL console_ok = AllocConsole(); freopen("CONOUT$", "wb", stdout); freopen("CONOUT$", "wb", stderr); //freopen( "console.txt", "wb", stdout); //freopen( "console.txt", "wb", stderr); printf("testing stdout\n"); fprintf(stderr, "testing stderr\n"); #endif try { fc::tcp_server _tcp_serv; //maps keyhoteeId -> founderCode,points,publicKey bts::db::level_map<std::string,record> _known_names; _known_names.open( "reg_db" ); auto fix_itr = _known_names.begin(); while (fix_itr.valid()) { std::string kid = fix_itr.key(); std::string asciiName; convertToAscii(kid,&asciiName); if (kid != asciiName) { auto unchanged_record = fix_itr.value(); deb << kid << " to " << asciiName << std::endl; _known_names.remove(kid); _known_names.store(asciiName,unchanged_record); } ++fix_itr; } if (argc == 3) { //update records in goood dbase with matching records from messy database std::cerr << "update records with records from messy database" << std::endl; bts::db::level_map<std::string,record> _messy_names; _messy_names.open( "messy_db" ); //walkthrough all names in messydb, see if it matches record in good db, update good db with public key if so auto itr = _messy_names.begin(); while( itr.valid() ) { auto found_itr = _known_names.find( itr.key() ); if (found_itr.valid()) { auto id_record = itr.value(); auto found_record = found_itr.value(); found_record.pub_key = id_record.pub_key; ilog( "${key} => ${value}", ("key",itr.key())("value",found_record)); _known_names.store( itr.key(), found_record); } else //report couldn't be found in debug.txt { std::string lower_kid = itr.key(); boost::to_lower(lower_kid); found_itr = _known_names.find(lower_kid); if (found_itr.valid()) deb << "found " << itr.key() << " as " << lower_kid << std::endl; else deb << "missing " << itr.key() << std::endl; } ++itr; } } // TODO: import CSV list of new keyhoteeIds that can be registered else if( argc == 2 ) { FC_ASSERT( fc::exists(argv[1]) ); std::ifstream in(argv[1]); std::string line; std::getline(in, line); int num_commas = std::count(line.begin(), line.end(), ','); deb << "num_commas=" << num_commas << "\n"; std::cerr << "num_commas=" << num_commas << "\n"; if (num_commas == 1) { //fix badly transcribed keyhoteeIDs (replace 1st column names with 2nd column names) while( in.good() ) { std::stringstream ss(line); std::string original_name; //old keyhoteeId std::getline( ss, original_name, ',' ); std::string name; convertToAscii(original_name,&name); std::string original_new_name; //old keyhoteeId std::getline(ss, original_new_name); std::string new_name; convertToAscii(original_new_name,&new_name); try { auto itr = _known_names.find( name ); if (itr.valid()) { deb << "found " << name << " replacing with " << new_name << std::endl; auto rec = itr.value(); rec.key = new_name; _known_names.store( new_name, rec ); } else { deb << name << " NOT FOUND when trying to replace" << std::endl; } } catch (...) { deb << "Couldn't find name " << name << std::endl; } } deb << "FINISHED replacing bad KIDs" << std::endl; deb.flush(); } else if (num_commas == 2 || num_commas == 3) { while( in.good() ) { std::stringstream ss(line); std::string oname; //keyhoteeId std::getline( ss, oname, ',' ); std::string name; convertToAscii(oname,&name); //boost::to_lower(name); std::string key; //founderCode std::getline( ss, key, ',' ); std::string points; std::getline( ss, points, ',' ); deb << "OK"<< std::endl; try { auto itr = _known_names.find( name ); if (itr.valid()) { deb << "found " << name << std::endl; } else { deb << "adding " << name << "\t\t" << key << "\t\t'" << points << std::endl; double pointsd = atof( points.c_str() ); _known_names.store( name, record( key, pointsd ) ); } } catch (...) { deb << "Couldn't find name" << std::endl; } std::getline(in, line); } deb << "FINISHED importing more KIDs" << std::endl; deb.flush(); } else if (num_commas >= 5) { //update registered keyhoteeIds with public keys sent from web form while( in.good() ) { std::stringstream ss(line); std::string date; std::getline( ss, date, ',' ); std::string email; std::getline( ss, email, ',' ); std::string oname; //keyhoteeId std::getline( ss, oname, ',' ); std::string name; convertToAscii(oname,&name); //boost::to_lower(name); std::string key; //founderCode std::getline( ss, key, ',' ); std::string public_key; std::getline( ss, public_key, ',' ); auto itr = _known_names.find( name ); if (!itr.valid()) { std::string similar_name = name; boost::to_lower(similar_name); itr = _known_names.find( similar_name ); if (!itr.valid()) { boost::to_upper(similar_name); itr = _known_names.find( similar_name ); } } if( itr.valid() ) { auto record_to_update = itr.value(); if (!public_key.empty()) { record_to_update.pub_key = public_key; if (record_to_update.key == key) _known_names.store( name, record_to_update); else deb << "Founder code mismatch for " << name << std::endl; } else { deb << "Public key empty for " << name << std::endl; } } else { deb << "Looking for " << name << " "; std::string similar_name = name; boost::to_lower(similar_name); if (!is_known(_known_names,similar_name)) boost::to_upper(similar_name); if (!is_known(_known_names,similar_name)) deb << "NOT FOUND" << std::endl; deb.flush(); } std::getline(in, line); } } else { std::cerr << "Invalid file format: file should have 3 or 5+ fields, has " << num_commas << std::endl; return 1; } } else //argc != 2 { //configure logger to also write to log file fc::file_appender::config ac; /** \warning Use wstring to construct log file name since %TEMP% can point to path containing native chars. */ ac.filename = "log.txt"; ac.truncate = false; ac.flush = true; fc::logger::get().add_appender( fc::shared_ptr<fc::file_appender>( new fc::file_appender( fc::variant(ac) ) ) ); std::ofstream report_stream("report.txt"); int id_count = 0; int unregistered_count = 0; auto itr = _known_names.begin(); while( itr.valid() ) { auto id_record = itr.value(); //ilog( "${key} => ${value}", ("key",itr.key())("value",id_record)); ilog( "${key}, ${pub_key}, ${p}", ("key",itr.key())("pub_key",id_record.pub_key)("p",id_record.points)); report_stream << itr.key() << "," << id_record.pub_key << std::endl; ++id_count; if (id_record.pub_key.empty()) ++unregistered_count; ++itr; } report_stream.close(); ilog( "Total Id Count: ${id_count} Unregistered: ${unregistered_count}",("id_count",id_count)("unregistered_count",unregistered_count) ); } _tcp_serv.listen( 3879 ); //fc::future<void> _accept_loop_complete = fc::async( [&]() { while( true ) //!_accept_loop_complete.canceled() ) { fc::tcp_socket_ptr sock = std::make_shared<fc::tcp_socket>(); try { _tcp_serv.accept( *sock ); } catch ( const fc::exception& e ) { elog( "fatal: error opening socket for rpc connection: ${e}", ("e", e.to_detail_string() ) ); //exit(1); } auto buf_istream = std::make_shared<fc::buffered_istream>( sock ); auto buf_ostream = std::make_shared<fc::buffered_ostream>( sock ); auto json_con = std::make_shared<fc::rpc::json_connection>( std::move(buf_istream), std::move(buf_ostream) ); json_con->add_method( "register_key", [&]( const fc::variants& params ) -> fc::variant { FC_ASSERT( params.size() == 3 ); auto oname = params[0].as_string(); oname = fc::trim(oname); std::string name; convertToAscii(oname,&name); auto rec = _known_names.fetch( name ); //ensure founder code is correct if( rec.key != params[1].as_string() ) //, "Key ${key} != ${expected}", ("key",params[1])("expected",rec.key) ); { FC_ASSERT( !"Invalid Key" ); } //report if key is already registered, don't allow re-registering if( !(rec.pub_key.size() == 0 || rec.pub_key == params[2].as_string() ) ) { // FC_ASSERT( rec.pub_key.size() == 0 || rec.pub_key == params[2].as_string() ); FC_ASSERT( !"Key already Registered" ); } //register the public key rec.pub_key = params[2].as_string(); _known_names.store( name, rec ); return fc::variant( rec ); }); fc::async( [json_con]{ json_con->exec().wait(); } ); } // } // ); //_accept_loop_complete.wait(); return 0; } catch ( fc::exception& e ) { elog( "${e}", ("e",e.to_detail_string() ) ); } }
void alsa_iface(lua_State *lstate) { init_fader(&(unit.fader), 1.0); add_method(lstate, "cards", cards); add_method(lstate, "new", new_obj); return; }
static void add_methods(const int *ml) { while (*ml != 0) add_method(*ml++); }