示例#1
0
    void
    GuiApp::run()
    {
        commander().registerAllCommandsForTarget (JUCEApplication::getInstance());
        commander().registerAllCommandsForTarget (this);

        globals().session().open();
        sessionDoc = new SessionDocument (globals().session());

        content = new ContentComponent (*this);
        content->setSize (800, 600);
        mainWindow = new MainWindow (*this);
        mainWindow->setContentNonOwned (content.get(), true);

        PropertiesFile* pf = globals().settings().getUserSettings();
        mainWindow->restoreWindowStateFromString (pf->getValue ("mainWindowState"));

       #if JUCE_IOS || JUCE_ANDROID
        Desktop& d = Desktop::getInstance();
        d.setKioskModeComponent (mainWindow);
       #endif

        mainWindow->addToDesktop();
        mainWindow->setVisible (true);
        dispatch->startTimer (250);

        openWindow (ELEMENT_PLUGIN_MANAGER);

        File sess (pf->getValue ("lastSession"));
        if (sess.existsAsFile()) {
            sessionDoc->loadFrom (sess, true);
            mainWindow->setName (sessionDoc->getDocumentTitle());
        }
    }
示例#2
0
    void
    GuiApp::newSession()
    {
        if (sessionDoc->hasChangedSinceSaved()) {
            sessionDoc->save (true, true);
            // content->stabilize();
        }

        DialogWindow::LaunchOptions opts;
        opts.dialogBackgroundColour = Colours::darkgrey;
        opts.content.set (new NewSessionView (globals().session()), true);
        opts.dialogTitle = "New Session";
        opts.resizable = false;
        opts.useBottomRightCornerResizer = false;
        opts.useNativeTitleBar = true;
        opts.componentToCentreAround = (Component*) mainWindow.get();
        if (DialogWindow* dw = opts.create())
        {
            windowManager->push (dw);

            sessionDoc->setFile (File::nonexistent);
            globals().session().clear();
            globals().session().open();

            // content->stabilize();
            sessionDoc->setChangedFlag (false);
        }
    }
