Example #1
0
int main()
{
	Lua luaInstance;
	std::stringstream ss;
	auto globalTable = luaInstance.GetGlobalEnvironment();
	auto myOwnPrint = luaInstance.CreateYieldingFunction<void(std::string)>
		(
			[&](std::string str)
			{
				ss << str;
			}
		);

	globalTable.Set("myownprint", myOwnPrint);

	luaInstance.LoadStandardLibraries();

	auto cr = luaInstance.CreateCoroutine();

	auto err = cr.RunScript(
		"	myownprint 'hello '\n"
		"	myownprint 'hello2 '\n"
		"	myownprint 'hello3 '\n"
		);
	
	while (cr.CanResume())
	{
		ss << "yield ";
		auto err = cr.Resume();
	}
	
	auto resstr = ss.str();
	
	return resstr.compare("hello yield hello2 yield hello3 yield ");
}
Example #2
0
/*!
 * Enables the buttons that are valid based on the current selection in the
 * list control. For example, if only done jobs are selected, it would leave
 * the "Pause" button greyed out, since pausing makes no sense for done jobs.
 */
void GamessQFrame::RefreshButtons()
{
	int *status = GetSelectedStatus();
	// everything should be grey if we can't connect
	mConnected = mQueueManager.IsConnected();

	// you can always add, refresh and clear
	jobsToolbar->EnableTool(wxID_ADD, mConnected);
	jobsMenu->Enable(wxID_ADD, mConnected);
	jobsToolbar->EnableTool(ID_REFRESH, mConnected);
	jobsMenu->Enable(ID_REFRESH, mConnected);
	jobsToolbar->EnableTool(wxID_CLEAR, mConnected);
	jobsMenu->Enable(wxID_CLEAR, mConnected);

	jobsToolbar->EnableTool(wxID_REMOVE, mConnected && CanRemove());
	jobsMenu->Enable(wxID_REMOVE, mConnected && CanRemove());

	jobsToolbar->EnableTool(ID_PAUSE, mConnected && mActive &&
			CanPause(status));
	jobsMenu->Enable(ID_PAUSE, mConnected && mActive && CanPause(status));

	jobsToolbar->EnableTool(ID_RESUME, mConnected && mActive &&
			CanResume(status));
	jobsMenu->Enable(ID_RESUME, mConnected && mActive && CanResume(status));

	jobsToolbar->EnableTool(wxID_CANCEL, mConnected && mActive &&
			CanCancel(status));
	jobsMenu->Enable(wxID_CANCEL, mConnected && mActive && CanCancel(status));

	jobsMenu->Enable(ID_VIEWLOGS, mConnected && CanViewLogs(status));

	jobsMenu->Enable(ID_SAVEFOLDER, mConnected && CanSaveFolder(status));

	jobsMenu->Enable(ID_SAVEAS, mConnected && CanSaveAs(status));

	jobsMenu->Enable(ID_MACMOLPLT, mConnected && CanSaveFolder(status));

	delete status;
}
Example #3
0
/*!
 * This function is called when the user clicks "Resume". It looks through the
 * selected items and tells the server to resume whichever ones can be resumed.
 *
 * \sa CanResume(job *)
 */
void GamessQFrame::OnResumeClick( wxCommandEvent& event )
{
	GreyButtons();
	int index = jobListCtrl->GetNextItem(-1, wxLIST_NEXT_ALL,
			wxLIST_STATE_SELECTED);
	int status;
	while (index != -1) {
		Job *job = mJobList.Item(index)->GetData();
		if (CanResume(job)) {
			mQueueManager.Resume(job->GetId());
		}
		index = jobListCtrl->GetNextItem(index, wxLIST_NEXT_ALL,
				wxLIST_STATE_SELECTED);
	}
	RefreshList();
	RefreshButtons();
}