Epoch reference parameters

Published September 06, 2008
Advertisement
With nothing better to do over the weekend, I hacked out reference parameters for Epoch. This means that it is now possible to pass structures to external APIs and get results back. For example, the following Epoch program retrieves the number of processor cores in the host system:

//// STRUCTUREAPI.EPOCH//// Simple demonstration of how to use structure (record) types with external APIs//structure msgboxtype :(	integer(size),	integer(ownerwnd),	integer(instance),	string(text),	string(caption),	integer(style),	string(icon),	integer(helpid),	integer(callback),	integer(language)	)structure systeminfotype :(	integer16(architecture),	integer16(reserved),	integer(pagesize),	integer(minappaddress),	integer(maxappaddress),	integer(activeprocmask),	integer(numprocessors),	integer(proctype),	integer(allocgranularity),	integer16(proclevel),	integer16(procrevision))external "user32.dll" MessageBoxIndirectW : (msgboxtype(params)) -> (integer)external "kernel32.dll" GetSystemInfo : (systeminfotype ref(info)) -> ()entrypoint : () -> (){	systeminfotype(info, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)	GetSystemInfo(info)	string(proccountstr, "")	assign(proccountstr, concat("System processor count: ", cast(string, readstructure(info, numprocessors))))	integer(styleflags, 64)	msgboxtype(params, sizeof(msgboxtype), 0, 0, proccountstr, "Epoch test", styleflags, "", 0, 0, 0)	MessageBoxIndirectW(params)}


Woot.


Of course, simpler programs that use reference parameters also work:

entrypoint : () -> (){	integer(foo, 0)	increment(foo)	debugwritestring(cast(string, foo))}increment : (integer ref(value)) -> (){	assign(value, add(value, 1))}



All in all, a happy improvement to the system.
Previous Entry Epoch (what else?)
0 likes 2 comments

Comments

choffstein
tickle me impressed. i can't wait to give it a try.
September 06, 2008 08:13 PM
rip-off
Very impressive progress.
September 07, 2008 03:06 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement