Module Module::GetProviding(std::string name)
	{
#if defined(_WIN32)
		try
		{
			Module psapi(L"Psapi.dll");
			auto EnumProcessModules = (BOOL WINAPI (*)(HANDLE, HMODULE*, DWORD, LPDWORD))psapi["EnumProcessModules"];
			auto GetModuleFileNameExW = (DWORD WINAPI (*)(HANDLE, HMODULE, LPWSTR, DWORD))psapi["GetModuleFileNameExW"];

			HANDLE process = GetCurrentProcess();
			DWORD bytes_needed = 0;
			EnumProcessModules(process, nullptr, 0, &bytes_needed);
			size_t n_modules = bytes_needed / sizeof(HMODULE);
			std::vector<HMODULE> modules(n_modules);

			EnumProcessModules(process, modules.data(), modules.size()*sizeof(HMODULE), &bytes_needed);
			for (auto m: modules)
			{
				Module module(m);
				if (module.Probe(name))
				{
					wchar_t filename[MAX_PATH];
					GetModuleFileNameExW(process, m, filename, MAX_PATH);
					//LOG(Info, "Symbol \"" << name.c_str() << "\" was found in \"" << filename << "\""); // FIXME: global object dependency failure

					return module;
				}
			}
		}
		catch (std::exception& e)
		{
			//LOG(Error, "Module enumeration has failed: " << e.what()); // FIXME: global object dependency failure
		}
#else
		void* m = dlopen(0, RTLD_NOW|RTLD_GLOBAL);
		if (dlsym(m, name.c_str()) != nullptr)
		{
			return Module(m);
		}
#endif
		return Module();
	}
Example #2
0
		bool generateOutput(const string& fileContents, const string& outputBitCodeName) {
			// Parse the source file
			//cout << "Parsing..." << endl;
			base_expr_node rootAst;
			if (!parse(fileContents, rootAst)) {
				cerr << "Failed to parse source file!" << endl;
				return false;
			}

			// Generate the code
			//cout << "Generating code..." << endl;
			LLVMContext &context = getGlobalContext();
			unique_ptr<Module> module(new Module("", context));
			IRBuilder<> builder(getGlobalContext());

			ast_codegen codeGenerator(module.get(), builder);

			// Generate code for each expression at the root level
			const base_expr* expr = boost::get<base_expr>(&rootAst);
			for (auto& itr : expr->children) {
				boost::apply_visitor(codeGenerator, itr);
			}

			// Perform an LLVM verify as a sanity check
			string errorInfo;
			raw_string_ostream errorOut(errorInfo);

			if (verifyModule(*module, &errorOut)) {
				cerr << "Failed to generate LLVM IR: " << errorInfo << endl;

				module->print(errorOut, nullptr);
				cerr << "Module:" << endl << errorInfo << endl;
				return false;
			}

			// Dump the LLVM IR to a file
			llvm::raw_fd_ostream outStream(outputBitCodeName.c_str(), errorInfo, llvm::sys::fs::F_None);
			llvm::WriteBitcodeToFile(module.get(), outStream);

			return true;
		}