示例#3
0
文件: fx.cpp 项目: xuxiaojing/antares
void RemoveAllUnusedSounds() {
    for (int count = kMinVolatileSound; count < kSoundNum; count++) {
        if ((!globals()->gSound[count].keepMe) &&
                (globals()->gSound[count].soundHandle.get() != NULL)) {
            globals()->gSound[count].soundHandle.reset();
            globals()->gSound[count].id = -1;
        }
    }
}
示例#4
0
文件: fx.cpp 项目: xuxiaojing/antares
void SoundFXCleanup() {
    for (int i = 0; i < kMaxChannelNum; i++) {
        globals()->gChannel[i].channelPtr.reset();
    }

    for (int i = 0; i < kSoundNum; i++) {
        globals()->gSound[i].soundHandle.reset();
    }
}
示例#5
0
bool CodeGenContext::LookupBitVariable(BitVariable& outVar,const std::string& module, const std::string& name,const YYLTYPE &modLoc,const YYLTYPE &nameLoc)
{
	if ((currentBlock()!=nullptr) && (locals().find(name) != locals().end()))
	{
		outVar=locals()[name];
		outVar.refLoc = nameLoc;
	}
	else
	{
		if (globals().find(name) == globals().end())
		{
			if (m_includes.find(module)!=m_includes.end())
			{
				if (m_includes[module]->LookupBitVariable(outVar,"",name,modLoc,nameLoc))
				{
					if (outVar.pinType!=0)		// TODO: Globals Vars!
					{
						outVar.fromExternal=true;
						outVar.refLoc = CombineTokenLocations(nameLoc,modLoc);
						return true;
					}
					else
					{
						return gContext.ReportError(false, EC_InternalError, CombineTokenLocations(nameLoc, modLoc), "TODO: Globals");
					}
				}
				else
				{
					return gContext.ReportError(false, EC_ErrorAtLocation, CombineTokenLocations(nameLoc,modLoc), "undeclared variable %s%s", module.c_str(), name.c_str());
				}
			}
			else if (isRoot)
			{
				if (module == "")
				{
					return gContext.ReportError(false, EC_ErrorAtLocation, nameLoc, "undeclared variable %s", name.c_str());
				}
				else
				{
					return gContext.ReportError(false, EC_ErrorAtLocation, CombineTokenLocations(nameLoc,modLoc), "undeclared variable %s%s", module.c_str(), name.c_str());
				}
			}
			return false;
		}
		else
		{
			outVar=globals()[name];
			outVar.refLoc = nameLoc;
		}
	}

	outVar.fromExternal=false;
	return true;
}
示例#6
0
文件: fx.cpp 项目: xuxiaojing/antares
void KeepSound(int soundID) {
    short whichSound;

    whichSound = 0;
    while ((globals()->gSound[whichSound].id != soundID) && (whichSound < kSoundNum)) {
        whichSound++;
    }

    if (whichSound < kSoundNum) {
        globals()->gSound[whichSound].keepMe = true;
    }
}
OSStatus
SecKeychainItemCreateFromContent(SecItemClass itemClass, SecKeychainAttributeList *attrList,
		UInt32 length, const void *data, SecKeychainRef keychainRef,
		SecAccessRef initialAccess, SecKeychainItemRef *itemRef)
{
	BEGIN_SECAPI

	KCThrowParamErrIf_(length!=0 && data==NULL);
	Item item(itemClass, attrList, length, data);
	if (initialAccess) {
		item->setAccess(Access::required(initialAccess));
	}
	Keychain keychain = nil;
	try
	{
		keychain = Keychain::optional(keychainRef);
		if ( !keychain->exists() )
		{
			MacOSError::throwMe(errSecNoSuchKeychain);	// Might be deleted or not available at this time.
		}
	}
	catch(...)
	{
		keychain = globals().storageManager.defaultKeychainUI(item);
	}

	keychain->add(item);
	if (itemRef) {
		*itemRef = item->handle();
	}

	END_SECAPI
}
示例#8
0
/**
 * Interpret a builtin call. Yes, this can be slow because each time we invoke
 * this we must query the mapping in the builtins table to see if it can be 
 * executed (builtin implementation). HOWEVER, this also allows us to swap out
 * builtin implementations on the fly.
 *
 * @return The interpreted element.
 */
Element Builtin_::InterpretCall( Environment& environment
                               , Element const& builtin_element
                               , std::vector<Element> const& parms )
{
    std::shared_ptr<Builtin_> builtin(std::dynamic_pointer_cast<Builtin_>(builtin_element.ElementHandle()));
    BuiltinsTable& table = *(builtin->table);
    BuiltinImplementation* impl = table.Get(builtin->Name());

    Element result;

    if (0 != builtin && 0 != impl)
    {
        std::vector<Element> output_parameters; 
        GlobalEnvironment globals(environment.Globals());
        Environment output_environment = Environment::Create(globals);
        bool success = Funcall_::CreateEnvironment( environment
                                                  , parms
                                                  , output_parameters);


        if (success && (0 != impl))
        {
            result = impl->Interpret( output_environment
                                    , output_parameters 
                                    , builtin->AdditionalParameter() );
        }
    }

    return result;
}
		virtual ~tnet_execution()
		{
			const xr_vector<e_net_globals>& v = exe_gl_reg().get_globals(etype);
			u32 size = v.size();
			for(u32 i = 0; i< size; ++i )
				globals().get(v[i]).free_ref();
		}
