Allow named Enumerations as valid integer data type.

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Allow named Enumerations as valid integer data type.

Post by skywalk »

I come across this when interfacing with c libraries.

Code: Select all

Enumeration my_enum
  #my_enum1 = $0
  #my_enum2 = $1
EndEnumeration
Structure My_struc
  x.d
  y.i         ;<-- Instead of using .i, allow Enum as valid integer data type.
  ;y.My_enum  ;<-- Since Enum's are integer anyway.
              ;<-- Instead of "Error - Structure not found."
EndStructure
Structure My_strucu
  x.d
  StructureUnion
    y_my_enum1.i  
    y_my_enum2.i  ;<-- with y_my_enum1 & 2, trigger an autocomplete fill with '='
  EndStructureUnion
EndStructure
Define.My_struc mys
Define.My_strucu mysu
Debug SizeOf(My_struc)
Debug SizeOf(My_strucu)
mysu\y_my_enum1 = #my_enum1 ;<-- Instead of creating this mnemonic to fill auotcomplete #My_enum1 & #My_enum2.
mys\y           = #my_enum1
;...............^ Trigger autocomplete to only show #my_enum1 & #my_enum2 on press of '=' sign.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
idle
Always Here
Always Here
Posts: 5844
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Allow named Enumerations as valid integer data type.

Post by idle »

+1
Adding a typedef system would greatly ease the porting and handle enumerations as well
Windows 11, Manjaro, Raspberry Pi OS
Image
Post Reply