Example #3
0
void test_module()
{
	v8pp::context context;

	v8::HandleScope scope(context.isolate());

	v8pp::module module(context.isolate());
	v8pp::module consts(context.isolate());

	consts
		.set_const("bool", true)
		.set_const("char", 'Z')
		.set_const("int", 100)
		.set_const("str", "str")
		.set_const("num", 99.9)
		;

	module
		.set("consts", consts)
		.set("var", var)
		.set("fun", &fun)
		.set("empty", v8::Null(context.isolate()))
		.set("rprop", v8pp::property(get_x))
		.set("wprop", v8pp::property(get_x, set_x))
		;
	context.set("module", module);

	check_eq("module.consts.bool", run_script<bool>(context, "module.consts.bool"), true);
	check_eq("module.consts.char", run_script<char>(context, "module.consts.char"), 'Z');
	check_eq("module.consts.int", run_script<char>(context, "module.consts.int"), 100);
	check_eq("module.consts.str", run_script<std::string>(context, "module.consts.str"), "str");

	check_eq("module.var", run_script<std::string>(context, "module.var = 'test'; module.var"), "test");
	check_eq("var", var, "test");

	check_eq("module.fun", run_script<int>(context, "module.fun(100)"), 101);

	check_eq("module.rprop", run_script<int>(context, "module.rprop"), 2);
	check_eq("module.wrop", run_script<int>(context, "++module.wprop"), 3);
	check_eq("x", x, 2);
}
Example #4
0
int cmd_enable(FILE * f, int argc, char ** argv)
{
	uint32_t sb[160 / 32];
	uint32_t mb[160 / 32];
	int ret;

	if (argc == 1) {
		struct ss_device * dev;
		unsigned int addr;

		/* Print enabled status flag of all the devices */

		fprintf(f, "Sensors:");
		for (addr = 0; addr < 160; ++addr) {
			dev = sensor(addr);
			if (dev->enabled)
				fprintf(f, " %3d", addr);
		}

		fprintf(f, "\nModules:");
		for (addr = 0; addr < 160; ++addr) {
			dev = module(addr);
			if (dev->enabled)
				fprintf(f, " %3d", addr);
		}
		fprintf(f, "\n");

		return 0;
	}

	if ((ret = dev_lst_cmd_parse(f, argc, argv, sb, mb)) < 0)
		return ret;

	dev_lst_remove_unconfigured(sb, mb);

	dev_sim_multiple_enable(sb, mb);

	fprintf(f, "Enabled.\n");

	return 0;
}
Example #5
0
Module Process::isInjected(const Library& lib)
{
	MEMORY_BASIC_INFORMATION mem_basic_info = { 0 };
	SYSTEM_INFO sys_info = getSystemInfo();

	for (SIZE_T mem = 0; mem < (SIZE_T)sys_info.lpMaximumApplicationAddress; mem += mem_basic_info.RegionSize)
	{
		mem_basic_info = memBasicInfo((const void*)mem);

		if ((mem_basic_info.AllocationProtect & PAGE_EXECUTE_WRITECOPY) &&
			(mem_basic_info.Protect & (PAGE_EXECUTE | PAGE_EXECUTE_READ |
				PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY)))
		{
			Module module((HMODULE)mem_basic_info.AllocationBase, *this);
			if (boost::iequals(module.mappedFilename(*this), lib.ntFilename()))
				return module;
		}
	}

	return Module(); // access denied or not found
}
void JsonObject::bindToScript(lua_State* lua_state)
{
	module(lua_state)
		[
			class_<JsonObject>("JsonObject")
			.def(constructor<>())
			.def("isNull", &JsonObject::isNull)
			.def("asInt", &JsonObject::asInt)
			.def("asDouble", &JsonObject::asDouble)
			.def("asString", &JsonObject::asString)
			.def("asBool", &JsonObject::asBool)
			.def("asArray", &JsonObject::asArray)
			.def("asMember", &JsonObject::asMember)
			.def("getTypeAsString", &JsonObject::getTypeAsString)
			.def("show", &JsonObject::show)
			.def("selectChildNode", static_cast<JsonObject(JsonObject::*)(const string&)>(&JsonObject::selectChildNode))
			.def("selectChildNode", static_cast<JsonObject(JsonObject::*)(int)>(&JsonObject::selectChildNode))
			.def("count", &JsonObject::count)

		];
}
void UndoDiagramModulePasteActionFn(void *info)
{
	TransformNode		*dgmNode = ((UndoDiagramModuleCut *)info)->mpDiagramNode;
	int			nScriptNode		= ((UndoDiagramModulePaste *)info)->mnScriptNode;
	ScriptNode	**scriptNode	= ((UndoDiagramModulePaste *)info)->mpScriptNode;
	int			nRoute			= ((UndoDiagramModulePaste *)info)->mnRoute;
	Route		**route			= ((UndoDiagramModulePaste *)info)->mpRoute;

	for (int n=0; n<nRoute; n++) {
		GetWorld()->getSceneGraph()->removeRoute(route[n]);
	}

	CDiagram dgm(dgmNode);
	for (n=0; n<nScriptNode; n++) {
		CModule module(scriptNode[n]);
		dgm.removeModule(&module);
	}

	delete	[]scriptNode;
	delete	[]route;
}
void UndoDiagramModuleDeleteActionFn(void *info)
{
	UndoDiagramModuleDelete *dmInfo = (UndoDiagramModuleDelete *)info;

	TransformNode	*diagramNode = dmInfo->mpDiagramNode;
	ScriptNode		*moduleNode = dmInfo->mpNode;

	CDiagram	diagram(diagramNode);
	CModule		module(moduleNode);
	diagram.addModule(&module);

	if (0 < dmInfo->mnRouteInfo) {
		for (int n=0; n<dmInfo->mnRouteInfo; n++) {
			RouteInfo *routeInfo = &dmInfo->maRouteInfo[n];
			GetWorld()->getSceneGraph()->addRoute(routeInfo->mOutNode, routeInfo->mOutField, routeInfo->mInNode, routeInfo->mInField);
		}
	}

	if (dmInfo->maRouteInfo)
		delete dmInfo->maRouteInfo;
}
//------------------------------------------------------------------------------------
void CHomogeneousTexture_Extractor::FeatureExtraction(unsigned char* image)
{
    int	n, m;
    Num_pixel = 180*64;


    vatomdesign();
    hatomdesign();
    module(image, image_height, image_width);

    m_dc = (int)dc;
    m_std = (int)stdev;

    for(n=0; n<5; n++)
        for(m=0; m<6; m++)
            mean2[n][m]=(int)(vec[n][m]);		// mean : 30 energy features
    for(n=0; n<5; n++)
        for(m=0; m<6; m++)
            dev2[n][m]=(int)(dvec[n][m]);		// dev	: 30 deviation features

}
Example #10
0
CUresult CuContext::LoadModuleFilenameEx(const std::string& filename, 
	ModulePtr* ppModule, uint maxRegisters) {

	std::ifstream file(filename.c_str());
	if(!file.good()) return CUDA_ERROR_FILE_NOT_FOUND;

	std::string contents(std::istreambuf_iterator<char>(file),
		std::istreambuf_iterator<char>(0));

	ModulePtr module(new CuModule);

	CUjit_option options[1] = { CU_JIT_MAX_REGISTERS };
	uint values[1] = { maxRegisters };
	CUresult result = cuModuleLoadDataEx(&module->_module, contents.c_str(),
		1, options, (void**)values);
	HANDLE_RESULT();

	module->_context = this;
	ppModule->swap(module);
	return CUDA_SUCCESS;
}
Example #11
0
void x86_kernel_main(struct multiboot *multiboot)
{
	init_output();
	init_paging(multiboot);
	init_acpi();
	init_descriptor_tables();

	kprint("Stack pointer: ");
	kprint_hexnl(read_esp());
	kprint("Mod count: ");
	kprint_hexnl(multiboot->mods_count);
	kprint("Kernel phys end : ");
	kprint_hexnl((u32)&__phys_end);
	kprint("Mod addr start : ");
	kprint_hexnl(*(u32*)(phys_to_virt(multiboot->mods_addr)));
	kprint("Mod addr end : ");
	kprint_hexnl(*(u32*)(phys_to_virt(multiboot->mods_addr) + 4));

	//init_tasking();

	kernel_main();

	if (multiboot->mods_count == 13) {
		kprint("Executing module..\n");

		typedef void (*module_fun)(void);

		u32 modaddr = phys_to_virt(multiboot->mods_addr);
		modaddr = phys_to_virt(*(u32*)modaddr);

		//kprint_hexnl(modaddr);
		//kprint_hexnl(*(u32*)modaddr);

		module_fun module = (module_fun)modaddr;

		module();
		kprint("Modadr is ");

	}
}
Example #12
0
// Add a new PKCS11 module to the user's profile.
NS_IMETHODIMP
nsPkcs11::AddModule(const nsAString& aModuleName,
                    const nsAString& aLibraryFullPath,
                    int32_t aCryptoMechanismFlags,
                    int32_t aCipherFlags)
{
  nsNSSShutDownPreventionLock locker;
  if (isAlreadyShutDown()) {
    return NS_ERROR_NOT_AVAILABLE;
  }

  if (aModuleName.IsEmpty()) {
    return NS_ERROR_INVALID_ARG;
  }

  NS_ConvertUTF16toUTF8 moduleName(aModuleName);
  nsCString fullPath;
  // NSS doesn't support Unicode path.  Use native charset
  NS_CopyUnicodeToNative(aLibraryFullPath, fullPath);
  uint32_t mechFlags = SECMOD_PubMechFlagstoInternal(aCryptoMechanismFlags);
  uint32_t cipherFlags = SECMOD_PubCipherFlagstoInternal(aCipherFlags);
  SECStatus srv = SECMOD_AddNewModule(moduleName.get(), fullPath.get(),
                                      mechFlags, cipherFlags);
  if (srv != SECSuccess) {
    return NS_ERROR_FAILURE;
  }

#ifndef MOZ_NO_SMART_CARDS
  mozilla::UniqueSECMODModule module(SECMOD_FindModule(moduleName.get()));
  if (!module) {
    return NS_ERROR_FAILURE;
  }
  nsCOMPtr<nsINSSComponent> nssComponent(
    do_GetService(PSM_COMPONENT_CONTRACTID));
  nssComponent->LaunchSmartCardThread(module.get());
#endif

  return NS_OK;
}
Example #13
0
/** @note This function looks quite similar to @ref register_logger_module. */
tmodule* tmodule::find(const std::string& path)
{
	VALIDATE(!path.empty());

	tmodule* result{&module()};

	/*
	 * Note lib::split returns 2 elements if path == "/".
	 * So handle this case manually. Since the register function can never
	 * have a non-existing root the test is not there.
	 */
	if(path == "/") {
		return result;
	}

	std::vector<std::string> walk;
	boost::split(walk, path, boost::is_any_of("/"));

	VALIDATE(!walk.empty());
	VALIDATE(walk.front().empty());

	walk.erase(walk.begin());
	while(!walk.empty()) {
		VALIDATE(!walk.front().empty());
		VALIDATE(walk.front().find('*') == std::string::npos);
		for(auto& child : result->children()) {
			if(child.id() == walk.front()) {
				result = &child;
				goto loop;
			}
		}

		/* Didn't find the path. */
		return nullptr;
	loop:
		walk.erase(walk.begin());
	}
	return result;
}
Example #14
0
File: Chain.C Project: imv/non
/* rename chain... we have to let our modules know our name has
 * changed so they can take the appropriate action (in particular the
 * JACK module). */
