Re: Andrea Cini's euwingui

new topic     » goto parent     » topic index » view thread      » older message » newer message
jimcbrown said...
jimcbrown said...
ChrisB said...

Hi

Purely for curiosity's sake, please explain. How have they changed? How would you one write a shim that would convert? What would they convert - from / to? Has the internal structure / arrangement of the sequence changed from 3.x to 4?

Chris

The biggest change was the addition of the cleanup_ptr at the end of every structure (s1 [for sequences], d [for atoms], etc) used internally by euphoria to represent non-integer types. The code checks to see if this is NULL or not, and if not it attempts to interpret the value as an euphoria routine and calls it (runs the code of the routine). So if a 3.1 object was passed, we'd try to read pass the end of the memory for the structure. And then execute it. (But this particular issue is easy to deal with, a shim just needs add NULL to the end of the structure.)

It might not have been as easy as I thought. I wrote the following shim code, but EuWinGUI no longer crashes but doesn't seem to work either.

I realized that it was possible to write the shim layer in 100% Eu instead of in C. This was significantly easier to get working, and wokred out of the box on the first try.

You can get it at http://malcom.unkmar.com/lostsouls/euconvert.zip - euconvert.dll and euconvertinc.e are what you want.

euconvert.e is the source of euconvert.dll, and I also left the watcom build artifacts in (just in case someone needs to rebuild with a different version of watcom or wants to hack the C layer for some reason).

Here are the required changes to EuWinGUI.ew

integer spa,closeapp,waitevent,window,control,infomsg,warnmsg,askmsg,setpos,setdim,settext,setcheck, 
ischecked,loadpic,setico,gettext,setenable,setvisible,listclear,listadd,listdel,listins,listseek, 
getitem,getcount,getindex,listput,filedlg,activate,activatetext,setrefresh,setwintimer,seticon, 
runapp,screenwidth,screenheight,setparentwindow,setfixedfont,setdrawingproc,deleteimage,setlistcwidth, 
setrepainton,getlistitemheight,listindex,listcount,setcur,setdrawingcontrol,drawline,drawpoint, 
drawstring,drawpolygon,setpencolor,setpensize,playsnd,stopsnd,drawmultiline,trapmessage,loadcur,setpicture, 
message,gettrappedmessage,setpic,loadico,getstringsize,newfont,setfont,setdrawingfont,getglobalvars, 
setglobalvars,newmb,setdrawingmb,copymb,copymbtocontrol,getpixelcolor,seteditsel,geteditsel,iskeypressed, 
processevent,iseventwaiting,setcolor,selectprinter,getpagesize,getprinterstringsize,setprinterpencolor, 
setprinterfont,printmb,printstring,newdocument,newpage,startprinting,getselec,setexpp 
 
-- INSERT THIS LINE -- 
include euconvertinc.e 
-- END OF INSERT -- 
 
procedure infail(sequence name) 
integer k 
puts(1, "The EuWinGUI Library\n") 
puts(1, "(C)2001-2006 by Andrea Cini.\n\n") 
puts(1, "ERROR: Unable to initialize " & name & "!\n\nPress any key to abort...\n") 
while 1 do 
k = get_key() 
if k != -1 then 
abort(1) 
end if 
end while 
end procedure	  
function indll(sequence file_name) 
atom res 
res = machine_func(50, file_name) 
if res = NULL then infail(file_name) end if 
return res 
end function 
function infunc(atom dll, sequence name, sequence args, atom result) 
integer handle 
-- INSERT THIS -- 
--handle = machine_func(51, {dll, name, args, result}) 
handle = v3_define_c_func(dll, name, args, result) 
-- END OF INSERT -- 
if handle = -1 then 
infail(name) 
else 
return handle 
end if 
end function 
function inproc(atom dll, sequence name, sequence args) 
integer handle 
-- INSERT THIS -- 
--handle = machine_func(51, {dll, name, args, 0}) 
handle = v3_define_c_proc(dll, name, args) 
-- END OF INSERT -- 
if handle = -1 then 
infail(name) 
else 
return handle 
end if 
end function 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu