now have better yield checking
This commit is contained in:
parent
ddf06aecc2
commit
e4461f3663
|
@ -315,6 +315,7 @@ view_summary_zero(){
|
||||||
}
|
}
|
||||||
|
|
||||||
enum User_Input_Type{
|
enum User_Input_Type{
|
||||||
|
UserInputNone,
|
||||||
UserInputKey,
|
UserInputKey,
|
||||||
UserInputMouse
|
UserInputMouse
|
||||||
};
|
};
|
||||||
|
@ -336,6 +337,7 @@ struct Query_Bar{
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Event_Message_Type{
|
enum Event_Message_Type{
|
||||||
|
EM_No_Message,
|
||||||
EM_Open_View,
|
EM_Open_View,
|
||||||
EM_Frame,
|
EM_Frame,
|
||||||
EM_Close_View
|
EM_Close_View
|
||||||
|
@ -591,8 +593,9 @@ struct Application_Links{
|
||||||
|
|
||||||
// Internal
|
// Internal
|
||||||
void *cmd_context;
|
void *cmd_context;
|
||||||
void *current_coroutine;
|
|
||||||
void *system_links;
|
void *system_links;
|
||||||
|
void *current_coroutine;
|
||||||
|
int type_coroutine;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define _GET_VERSION_SIG(n) int n(int maj, int min, int patch)
|
#define _GET_VERSION_SIG(n) int n(int maj, int min, int patch)
|
||||||
|
|
57
4ed.cpp
57
4ed.cpp
|
@ -87,32 +87,59 @@ struct App_Vars{
|
||||||
Command_Data command_data;
|
Command_Data command_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum Coroutine_Type{
|
||||||
|
Co_View,
|
||||||
|
Co_Command
|
||||||
|
};
|
||||||
|
struct App_Coroutine_State{
|
||||||
|
void *co;
|
||||||
|
int type;
|
||||||
|
};
|
||||||
|
inline App_Coroutine_State
|
||||||
|
get_state(Application_Links *app){
|
||||||
|
App_Coroutine_State state = {0};
|
||||||
|
state.co = app->current_coroutine;
|
||||||
|
state.type = app->type_coroutine;
|
||||||
|
return(state);
|
||||||
|
}
|
||||||
|
inline void
|
||||||
|
restore_state(Application_Links *app, App_Coroutine_State state){
|
||||||
|
app->current_coroutine = state.co;
|
||||||
|
app->type_coroutine = state.type;
|
||||||
|
}
|
||||||
|
|
||||||
inline Coroutine*
|
inline Coroutine*
|
||||||
app_launch_coroutine(System_Functions *system, Application_Links *app,
|
app_launch_coroutine(System_Functions *system, Application_Links *app, Coroutine_Type type,
|
||||||
Coroutine *co, void *in, void *out){
|
Coroutine *co, void *in, void *out){
|
||||||
Coroutine* result = 0;
|
Coroutine* result = 0;
|
||||||
|
|
||||||
Coroutine *prev_coroutine = (Coroutine*)app->current_coroutine;
|
App_Coroutine_State prev_state = get_state(app);
|
||||||
|
|
||||||
app->current_coroutine = co;
|
app->current_coroutine = co;
|
||||||
|
app->type_coroutine = type;
|
||||||
{
|
{
|
||||||
result = system->launch_coroutine(co, in, out);
|
result = system->launch_coroutine(co, in, out);
|
||||||
}
|
}
|
||||||
app->current_coroutine = prev_coroutine;
|
|
||||||
|
restore_state(app, prev_state);
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Coroutine*
|
inline Coroutine*
|
||||||
app_resume_coroutine(System_Functions *system, Application_Links *app,
|
app_resume_coroutine(System_Functions *system, Application_Links *app, Coroutine_Type type,
|
||||||
Coroutine *co, void *in, void *out){
|
Coroutine *co, void *in, void *out){
|
||||||
Coroutine* result = 0;
|
Coroutine* result = 0;
|
||||||
|
|
||||||
Coroutine *prev_coroutine = (Coroutine*)app->current_coroutine;
|
App_Coroutine_State prev_state = get_state(app);
|
||||||
|
|
||||||
app->current_coroutine = co;
|
app->current_coroutine = co;
|
||||||
|
app->type_coroutine = type;
|
||||||
{
|
{
|
||||||
result = system->resume_coroutine(co, in, out);
|
result = system->resume_coroutine(co, in, out);
|
||||||
}
|
}
|
||||||
app->current_coroutine = prev_coroutine;
|
|
||||||
|
restore_state(app, prev_state);
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
@ -2427,14 +2454,16 @@ extern "C"{
|
||||||
GET_USER_INPUT_SIG(external_get_user_input){
|
GET_USER_INPUT_SIG(external_get_user_input){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
System_Functions *system = cmd->system;
|
System_Functions *system = cmd->system;
|
||||||
Coroutine *coroutine = cmd->models->command_coroutine;
|
Coroutine *coroutine = (Coroutine*)app->current_coroutine;
|
||||||
User_Input result;
|
User_Input result = {0};
|
||||||
|
|
||||||
|
if (app->type_coroutine == Co_Command){
|
||||||
Assert(coroutine);
|
Assert(coroutine);
|
||||||
*((u32*)coroutine->out+0) = get_type;
|
*((u32*)coroutine->out+0) = get_type;
|
||||||
*((u32*)coroutine->out+1) = abort_type;
|
*((u32*)coroutine->out+1) = abort_type;
|
||||||
system->yield_coroutine(coroutine);
|
system->yield_coroutine(coroutine);
|
||||||
result = *(User_Input*)coroutine->in;
|
result = *(User_Input*)coroutine->in;
|
||||||
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
@ -2456,9 +2485,11 @@ extern "C"{
|
||||||
System_Functions *system = (System_Functions*)app->system_links;
|
System_Functions *system = (System_Functions*)app->system_links;
|
||||||
Coroutine *coroutine = (Coroutine*)app->current_coroutine;
|
Coroutine *coroutine = (Coroutine*)app->current_coroutine;
|
||||||
|
|
||||||
|
if (app->type_coroutine == Co_View){
|
||||||
Assert(coroutine);
|
Assert(coroutine);
|
||||||
system->yield_coroutine(coroutine);
|
system->yield_coroutine(coroutine);
|
||||||
message = *(Event_Message*)coroutine->in;
|
message = *(Event_Message*)coroutine->in;
|
||||||
|
}
|
||||||
|
|
||||||
return(message);
|
return(message);
|
||||||
}
|
}
|
||||||
|
@ -3836,7 +3867,7 @@ App_Step_Sig(app_step){
|
||||||
models->command_coroutine = persistent->coroutine;
|
models->command_coroutine = persistent->coroutine;
|
||||||
|
|
||||||
persistent->coroutine =
|
persistent->coroutine =
|
||||||
app_launch_coroutine(system, &models->app_links,
|
app_launch_coroutine(system, &models->app_links, Co_View,
|
||||||
persistent->coroutine,
|
persistent->coroutine,
|
||||||
view,
|
view,
|
||||||
0);
|
0);
|
||||||
|
@ -3912,7 +3943,7 @@ App_Step_Sig(app_step){
|
||||||
user_in.abort = 1;
|
user_in.abort = 1;
|
||||||
|
|
||||||
command_coroutine =
|
command_coroutine =
|
||||||
app_resume_coroutine(system, &models->app_links,
|
app_resume_coroutine(system, &models->app_links, Co_Command,
|
||||||
command_coroutine,
|
command_coroutine,
|
||||||
&user_in,
|
&user_in,
|
||||||
models->command_coroutine_flags);
|
models->command_coroutine_flags);
|
||||||
|
@ -3993,7 +4024,7 @@ App_Step_Sig(app_step){
|
||||||
|
|
||||||
if (pass_in){
|
if (pass_in){
|
||||||
models->command_coroutine =
|
models->command_coroutine =
|
||||||
app_resume_coroutine(system, &models->app_links,
|
app_resume_coroutine(system, &models->app_links, Co_Command,
|
||||||
command_coroutine,
|
command_coroutine,
|
||||||
&user_in,
|
&user_in,
|
||||||
models->command_coroutine_flags);
|
models->command_coroutine_flags);
|
||||||
|
@ -4062,7 +4093,7 @@ App_Step_Sig(app_step){
|
||||||
|
|
||||||
if (pass_in){
|
if (pass_in){
|
||||||
models->command_coroutine =
|
models->command_coroutine =
|
||||||
app_resume_coroutine(system, &models->app_links,
|
app_resume_coroutine(system, &models->app_links, Co_Command,
|
||||||
command_coroutine,
|
command_coroutine,
|
||||||
&user_in,
|
&user_in,
|
||||||
models->command_coroutine_flags);
|
models->command_coroutine_flags);
|
||||||
|
@ -4191,7 +4222,7 @@ App_Step_Sig(app_step){
|
||||||
cmd_in.bind = cmd_bind;
|
cmd_in.bind = cmd_bind;
|
||||||
|
|
||||||
models->command_coroutine =
|
models->command_coroutine =
|
||||||
app_launch_coroutine(system, &models->app_links,
|
app_launch_coroutine(system, &models->app_links, Co_Command,
|
||||||
models->command_coroutine,
|
models->command_coroutine,
|
||||||
&cmd_in,
|
&cmd_in,
|
||||||
models->command_coroutine_flags);
|
models->command_coroutine_flags);
|
||||||
|
|
Loading…
Reference in New Issue