示例#10
0
void
Server::handleRequestInternal(const HandlerSet::HandlerDescription* handler, RequestTask task) {
	if (NULL == handler || handler->handlers.empty()) {
		task.request->sendError(404);
		return;
	}

	try {
		task.handlers = handler->handlers;
		RequestsThreadPool* pool = globals()->pools().find(handler->poolName)->second.get();
		if (pool->delay()) {
			struct timeval now;
			gettimeofday(&now, 0);
			task.start = (now.tv_sec * 1000) + (now.tv_usec / 1000);
		}
		else {
			task.start = 0;
		}
		pool->addTask(task);
	}
	catch (const std::exception &e) {
		task.request->sendError(503);
		logger()->error("cannot add request to pool: %s", e.what());
	}
}
示例#11
0
void SoloGame::handle_game_result() {
    switch (_game_result) {
    case WIN_GAME:
    {
        _state = EPILOGUE;
        const int epilogue = _scenario->epilogue_id();
        if (epilogue > 0) {
            // normal scrolltext song
            int scroll_song = 4002;
            if (globals()->gScenarioWinner.next == -1) {
                // we win but no next level? Play triumph song
                scroll_song = 4003;
            }
            stack()->push(new ScrollTextScreen(epilogue, 450, 15.0, scroll_song));
        } else {
            become_front();
        }
    }
    break;

    case RESTART_GAME:
        _state = RESTART_LEVEL;
        become_front();
        break;

    case QUIT_GAME:
        _state = QUIT;
        become_front();
        break;

    default:
        throw Exception(format("_play_again was invalid after PLAY_AGAIN ({0})", _play_again));
    }
}
示例#12
0
Dist bi_partition(CommPtr comm, Read<I8> marks) {
  CHECK(comm->size() % 2 == 0);
  Write<I32> dest_ranks(marks.size());
  Write<LO> dest_idxs(marks.size());
  LO linsize = -1;
  auto halfsize = comm->size() / 2;
  I32 rank_start = 0;
  for (Int half = 0; half < 2; ++half) {
    marks = invert_marks(marks);
    auto marked = collect_marked(marks);
    auto total = comm->allreduce(GO(marked.size()), OMEGA_H_SUM);
    auto start = comm->exscan(GO(marked.size()), OMEGA_H_SUM);
    Read<GO> globals(marked.size(), start, 1);
    auto owners = globals_to_linear_owners(globals, total, halfsize);
    map_into(add_to_each(owners.ranks, rank_start), marked, dest_ranks, 1);
    map_into(owners.idxs, marked, dest_idxs, 1);
    if (rank_start <= comm->rank() && comm->rank() < (rank_start + halfsize)) {
      linsize =
          linear_partition_size(total, halfsize, comm->rank() - rank_start);
    }
    rank_start += halfsize;
  }
  auto dests = Remotes(Read<I32>(dest_ranks), Read<LO>(dest_idxs));
  return Dist(comm, dests, linsize);
}
示例#13
0
文件: vm.cpp 项目: dziulius/rubinius
  void VM::initialize_as_root() {

    om = new ObjectMemory(this, shared.config);
    shared.om = om;

    allocation_tracking_ = shared.config.allocation_tracking;

    local_slab_.refill(0, 0);

    shared.set_initialized();

    shared.gc_dependent(this);

    State state(this);

    TypeInfo::auto_learn_fields(&state);

    bootstrap_ontology(&state);

    MachineCode::init(&state);

    // Setup the main Thread, which is wrapper of the main native thread
    // when the VM boots.
    thread.set(Thread::create(&state, this, G(thread), 0, true), &globals().roots);
    thread->alive(&state, cTrue);
    thread->sleep(&state, cFalse);

    VM::set_current(this, "rbx.ruby.main");
  }
