Ejemplo n.º 1
0
void register_remaining_widgets ()
	{ char Buffer[80];
	  status = browsing;
	  statuslabel = XtCreateManagedWidget ("status", immedLabelWidgetClass,
       				form, NoArgs);
	  sprintf (Buffer, "%d parse%s w%s found", nrofparses,
				(nrofparses == 1)?"":"s",
				(nrofparses == 1)?"as":"ere");
	  StartArgs;
	  SetArg (XtNlabel, Buffer);
	  parseslabel = XtCreateManagedWidget ("nrofparses", labelWidgetClass,
				form, UseArgs);
	  if (nrofparses) Buffer[0] = '\0';
	  else sprintf (Buffer, "Probable error: %s", pemsg);
	  StartArgs;
	  SetArg (XtNlabel, Buffer);
	  complainlabel = XtCreateManagedWidget ("complain", labelWidgetClass,
				form, UseArgs);
	  tempviewport = XtCreateManagedWidget ("tempviewport",
				viewportWidgetClass, form, NoArgs);
	  StartArgs;
	  SetArg (XtNbufferSize, max_nr_of_rules * screenwidth);
	  SetArg (XtNsource, template_buffer);
	  SetCallback (PressedTemplate, 0);
	  UseCallback (XtNpressedProc);
	  templateviewer = XtCreateManagedWidget ("templateviewer",
				editorWidgetClass, tempviewport, UseArgs);
	};
Ejemplo n.º 2
0
static void ActualSave (void (*ct)())
	{ unsigned int mask_return;
	  Window root_return, child_return;
	  int root_x_return, root_y_return, win_x_return, win_y_return;
	  
	  save_cont = ct;
	  if (!changed)
	     { ct ();
	       return;
	     };
	  StartArgs;
	  SetArg (XtNvalue, Filename);
	  XtSetValues (save_dialog, UseArgs);
	  if (XQueryPointer (MyDisplay, MyRootWindow,
		&root_return, &child_return, &root_x_return, &root_y_return,
		&win_x_return, &win_y_return, &mask_return))
	     { Dimension width, height;
	       StartArgs;
	       SetArg (XtNwidth, &width);
	       SetArg (XtNheight, &height);
	       XtGetValues (save_popup, UseArgs);
	       StartArgs;
	       SetArg (XtNx, win_x_return - width/2);
	       SetArg (XtNy, win_y_return - height/10);
	       XtSetValues (save_popup, UseArgs);
	     };
	  XtPopup (save_popup, XtGrabExclusive);
	};
Ejemplo n.º 3
0
static void FinishEditorActions ()
	{ SetStatus (browsing);
	  StartArgs;
	  SetArg (XtNeditable, FALSE);
	  SetArg (XtNfocusBeginX, 0);
	  SetArg (XtNfocusBeginY, 0);
	  SetArg (XtNfocusEndX, 0);
	  SetArg (XtNfocusEndY, 0);
	  XtSetValues (editor, UseArgs);
	};
