zip coroutine functions

This commit is contained in:
Allen Webster 2017-09-10 15:14:41 -04:00
parent fd141031b9
commit cdccd7d912
4 changed files with 83 additions and 114 deletions

View File

@ -0,0 +1,76 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 10.09.2017
*
* Mac C++ layer for 4coder
*
*/
// TOP
#if !defined(FRED_COROUTINE_FUNCTIONS_CPP)
#define FRED_COROUTINE_FUNCTIONS_CPP
//
// Coroutine
//
internal
Sys_Create_Coroutine_Sig(system_create_coroutine){
Coroutine *coroutine = coroutine_system_alloc(&coroutines);
Coroutine_Head *result = 0;
if (coroutine != 0){
coroutine_set_function(coroutine, func);
result = &coroutine->head;
}
return(result);
}
internal
Sys_Launch_Coroutine_Sig(system_launch_coroutine){
Coroutine *coroutine = (Coroutine*)head;
coroutine->head.in = in;
coroutine->head.out = out;
Coroutine *active = coroutine->sys->active;
Assert(active != 0);
coroutine_launch(active, coroutine);
Assert(active == coroutine->sys->active);
Coroutine_Head *result = &coroutine->head;
if (coroutine->state == CoroutineState_Dead){
coroutine_system_free(&coroutines, coroutine);
result = 0;
}
return(result);
}
Sys_Resume_Coroutine_Sig(system_resume_coroutine){
Coroutine *coroutine = (Coroutine*)head;
coroutine->head.in = in;
coroutine->head.out = out;
Coroutine *active = coroutine->sys->active;
Assert(active != 0);
coroutine_resume(active, coroutine);
Assert(active == coroutine->sys->active);
Coroutine_Head *result = &coroutine->head;
if (coroutine->state == CoroutineState_Dead){
coroutine_system_free(&coroutines, coroutine);
result = 0;
}
return(result);
}
Sys_Yield_Coroutine_Sig(system_yield_coroutine){
Coroutine *coroutine = (Coroutine*)head;
coroutine_yield(coroutine);
}
#endif
// BOTTOM

View File

@ -304,6 +304,8 @@ Sys_Send_Exit_Signal_Sig(system_send_exit_signal){
linuxvars.keep_running = false; linuxvars.keep_running = false;
} }
#include "4ed_coroutine_functions.cpp"
// //
// Clipboard // Clipboard
// //
@ -314,63 +316,6 @@ Sys_Post_Clipboard_Sig(system_post_clipboard){
XSetSelectionOwner(linuxvars.XDisplay, linuxvars.atom_CLIPBOARD, linuxvars.XWindow, CurrentTime); XSetSelectionOwner(linuxvars.XDisplay, linuxvars.atom_CLIPBOARD, linuxvars.XWindow, CurrentTime);
} }
//
// Coroutine
//
internal
Sys_Create_Coroutine_Sig(system_create_coroutine){
Coroutine *coroutine = coroutine_system_alloc(&coroutines);
Coroutine_Head *result = 0;
if (coroutine != 0){
coroutine_set_function(coroutine, func);
result = &coroutine->head;
}
return(result);
}
internal
Sys_Launch_Coroutine_Sig(system_launch_coroutine){
Coroutine *coroutine = (Coroutine*)head;
coroutine->head.in = in;
coroutine->head.out = out;
Coroutine *active = coroutine->sys->active;
Assert(active != 0);
coroutine_launch(active, coroutine);
Assert(active == coroutine->sys->active);
Coroutine_Head *result = &coroutine->head;
if (coroutine->state == CoroutineState_Dead){
coroutine_system_free(&coroutines, coroutine);
result = 0;
}
return(result);
}
Sys_Resume_Coroutine_Sig(system_resume_coroutine){
Coroutine *coroutine = (Coroutine*)head;
coroutine->head.in = in;
coroutine->head.out = out;
Coroutine *active = coroutine->sys->active;
Assert(active != 0);
coroutine_resume(active, coroutine);
Assert(active == coroutine->sys->active);
Coroutine_Head *result = &coroutine->head;
if (coroutine->state == CoroutineState_Dead){
coroutine_system_free(&coroutines, coroutine);
result = 0;
}
return(result);
}
Sys_Yield_Coroutine_Sig(system_yield_coroutine){
Coroutine *coroutine = (Coroutine*)head;
coroutine_yield(coroutine);
}
// //
// CLI // CLI
// //

View File

@ -91,6 +91,8 @@ OSX_Vars osx;
//////////////////////////////// ////////////////////////////////
#include "4ed_coroutine_functions.cpp"
// //
// Clipboard // Clipboard
// //
@ -108,7 +110,8 @@ Sys_Post_Clipboard_Sig(system_post_clipboard){
} }
memcpy(osx.clipboard_space, str.str, str.size); memcpy(osx.clipboard_space, str.str, str.size);
osx.clipboard_space[str.size] = 0; osx.clipboard_space[str.size] = 0;
string = osx.clipboard_space; string = osx.clipboard_space
;
} }
osx_post_to_clipboard(string); osx_post_to_clipboard(string);
} }

View File

@ -262,62 +262,7 @@ Sys_Send_Exit_Signal_Sig(system_send_exit_signal){
win32vars.send_exit_signal = true; win32vars.send_exit_signal = true;
} }
// #include "4ed_coroutine_functions.cpp"
// Coroutines
//
internal
Sys_Create_Coroutine_Sig(system_create_coroutine){
Coroutine *coroutine = coroutine_system_alloc(&coroutines);
Coroutine_Head *result = 0;
if (coroutine != 0){
coroutine_set_function(coroutine, func);
result = &coroutine->head;
}
return(result);
}
internal
Sys_Launch_Coroutine_Sig(system_launch_coroutine){
Coroutine *coroutine = (Coroutine*)head;
coroutine->head.in = in;
coroutine->head.out = out;
Coroutine *active = coroutine->sys->active;
Assert(active != 0);
coroutine_launch(active, coroutine);
Assert(active == coroutine->sys->active);
Coroutine_Head *result = &coroutine->head;
if (coroutine->state == CoroutineState_Dead){
coroutine_system_free(&coroutines, coroutine);
result = 0;
}
return(result);
}
Sys_Resume_Coroutine_Sig(system_resume_coroutine){
Coroutine *coroutine = (Coroutine*)head;
coroutine->head.in = in;
coroutine->head.out = out;
Coroutine *active = coroutine->sys->active;
Assert(active != 0);
coroutine_resume(active, coroutine);
Assert(active == coroutine->sys->active);
Coroutine_Head *result = &coroutine->head;
if (coroutine->state == CoroutineState_Dead){
coroutine_system_free(&coroutines, coroutine);
result = 0;
}
return(result);
}
Sys_Yield_Coroutine_Sig(system_yield_coroutine){
Coroutine *coroutine = (Coroutine*)head;
coroutine_yield(coroutine);
}
// //
// Clipboard // Clipboard