static
OSStatus _SecIdentityCopyPreferenceMatchingName(
    CFStringRef name,
    CSSM_KEYUSE keyUsage,
    CFArrayRef validIssuers,
    SecIdentityRef *identity)
{
    // this is NOT exported, and called only from SecIdentityCopyPreference (below), so no BEGIN/END macros here;
    // caller must handle exceptions

	StorageManager::KeychainList keychains;
	globals().storageManager.getSearchList(keychains);
	KCCursor cursor(keychains, kSecGenericPasswordItemClass, NULL);

	char idUTF8[MAXPATHLEN];
    Required(name);
    if (!CFStringGetCString(name, idUTF8, sizeof(idUTF8)-1, kCFStringEncodingUTF8))
        idUTF8[0] = (char)'\0';
    CssmData service(const_cast<char *>(idUTF8), strlen(idUTF8));
	FourCharCode itemType = 'iprf';
    cursor->add(CSSM_DB_EQUAL, Schema::attributeInfo(kSecServiceItemAttr), service);
	cursor->add(CSSM_DB_EQUAL, Schema::attributeInfo(kSecTypeItemAttr), itemType);
    if (keyUsage)
        cursor->add(CSSM_DB_EQUAL, Schema::attributeInfo(kSecScriptCodeItemAttr), (sint32)keyUsage);

	Item prefItem;
	if (!cursor->next(prefItem))
		return errSecItemNotFound;

	// get persistent certificate reference
	SecKeychainAttribute itemAttrs[] = { { kSecGenericItemAttr, 0, NULL } };
	SecKeychainAttributeList itemAttrList = { sizeof(itemAttrs) / sizeof(itemAttrs[0]), itemAttrs };
	prefItem->getContent(NULL, &itemAttrList, NULL, NULL);

	// find certificate, given persistent reference data
	CFDataRef pItemRef = CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)itemAttrs[0].data, itemAttrs[0].length, kCFAllocatorNull);
	SecKeychainItemRef certItemRef = nil;
	OSStatus status = SecKeychainItemCopyFromPersistentReference(pItemRef, &certItemRef); //%%% need to make this a method of ItemImpl
	prefItem->freeContent(&itemAttrList, NULL);
	if (pItemRef)
		CFRelease(pItemRef);
	if (status)
		return status;

    // filter on valid issuers, if provided
    if (validIssuers) {
        //%%%TBI
    }

	// create identity reference, given certificate
	Item certItem = ItemImpl::required(SecKeychainItemRef(certItemRef));
	SecPointer<Certificate> certificate(static_cast<Certificate *>(certItem.get()));
	SecPointer<Identity> identity_ptr(new Identity(keychains, certificate));
	if (certItemRef)
		CFRelease(certItemRef);

	Required(identity) = identity_ptr->handle();

    return status;
}
示例#15
0
void ModifyScriptDescriptor::CommitChanges(bool leave_closed) {
	WriteScriptDescriptor file; // The file to write the modified Lua state out to
	std::string temp_filename = _filename.substr(0, _filename.find_last_of('.')) + "_TEMP" + _filename.substr(_filename.find_last_of('.'));

	if (file.OpenFile(temp_filename) == false) {
		if (SCRIPT_DEBUG)
			_error_messages << "* ModifyScriptDescriptor::CommitChanges() failed because it could not open "
				<< "the file to write the modifications to" << std::endl;
		return;
	}

	// setup the iterator
	_open_tables_iterator = _open_tables.begin();

	// Write the global tables to the file. This in turn will write all other tables that are members of
	// the global tables, or members of those tables, and so on.
	object globals(luabind::from_stack(_lstack, LUA_GLOBALSINDEX));
	_CommitTable(file, globals);

	file.CloseFile(); // Close the temporary file we were writing to
	CloseFile(); // Close this file as well as it is about to be over-written

	// Now overwrite this file with the temporary file written, remove the temporary file, and re-open the new file

	if (MoveFile(temp_filename, _filename) == false) {
		_error_messages << "* ModifyScriptDescriptor::CommitChanges() failed because after writing the temporary file "
			<< temp_filename << ", it could not be moved to overwrite the original filename " << _filename << std::endl;
	}

	if (leave_closed == false)
		OpenFile();
} // void ModifyScriptDescriptor::CommitChanges(bool leave_closed)
示例#16
0
	void Log::flush(std::ostringstream* out, char* message)
    {
       LogLock lock;
       if (!lock.ok())
       {
           return;
       }
       
	   if(strlen(out->str().c_str()) < 128)
	   {
		   strcpy(message, out->str().c_str());
	   }
	   else
	   {
		   strncpy(message, out->str().c_str(), 127);
		   message[127] = '\0' ;
	   }
	   
	   AIAccess<Globals> globals(Globals::get());
       if (out == &globals->messageStream)
       {
           globals->messageStream.clear();
           globals->messageStream.str("");
           globals->messageStreamInUse = false;
       }
       else
       {
           delete out;
       }
	   return ;
    }
	void	global_data_cleanup::on_net_receive	( IAgent* agent, DWORD sessionId, IGenericStream* inStream  )
	{	
		 u32 state = u32(-1);
		 inStream->Read(&state, sizeof(id_state) );
		 lock.Enter();
		 if( state == id_state )
		 {
			 lock.Leave();
			 return;
		 }
		 IGenericStream* globalDataStream=0;
		 HRESULT rz = agent->GetData(sessionId, "data_cleanup", &globalDataStream);
		 if (rz!=S_OK) 
		 {
			 lock.Leave();	
			 return;
		 }
		 R_ASSERT( globalDataStream );
		 u8 buff[data_cleanup_callback_read_write_buff_size];
		 r_pod_vector( INetBlockReader( globalDataStream, buff, sizeof(buff) ), vec_cleanup );
		//  r_pod_vector( INetReaderGenStream( globalDataStream ), vec_cleanup );

		 free(globalDataStream->GetCurPointer());
		 id_state = state;
#ifdef CL_NET_LOG
		 Msg("cleanup call");
#endif
		 globals().cleanup();
		 lock.Leave();
		 return;
	}
		void on_construct( )
		{
			const xr_vector<e_net_globals>& v = exe_gl_reg().get_globals(etype);
			u32 size = v.size();
			for(u32 i = 0; i< size; ++i )
				globals().get(v[i]).add_ref();
		}