void
Chain::name ( const char *name )
{
    char ename[512];
    snprintf( ename, sizeof(ename), "%s/%s", instance_name, name );

    if ( ! _engine )
    {
        _engine = new Engine( &Chain::process, this );

        engine()->buffer_size_callback( &Chain::buffer_size, this );

        const char *jack_name = engine()->init( ename );

        if ( ! jack_name )
        {
            _engine = NULL;

            fl_alert( "Could not create JACK client. Perhaps the sound device already in use. In any event, now I'll die." );
            exit( 1 );
            return;
        }
    }
    else
    {
        DMESSAGE( "Renaming JACK client from \"%s\" to \"%s\"", _name, ename );

        _name = engine()->name( ename );
        /* FIXME: discarding the name jack picked is technically wrong! */

    }

    _name = name;

    for ( int i = 0; i < modules(); ++i )
    {
        module( i )->handle_chain_name_changed();
    }
}
void EmacsPythonCommand::runPythonStringInsideTryExcept( const EmacsString &_command )
{
    EmacsString command( _command );

    //_dbg_msg( FormatString( "runPythonStringInsideTryExcept: Command: %s" ) << command );

    int pos=0;
    for(;;)
    {
        pos = command.index( '\n', pos );
        if( pos < 0 )
            break;
        command.insert( pos+1, '\t' );
        pos = pos + 2;
    }


    EmacsString wrapped_command( FormatString( python_try_command_except_structure ) << command );

    PyRun_SimpleString( wrapped_command.sdataHack() );

    try
    {
        Py::Module module( "__main__" );
        Py::Dict dict( module.getDict() );

        Py::Object error_reason( dict[ "__bemacs_error" ] );
        if( error_reason.isString() )
        {
            std::string reason_1 = Py::String( error_reason );
            commandFailed( EmacsString( EmacsString::copy, reason_1.c_str() ) );
        }
    }
    catch( Py::Exception &e )
    {
        //_dbg_msg( "runPythonStringInsideTryExcept: catch()" );
        e.clear();
    }
}
Example #16
0
//Initialize application
Application::Application(int argc, char** argv) : app(nullptr)
{
    //Logging system initialization
    this->log.init("log.txt");
    
    //Initialize application type
    if( argc > 1 )
    {
        std::string module (argv [ 1 ]);
        if( module == "gen" )
        {
            this->app = new Generator(argc, argv);
        }
        else
        {
            if( module == "run" )
            {
                this->app = new Runner(argc, argv);
            }
        }
    }
}
VError VRIAJSCallbackModuleFunction::Call( VJSContext& inContext, const std::vector<VJSValue> *inParameters, VJSValue* outResult)
{
	VError err = VE_OK;

	JS4D::ExceptionRef exception = NULL;
	VJSObject object( inContext.GetGlobalObject());

	VJSValue nameParam( inContext);
	nameParam.SetString( fModuleName);
	std::vector<VJSValue> params;
	params.push_back( nameParam);

	VJSValue module( inContext);
	if (object.CallMemberFunction( L"require", &params, &module, &exception))
	{
		if (!module.IsUndefined() && !module.IsNull())
		{
			VJSObject moduleObject( inContext);
			module.GetObject( moduleObject);
			if (!moduleObject.CallMemberFunction( fFunctionName, inParameters, outResult, &exception))
			{
				JS4D::ThrowVErrorForException( inContext, exception);
				err = VE_RIA_JS_CALL_TO_FUNCTION_FAILED;
			}
		}
		else
		{
			err = VE_RIA_JS_CALL_TO_REQUIRE_FAILED;
		}
	}
	else
	{
		JS4D::ThrowVErrorForException( inContext, exception);
		err = VE_RIA_JS_CALL_TO_REQUIRE_FAILED;
	}

	return err;
}
void 	accel_update(Accel& accel , double vref, double mass){
	float x1=0.0,y1=0.0;
	double v[3], angle[3];
  //read accelerometer 
  adxl.readG(&v[X],&v[Y],&v[Z]);  
  double r=module((v[X]),(v[Y]),(v[Z]));
  
  // rotate XYZ to fit G
  angle[X]=alpha((v[X]),r)+offset[X];
  angle[Y]=alpha((v[Y]),r)+offset[Y];
  angle[Z]=alpha((v[Z]),r)+offset[Z];

  // get the new projected vectors[x,y,z] after rotation and
  // compute the force  F[N]=m*accel
  accel.force[X]=aalpha(angle[X]+ORTHOGONAL,r) * 9.81 * mass ;
  accel.force[Y]=aalpha(angle[Y]+ORTHOGONAL,r) * 9.81 * mass ;
  accel.force[Z]=aalpha(angle[Z],r) * 9.81 * mass ;


  // low-freq force on X
  accel.filtered_forward_force=0.2*accel.force[X]+0.8*accel.filtered_forward_force;
  
  //
  // remove high freq for pedelec A,B
  float pedelec=highpass(accel.force[X],x1,y1,0.2,0.14);
  if (pedelec>0.0)
  	accel.pedelec_a= 0.6*pedelec + 0.4*accel.pedelec_a;
  else
  	accel.pedelec_b= 0.6*pedelec + 0.4*accel.pedelec_b;

  //rotate to the initial position
  if (offset[Z]==0.0 && offset[X]==ORTHOGONAL){
    offset[X]=offset[X]-accel.force[X];
    offset[Y]=offset[Y]-accel.force[Y];
    offset[Z]=offset[Z]-accel.force[Z];
  }

}
Example #19
0
void Particle::update(float dt, glm::vec2 mpos) {

    if (REPULSION) {
        if (pos.x != mpos.x and pos.y != mpos.y) {
            float dist = module(pos.x-mpos.x, pos.y-mpos.y);
            glm::vec2 uvect = glm::vec2(pos.x-mpos.x, pos.y-mpos.y)/dist;
            glm::vec2 force = uvect / (dist*dist);
            vel += force*dt;
            //if (module(vel) > maxVel) vel = uvect * maxVel;
        }
    }

    if (GRAVITY) {
        vel.y -= dt*5;
    }

	pos += vel*dt;

    if (pos.x < -1) {
        vel.x *= -1;
        pos.x = -1 + (-1 -pos.x);
    }
    else if (pos.x > 1) {
        vel.x *= -1;
        pos.x = 1 - (pos.x -1);
    }
    if (pos.y < -1) {
        vel.y *= -0.9;
        pos.y = -1 + (-1 -pos.y);
    }
    else if (pos.y > 1) {
        vel.y *= -1;
        pos.y = 1 - (pos.y -1);
    }

    //LIFE UPDATE
    life = std::max(0.0f, life-dt);
}
Example #20
0
TEST_F(TestModule, basic)
{
    ib_module_t ib_module;
    ib_module.ib = m_engine.ib();
    IronBee::Module module(&ib_module);

    ASSERT_EQ(&ib_module, module.ib());
    ASSERT_EQ(m_engine, module.engine());

    ib_module.vernum   = 1;
    ib_module.abinum   = 2;
    ib_module.version  = "hello";
    ib_module.filename = "foobar";
    ib_module.idx      = 3;
    ib_module.name     = "IAmModule";

    ASSERT_EQ(ib_module.vernum,   module.version_number());
    ASSERT_EQ(ib_module.abinum,   module.abi_number());
    ASSERT_EQ(ib_module.version,  module.version());
    ASSERT_EQ(ib_module.filename, module.filename());
    ASSERT_EQ(ib_module.idx,      module.index());
    ASSERT_EQ(ib_module.name,     module.name());
}
Example #21
0
/* called by a module when it wants to alter the number of its
 * outputs. Also used to test for chain validity when inserting /
 * removing modules */