Ejemplo n.º 4
0
static void CreateLayoutPopup ()
	{ Widget layout_form, layout_box1, layout_box2;
	  Widget layout_view;
	  layout_popup = XtCreatePopupShell ("layout-popup",
			 transientShellWidgetClass, MyRootWidget, NoArgs);
	  layout_form = XtCreateManagedWidget ("layout-form",
			formWidgetClass, layout_popup, NoArgs);

	  /* First group of buttons */
	  layout_box1 = XtCreateManagedWidget ("layout-box1",
			boxWidgetClass, layout_form, NoArgs);
	  StartArgs;
	  SetCallback (LayoutOk, 0);
	  UseCallback (XtNcallback);
	  (void) XtCreateManagedWidget ("layout-ok", commandWidgetClass,
					layout_box1, UseArgs);
	  StartArgs;
	  SetCallback (LayoutCancel, 0);
	  UseCallback (XtNcallback);
	  (void) XtCreateManagedWidget ("layout-cancel", commandWidgetClass,
					  layout_box1, UseArgs);

	  /* Second group of buttons */
	  layout_box2 = XtCreateManagedWidget ("layout-box2", boxWidgetClass,
					       layout_form, NoArgs);
	  StartArgs;
	  SetCallback (LayoutHorizontal, 0);
	  UseCallback (XtNcallback);
	  layout_hor = XtCreateManagedWidget ("layout-horizontal",
				toggleWidgetClass, layout_box2, UseArgs);
	  StartArgs;
	  SetArg (XtNradioGroup, layout_hor);
	  SetCallback (LayoutVertical, 0);
	  UseCallback (XtNcallback);
	  (void) XtCreateManagedWidget ("layout-vertical", toggleWidgetClass,
					layout_box2, UseArgs);

	  /* Layout editor viewport */
	  layout_view = XtCreateManagedWidget ("layout-viewport",
			viewportWidgetClass, layout_form, NoArgs);
	  StartArgs;
	  SetArg (XtNsink, tuple_edit_buffer);
	  SetCallback (LayoutOnEscape, 0);
	  UseCallback (XtNescapeProc);
	  layout_edit = XtCreateManagedWidget ("layout-editor",
			editorWidgetClass, layout_view, UseArgs);

	  /* The error box */
	  layout_error = XtCreateManagedWidget ("layout-error",
			 labelWidgetClass, layout_form, NoArgs);

	  /* Realize the stuff */
	  XtRealizeWidget (layout_popup);
	};
Ejemplo n.º 5
0
static void CreateLoadPopup ()
	{ load_popup = XtCreatePopupShell ("load-popup",
		       transientShellWidgetClass, MyRootWidget, NoArgs);
	  StartArgs;
	  SetArg (XtNlabel, "Load from");
	  SetArg (XtNvalue, "");	
	  load_dialog = XtCreateManagedWidget ("load-dialog",
			dialogWidgetClass, load_popup, UseArgs);
	  XawDialogAddButton (load_dialog, "Yes", DoLoad, NULL);
	  XawDialogAddButton (load_dialog, "Cancel", CancelLoad, NULL);
	  XtRealizeWidget (load_popup);
	};
Ejemplo n.º 6
0
void register_editor_widget (int ubuffer_size)
	{ StartArgs;
	  SetArg (XtNbufferSize, ubuffer_size);
	  SetArg (XtNsource, unparse_buffer);
	  SetArg (XtNsink, unparse_buffer);
	  SetCallback (Escape, 0);
	  UseCallback (XtNescapeProc);
	  SetCallback (Pressed, 0);
	  UseCallback (XtNpressedProc);
	  SetCallback (EditChange, 0);
	  UseCallback (XtNeditChangeProc);
	  editor = XtCreateManagedWidget ("editor", editorWidgetClass,
			viewport, UseArgs);
	};
Ejemplo n.º 7
0
static void LayoutOnEscape ()
	{ if (try_and_replace_rule (layout_rule, layout_dir))
	     { XtPopdown (layout_popup);
	       Escape ();
	     }
	  else
	     { StartArgs;
	       SetArg (XtNlabel, tuple_error_buffer);
	       XtSetValues (layout_error, UseArgs);
	       StartArgs;
	       SetArg (XtNeditable, True);
	       XtSetValues (layout_edit, UseArgs);
	     };
	};
Ejemplo n.º 8
0
static void SetStatus (int newstatus)
	{ status = newstatus;
	  StartArgs;
	  switch (status)
	     { case browsing: SetArg (XtNlabel, "status: browsing"); break;
	       case parsing:  SetArg (XtNlabel, "status: parsing"); break;
	       case editing:  SetArg (XtNlabel, "status: editing"); break;
	       case focussed: SetArg (XtNlabel, "status: focussed"); break;
	       default:
		  { fprintf (stderr, "attempt to set impossible status\n");
		    exit (4);
		  };
	     };
	  XtSetValues (statuslabel, UseArgs);
	};