示例#19
0
文件: m4.cpp 项目: St0rmcrow/scummvm
void MadsEngine::showDialog() {
	// Switch to showing the given dialog
	RexDialogView *dlg = NULL;
	switch (globals()->dialogType) {
	case DIALOG_GAME_MENU:
		dlg = new RexGameMenuDialog();
		break;
	case DIALOG_OPTIONS:
		dlg = new RexOptionsDialog();
		break;
	default:
		error("Unknown dialog type");
	};

	globals()->dialogType = DIALOG_NONE;
	_viewManager->addView(dlg);
}
示例#20
0
    SessionRef
    GuiApp::session()
    {
        if (sessionRef.get() == nullptr)
            sessionRef = globals().session().makeRef();

        return sessionRef;
    }
示例#21
0
 void
 GuiApp::openWindow (const String& uri)
 {
     if (uri == ELEMENT_PLUGIN_MANAGER) {
         windowManager->push (new PluginListWindow (globals()));
     } else if (uri == ELEMENT_LEGACY_WINDOW) {
         //windowManager->push (new ABeatThangWindow (*this));
     }
 }
		virtual		void					send_task		( IGridUser& user, IGenericStream* outStream, u32  id )	 
		{
			const xr_vector<e_net_globals>& v = exe_gl_reg().get_globals(etype);
			u32 size = v.size();
			for(u32 i = 0; i< size; ++i )
				globals().get(v[i]).on_task_send(outStream);
			tnet_execution_base< etype >::send_task( user, outStream, id );
			execution_impl.send_task( outStream );
		};
		virtual		bool					receive_task	( IAgent* agent, DWORD sessionId, IGenericStream* inStream ) 
		{
			const xr_vector<e_net_globals>& v = exe_gl_reg().get_globals(etype);
			u32 size = v.size();
			for(u32 i = 0; i< size; ++i )
				if( ! globals().get(v[i]).on_task_receive(agent,sessionId,inStream) )
					return false;
			return execution_impl.receive_task( agent, sessionId, inStream );
		};