bool
Chain::can_configure_outputs ( Module *m, int n ) const
{
    /* start at the requesting module */

    int outs = n;

    int i = modules_pack->find( m );

    if ( modules() - 1 == i )
        /* last module */
        return true;

    for ( i++ ; i < modules(); ++i )
    {
        outs = module( i )->can_support_inputs( outs );

        if ( outs < 0 )
            return false;
    }

    return true;
}
void BtBookshelfDockWidget::slotItemActionTriggered(QAction *action) {
    CSwordModuleInfo *module((CSwordModuleInfo*) m_itemContextMenu->property("BtModule").value<void*>());
    if (module == 0) return;

    if (action == m_itemOpenAction) {
        emit moduleOpenTriggered(module);
    }
    else if (action == m_itemSearchAction) {
        emit moduleSearchTriggered(module);
    }
    else if (action == m_itemEditPlainAction) {
        emit moduleEditPlainTriggered(module);
    }
    else if (action == m_itemEditHtmlAction) {
        emit moduleEditHtmlTriggered(module);
    }
    else if (action == m_itemUnlockAction) {
        emit moduleUnlockTriggered(module);
    }
    else if (action == m_itemAboutAction) {
        emit moduleAboutTriggered(module);
    }
}
/** Returns true if his module has the text of desired type of testament */
bool CSwordBibleModuleInfo::hasTestament( CSwordBibleModuleInfo::Testament type ) {
	if (m_hasOT == -1 || m_hasNT == -1) {
		const bool oldStatus = module()->getSkipConsecutiveLinks();
		module()->setSkipConsecutiveLinks(true);

		*module() = sword::TOP; //position to first entry
		sword::VerseKey key( module()->KeyText() );

		if (key.Testament() == 1) { // OT && NT
			m_hasOT = 1;
		}
		else if (key.Testament() == 2) { //no OT
			m_hasOT = 0;
		}

		*module() = sword::BOTTOM;
		key = module()->KeyText();

		if (key.Testament() == 1) { // only OT, no NT
			m_hasNT = 0;
		}
		else if (key.Testament() == 2) { //has NT
			m_hasNT = 1;
		}

		module()->setSkipConsecutiveLinks(oldStatus);
	}

	switch (type) {

		case OldTestament:
		return m_hasOT>0;

		case NewTestament:
		return m_hasNT>0;

		default:
		return false;
	}
}
Example #24
0
void KotOREngine::mainMenuLoop() {
	playMenuMusic();

	Console console;
	Module module(console);

	console.setModule(&module);

	while (!EventMan.quitRequested()) {
		GUI *mainMenu = new MainMenu(module, _platform == Aurora::kPlatformXbox);

		EventMan.flushEvents();

		mainMenu->show();
		mainMenu->run();
		mainMenu->hide();

		delete mainMenu;

		if (EventMan.quitRequested())
			break;

		stopMenuMusic();

		module.run();
		if (EventMan.quitRequested())
			break;

		playMenuMusic();
		console.hide();
		module.clear();
	}

	console.setModule();

	stopMenuMusic();
}
/** Returns the current book as Text, not as integer. */
QString CSwordVerseKey::book( const QString& newBook ) {
    int min = 0;
    int max = 1;

    if (CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module())) {
        const bool hasOT = bible->hasTestament(CSwordBibleModuleInfo::OldTestament);
        const bool hasNT = bible->hasTestament(CSwordBibleModuleInfo::NewTestament);

        if (hasOT && hasNT) {
            min = 0;
            max = 1;
        }
        else if (hasOT && !hasNT) {
            min = 0;
            max = 0;
        }
        else if (!hasOT && hasNT) {
            min = 1;
            max = 1;
        }
        else if (!hasOT && !hasNT) {
            min = 0;
            max = -1; //no loop
        }
    }

    if (!newBook.isEmpty()) {
        setBookName(newBook.toUtf8().constData());
    }

    if ( (Testament() >= min + 1) && (Testament() <= max + 1) && (Book() <= BMAX[min]) ) {
        return QString::fromUtf8( getBookName() );
    }

    //return QString::fromUtf8( books[min][0].name ); //return the first book, i.e. Genesis
    return QString::null;
}
Example #26
0
void Trajectory::getPositioVelocity(float time, vec &position, vec &velocity)
{
  if (time > _currentEndTime)
    {
      _currentInitCheckpoint++;
      _currentInitTime = _currentEndTime;
    }
  time -= _currentInitTime;
  vec start = *_currentInitCheckpoint;
  list<vec>::iterator temp = next(_currentInitCheckpoint,1);
  vec end = *temp;
  float mod = module(start, end);
  float m = (end[1]-start[1])/(end[0]-start[0]);
  float theta_d = atan(m);
  //Traiettoria tra due punti
  position[0] = start[0] +  (_velocity * time) / mod * (end[0]- start[0]);
  position[1] = start[1] +  (_velocity * time) / mod * (end[1]- start[1]);
  _robotPosition = position;
  //X and y velocity beetwen the two point
  velocity[0] = _velocity * cos(theta_d);
  velocity[1] = _velocity * sin(theta_d);
  if (time > _currentEndTime)
    _currentEndTime = _velocity * mod;
}
void EmacsPythonCallCommand::executeCommandImpl()
{
    try
    {
        Py::Module module( "__main__" );
        Py::Dict dict( module.getDict() );

        //
        //    create the tuple of arguments
        //
        Py::Tuple args_tuple( num_args );
        for( int arg=0; arg < num_args; arg++ )
        {
            args_tuple[ arg ] = convertEmacsExpressionToPyObject( python_args[arg] );
        }

        dict[ "__bemacs_call_args__" ] = args_tuple;

        EmacsString command( FormatString
            (
            "__bemacs_eval_tmp__ = apply( %s, __bemacs_call_args__ )\n"
            ) << python_function );

        runPythonStringInsideTryExcept( command );

        if( !failed() )
        {
            Py::Object py_result( dict[ "__bemacs_eval_tmp__" ] );
            commandSucceeded( convertPyObjectToEmacsExpression( py_result ) );
        }
    }
    catch( Py::Exception &e )
    {
        e.clear();
    }
}
Example #28
0
// Delete a PKCS11 module from the user's profile.
NS_IMETHODIMP
nsPkcs11::DeleteModule(const nsAString& aModuleName)
{
  nsNSSShutDownPreventionLock locker;
  if (isAlreadyShutDown()) {
    return NS_ERROR_NOT_AVAILABLE;
  }

  if (aModuleName.IsEmpty()) {
    return NS_ERROR_INVALID_ARG;
  }

  NS_ConvertUTF16toUTF8 moduleName(aModuleName);
  // Introduce additional scope for module so all references to it are released
  // before we call SECMOD_DeleteModule, below.
#ifndef MOZ_NO_SMART_CARDS
  {
    mozilla::UniqueSECMODModule module(SECMOD_FindModule(moduleName.get()));
    if (!module) {
      return NS_ERROR_FAILURE;
    }
    nsCOMPtr<nsINSSComponent> nssComponent(
      do_GetService(PSM_COMPONENT_CONTRACTID));
    nssComponent->ShutdownSmartCardThread(module.get());
  }
#endif

  // modType is an output variable. We ignore it.
  int32_t modType;
  SECStatus srv = SECMOD_DeleteModule(moduleName.get(), &modType);
  if (srv != SECSuccess) {
    return NS_ERROR_FAILURE;
  }

  return NS_OK;
}
Example #29
0
/*===========================================================================*/
bool VisualizationPipeline::create_renderer_module( const kvs::ObjectBase* object )
{
    switch ( object->objectType() )
    {
    case kvs::ObjectBase::Geometry:
    {
        return this->create_renderer_module( kvs::GeometryObjectBase::DownCast( object ) );
    }
    case kvs::ObjectBase::Volume:
    {
        return this->create_renderer_module( kvs::VolumeObjectBase::DownCast( object ) );
    }
    case kvs::ObjectBase::Image:
    {
        kvs::PipelineModule module( new kvs::ImageRenderer );
        m_module_list.push_back( module );
        return true;
    }
    default:
        break;
    }

    return false;
}
Example #30
0
interpreter_t::interpreter_t()
{
    PyImport_AppendInittab(( char *) "_ramen", &init_ramen);
    Py_Initialize();

    bpy::object main_module( bpy::handle<>( bpy::borrowed( PyImport_AddModule( "__main__"))));
    main_namespace_ = main_module.attr( "__dict__");

	setup_python_paths( main_namespace_);

	init_pyside();

    // default import our module.
    bpy::object module(( bpy::handle<>( PyImport_ImportModule( "ramen"))));
    main_namespace_[ "ramen"] = module;
    exec( "from ramen import *");

    // execute startup files
    bfs::path exec_path = app().system().executable_path();
    bfs::path py_path = exec_path.parent_path() / "../python";
    exec_file( py_path / "app/init.py");

    exec_file( app().system().home_path() / "ramen/python/init.py");
}