Ejemplo n.º 9
0
static void CreateSavePopup ()
	{ save_popup = XtCreatePopupShell ("save-popup",
		       transientShellWidgetClass, MyRootWidget, NoArgs);
	  StartArgs;
	  SetArg (XtNlabel, "Save changes in");
	  SetArg (XtNvalue, "");	
	  save_dialog = XtCreateManagedWidget ("save-dialog",
			dialogWidgetClass, save_popup, UseArgs);
	  XawDialogAddButton (save_dialog, "Yes",
			      (XtCallbackProc) DoSave, NULL);
	  XawDialogAddButton (save_dialog, "No",
			      (XtCallbackProc) DontSave, NULL);
	  XawDialogAddButton (save_dialog, "Cancel",
			      (XtCallbackProc) CancelSave, NULL);
	  XtRealizeWidget (save_popup);
	}
Ejemplo n.º 10
0
int FunctionNode::Push( Compiler* pCompiler ) const
{
	const FunctionTag* pTag = pCompiler->GetFunctionTag( *m_pString );
	if( pTag == NULL ){
		pCompiler->error( m_Location, "Variable : " + *m_pString + " is not registered." );
	}
	
	int argSize = m_pArgs ? m_pArgs->Size() : 0;
	if( pTag->ArgSize() != argSize ){
		pCompiler->error( m_Location, "Size of argument is incorrect." );
	}

	// Push arguments.
	if( m_pArgs && pTag->ArgSize() == argSize ){
		m_pArgs->ForEach( SetArg( pCompiler, pTag ) );
	}

	// Push number of arguments.
	pCompiler->PushConst( argSize );

	// System call.
	if( pTag->IsSystem() ){
		pCompiler->OpSysCall( pTag->GetIndex() );
	}
	// Normal function call.
	else{
		pCompiler->OpCall( pTag->GetIndex() );
	}

	return pTag->m_Type;
}
Ejemplo n.º 11
0
static void UpdateEditorWidgets ()
	{ char Buffer[80];
	  StartArgs;
	  SetArg (XtNsource, unparse_buffer);
	  XtSetValues (editor, UseArgs);
	  sprintf (Buffer, "%d parse%s w%s found", nrofparses,
			(nrofparses == 1)?"":"s",
			(nrofparses == 1)?"as":"ere");
	  StartArgs;
	  SetArg (XtNlabel, Buffer);
	  XtSetValues (parseslabel, UseArgs);
	  if (nrofparses) Buffer[0] = '\0';
	  else sprintf (Buffer, "Probable error: %s", pemsg);
	  StartArgs;
	  SetArg (XtNlabel, Buffer);
	  XtSetValues (complainlabel, UseArgs);
	};
Ejemplo n.º 12
0
static void EditChange ()
	{ if (status != focussed) return;
	  SetStatus (editing);
	  changed = 1;
	  StartArgs;
	  SetArg (XtNeditable, TRUE);
	  XtSetValues (editor, UseArgs);
	};