//
// Set an individual trust element
//
void TrustStore::assign(Certificate *cert, Policy *policy, SecTrustUserSetting trust)
{
	StLock<Mutex> _(mMutex);

	TrustData trustData = { UserTrustItem::currentVersion, trust };
	Keychain defaultKeychain = Keychain::optional(NULL);
	Keychain trustLocation = defaultKeychain;	// default keychain, unless trust entry found
	StorageManager::KeychainList searchList;
	globals().storageManager.getSearchList(searchList);

	if (Item item = findItem(cert, policy, searchList)) {
		// user has a trust setting in a keychain - modify that
		trustLocation = item->keychain();
		if (trust == kSecTrustResultUnspecified)
			item->keychain()->deleteItem(item);
		else
			item->modifyContent(NULL, sizeof(trustData), &trustData);
	} else {
		// no trust entry: make one
		if (trust != kSecTrustResultUnspecified) {
			Item item = new UserTrustItem(cert, policy, trustData);
			if (Keychain location = cert->keychain()) {
				try {
					location->add(item);				// try the cert's keychain first
					trustLocation = location;
				} catch (...) {
					if (&*location != &*defaultKeychain)
						defaultKeychain->add(item);		// try the default (if it's not the same)
				}
			} else {
				defaultKeychain->add(item);				// raw cert - use default keychain
			}
		}
	}

	// Make sure that the certificate is available in some keychain,
	// to provide a basis for editing the trust setting that we're assigning.
	if (cert->keychain() == NULL) {
		if (cert->findInKeychain(searchList) == NULL) {
			try {
				cert->copyTo(trustLocation);	// add cert to the trust item's keychain
			} catch (...) {
				secdebug("trusteval", "failed to add certificate %p to keychain \"%s\"",
					cert, trustLocation->name());
				try {
					if (&*trustLocation != &*defaultKeychain)
						cert->copyTo(defaultKeychain);	// try the default (if it's not the same)
				} catch (...) {
					// unable to add the certificate
					secdebug("trusteval", "failed to add certificate %p to keychain \"%s\"",
						cert, defaultKeychain->name());
				}
			}
		}
	}
}
示例#25
0
BuiltinFunc::BuiltinFunc(const char* name, const char* paramstr, BuiltinFn f) {
	pfn = f;
	ndefaults = 0;
	rest = false;
	literals = nullptr;
	nparams = 0;

	verify(isupper(*name));
	if (name[strlen(name) - 1] == 'Q') {
		char* s = STRDUPA(name);
		s[strlen(name) - 1] = '?';
		name = s;
	}
	named.num = globals(name);

	Scanner scanner(paramstr);
	verify(scanner.next() == '(');
	const int maxparams = 20;
	short params[maxparams];
	Value defaults[maxparams];
	int token = scanner.next();
	while (token != ')') {
		verify(token == T_IDENTIFIER);
		verify(nparams < maxparams);
		params[nparams++] = ::symnum(scanner.value);
		token = scanner.next();
		if (token == I_EQ) {
			Value x;
			token = scanner.next();
			if (token == T_NUMBER)
				x = SuNumber::literal(scanner.value);
			else if (token == T_STRING)
				x = new SuString(scanner.value, scanner.len);
			else if (token == T_IDENTIFIER && scanner.keyword == K_TRUE)
				x = SuTrue;
			else if (token == T_IDENTIFIER && scanner.keyword == K_FALSE)
				x = SuFalse;
			else
				fatal("invalid parameters for Primitive:", paramstr);
			defaults[ndefaults++] = x;
			token = scanner.next();
		} else if (ndefaults > 0)
			fatal("invalid parameters for Primitive:", paramstr);
		if (token == ',')
			token = scanner.next();
	}

	locals = new short[nparams];
	if (ndefaults > 0) {
		literals = new Value[ndefaults];
		memcpy(literals, defaults, ndefaults * sizeof(Value));
	}
	memcpy(locals, params, nparams * sizeof(short));
}
示例#26
0
static void luasetup(TestLuaState& L) {
	LuaValue globals(L, LUA_GLOBALSINDEX);
	install_types();

	globals["assert"].bind_function(unit_test_assert);
	globals["foo_unbox1"].bind_function(foo_unbox1);
	globals["foo_unbox2"].bind_function(foo_unbox2);
	globals["foo_unbox3"].bind_function(foo_unbox3);
	globals["foo_unbox4"].bind_function(foo_unbox4);
	globals["foo_unbox5"].bind_function(foo_unbox5);
	globals["foo_box"].bind_function(foo_box);
}
		virtual		LPCSTR					data_files		(string_path &buf)
		{
			const xr_vector<e_net_globals>& v = exe_gl_reg().get_globals(etype);
			//xr_vector<e_net_globals>::const_iterator i = v.begin(), e = v.end();
			u32 size = v.size();
			buf[0] = 0;
			for(u32 i = 0; i< size; ++i )
			{
				string_path lbuf;
				strconcat( sizeof(string_path), buf, buf,globals().get(v[i]).files(lbuf));
			}
			return buf;
		}
