void CBundle::PreStart() { if(SF_FAILED( m_module.Init(m_location.c_str()) )) return; create_instance(&m_activator, m_module); create_instance_impl(&m_context); m_context->FinalConstruct(m_systemBundle, this); m_state = eBndlState_Starting; }
Agent* Agent_builder::build(Agent_params p){ FILE_LOG(logDEBUG) << " Agent_builder::build "<<std::endl; Agent* agent= create_instance(p.implementation); assert(agent); FILE_LOG(logDEBUG) << " Instance created "<<std::endl; agent->set_properties(p.m_properties); agent->set_agent_file(p.agent_file); FILE_LOG(logDEBUG) << " Agent init "<<std::endl; agent->init(); return agent; }
void COZIR_WV_tick(void) { float CO2 , temp , humi; if(COZIR_WV_100_read(&CO2 , &temp , &humi)) { instance inst = create_instance(MODULE_NAME); if(inst.def != NULL && inst.values != NULL){ (*(float*) inst.values[0]) = CO2; portBASE_TYPE xStatus = xQueueSendToBack(module_out, &inst , 10 / portTICK_RATE_MS ); if(xStatus != pdPASS){ release_instance(inst); } } } }
void ENV_TEMP_tick(void) { float temp; if(ENV_TMP_read_temp(&temp)) { instance inst = create_instance(MODULE_NAME); if(inst.def != NULL && inst.values != NULL){ (*(float*) inst.values[0]) = temp; portBASE_TYPE xStatus = xQueueSendToBack(module_out, &inst , 10 / portTICK_RATE_MS ); if(xStatus != pdPASS){ release_instance(inst); } } } }
static logger_p &get_instance() { #if defined(BOOST_HAS_THREADS) && !defined (LOGLITE_NO_THREAD) static boost::once_flag once = BOOST_ONCE_INIT; boost::call_once(logger::create_instance, once); #else static bool once = true; if (once) { create_instance(); once = false; } #endif return g__logger; }
void STH31_D_tick(void) { double temp , humi; if(STH31_D_read_temp_humi(&temp , &humi)) { instance inst = create_instance(MODULE_NAME); if(inst.def != NULL && inst.values != NULL){ (*(double*) inst.values[0]) = temp; (*(double*) inst.values[1]) = humi; portBASE_TYPE xStatus = xQueueSendToBack(module_out, &inst , 10 / portTICK_RATE_MS ); if(xStatus != pdPASS){ release_instance(inst); } } } }
void CCore::Initialize(const char* paramsFile) { if(gEnv->PluginManager) throw CoreException("Multiple Core initialization"); mLogModule.Init("Logging.dll"); create_instance(&gEnv->Logger, Logging::CLSID_CLogService, mLogModule); gEnv->Logger->Initialize("Execution.log", "Error.log"); LogInfoAlways("[Init] Initializing core"); LogTrace("[Init] Creating plugin manager"); create_instance<CPluginManager>(&gEnv->PluginManager); static_cast<CPluginManager*>(gEnv->PluginManager)->Run(paramsFile); }
bool init(const char* pipeline, core::c_window *window, bool validation) { VERIFY(graphics::render3d::resources::load_pipeline(pipeline)); VERIFY(create_instance("appname")); VERIFY(create_surface(window)); VERIFY(create_device()); VERIFY(create_device_queue()); VERIFY(graphics::render3d::resources::create_pipeline()); vk_globals::is_init = true; flag_needs_recreate_swapchain.store(false); flag_needs_shutdown.store(false); on_window_resize_listener = window->add_event_listener(core::e_window_event::ON_RESIZE, on_window_resize); return true; }
SV * Widget_accelItems( Handle self, Bool set, SV * accelItems) { dPROFILE; enter_method; if ( var-> stage > csFrozen) return nilSV; if ( !set) return var-> accelTable ? CAbstractMenu( var-> accelTable)-> get_items( var-> accelTable, "") : nilSV; if ( var-> accelTable == nilHandle) { HV * profile = newHV(); if ( SvTYPE( accelItems)) pset_sv( items, accelItems); pset_H ( owner, self); my-> set_accelTable( self, create_instance( "Prima::AccelTable")); sv_free(( SV *) profile); } else CAbstractMenu( var-> accelTable)-> set_items( var-> accelTable, accelItems); return nilSV; }
/*创建一个对象,传入该对象对应的原型的ID,并传入构造函数所需的参数(如果有的话)*/ Var struct_Create(int id,Var init_arg[],int args) { Var result; result.content.type=VAR_TYPE_OBJ; result.content.var_value.struct_obj.handle_value=create_instance(id); var_SetObjId (&result,id); /*若存在初始化函数,则调用它*/ if(struct_list[id].initializer_index>=0) { if(struct_list[id].initializer_acc==STRUCT_PRIVATE && env_index!=id) { STOP("private initializer only can be assigned inside\n"); } int old_env =env_index; env_index=id;/*环境索引改变为类内部*/ /*函数栈压入*/ vm_RTstackPush(); /*获取构造函数*/ Function *f=func_get_by_index(struct_list[id].initializer_index); if(f->arg_counts!=args) { STOP("struct constructor not matched!"); } self_ptr=result; /*传入参数*/ int i; for(i=0; i<f->arg_counts; i++) { vm_rt_stack_var_cast_set ( i,init_arg[i]); } IL_list * old_list=current_list; func_PlainInvoke ( struct_list[id].initializer_index);/*执行构造函数*/ current_list=old_list; /*函数的栈弹出*/ vm_RTstackPop(); self_ptr.content.type=VAR_TYPE_NILL; env_index=old_env;/*维持环境*/ } return result; }
SV * Window_menuItems( Handle self, Bool set, SV * menuItems) { dPROFILE; if ( var-> stage > csFrozen) return nilSV; if ( !set) return var-> menu ? CMenu( var-> menu)-> get_items( var-> menu, "") : nilSV; if ( var-> menu == nilHandle) { if ( SvTYPE( menuItems)) { HV * profile = newHV(); pset_sv( items, menuItems); pset_H ( owner, self); pset_i ( selected, false); my-> set_menu( self, create_instance( "Prima::Menu")); sv_free(( SV *) profile); } } else CMenu( var-> menu)-> set_items( var-> menu, menuItems); return menuItems; }
/** Load a specific plugin * The plugin loader is clever and guarantees that every plugin is only * loaded once (as long as you use only one instance of the PluginLoader, * using multiple instances is discouraged. If you try to open a plugin * a second time it will return the * very same instance that it returned on previous load()s. * @param plugin_name The name of the plugin to be loaded, the plugin name has to * correspond to a plugin name and the name of the shared object that will * be opened for this plugin (for instance on Linux systems opening the * plugin test_plugin will look for plugin_base_dir/test_plugin.so) * @return Returns a pointer to the opened plugin. Do not under any * circumstances delete this object, use unload() instead! Since the delete * operator could be overloaded this would result in memory chaos. * @exception PluginLoadException thrown if plugin could not be loaded * @exception ModuleOpenException passed along from module manager */ Plugin * PluginLoader::load(const char *plugin_name) { std::string pn = plugin_name; if ( d->name_plugin_map.find(pn) != d->name_plugin_map.end() ) { return d->name_plugin_map[pn]; } try { Module *module = open_module(plugin_name); Plugin *p = create_instance(plugin_name, module); d->plugin_module_map[p] = module; d->name_plugin_map[pn] = p; d->plugin_name_map[p] = pn; return p; } catch (PluginLoadException &e) { throw; } }
void trace_stat (int argc, char **argv) { struct buffer_instance *instance = &top_instance; int topt = 0; int c; for (;;) { c = getopt(argc-1, argv+1, "tB:"); if (c == -1) break; switch (c) { case 'h': usage(argv); break; case 'B': instance = create_instance(optarg); add_instance(instance); /* top instance requires direct access */ if (!topt && is_top_instance(first_instance)) first_instance = instance; break; case 't': /* Force to use top instance */ topt = 1; instance = &top_instance; break; default: usage(argv); } } update_first_instance(instance, topt); for_all_instances(instance) { stat_instance(instance); } exit(0); }
/** * This is an example of the C API that transmits a flow file to a remote instance. */ int main(int argc, char **argv) { if (argc < 4) { printf("Error: must run ./transmit_flow <instance> <remote port> <file or directory>\n"); exit(1); } char *instance_str = argv[1]; char *portStr = argv[2]; char *file = argv[3]; nifi_port port; port.pord_id = portStr; nifi_instance *instance = create_instance(instance_str, &port); // initializing will make the transmission slightly more efficient. //initialize_instance(instance); transfer_file_or_directory(instance,file); free_instance(instance); }
SV * Widget_popupItems( Handle self, Bool set, SV * popupItems) { dPROFILE; enter_method; if ( var-> stage > csFrozen) return nilSV; if ( !set) return var-> popupMenu ? CAbstractMenu( var-> popupMenu)-> get_items( var-> popupMenu, "") : nilSV; if ( var-> popupMenu == nilHandle) { if ( SvTYPE( popupItems)) { HV * profile = newHV(); pset_sv( items, popupItems); pset_H ( owner, self); my-> set_popup( self, create_instance( "Prima::Popup")); sv_free(( SV *) profile); } } else CAbstractMenu( var-> popupMenu)-> set_items( var-> popupMenu, popupItems); return popupItems; }
TEST(ppb_net_address, ipv6_compose_decompose) { PP_Instance instance = create_instance(); const struct PP_NetAddress_IPv6 ipv6 = { .addr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, .port = htons(3456) }; struct PP_NetAddress_IPv6 ipv6_a = {}; struct PP_NetAddress_IPv4 ipv4 = {}; PP_Resource addr = ppb_net_address_create_from_ipv6_address(instance, &ipv6); ASSERT_EQ(ppb_net_address_is_net_address(addr), PP_TRUE); ASSERT_EQ(ppb_net_address_get_family(addr), PP_NETADDRESS_FAMILY_IPV6); ASSERT_EQ(ppb_net_address_describe_as_ipv4_address(addr, &ipv4), PP_FALSE); ASSERT_EQ(ppb_net_address_describe_as_ipv6_address(addr, &ipv6_a), PP_TRUE); ASSERT_EQ(memcmp(&ipv6, &ipv6_a, sizeof(ipv6_a)), 0); struct PP_Var s = ppb_net_address_describe_as_string(addr, PP_TRUE); ASSERT_STREQ(ppb_var_var_to_utf8(s, NULL), "[102:304:506:708:90a:b0c:d0e:f10]:3456"); ppb_var_release(s); ppb_core_release_resource(addr); destroy_instance(instance); }
TEST(ppb_net_address, ipv4_compose_decompose) { PP_Instance instance = create_instance(); const struct PP_NetAddress_IPv4 ipv4 = { .addr = {192, 168, 1, 2}, .port = htons(3456) }; struct PP_NetAddress_IPv4 ipv4_a = {}; struct PP_NetAddress_IPv6 ipv6 = {}; PP_Resource addr = ppb_net_address_create_from_ipv4_address(instance, &ipv4); ASSERT_EQ(ppb_net_address_is_net_address(addr), PP_TRUE); ASSERT_EQ(ppb_net_address_get_family(addr), PP_NETADDRESS_FAMILY_IPV4); ASSERT_EQ(ppb_net_address_describe_as_ipv6_address(addr, &ipv6), PP_FALSE); ASSERT_EQ(ppb_net_address_describe_as_ipv4_address(addr, &ipv4_a), PP_TRUE); ASSERT_EQ(memcmp(&ipv4, &ipv4_a, sizeof(ipv4_a)), 0); struct PP_Var s = ppb_net_address_describe_as_string(addr, PP_TRUE); ASSERT_STREQ(ppb_var_var_to_utf8(s, NULL), "192.168.1.2:3456"); ppb_var_release(s); ppb_core_release_resource(addr); destroy_instance(instance); }
static int afpacket_daq_initialize(const DAQ_Config_t *config, void **ctxt_ptr, char *errbuf, size_t errlen) { AFPacket_Context_t *afpc; AFPacketInstance *instance; const char *size_str = NULL; char *name1, *name2, *dev; char intf[IFNAMSIZ]; uint32_t size; size_t len; int num_intfs = 0; int rval = DAQ_ERROR; DAQ_Dict *entry; afpc = calloc(1, sizeof(AFPacket_Context_t)); if (!afpc) { snprintf(errbuf, errlen, "%s: Couldn't allocate memory for the new AFPacket context!", __FUNCTION__); rval = DAQ_ERROR_NOMEM; goto err; } afpc->device = strdup(config->name); if (!afpc->device) { snprintf(errbuf, errlen, "%s: Couldn't allocate memory for the device string!", __FUNCTION__); rval = DAQ_ERROR_NOMEM; goto err; } afpc->snaplen = config->snaplen; afpc->timeout = (config->timeout > 0) ? (int) config->timeout : -1; dev = afpc->device; if (*dev == ':' || ((len = strlen(dev)) > 0 && *(dev + len - 1) == ':') || (config->mode == DAQ_MODE_PASSIVE && strstr(dev, "::"))) { snprintf(errbuf, errlen, "%s: Invalid interface specification: %s!", __FUNCTION__, afpc->device); goto err; } while (*dev != '\0') { len = strcspn(dev, ":"); if (len >= IFNAMSIZ) { snprintf(errbuf, errlen, "%s: Interface name too long! (%zu)", __FUNCTION__, len); goto err; } if (len != 0) { afpc->intf_count++; if (afpc->intf_count >= AF_PACKET_MAX_INTERFACES) { snprintf(errbuf, errlen, "%s: Using more than %d interfaces is not supported!", __FUNCTION__, AF_PACKET_MAX_INTERFACES); goto err; } snprintf(intf, len + 1, "%s", dev); instance = create_instance(afpc, intf); if (!instance) goto err; instance->next = afpc->instances; afpc->instances = instance; num_intfs++; if (config->mode != DAQ_MODE_PASSIVE) { if (num_intfs == 2) { name1 = afpc->instances->next->name; name2 = afpc->instances->name; if (create_bridge(afpc, name1, name2) != DAQ_SUCCESS) { snprintf(errbuf, errlen, "%s: Couldn't create the bridge between %s and %s!", __FUNCTION__, name1, name2); goto err; } num_intfs = 0; } else if (num_intfs > 2) break; } } else len = 1; dev += len; } /* If there are any leftover unbridged interfaces and we're not in Passive mode, error out. */ if (config->mode != DAQ_MODE_PASSIVE && num_intfs != 0) { snprintf(errbuf, errlen, "%s: Invalid interface specification: %s!", __FUNCTION__, afpc->device); goto err; } /* * Determine the dimensions of the kernel RX ring(s) to request. */ /* 1. Find the total desired packet buffer memory for all instances. */ for (entry = config->values; entry; entry = entry->next) { if (!strcmp(entry->key, "buffer_size_mb")) size_str = entry->value; else if (!strcmp(entry->key, "debug")) afpc->debug = 1; } /* Fall back to the environment variable. */ if (!size_str) size_str = getenv("AF_PACKET_BUFFER_SIZE"); if (size_str && strcmp("max", size_str) != 0) size = strtoul(size_str, NULL, 10); else size = AF_PACKET_DEFAULT_BUFFER_SIZE; /* The size is specified in megabytes. */ size = size * 1024 * 1024; /* 2. Divide it evenly across the number of interfaces. */ num_intfs = 0; for (instance = afpc->instances; instance; instance = instance->next) num_intfs++; afpc->size = size / num_intfs; afpc->state = DAQ_STATE_INITIALIZED; *ctxt_ptr = afpc; return DAQ_SUCCESS; err: if (afpc) { af_packet_close(afpc); if (afpc->device) free(afpc->device); free(afpc); } return rval; }
jobject mesh_material(JNIEnv *env, const aiScene *assimp_scene, int index) { aiMesh* assimp_mesh = assimp_scene->mMeshes[index]; aiMaterial* assimp_material = assimp_scene->mMaterials[assimp_mesh->mMaterialIndex]; jobject jassimp_material = NULL; if (!create_instance(env, "org/gearvrf/jassimp/AiMaterial", jassimp_material)) { return NULL; } /* set texture numbers */ for (int texture_type_index = aiTextureType_DIFFUSE; texture_type_index < aiTextureType_UNKNOWN; texture_type_index++) { aiTextureType texture_type = static_cast<aiTextureType>(texture_type_index); unsigned int total_textures = assimp_material->GetTextureCount( texture_type); jvalue set_number_params[2]; set_number_params[0].i = texture_type_index; set_number_params[1].i = total_textures; if (!call_void_method(env, jassimp_material, "org/gearvrf/jassimp/AiMaterial", "setTextureNumber", "(II)V", set_number_params)) { return NULL; } } for (unsigned int p = 0; p < assimp_material->mNumProperties; p++) { const aiMaterialProperty* assimp_material_property = assimp_material->mProperties[p]; jobject jassimp_material_property = NULL; jvalue constructor_params[5]; constructor_params[0].l = env->NewStringUTF( assimp_material_property->mKey.C_Str()); constructor_params[1].i = assimp_material_property->mSemantic; constructor_params[2].i = assimp_material_property->mIndex; constructor_params[3].i = assimp_material_property->mType; /* special case conversion for color3 */ if (NULL != strstr(assimp_material_property->mKey.C_Str(), "clr") && assimp_material_property->mType == aiPTI_Float && assimp_material_property->mDataLength == 3 * sizeof(float)) { jobject jassimp_data = NULL; /* wrap color */ jvalue wrap_color_params[3]; wrap_color_params[0].f = ((float*) assimp_material_property->mData)[0]; wrap_color_params[1].f = ((float*) assimp_material_property->mData)[1]; wrap_color_params[2].f = ((float*) assimp_material_property->mData)[2]; if (!call_static_object(env, "org/gearvrf/jassimp/Jassimp", "wrapColor3", "(FFF)Ljava/lang/Object;", wrap_color_params, jassimp_data)) { return NULL; } constructor_params[4].l = jassimp_data; if (!create_instance(env, "org/gearvrf/jassimp/AiMaterial$Property", "(Ljava/lang/String;IIILjava/lang/Object;)V", constructor_params, jassimp_material_property)) { return NULL; } } /* special case conversion for color4 */ else if (NULL != strstr(assimp_material_property->mKey.C_Str(), "clr") && assimp_material_property->mType == aiPTI_Float && assimp_material_property->mDataLength == 4 * sizeof(float)) { jobject jassimp_data = NULL; /* wrap color */ jvalue wrap_color_params[4]; wrap_color_params[0].f = ((float*) assimp_material_property->mData)[0]; wrap_color_params[1].f = ((float*) assimp_material_property->mData)[1]; wrap_color_params[2].f = ((float*) assimp_material_property->mData)[2]; wrap_color_params[3].f = ((float*) assimp_material_property->mData)[3]; if (!call_static_object(env, "org/gearvrf/jassimp/Jassimp", "wrapColor4", "(FFFF)Ljava/lang/Object;", wrap_color_params, jassimp_data)) { return NULL; } constructor_params[4].l = jassimp_data; if (!create_instance(env, "org/gearvrf/jassimp/AiMaterial$Property", "(Ljava/lang/String;IIILjava/lang/Object;)V", constructor_params, jassimp_material_property)) { return NULL; } } else if (assimp_material_property->mType == aiPTI_Float && assimp_material_property->mDataLength == sizeof(float)) { jobject jassimp_data = NULL; jvalue new_float_params[1]; new_float_params[0].f = ((float*) assimp_material_property->mData)[0]; if (!create_instance(env, "java/lang/Float", "(F)V", new_float_params, jassimp_data)) { return NULL; } constructor_params[4].l = jassimp_data; if (!create_instance(env, "org/gearvrf/jassimp/AiMaterial$Property", "(Ljava/lang/String;IIILjava/lang/Object;)V", constructor_params, jassimp_material_property)) { return NULL; } } else if (assimp_material_property->mType == aiPTI_Integer && assimp_material_property->mDataLength == sizeof(int)) { jobject jassimp_data = NULL; jvalue new_int_params[1]; new_int_params[0].i = ((int*) assimp_material_property->mData)[0]; if (!create_instance(env, "java/lang/Integer", "(I)V", new_int_params, jassimp_data)) { return NULL; } constructor_params[4].l = jassimp_data; if (!create_instance(env, "org/gearvrf/jassimp/AiMaterial$Property", "(Ljava/lang/String;IIILjava/lang/Object;)V", constructor_params, jassimp_material_property)) { return NULL; } } else if (assimp_material_property->mType == aiPTI_String) { /* skip length prefix */ jobject jassimp_data = env->NewStringUTF( assimp_material_property->mData + 4); constructor_params[4].l = jassimp_data; if (!create_instance(env, "org/gearvrf/jassimp/AiMaterial$Property", "(Ljava/lang/String;IIILjava/lang/Object;)V", constructor_params, jassimp_material_property)) { return NULL; } } else { constructor_params[4].i = assimp_material_property->mDataLength; /* generic copy code, uses dump ByteBuffer on java side */ if (!create_instance(env, "org/gearvrf/jassimp/AiMaterial$Property", "(Ljava/lang/String;IIII)V", constructor_params, jassimp_material_property)) { return NULL; } jobject jassimp_buffer = NULL; if (!get_field(env, jassimp_material_property, "m_data", "Ljava/lang/Object;", jassimp_buffer)) { return NULL; } if (env->GetDirectBufferCapacity(jassimp_buffer) != assimp_material_property->mDataLength) { LOGE("invalid direct buffer\n"); return NULL; } void* jassimp_buffer_ptr = env->GetDirectBufferAddress( jassimp_buffer); if (NULL == jassimp_buffer_ptr) { LOGE("could not access direct buffer\n"); return NULL; } memcpy(jassimp_buffer_ptr, assimp_material_property->mData, assimp_material_property->mDataLength); } /* add property */ jobject jassimp_properties = NULL; if (!get_field(env, jassimp_material, "m_properties", "Ljava/util/List;", jassimp_properties)) { return NULL; } jvalue add_properties_params[1]; add_properties_params[0].l = jassimp_material_property; if (!call_method(env, jassimp_properties, "java/util/Collection", "add", "(Ljava/lang/Object;)Z", add_properties_params)) { return NULL; } } return jassimp_material; }
void Application_init( Handle self, HV * profile) { dPROFILE; int hintPause = pget_i( hintPause); Color hintColor = pget_i( hintColor), hintBackColor = pget_i( hintBackColor); SV * hintFont = pget_sv( hintFont); SV * sv; char * hintClass = pget_c( hintClass); if ( application != nilHandle) croak( "Attempt to create more than one application instance"); CDrawable-> init( self, profile); list_create( &var-> widgets, 16, 16); list_create( &var-> modalHorizons, 0, 8); application = self; if ( !apc_application_create( self)) croak( "Error creating application"); /* Widget init */ SvHV_Font( pget_sv( font), &Font_buffer, "Application::init"); my-> set_font( self, Font_buffer); SvHV_Font( pget_sv( popupFont), &Font_buffer, "Application::init"); my-> set_popup_font( self, Font_buffer); { AV * av = ( AV *) SvRV( pget_sv( designScale)); SV ** holder = av_fetch( av, 0, 0); if ( holder) var-> designScale. x = SvNV( *holder); else warn("Array panic on 'designScale'"); holder = av_fetch( av, 1, 0); if ( holder) var-> designScale. y = SvNV( *holder); else warn("Array panic on 'designScale'"); pdelete( designScale); } var-> text = duplicate_string(""); opt_set( optModalHorizon); /* store extra info */ { HV * hv = ( HV *) SvRV( var-> mate); (void) hv_store( hv, "PrinterClass", 12, newSVpv( pget_c( printerClass), 0), 0); (void) hv_store( hv, "PrinterModule", 13, newSVpv( pget_c( printerModule), 0), 0); (void) hv_store( hv, "HelpClass", 9, newSVpv( pget_c( helpClass), 0), 0); (void) hv_store( hv, "HelpModule", 10, newSVpv( pget_c( helpModule), 0), 0); } { HV * profile = newHV(); static Timer_vmt HintTimerVmt; pset_H( owner, self); pset_i( timeout, hintPause); pset_c( name, "HintTimer"); var-> hintTimer = create_instance( "Prima::Timer"); protect_object( var-> hintTimer); hv_clear( profile); memcpy( &HintTimerVmt, CTimer, sizeof( HintTimerVmt)); HintTimerVmt. handle_event = Application_HintTimer_handle_event; (( PTimer) var-> hintTimer)-> self = &HintTimerVmt; pset_H( owner, self); pset_i( color, hintColor); pset_i( backColor, hintBackColor); pset_i( visible, 0); pset_i( selectable, 0); pset_i( showHint, 0); pset_c( name, "HintWidget"); pset_sv( font, hintFont); var-> hintWidget = create_instance( hintClass); protect_object( var-> hintWidget); sv_free(( SV *) profile); } if ( SvTYPE( sv = pget_sv( accelItems)) != SVt_NULL) my-> set_accelItems( self, sv); if ( SvTYPE( sv = pget_sv( popupItems)) != SVt_NULL) my-> set_popupItems( self, sv); pdelete( accelTable); pdelete( accelItems); pdelete( popupItems); my-> set( self, profile); CORE_INIT_TRANSIENT(Application); }
v8::Persistent<v8::Object> create_persistent_instance(TWrapped* wrapped) { v8::Persistent<v8::Object> instance = v8::Persistent<v8::Object>::New(create_instance(wrapped)); instance.MakeWeak(wrapped, Osmium::Javascript::Template::free_instance<TWrapped>); return instance; }
static int transition_get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) { // Error we will return int error = 0; // We will get the 'b frame' from the frame stack mlt_frame b_frame = mlt_frame_pop_frame( frame ); // Get the watermark transition object mlt_transition transition = mlt_frame_pop_service( frame ); // Get the properties of the transitionfin mlt_properties properties = MLT_TRANSITION_PROPERTIES( transition ); // Get the properties of the a frame mlt_properties a_props = MLT_FRAME_PROPERTIES( frame ); mlt_service_lock( MLT_TRANSITION_SERVICE( transition ) ); // Get the composite from the transition mlt_transition composite = mlt_properties_get_data( properties, "composite", NULL ); // Look for the first filter mlt_filter filter = mlt_properties_get_data( properties, "_filter_0", NULL ); // Get the position mlt_position position = mlt_transition_get_position( transition, frame ); // Create a composite if we don't have one if ( composite == NULL ) { // Create composite via the factory mlt_profile profile = mlt_service_profile( MLT_TRANSITION_SERVICE( transition ) ); composite = mlt_factory_transition( profile, "composite", NULL ); // If we have one if ( composite != NULL ) { // Get the properties mlt_properties composite_properties = MLT_TRANSITION_PROPERTIES( composite ); // We want to ensure that we don't get a wobble... //mlt_properties_set_int( composite_properties, "distort", 1 ); mlt_properties_set_int( composite_properties, "progressive", 1 ); // Pass all the composite. properties on the transition down mlt_properties_pass( composite_properties, properties, "composite." ); // Register the composite for reuse/destruction mlt_properties_set_data( properties, "composite", composite, 0, ( mlt_destructor )mlt_transition_close, NULL ); } } else { // Pass all current properties down mlt_properties composite_properties = MLT_TRANSITION_PROPERTIES( composite ); mlt_properties_pass( composite_properties, properties, "composite." ); } // Create filters if ( filter == NULL ) { // Loop Variable int i = 0; // Number of filters created int count = 0; // Loop for all properties for ( i = 0; i < mlt_properties_count( properties ); i ++ ) { // Get the name of this property char *name = mlt_properties_get_name( properties, i ); // If the name does not contain a . and matches filter if ( strchr( name, '.' ) == NULL && !strncmp( name, "filter", 6 ) ) { // Get the filter constructor char *value = mlt_properties_get_value( properties, i ); // Create an instance if ( create_instance( transition, name, value, count ) == 0 ) count ++; } } // Look for the first filter again filter = mlt_properties_get_data( properties, "_filter_0", NULL ); } else { // Pass all properties down mlt_filter temp = NULL; // Loop Variable int i = 0; // Number of filters found int count = 0; // Loop for all properties for ( i = 0; i < mlt_properties_count( properties ); i ++ ) { // Get the name of this property char *name = mlt_properties_get_name( properties, i ); // If the name does not contain a . and matches filter if ( strchr( name, '.' ) == NULL && !strncmp( name, "filter", 6 ) ) { // Strings to hold the id and pass down key char id[ 256 ]; char key[ 256 ]; // Construct id and key sprintf( id, "_filter_%d", count ); sprintf( key, "%s.", name ); // Get the filter temp = mlt_properties_get_data( properties, id, NULL ); if ( temp != NULL ) { mlt_properties_pass( MLT_FILTER_PROPERTIES( temp ), properties, key ); count ++; } } } } mlt_properties_set_int( a_props, "width", *width ); mlt_properties_set_int( a_props, "height", *height ); // Only continue if we have both filter and composite if ( composite != NULL ) { // Get the resource of this filter (could be a shape [rectangle/circle] or an alpha provider of choice const char *resource = mlt_properties_get( properties, "resource" ); // Get the old resource in case it's changed char *old_resource = mlt_properties_get( properties, "_old_resource" ); // String to hold the filter to query on char id[ 256 ]; // Index to hold the count int i = 0; // We will get the 'b frame' from the composite only if it's NULL (region filter) if ( b_frame == NULL ) { // Copy the region b_frame = composite_copy_region( composite, frame, position ); // Ensure a destructor char *name = mlt_properties_get( properties, "_unique_id" ); mlt_properties_set_data( a_props, name, b_frame, 0, ( mlt_destructor )mlt_frame_close, NULL ); } // Properties of the B framr mlt_properties b_props = MLT_FRAME_PROPERTIES( b_frame ); // filter_only prevents copying the alpha channel of the shape to the output frame // by compositing filtered frame over itself if ( mlt_properties_get_int( properties, "filter_only" ) ) { char *name = mlt_properties_get( properties, "_unique_id" ); frame = composite_copy_region( composite, b_frame, position ); mlt_properties_set_data( b_props, name, frame, 0, ( mlt_destructor )mlt_frame_close, NULL ); } // Make sure the filter is in the correct position while ( filter != NULL ) { // Stack this filter if ( mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "off" ) == 0 ) mlt_filter_process( filter, b_frame ); // Generate the key for the next sprintf( id, "_filter_%d", ++ i ); // Get the next filter filter = mlt_properties_get_data( properties, id, NULL ); } // Allow filters to be attached to a region filter filter = mlt_properties_get_data( properties, "_region_filter", NULL ); if ( filter != NULL ) mlt_service_apply_filters( MLT_FILTER_SERVICE( filter ), b_frame, 0 ); // Hmm - this is probably going to go wrong.... mlt_frame_set_position( frame, position ); // Get the b frame and process with composite if successful mlt_transition_process( composite, frame, b_frame ); // If we have a shape producer copy the alpha mask from the shape frame to the b_frame if ( strcmp( resource, "rectangle" ) != 0 ) { // Get the producer from the transition mlt_producer producer = mlt_properties_get_data( properties, "producer", NULL ); // If We have no producer then create one if ( producer == NULL || ( old_resource != NULL && strcmp( resource, old_resource ) ) ) { // Get the factory producer service char *factory = mlt_properties_get( properties, "factory" ); // Store the old resource mlt_properties_set( properties, "_old_resource", resource ); // Special case circle resource if ( strcmp( resource, "circle" ) == 0 ) resource = "pixbuf:<svg width='100' height='100'><circle cx='50' cy='50' r='50' fill='black'/></svg>"; // Create the producer mlt_profile profile = mlt_service_profile( MLT_TRANSITION_SERVICE( transition ) ); producer = mlt_factory_producer( profile, factory, resource ); // If we have one if ( producer != NULL ) { // Get the producer properties mlt_properties producer_properties = MLT_PRODUCER_PROPERTIES( producer ); // Ensure that we loop mlt_properties_set( producer_properties, "eof", "loop" ); // Now pass all producer. properties on the transition down mlt_properties_pass( producer_properties, properties, "producer." ); // Register the producer for reuse/destruction mlt_properties_set_data( properties, "producer", producer, 0, ( mlt_destructor )mlt_producer_close, NULL ); } } // Now use the shape producer if ( producer != NULL ) { // We will get the alpha frame from the producer mlt_frame shape_frame = NULL; // Make sure the producer is in the correct position mlt_producer_seek( producer, position ); // Get the shape frame if ( mlt_service_get_frame( MLT_PRODUCER_SERVICE( producer ), &shape_frame, 0 ) == 0 ) { // Ensure that the shape frame will be closed mlt_properties_set_data( b_props, "shape_frame", shape_frame, 0, ( mlt_destructor )mlt_frame_close, NULL ); if ( mlt_properties_get_int(properties, "holecolor") ) { mlt_properties_set_int(b_props, "holecolor", mlt_properties_get_int(properties,"holecolor")); } // Specify the callback for evaluation b_frame->get_alpha_mask = filter_get_alpha_mask; } } } // Get the image error = mlt_frame_get_image( frame, image, format, width, height, 0 ); } mlt_service_unlock( MLT_TRANSITION_SERVICE( transition ) ); return error; }
static int create_service(const char *instance_name, const char *kssl_entry, const char *command, const char *username, char *inaddr_any_name) { int status = FAILURE; scf_scope_t *scope; scf_service_t *svc; scf_handle_t *handle; boolean_t errflag = B_TRUE; handle = scf_handle_create(SCF_VERSION); if (handle == NULL) { KSSL_DEBUG("scf_handle_create failed: %s\n", scf_strerror(scf_error())); goto out1; } KSSL_DEBUG("scf_handle_create succeeded\n"); if (scf_handle_bind(handle) == -1) { KSSL_DEBUG("scf_handle_bind failed: %s\n", scf_strerror(scf_error())); goto out1; } KSSL_DEBUG("scf_handle_bind succeeded\n"); if ((scope = scf_scope_create(handle)) == NULL) { KSSL_DEBUG("scf_scope_create failed: %s\n", scf_strerror(scf_error())); goto out2; } KSSL_DEBUG("scf_scope_create succeeded\n"); if ((svc = scf_service_create(handle)) == NULL) { KSSL_DEBUG("scf_service_create failed: %s\n", scf_strerror(scf_error())); goto out3; } KSSL_DEBUG("scf_service_create succeeded\n"); if (scf_handle_decode_fmri(handle, SERVICE_NAME, NULL, svc, NULL, NULL, NULL, SCF_DECODE_FMRI_EXACT) != 0) { KSSL_DEBUG("scf_handle_decode_fmri failed: %s\n", scf_strerror(scf_error())); if (scf_error() == SCF_ERROR_NOT_FOUND) { (void) fprintf(stderr, gettext( "service %s not found in the repository." " Exiting.\n"), SERVICE_NAME); errflag = B_FALSE; } goto out4; } status = create_instance(handle, svc, instance_name, kssl_entry, command, username, inaddr_any_name); out4: scf_service_destroy(svc); out3: scf_scope_destroy(scope); out2: (void) scf_handle_unbind(handle); out1: if (handle != NULL) scf_handle_destroy(handle); if (status != SUCCESS && status != INSTANCE_OTHER_EXISTS && status != INSTANCE_ANY_EXISTS && errflag) (void) fprintf(stderr, gettext( "Unexpected fatal libscf error: %s. Exiting.\n"), scf_strerror(scf_error())); return (status); }
int main (int argc, char **argv) { int c; errno = 0; if (argc < 2) usage(argv); if (strcmp(argv[1], "report") == 0) { trace_report(argc, argv); exit(0); } else if (strcmp(argv[1], "snapshot") == 0) { trace_snapshot(argc, argv); exit(0); } else if (strcmp(argv[1], "hist") == 0) { trace_hist(argc, argv); exit(0); } else if (strcmp(argv[1], "mem") == 0) { trace_mem(argc, argv); exit(0); } else if (strcmp(argv[1], "listen") == 0) { trace_listen(argc, argv); exit(0); } else if (strcmp(argv[1], "split") == 0) { trace_split(argc, argv); exit(0); } else if (strcmp(argv[1], "restore") == 0) { trace_restore(argc, argv); exit(0); } else if (strcmp(argv[1], "stack") == 0) { trace_stack(argc, argv); exit(0); } else if (strcmp(argv[1], "check-events") == 0) { const char *tracing; int ret; struct pevent *pevent = NULL; struct plugin_list *list = NULL; while ((c = getopt(argc-1, argv+1, "+hN")) >= 0) { switch (c) { case 'h': default: usage(argv); break; case 'N': tracecmd_disable_plugins = 1; break; } } tracing = tracecmd_get_tracing_dir(); if (!tracing) { printf("Can not find or mount tracing directory!\n" "Either tracing is not configured for this " "kernel\n" "or you do not have the proper permissions to " "mount the directory"); exit(EINVAL); } pevent = pevent_alloc(); if (!pevent) exit(EINVAL); list = tracecmd_load_plugins(pevent); ret = tracecmd_fill_local_events(tracing, pevent); if (ret || pevent->parsing_failures) ret = EINVAL; tracecmd_unload_plugins(list, pevent); pevent_free(pevent); exit(ret); } else if (strcmp(argv[1], "record") == 0 || strcmp(argv[1], "start") == 0 || strcmp(argv[1], "extract") == 0 || strcmp(argv[1], "stop") == 0 || strcmp(argv[1], "stream") == 0 || strcmp(argv[1], "profile") == 0 || strcmp(argv[1], "restart") == 0 || strcmp(argv[1], "reset") == 0) { trace_record(argc, argv); exit(0); } else if (strcmp(argv[1], "stat") == 0) { trace_stat(argc, argv); exit(0); } else if (strcmp(argv[1], "options") == 0) { show_plugin_options(); exit(0); } else if (strcmp(argv[1], "show") == 0) { const char *buffer = NULL; const char *file = "trace"; const char *cpu = NULL; struct buffer_instance *instance = &top_instance; char cpu_path[128]; char *path; int snap = 0; int pipe = 0; int show_name = 0; int option_index = 0; int stop = 0; static struct option long_options[] = { {"tracing_on", no_argument, NULL, OPT_tracing_on}, {"current_tracer", no_argument, NULL, OPT_current_tracer}, {"buffer_size", no_argument, NULL, OPT_buffer_size_kb}, {"buffer_total_size", no_argument, NULL, OPT_buffer_total_size_kb}, {"ftrace_filter", no_argument, NULL, OPT_ftrace_filter}, {"ftrace_notrace", no_argument, NULL, OPT_ftrace_notrace}, {"ftrace_pid", no_argument, NULL, OPT_ftrace_pid}, {"graph_function", no_argument, NULL, OPT_graph_function}, {"graph_notrace", no_argument, NULL, OPT_graph_notrace}, {"cpumask", no_argument, NULL, OPT_cpumask}, {"help", no_argument, NULL, '?'}, {NULL, 0, NULL, 0} }; while ((c = getopt_long(argc-1, argv+1, "B:c:fsp", long_options, &option_index)) >= 0) { switch (c) { case 'h': usage(argv); break; case 'B': if (buffer) die("Can only show one buffer at a time"); buffer = optarg; instance = create_instance(optarg); if (!instance) die("Failed to create instance"); break; case 'c': if (cpu) die("Can only show one CPU at a time"); cpu = optarg; break; case 'f': show_name = 1; break; case 's': snap = 1; if (pipe) die("Can not have -s and -p together"); break; case 'p': pipe = 1; if (snap) die("Can not have -s and -p together"); break; case OPT_tracing_on: show_instance_file(instance, "tracing_on"); stop = 1; break; case OPT_current_tracer: show_instance_file(instance, "current_tracer"); stop = 1; break; case OPT_buffer_size_kb: show_instance_file(instance, "buffer_size_kb"); stop = 1; break; case OPT_buffer_total_size_kb: show_instance_file(instance, "buffer_total_size_kb"); stop = 1; break; case OPT_ftrace_filter: show_instance_file(instance, "set_ftrace_filter"); stop = 1; break; case OPT_ftrace_notrace: show_instance_file(instance, "set_ftrace_notrace"); stop = 1; break; case OPT_ftrace_pid: show_instance_file(instance, "set_ftrace_pid"); stop = 1; break; case OPT_graph_function: show_instance_file(instance, "set_graph_function"); stop = 1; break; case OPT_graph_notrace: show_instance_file(instance, "set_graph_notrace"); stop = 1; break; case OPT_cpumask: show_instance_file(instance, "tracing_cpumask"); stop = 1; break; default: usage(argv); } } if (stop) exit(0); if (pipe) file = "trace_pipe"; else if (snap) file = "snapshot"; if (cpu) { snprintf(cpu_path, 128, "per_cpu/cpu%d/%s", atoi(cpu), file); file = cpu_path; } if (buffer) { path = malloc(strlen(buffer) + strlen("instances//") + strlen(file) + 1); if (path) die("Failed to allocate instance path %s", file); sprintf(path, "instances/%s/%s", buffer, file); file = path; } if (show_name) { char *name; name = tracecmd_get_tracing_file(file); printf("%s\n", name); tracecmd_put_tracing_file(name); } show_file(file); if (buffer) free(path); exit(0); } else if (strcmp(argv[1], "list") == 0) { int events = 0; int tracer = 0; int options = 0; int funcs = 0; int buffers = 0; int clocks = 0; int plug = 0; int plug_op = 0; int flags = 0; int show_all = 1; int i; const char *arg; const char *funcre = NULL; const char *eventre = NULL; for (i = 2; i < argc; i++) { arg = NULL; if (argv[i][0] == '-') { if (i < argc - 1) { if (argv[i+1][0] != '-') arg = argv[i+1]; } switch (argv[i][1]) { case 'h': usage(argv); break; case 'e': events = 1; eventre = arg; show_all = 0; break; case 'B': buffers = 1; show_all = 0; break; case 'C': clocks = 1; show_all = 0; break; case 'F': flags |= SHOW_EVENT_FORMAT; break; case 'R': flags |= SHOW_EVENT_TRIGGER; break; case 'l': flags |= SHOW_EVENT_FILTER; break; case 'p': case 't': tracer = 1; show_all = 0; break; case 'P': plug = 1; show_all = 0; break; case 'O': plug_op = 1; show_all = 0; break; case 'o': options = 1; show_all = 0; break; case 'f': funcs = 1; funcre = arg; show_all = 0; break; default: fprintf(stderr, "list: invalid option -- '%c'\n", argv[optind][1]); usage(argv); } } } if (events) show_events(eventre, flags); if (tracer) show_tracers(); if (options) show_options(); if (plug) show_plugins(); if (plug_op) show_plugin_options(); if (funcs) show_functions(funcre); if (buffers) show_buffers(); if (clocks) show_clocks(); if (show_all) { printf("events:\n"); show_events(NULL, 0); printf("\ntracers:\n"); show_tracers(); printf("\noptions:\n"); show_options(); } exit(0); } else if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "help") == 0) { usage(argv); } else { fprintf(stderr, "unknown command: %s\n", argv[1]); usage(argv); } return 0; }
int main(int argc, char **argv) { install_default_signal_handler(); struct tesla_store *global_store; struct tesla_class *glob_automaton; check(tesla_store_get(TESLA_CONTEXT_GLOBAL, 1, 3, &global_store)); check(tesla_class_get(global_store, &glob, &glob_automaton)); struct tesla_store *perthread_store; struct tesla_class *thr_automaton; check(tesla_store_get(TESLA_CONTEXT_THREAD, 1, 3, &perthread_store)); check(tesla_class_get(perthread_store, &thr, &thr_automaton)); /* Create some automata instances. */ create_instance(glob_automaton, &instances[0], 42, 0, 1000); create_instance(glob_automaton, &instances[1], 43, 0, 1000); create_instance(glob_automaton, &instances[2], 42, 0, -1); create_instance(thr_automaton, &instances[3], 42, 0, 1000); create_instance(thr_automaton, &instances[4], 43, 1, 1000); create_instance(thr_automaton, &instances[5], 42, 1, -1); // Make sure they are all unique; this is n^2, but n is small. for (int32_t i = 0; i < INSTANCES; i++) { for (int32_t j = 0; j < INSTANCES; j++) { if (i == j) continue; assert(instances[i] != instances[j]); } } // Ok, let's go looking for automata instances! struct tesla_key pattern; // keys[0] == 42 => {0,2,3,5} pattern.tk_mask = 1 << 0; pattern.tk_keys[0] = 42; assert((search_for_pattern(glob_automaton, &pattern) | search_for_pattern(thr_automaton, &pattern)) == 0x2D ); // keys[1] == 0 => {0,1,2,3} pattern.tk_mask = 1 << 1; pattern.tk_keys[1] = 0; // the value 0 is not special assert((search_for_pattern(glob_automaton, &pattern) | search_for_pattern(thr_automaton, &pattern)) == 0x0F ); // keys[2] == -1 => {2,5} pattern.tk_mask = 1 << 2; pattern.tk_keys[2] = -1; // the value -1 is not special, either assert((search_for_pattern(glob_automaton, &pattern) | search_for_pattern(thr_automaton, &pattern)) == 0x24 ); // keys[0] == 42 && keys[1] == 1 => {5} pattern.tk_mask = (1 << 0) + (1 << 1); pattern.tk_keys[0] = 42; pattern.tk_keys[1] = 1; assert((search_for_pattern(glob_automaton, &pattern) | search_for_pattern(thr_automaton, &pattern)) == 0x20 ); // 'ANY' pattern => all pattern.tk_mask = 0; assert((search_for_pattern(glob_automaton, &pattern) | search_for_pattern(thr_automaton, &pattern)) == 0x3F ); tesla_class_put(glob_automaton); tesla_class_put(thr_automaton); return 0; }
static nifi_instance *create_instance_obj(const char *name = "random_instance") { nifi_port port; char port_str[] = "12345"; port.port_id = port_str; return create_instance("random_instance", &port); }
void MidiMap::reset_instance() { create_instance(); __instance->reset(); }
/**************** * Load and initialize the winseed DLL * NOTE: winseed is not part of the GnuPG distribution. It should be available * at the GNU crypto FTP server site. * We do not load the DLL on demand to have a better control over the * location of the library. */ static void load_and_init_winseed( void ) { HANDLE hInstance; void *addr; unsigned int reason = 0; unsigned int n1, n2; const char *dllname; dllname = read_w32_registry_string( "HKEY_LOCAL_MACHINE", "Software\\GNU\\GnuPG", "EntropyDLL" ); if( !dllname ) dllname = "c:/gnupg/entropy.dll"; hInstance = LoadLibrary( dllname ); if( !hInstance ) goto failure; if( !(addr = GetProcAddress( hInstance, "WS_create_instance" )) ) goto failure; create_instance = addr; if( !(addr = GetProcAddress( hInstance, "WS_delete_instance" )) ) goto failure; delete_instance = addr; if( !(addr = GetProcAddress( hInstance, "WS_get_internal_seed_size" )) ) goto failure; get_internal_seed_size = addr; if( !(addr = GetProcAddress( hInstance, "WS_set_internal_seed_size" )) ) goto failure; set_internal_seed_size = addr; if( !(addr = GetProcAddress( hInstance, "WS_get_expected_seed_size" )) ) goto failure; get_expected_seed_size = addr; if( !(addr = GetProcAddress( hInstance, "WS_get_seed" )) ) goto failure; get_seed = addr; /* we have all the functions - init the system */ slow_seeder = create_instance( WIN32_SLOW_SEEDER, &reason); if( !slow_seeder ) { g10_log_fatal("error creating winseed slow seeder: rc=%u\n", reason ); goto failure; } fast_seeder = create_instance( WIN32_FAST_SEEDER, &reason); if( !fast_seeder ) { g10_log_fatal("error creating winseed fast seeder: rc=%u\n", reason ); goto failure; } n1 = get_internal_seed_size( slow_seeder ); /*g10_log_info("slow buffer size=%u\n", n1);*/ n2 = get_internal_seed_size( fast_seeder ); /*g10_log_info("fast buffer size=%u\n", n2);*/ entropy_buffer_size = n1 > n2? n1: n2; entropy_buffer = m_alloc( entropy_buffer_size ); /*g10_log_info("using a buffer of size=%u\n", entropy_buffer_size );*/ return; failure: g10_log_fatal("error loading winseed DLL `%s'\n", dllname ); }