Ejemplo n.º 13
0
int luajack_xmove(lua_State *T, lua_State *L, int chunck_index, int last_index)
/* Checks and copies arguments between unrelated states L and T (L to T)
 * (lua_xmove() cannot be used here, because the states are not related).
 *
 * L[chunck_index] -----> arg[0] script name, or chunk
 * L[chunck_index +1] --> arg[1]
 * L[chunck_index +2] --> arg[2]
 * ...
 * L[last_index]      --> arg[N]
 * Since arguments are to be passed between unrelated states, the only admitted
 * types are: nil, boolean, number and string.
 */ 
	{
	int arg_index, argn, n, typ, nargs;
	nargs = last_index - chunck_index; /* no. of optional arguments */
	luaL_checkstack(T, nargs, "cannot grow Lua stack for thread");

	lua_newtable(T); /* "arg" table */
	arg_index = lua_gettop(T);

	lua_pushstring(T, lua_tostring(L, chunck_index)); /* arg[0] = full scriptname */
	lua_seti(T, arg_index, 0);

	argn = 1;
	for(n = chunck_index+1; n <= last_index; n++)
		{
		typ = lua_type(L, n);
		switch(typ)
			{
#define SetArg() do { lua_pushvalue(T, -1); lua_seti(T, arg_index, argn++); } while(0)
			case LUA_TNIL: lua_pushnil(T); SetArg(); break;
			case LUA_TBOOLEAN: lua_pushboolean(T, lua_toboolean(L, n)); SetArg(); break;
			case LUA_TNUMBER: lua_pushnumber(T, lua_tonumber(L, n)); SetArg(); break;
			case LUA_TSTRING: lua_pushstring(T, lua_tostring(L, n)); SetArg(); break;
			default:
				return luaL_error(L, "invalid type '%s' of argument #%d ", 
									lua_typename(L, typ), n - chunck_index);
#undef SetArg
			}
		}
	lua_pushvalue(T, arg_index);
	lua_setglobal(T, "arg");
	lua_remove(T, arg_index);
	return 0;
	}
Ejemplo n.º 14
0
static void Pressed (EditorWidget w,
		      XtPointer client_data, XtPointer call_data)
	{ PressedData data = (PressedData) call_data;
	  if (status == editing) return;
	  SetStatus (focussed);
	  switch (data -> button)
	     { case 1: set_focus_from_pos (data -> x, data -> y); break;
	       case 2: set_focus_to_father (); break;
	       default: ;
	     };
	  update_template_buffer (current_focus -> node -> nodenr);
	  StartArgs;
	  SetArg (XtNsource, template_buffer);
	  XtSetValues (templateviewer, UseArgs);
	  StartArgs;
	  SetArg (XtNfocusBeginX, current_focus -> begin_x);
	  SetArg (XtNfocusBeginY, current_focus -> begin_y);
	  SetArg (XtNfocusEndX, current_focus -> end_x);
	  SetArg (XtNfocusEndY, current_focus -> end_y);
	  XtSetValues (editor, UseArgs);
	};
Ejemplo n.º 15
0
void static ApplyMiningSettings()
{
    QSettings settings;
    if (settings.contains("bMiningEnabled"))
        SetBoolArg("-gen", settings.value("bMiningEnabled").toBool());
    if (settings.contains("nMiningIntensity"))
        SetArg("-genproclimit", settings.value("nMiningIntensity").toString().toStdString());
    // stop
    GenerateBitcoins(false, NULL);
    // start
    GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain);
}
Ejemplo n.º 16
0
static void CheckToSaveLayoutRules ()
	{ unsigned int mask_return;
	  Window root_return, child_return;
	  int root_x_return, root_y_return, win_x_return, win_y_return;
	  
	  if (!changed_rules) ActualExit ();
	  if (XQueryPointer (MyDisplay, MyRootWindow,
		&root_return, &child_return, &root_x_return, &root_y_return,
		&win_x_return, &win_y_return, &mask_return))
	     { Dimension width, height;
	       StartArgs;
	       SetArg (XtNwidth, &width);
	       SetArg (XtNheight, &height);
	       XtGetValues (check_popup, UseArgs);
	       StartArgs;
	       SetArg (XtNx, win_x_return - width/2);
	       SetArg (XtNy, win_y_return - height/10);
	       XtSetValues (check_popup, UseArgs);
	     };
	  XtPopup (check_popup, XtGrabExclusive);
	};
