1. AutoIt vs Euphoria
- Posted by Icy_Viking May 08, 2018
- 2519 views
So I recently came across AutoIt. It is a programming language that shares some similiarties with Euphoria. I even noticed that wrapping DLL functions in AutoIt is quite similar to how it is done in Euphoria. However one advantage AutoIt has over Euphoria when it comes to wrapping things such as DLL functions, it actually has struct support. I'll show below in code.
;Struct for SDL_RECT Func SDL_Rect($x,$y,$w,$h) $xSDL_Rect = DllStructCreate("int;int;int;int") DllStructSetData($SDL_Rect,1,$x) DllStructSetData($SDL_Rect,2,$y) DllStructSetData($SDL_Rect,3,$w) DllStructSetData($SDL_Rect,4,$h) Return $xSDL_Rect EndFunc Func SDL_GetDisplayBounds($display,$xSDL_Rect) Local $xSDL_GetDesktopDisplayMode = DllCall($SDL,"int:cdecl","SDL_GetDisplayBounds","int",$display,"ptr",DllStructGetPtr($xSDL_Rect)) Return $xSDL_GetDesktopDisplayMode[0] EndFunc
You basiclly make a variable for the struct, then you can access/use it via a pointer. Also, note the similarity in how similar it looks to as if you were wrapping it for Euphoria.
public constant xSDL_GetDisplayBounds = define_c_func(sdl2,"SDL_GetDisplayBounds",{C_INT,C_POINTER},C_INT) public function SDL_GetDisplayBounds(atom dis,atom rect) rect = allocate(16) poke4(rect + RECT_LEFT, 10) poke4(rect + RECT_TOP, 20) poke4(rect + RECT_RIGHT, 90) poke4(rect + RECT_BOTTOM, 100) return c_func(xSDL_GetDisplayBounds,{dis,rect}) end function
While Euphoria is still simple, having something to directly access structs or a struct for Euphoria would be excellent. Is it still true that the next version of Euphoria will have some sorta of primitive struct functionality? I'm sure it would probably be even more simple in Eu than it would be in AutoIt. Something like
Struct Eu_Struct {atom x,atom y,atom w, atom h} Eu_Struct.x = 15 Eu_Struct.y = 30 Eu_Struct.w = 25 Eu_Struct.h = 25 for i = 1 to length(Eu_Struct) printf(1,"Size: %d",{Eu_Struct[i]}) end for
At least that is how I think it would be like. Might be a little different in actual implentation. Thoughts?
P.S. Euphoria is still one of my favorite programming languages.
2. Re: AutoIt vs Euphoria
- Posted by begin May 11, 2018
- 2371 views
i know one can deal with structures in phix pretty easly, but is it possible to have a struct in phix that can contain/declare objects or sequences?
3. Re: AutoIt vs Euphoria
- Posted by Icy_Viking May 11, 2018
- 2303 views
i know one can deal with structures in phix pretty easly, but is it possible to have a struct in phix that can contain/declare objects or sequences?
I haven't used Phix a lot. I'm not sure if it is possible to contain/declare objects or sequences with a struct. I was demonstrating that perhaps in the next version of Euphoria or Phix, that a easier way to declare and use structs could be possible.
4. Re: AutoIt vs Euphoria
- Posted by petelomax May 11, 2018
- 2318 views
i know one can deal with structures in phix pretty easly, but is it possible to have a struct in phix that can contain/declare objects or sequences?
Not entirely sure I understand the question.
If you mean nested C structs, then obviously yes, as long as you (can) declare them in the right order. See Example 2.
If you mean embedded Eu objects/sequences inside a C struct, then, obviously, no.
If you mean nested Eu objects/sequences, then, obviously, yes.
5. Re: AutoIt vs Euphoria
- Posted by petelomax May 11, 2018
- 2301 views
I was demonstrating that perhaps in the next version of Euphoria or Phix, that a easier way to declare and use structs could be possible.
To my mind your proposal was quite horrific - a really feeble watered-down version of what you would actually need.
If you want to do C structs, do C structs, with unions, 170+ builtin types (really - eg see cffi.e), nested substructures, etc.
Otherwise you are just setting yourself up for an unending deluge of problems that sort of naive attempt will inevitably bring.
If your argument is along the lines of that instead of
set_struct_field(idRect,pRect,"x",10)
that
Rect.x=10
will somehow solve world hunger, I'm not impressed.
Sorry to be so blunt. <mutter>not really</mutter>
Pete
6. Re: AutoIt vs Euphoria
- Posted by begin May 12, 2018
- 2326 views
i know one can deal with structures in phix pretty easly, but is it possible to have a struct in phix that can contain/declare objects or sequences?
Not entirely sure I understand the question.
If you mean nested C structs, then obviously yes, as long as you (can) declare them in the right order. See Example 2.
If you mean embedded Eu objects/sequences inside a C struct, then, obviously, no.
If you mean nested Eu objects/sequences, then, obviously, yes.
well, i mean define a struct with Eu objects/sequences in it. that would be nice to have as a feature.
7. Re: AutoIt vs Euphoria
- Posted by petelomax May 12, 2018
- 2287 views
If you mean embedded Eu objects/sequences inside a C struct, then, obviously, no.
well, i mean define a struct with Eu objects/sequences in it. that would be nice to have as a feature.
how/why would you use them?
I suppose you could serialize()/deserialize() any Eu objects and store the resulting byte-string pointer in a C struct, if that helps any...
8. Re: AutoIt vs Euphoria
- Posted by begin May 12, 2018
- 2271 views
the following is a dumb example
typedef struct _ListCapsule { object andlist; object orlist; object rules; object certainties; } ,one could encapsulate data, but may i think to much in other languages.
9. Re: AutoIt vs Euphoria
- Posted by petelomax May 12, 2018
- 2261 views
the following is a dumb example
typedef struct _ListCapsule { object andlist; object orlist; object rules; object certainties; } ,one could encapsulate data, but may i think to much in other languages.
What about:
enum ANDLIST, ORLIST, RULES, CERTAINTIES, LISTCAPSULELEN = $ type ListCapsule(object o) return sequence(o) and length(o)=LISTCAPSULELEN -- if you have also defined types for the elements: -- and andlist(o[ANDLIST]) -- and orlist(o[ORLIST]) -- and rules(o[RULES]) -- and certainties(o[CERTAINTIES]) end type
10. Re: AutoIt vs Euphoria
- Posted by Icy_Viking May 12, 2018
- 2249 views
I was saying that AutoIt has a nice way of dealing with C structs. Making it eaiser to wrap C libraries. I was thinking maybe something similar for Euphoria could be done at some point. Maybe the example I gave wasn't the best, but hey I'm trying.
11. Re: AutoIt vs Euphoria
- Posted by begin May 13, 2018
- 2249 views
What about:
enum ANDLIST, ORLIST, RULES, CERTAINTIES, LISTCAPSULELEN = $ type ListCapsule(object o) return sequence(o) and length(o)=LISTCAPSULELEN -- if you have also defined types for the elements: -- and andlist(o[ANDLIST]) -- and orlist(o[ORLIST]) -- and rules(o[RULES]) -- and certainties(o[CERTAINTIES]) end type
[/quote]
thanks for the suggestion. i guess, i need to reread the docs again.
12. Re: AutoIt vs Euphoria
- Posted by SDPringle May 13, 2018
- 2236 views
I believe this can be done in Euphoria. Maybe there is something in the archive.