示例#28
0
dummy_python_frame::dummy_python_frame ()
: m_valid (false),
  m_saved_frame (NULL),
  m_tstate (NULL)
{
  PyCodeObject *code;
  PyFrameObject *frame;

  gdbpy_ref<> empty_string (PyString_FromString (""));
  if (empty_string == NULL)
    return;

  gdbpy_ref<> null_tuple (PyTuple_New (0));
  if (null_tuple == NULL)
    return;

  code = PyCode_New (0,			  /* argcount */
		     0,			  /* locals */
		     0,			  /* stacksize */
		     0,			  /* flags */
		     empty_string.get (), /* code */
		     null_tuple.get (),	  /* consts */
		     null_tuple.get (),	  /* names */
		     null_tuple.get (),	  /* varnames */
#if PYTHON_API_VERSION >= 1010
		     null_tuple.get (),	  /* freevars */
		     null_tuple.get (),	  /* cellvars */
#endif
		     empty_string.get (), /* filename */
		     empty_string.get (), /* name */
		     1,			  /* firstlineno */
		     empty_string.get ()  /* lnotab */
		     );
  if (code == NULL)
    return;
  gdbpy_ref<> code_holder ((PyObject *) code);

  gdbpy_ref<> globals (PyDict_New ());
  if (globals == NULL)
    return;

  m_tstate = PyThreadState_GET ();
  frame = PyFrame_New (m_tstate, code, globals.get (), NULL);
  if (frame == NULL)
    return;

  m_frame.reset ((PyObject *) frame);
  m_tstate->frame = frame;
  m_saved_frame = frame->f_back;
  m_valid = true;
}
示例#29
0
文件: fx.cpp 项目: xuxiaojing/antares
int AddSound(int soundID) {
    int whichSound = 0;
    while ((globals()->gSound[whichSound].id != soundID) && (whichSound < kSoundNum)) {
        whichSound++;
    }

    if (whichSound == kSoundNum) {
        whichSound = 0;
        while ((globals()->gSound[whichSound].soundHandle.get() != NULL) &&
                (whichSound < kSoundNum)) {
            whichSound++;
        }

        if (whichSound == kSoundNum) {
            throw Exception("Can't manage any more sounds");
        }

        SoundDriver::driver()->open_sound(
                format("/sounds/{0}.aiff", soundID),
                globals()->gSound[whichSound].soundHandle);
        globals()->gSound[whichSound].id = soundID;
    }
    return whichSound;
}
OSStatus
SecIdentityCreateWithCertificate(
	CFTypeRef keychainOrArray,
	SecCertificateRef certificateRef,
	SecIdentityRef *identityRef)
{
    BEGIN_SECAPI

	SecPointer<Certificate> certificatePtr(Certificate::required(certificateRef));
	StorageManager::KeychainList keychains;
	globals().storageManager.optionalSearchList(keychainOrArray, keychains);
	SecPointer<Identity> identityPtr(new Identity(keychains, certificatePtr));
	Required(identityRef) = identityPtr->handle();

    END_SECAPI
}