Ejemplo n.º 17
0
s64 CPUThread::ExecAsCallback(u64 pc, bool wait, u64 a1, u64 a2, u64 a3, u64 a4) // not multithread-safe
{
    while (m_alive)
    {
        if (Emu.IsStopped())
        {
            ConLog.Warning("ExecAsCallback() aborted");
            return CELL_ECANCELED; // doesn't mean anything
        }
        Sleep(1);
    }

    Stop();
    Reset();

    SetEntry(pc);
    SetPrio(1001);
    SetStackSize(0x10000);
    SetExitStatus(CELL_OK);

    SetArg(0, a1);
    SetArg(1, a2);
    SetArg(2, a3);
    SetArg(3, a4);
    Run();

    Exec();

    while (wait && m_alive)
    {
        if (Emu.IsStopped())
        {
            ConLog.Warning("ExecAsCallback(wait=%s) aborted", wait ? "true" : "false");
            return CELL_EABORT; // doesn't mean anything
        }
        Sleep(1);
    }

    return wait * m_exit_status;
}
Ejemplo n.º 18
0
s64 CPUThread::ExecAsCallback(u64 pc, bool wait, u64 a1, u64 a2, u64 a3, u64 a4) // not multithread-safe
{
	while (m_alive)
	{
		if (Emu.IsStopped())
		{
			LOG_WARNING(PPU, "ExecAsCallback() aborted");
			return CELL_ECANCELED; // doesn't mean anything
		}
		std::this_thread::sleep_for(std::chrono::milliseconds(1));
	}

	Stop();
	Reset();

	SetEntry(pc);
	SetPrio(1001);
	SetStackSize(0x10000);
	SetExitStatus(CELL_OK);

	SetArg(0, a1);
	SetArg(1, a2);
	SetArg(2, a3);
	SetArg(3, a4);
	Run();

	Exec();

	while (wait && m_alive)
	{
		if (Emu.IsStopped())
		{
			LOG_WARNING(PPU, "ExecAsCallback(wait=%s) aborted", wait ? "true" : "false");
			return CELL_EABORT; // doesn't mean anything
		}
		std::this_thread::sleep_for(std::chrono::milliseconds(1));
	}

	return wait * m_exit_status;
}
Ejemplo n.º 19
0
static void Layout ()
	{ unsigned int mask_return;
	  Window root_return, child_return;
	  int root_x_return, root_y_return, win_x_return, win_y_return;
	  
	  if (status != focussed) return;
	  layout_rule = ruletable [current_focus -> node -> nodenr];
	  if (layout_rule == rule_nil) return;
	  StartArgs;
	  SetArg (XtNstate, True);
	  XtSetValues (layout_hor, UseArgs);
	  layout_dir = hor_rule;
	  write_rule_to_buffer (layout_rule, hor_rule);
	  StartArgs;
	  SetLayoutEditWidgetFocus ();
	  XtSetValues (layout_edit, UseArgs);
	  StartArgs;
	  SetArg (XtNlabel, "");
	  XtSetValues (layout_error, UseArgs);
	  if (XQueryPointer (MyDisplay, MyRootWindow,
		&root_return, &child_return, &root_x_return, &root_y_return,
		&win_x_return, &win_y_return, &mask_return))
	     { Dimension width, height;
	       StartArgs;
	       SetArg (XtNwidth, &width);
	       SetArg (XtNheight, &height);
	       XtGetValues (layout_popup, UseArgs);
	       StartArgs;
	       SetArg (XtNx, win_x_return - width/2);
	       SetArg (XtNy, win_y_return - height/10);
	       XtSetValues (layout_popup, UseArgs);
	     };
	  XtPopup (layout_popup, XtGrabExclusive);
	};
Ejemplo n.º 20
0
static void ActualLoad ()
	{ unsigned int mask_return;
	  Window root_return, child_return;
	  int root_x_return, root_y_return, win_x_return, win_y_return;
	  
	  StartArgs;
	  SetArg (XtNvalue, Filename);
	  XtSetValues (load_dialog, UseArgs);
	  if (XQueryPointer (MyDisplay, MyRootWindow,
		&root_return, &child_return, &root_x_return, &root_y_return,
		&win_x_return, &win_y_return, &mask_return))
	     { Dimension width, height;
	       StartArgs;
	       SetArg (XtNwidth, &width);
	       SetArg (XtNheight, &height);
	       XtGetValues (load_popup, UseArgs);
	       StartArgs;
	       SetArg (XtNx, win_x_return - width/2);
	       SetArg (XtNy, win_y_return - height/10);
	       XtSetValues (load_popup, UseArgs);
	     };
	  XtPopup (load_popup, XtGrabExclusive);
	};
Ejemplo n.º 21
0
static void CreateCheckPopup ()
	{ check_popup = XtCreatePopupShell ("check-popup",
			transientShellWidgetClass, MyRootWidget, NoArgs);
	  StartArgs;
	  SetArg (XtNlabel, "Save changes to layout rules");
	  check_dialog = XtCreateManagedWidget ("check-dialog",
			 dialogWidgetClass, check_popup, UseArgs);
	  XawDialogAddButton (check_dialog, "Yes",
			      (XtCallbackProc) DoSaveLayoutRules, NULL);
	  XawDialogAddButton (check_dialog, "No",
			      (XtCallbackProc) DontSaveLayoutRules, NULL);
	  XawDialogAddButton (check_dialog, "Cancel",
			      (XtCallbackProc) CancelFinalExit, NULL);
	  XtRealizeWidget (check_popup);
	};
Ejemplo n.º 22
0
static void SetLayoutEditWidgetFocus ()
	{ int endx = 0;
	  int endy = 0;
	  char *ptr;

	  for (ptr = tuple_edit_buffer; *ptr; ptr++)
	     if (*ptr == '\n') { endy++; endx = 0; }
	     else endx++;
	  SetArg (XtNfocusBeginX, 0);
	  SetArg (XtNfocusBeginY, 0);
	  SetArg (XtNfocusEndX, endx);
	  SetArg (XtNfocusEndY, endy);
	  SetArg (XtNeditable, True);
	  SetArg (XtNsource, tuple_edit_buffer);
	};
Ejemplo n.º 23
0
bool CommandBase::ProcessLine()
{
	assert(line != NULL);
	if(line->size() < NumArgs()) {
		cout<<"Not enough arguments to "<<Name()<<endl;
		return false;
	}
	int args_remaining = (int)line->size();
	int j;
	for(j=0; j<NumArgs(); j++,args_remaining--) {
		if(!SetArg(j,(*line)[j])) {
			cout<<"Error reading argument "<<GetArgName(j)<<"="<<(*line)[j]<<" to "<<Name()<<endl;
			return false;
		}
	}
	int num_inputs = args_remaining - NumOutputs();
	if(MaxInputs() >= 0) {
		if(num_inputs > MaxInputs()) {
			cout << "The number of max inputs to -" <<Name()<<" was exceeded."<<endl;
			return false;
		}
	}
	if(num_inputs < MinInputs()) {
		cout << "Not enough inputs given to -" <<Name()<<endl;
		return false;
	}
	inputs.resize(num_inputs);
	for(int i=0;i<num_inputs;i++,j++,args_remaining--) {
		inputs[i]=(*line)[j];
	}
	assert(args_remaining == NumOutputs());
	outputs.resize(NumOutputs());
	for(int i=0;i<NumOutputs();i++,j++,args_remaining--) {
		outputs[i]=(*line)[j];
	}
	assert(j == line->size());
	assert(args_remaining == 0);
	return true;
}
Ejemplo n.º 24
0
	ConnectorThread(Connector* pConnector) { SetArg(pConnector); }
Ejemplo n.º 25
0
		void Kernel:: SetArg( cl_uint arg_index, MemObject &mem )
		{
			cl_mem obj = *mem;
			SetArg( arg_index, sizeof(cl_mem), &obj );
		}
Ejemplo n.º 26
0
		void Kernel:: SetArg(cl_uint arg_index, size_t local_mem_size )
		{
			SetArg(arg_index, local_mem_size, NULL);
		}
Ejemplo n.º 27
0
			inline void SetArgAs(cl_uint arg_index, T arg ) 
			{
				SetArg(arg_index, sizeof(T), &arg );
			}