updated iup.nim; made tests green

This commit is contained in:
Araq 2014-08-31 22:55:51 +02:00
commit 41c7cde61f
9 changed files with 1055 additions and 1058 deletions

View file

@ -1036,8 +1036,8 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
internalError(c.debug[pc], "too implement") internalError(c.debug[pc], "too implement")
of opcNarrowS: of opcNarrowS:
decodeB(rkInt) decodeB(rkInt)
let min = -(1 shl (rb-1)) let min = -(1.BiggestInt shl (rb-1))
let max = (1 shl (rb-1))-1 let max = (1.BiggestInt shl (rb-1))-1
if regs[ra].intVal < min or regs[ra].intVal > max: if regs[ra].intVal < min or regs[ra].intVal > max:
stackTrace(c, tos, pc, errGenerated, stackTrace(c, tos, pc, errGenerated,
msgKindToString(errUnhandledExceptionX) % "value out of range") msgKindToString(errUnhandledExceptionX) % "value out of range")

View file

@ -1,37 +1,37 @@
# Example IUP program # Example IUP program
# IupTabs: Creates a IupTabs control. # iupTabs: Creates a iupTabs control.
import iup import iup
discard iup.Open(nil, nil) discard iup.open(nil, nil)
var vbox1 = Iup.Vbox(Iup.Label("Inside Tab A"), Iup.Button("Button A", ""), nil) var vbox1 = iup.vbox(iup.label("Inside Tab A"), iup.button("Button A", ""), nil)
var vbox2 = Iup.Vbox(Iup.Label("Inside Tab B"), Iup.Button("Button B", ""), nil) var vbox2 = iup.vbox(iup.label("Inside Tab B"), iup.button("Button B", ""), nil)
Iup.SetAttribute(vbox1, "TABTITLE", "Tab A") iup.setAttribute(vbox1, "TABTITLE", "Tab A")
Iup.SetAttribute(vbox2, "TABTITLE", "Tab B") iup.setAttribute(vbox2, "TABTITLE", "Tab B")
var tabs1 = Iup.Tabs(vbox1, vbox2, nil) var tabs1 = iup.tabs(vbox1, vbox2, nil)
vbox1 = Iup.Vbox(Iup.Label("Inside Tab C"), Iup.Button("Button C", ""), nil) vbox1 = iup.vbox(iup.label("Inside Tab C"), iup.button("Button C", ""), nil)
vbox2 = Iup.Vbox(Iup.Label("Inside Tab D"), Iup.Button("Button D", ""), nil) vbox2 = iup.vbox(iup.label("Inside Tab D"), iup.button("Button D", ""), nil)
Iup.SetAttribute(vbox1, "TABTITLE", "Tab C") iup.setAttribute(vbox1, "TABTITLE", "Tab C")
Iup.SetAttribute(vbox2, "TABTITLE", "Tab D") iup.setAttribute(vbox2, "TABTITLE", "Tab D")
var tabs2 = Iup.Tabs(vbox1, vbox2, nil) var tabs2 = iup.tabs(vbox1, vbox2, nil)
Iup.SetAttribute(tabs2, "TABTYPE", "LEFT") iup.setAttribute(tabs2, "TABTYPE", "LEFT")
var box = Iup.Hbox(tabs1, tabs2, nil) var box = iup.hbox(tabs1, tabs2, nil)
Iup.SetAttribute(box, "MARGIN", "10x10") iup.setAttribute(box, "MARGIN", "10x10")
Iup.SetAttribute(box, "GAP", "10") iup.setAttribute(box, "GAP", "10")
var dlg = Iup.Dialog(box) var dlg = iup.dialog(box)
Iup.SetAttribute(dlg, "TITLE", "IupTabs") iup.setAttribute(dlg, "TITLE", "iupTabs")
Iup.SetAttribute(dlg, "SIZE", "200x100") iup.setAttribute(dlg, "SIZE", "200x100")
discard ShowXY(dlg, IUP_CENTER, IUP_CENTER) discard showXY(dlg, IUP_CENTER, IUP_CENTER)
discard MainLoop() discard mainLoop()
Close() close()

View file

@ -9,21 +9,21 @@ var
event: TEvent event: TEvent
bgColor = colChocolate.int32 bgColor = colChocolate.int32
if init(INIT_VIDEO) != 0: if Init(INIT_VIDEO) != 0:
quit "SDL failed to initialize!" quit "SDL failed to initialize!"
screen = SetVideoMode(640, 480, 16, SWSURFACE or ANYFORMAT) screen = SetVideoMode(640, 480, 16, SWSURFACE or ANYFORMAT)
if screen.isNil: if screen.isNil:
quit($sdl.getError()) quit($sdl.GetError())
greeting = IMG_load("tux.png") greeting = IMG_load("tux.png")
if greeting.isNil: if greeting.isNil:
echo "Failed to load tux.png" echo "Failed to load tux.png"
else: else:
## convert the image to alpha and free the old one ## convert the image to alpha and free the old one
var s = greeting.displayFormatAlpha() var s = greeting.DisplayFormatAlpha()
swap(greeting, s) swap(greeting, s)
s.freeSurface() s.FreeSurface()
r.x = 0 r.x = 0
r.y = 0 r.y = 0
@ -31,7 +31,7 @@ r.y = 0
block game_loop: block game_loop:
while true: while true:
while pollEvent(addr event) > 0: while PollEvent(addr event) > 0:
case event.kind case event.kind
of QUITEV: of QUITEV:
break game_loop break game_loop
@ -41,12 +41,12 @@ block game_loop:
else: else:
discard discard
discard fillRect(screen, nil, bgColor) discard FillRect(screen, nil, bgColor)
discard blitSurface(greeting, nil, screen, addr r) discard BlitSurface(greeting, nil, screen, addr r)
discard flip(screen) discard Flip(screen)
greeting.freeSurface() greeting.FreeSurface()
screen.freeSurface() screen.FreeSurface()
sdl.Quit() sdl.Quit()
## fowl wuz here 10/2012 ## fowl wuz here 10/2012

View file

@ -8,14 +8,14 @@ import os, streams, parsecsv, strutils, math
if paramCount() < 1: if paramCount() < 1:
quit("Usage: statcsv filename[.csv]") quit("Usage: statcsv filename[.csv]")
var filename = addFileExt(ParamStr(1), "csv") var filename = addFileExt(paramStr(1), "csv")
var s = newFileStream(filename, fmRead) var s = newFileStream(filename, fmRead)
if s == nil: quit("cannot open the file " & filename) if s == nil: quit("cannot open the file " & filename)
var var
x: TCsvParser x: CsvParser
header: seq[string] header: seq[string]
res: seq[TRunningStat] res: seq[RunningStat]
open(x, s, filename, separator=';', skipInitialSpace = true) open(x, s, filename, separator=';', skipInitialSpace = true)
while readRow(x): while readRow(x):
if processedRows(x) == 1: if processedRows(x) == 1:

File diff suppressed because it is too large Load diff

View file

@ -13,7 +13,7 @@
{.deadCodeElim: on.} {.deadCodeElim: on.}
import # Data structure templates import # Data structure templates
Windows windows
const const
NCBNAMSZ* = 16 # absolute length of a net name NCBNAMSZ* = 16 # absolute length of a net name
@ -24,20 +24,20 @@ type # Network Control Block
TNCBPostProc* = proc (P: PNCB) {.stdcall.} TNCBPostProc* = proc (P: PNCB) {.stdcall.}
TNCB* {.final.} = object # Structure returned to the NCB command NCBASTAT is ADAPTER_STATUS followed TNCB* {.final.} = object # Structure returned to the NCB command NCBASTAT is ADAPTER_STATUS followed
# by an array of NAME_BUFFER structures. # by an array of NAME_BUFFER structures.
ncb_command*: Char # command code ncb_command*: char # command code
ncb_retcode*: Char # return code ncb_retcode*: char # return code
ncb_lsn*: Char # local session number ncb_lsn*: char # local session number
ncb_num*: Char # number of our network name ncb_num*: char # number of our network name
ncb_buffer*: cstring # address of message buffer ncb_buffer*: cstring # address of message buffer
ncb_length*: int16 # size of message buffer ncb_length*: int16 # size of message buffer
ncb_callname*: array[0..NCBNAMSZ - 1, char] # blank-padded name of remote ncb_callname*: array[0..NCBNAMSZ - 1, char] # blank-padded name of remote
ncb_name*: array[0..NCBNAMSZ - 1, char] # our blank-padded netname ncb_name*: array[0..NCBNAMSZ - 1, char] # our blank-padded netname
ncb_rto*: Char # rcv timeout/retry count ncb_rto*: char # rcv timeout/retry count
ncb_sto*: Char # send timeout/sys timeout ncb_sto*: char # send timeout/sys timeout
ncb_post*: TNCBPostProc # POST routine address ncb_post*: TNCBPostProc # POST routine address
ncb_lana_num*: Char # lana (adapter) number ncb_lana_num*: char # lana (adapter) number
ncb_cmd_cplt*: Char # 0xff => commmand pending ncb_cmd_cplt*: char # 0xff => commmand pending
ncb_reserve*: array[0..9, Char] # reserved, used by BIOS ncb_reserve*: array[0..9, char] # reserved, used by BIOS
ncb_event*: THandle # HANDLE to Win32 event which ncb_event*: THandle # HANDLE to Win32 event which
# will be set to the signalled # will be set to the signalled
# state when an ASYNCH command # state when an ASYNCH command
@ -45,11 +45,11 @@ type # Network Control Block
PAdapterStatus* = ptr TAdapterStatus PAdapterStatus* = ptr TAdapterStatus
TAdapterStatus* {.final.} = object TAdapterStatus* {.final.} = object
adapter_address*: array[0..5, Char] adapter_address*: array[0..5, char]
rev_major*: Char rev_major*: char
reserved0*: Char reserved0*: char
adapter_type*: Char adapter_type*: char
rev_minor*: Char rev_minor*: char
duration*: int16 duration*: int16
frmr_recv*: int16 frmr_recv*: int16
frmr_xmit*: int16 frmr_xmit*: int16
@ -75,9 +75,9 @@ type # Network Control Block
PNameBuffer* = ptr TNameBuffer PNameBuffer* = ptr TNameBuffer
TNameBuffer* {.final.} = object TNameBuffer* {.final.} = object
name*: array[0..NCBNAMSZ - 1, Char] name*: array[0..NCBNAMSZ - 1, char]
name_num*: Char name_num*: char
name_flags*: Char name_flags*: char
const # values for name_flags bits. const # values for name_flags bits.
@ -96,19 +96,19 @@ type # Structure returned to the NCB command NCBSSTAT is SESSION_HEADER followed
# status for all names. # status for all names.
PSessionHeader* = ptr TSessionHeader PSessionHeader* = ptr TSessionHeader
TSessionHeader* {.final.} = object TSessionHeader* {.final.} = object
sess_name*: Char sess_name*: char
num_sess*: Char num_sess*: char
rcv_dg_outstanding*: Char rcv_dg_outstanding*: char
rcv_any_outstanding*: Char rcv_any_outstanding*: char
PSessionBuffer* = ptr TSessionBuffer PSessionBuffer* = ptr TSessionBuffer
TSessionBuffer* {.final.} = object TSessionBuffer* {.final.} = object
lsn*: Char lsn*: char
state*: Char state*: char
local_name*: array[0..NCBNAMSZ - 1, Char] local_name*: array[0..NCBNAMSZ - 1, char]
remote_name*: array[0..NCBNAMSZ - 1, Char] remote_name*: array[0..NCBNAMSZ - 1, char]
rcvs_outstanding*: Char rcvs_outstanding*: char
sends_outstanding*: Char sends_outstanding*: char
const # Values for state const # Values for state
@ -125,24 +125,24 @@ type # Structure returned to the NCB command NCBENUM.
PLanaEnum* = ptr TLanaEnum PLanaEnum* = ptr TLanaEnum
TLanaEnum* {.final.} = object # Structure returned to the NCB command NCBFINDNAME is FIND_NAME_HEADER followed TLanaEnum* {.final.} = object # Structure returned to the NCB command NCBFINDNAME is FIND_NAME_HEADER followed
# by an array of FIND_NAME_BUFFER structures. # by an array of FIND_NAME_BUFFER structures.
len*: Char # Number of valid entries in lana[] len*: char # Number of valid entries in lana[]
lana*: array[0..MAX_LANA, Char] lana*: array[0..MAX_LANA, char]
PFindNameHeader* = ptr TFindNameHeader PFindNameHeader* = ptr TFindNameHeader
TFindNameHeader* {.final.} = object TFindNameHeader* {.final.} = object
node_count*: int16 node_count*: int16
reserved*: Char reserved*: char
unique_group*: Char unique_group*: char
PFindNameBuffer* = ptr TFindNameBuffer PFindNameBuffer* = ptr TFindNameBuffer
TFindNameBuffer* {.final.} = object # Structure provided with NCBACTION. The purpose of NCBACTION is to provide TFindNameBuffer* {.final.} = object # Structure provided with NCBACTION. The purpose of NCBACTION is to provide
# transport specific extensions to netbios. # transport specific extensions to netbios.
len*: Char len*: char
access_control*: Char access_control*: char
frame_control*: Char frame_control*: char
destination_addr*: array[0..5, Char] destination_addr*: array[0..5, char]
source_addr*: array[0..5, Char] source_addr*: array[0..5, char]
routing_info*: array[0..17, Char] routing_info*: array[0..17, char]
PActionHeader* = ptr TActionHeader PActionHeader* = ptr TActionHeader
TActionHeader* {.final.} = object TActionHeader* {.final.} = object
@ -227,6 +227,6 @@ const # NCB Command codes
# main user entry point for NetBIOS 3.0 # main user entry point for NetBIOS 3.0
# Usage: Result = Netbios( pncb ); # Usage: Result = Netbios( pncb );
proc Netbios*(P: PNCB): Char{.stdcall, dynlib: "netapi32.dll", proc Netbios*(P: PNCB): char{.stdcall, dynlib: "netapi32.dll",
importc: "Netbios".} importc: "Netbios".}
# implementation # implementation

View file

@ -28,14 +28,14 @@
# Copyright (c) Microsoft Corporation. All rights reserved. # Copyright (c) Microsoft Corporation. All rights reserved.
import import
Windows windows
type type
HDROP* = THandle HDROP* = THandle
UINT_PTR* = ptr UINT UINT_PTR* = ptr uint32
DWORD_PTR* = ptr DWORD DWORD_PTR* = ptr DWORD
pHICON* = ptr HICON PHICON* = ptr HICON
pBool* = ptr BOOL PBool* = ptr bool
STARTUPINFOW* {.final.} = object # a guess. Omission should get fixed in Windows. STARTUPINFOW* {.final.} = object # a guess. Omission should get fixed in Windows.
cb*: DWORD cb*: DWORD
lpReserved*: LPTSTR lpReserved*: LPTSTR
@ -60,27 +60,27 @@ type
TSTARTUPINFOW* = STARTUPINFOW TSTARTUPINFOW* = STARTUPINFOW
PSTARTUPINFOW* = ptr STARTUPINFOW #unicode PSTARTUPINFOW* = ptr STARTUPINFOW #unicode
proc DragQueryFileA*(arg1: HDROP, arg2: UINT, arg3: LPSTR, arg4: UINT): UINT{. proc DragQueryFileA*(arg1: HDROP, arg2: uint32, arg3: LPSTR, arg4: uint32): uint32{.
stdcall, dynlib: "shell32.dll", importc: "DragQueryFileA".} stdcall, dynlib: "shell32.dll", importc: "DragQueryFileA".}
proc DragQueryFileW*(arg1: HDROP, arg2: UINT, arg3: LPWSTR, arg4: UINT): UINT{. proc DragQueryFileW*(arg1: HDROP, arg2: uint32, arg3: LPWSTR, arg4: uint32): uint32{.
stdcall, dynlib: "shell32.dll", importc: "DragQueryFileW".} stdcall, dynlib: "shell32.dll", importc: "DragQueryFileW".}
proc DragQueryFile*(arg1: HDROP, arg2: UINT, arg3: LPSTR, arg4: UINT): UINT{. proc DragQueryFile*(arg1: HDROP, arg2: uint32, arg3: LPSTR, arg4: uint32): uint32{.
stdcall, dynlib: "shell32.dll", importc: "DragQueryFileA".} stdcall, dynlib: "shell32.dll", importc: "DragQueryFileA".}
proc DragQueryFile*(arg1: HDROP, arg2: UINT, arg3: LPWSTR, arg4: UINT): UINT{. proc DragQueryFile*(arg1: HDROP, arg2: uint32, arg3: LPWSTR, arg4: uint32): uint32{.
stdcall, dynlib: "shell32.dll", importc: "DragQueryFileW".} stdcall, dynlib: "shell32.dll", importc: "DragQueryFileW".}
proc DragQueryPoint*(arg1: HDROP, arg2: LPPOINT): BOOL{.stdcall, proc DragQueryPoint*(arg1: HDROP, arg2: LPPOINT): bool{.stdcall,
dynlib: "shell32.dll", importc: "DragQueryPoint".} dynlib: "shell32.dll", importc: "DragQueryPoint".}
proc DragFinish*(arg1: HDROP){.stdcall, dynlib: "shell32.dll", proc DragFinish*(arg1: HDROP){.stdcall, dynlib: "shell32.dll",
importc: "DragFinish".} importc: "DragFinish".}
proc DragAcceptFiles*(hwnd: HWND, arg2: BOOL){.stdcall, dynlib: "shell32.dll", proc DragAcceptFiles*(hwnd: HWND, arg2: bool){.stdcall, dynlib: "shell32.dll",
importc: "DragAcceptFiles".} importc: "DragAcceptFiles".}
proc ShellExecuteA*(HWND: hwnd, lpOperation: LPCSTR, lpFile: LPCSTR, proc ShellExecuteA*(hwnd: HWND, lpOperation: LPCSTR, lpFile: LPCSTR,
lpParameters: LPCSTR, lpDirectory: LPCSTR, nShowCmd: int32): HInst{. lpParameters: LPCSTR, lpDirectory: LPCSTR, nShowCmd: int32): HInst{.
stdcall, dynlib: "shell32.dll", importc: "ShellExecuteA".} stdcall, dynlib: "shell32.dll", importc: "ShellExecuteA".}
proc ShellExecuteW*(hwnd: HWND, lpOperation: LPCWSTR, lpFile: LPCWSTR, proc ShellExecuteW*(hwnd: HWND, lpOperation: LPCWSTR, lpFile: LPCWSTR,
lpParameters: LPCWSTR, lpDirectory: LPCWSTR, nShowCmd: int32): HInst{. lpParameters: LPCWSTR, lpDirectory: LPCWSTR, nShowCmd: int32): HInst{.
stdcall, dynlib: "shell32.dll", importc: "ShellExecuteW".} stdcall, dynlib: "shell32.dll", importc: "ShellExecuteW".}
proc ShellExecute*(HWND: hwnd, lpOperation: LPCSTR, lpFile: LPCSTR, proc ShellExecute*(hwnd: HWND, lpOperation: LPCSTR, lpFile: LPCSTR,
lpParameters: LPCSTR, lpDirectory: LPCSTR, nShowCmd: int32): HInst{. lpParameters: LPCSTR, lpDirectory: LPCSTR, nShowCmd: int32): HInst{.
stdcall, dynlib: "shell32.dll", importc: "ShellExecuteA".} stdcall, dynlib: "shell32.dll", importc: "ShellExecuteA".}
proc ShellExecute*(hwnd: HWND, lpOperation: LPCWSTR, lpFile: LPCWSTR, proc ShellExecute*(hwnd: HWND, lpOperation: LPCWSTR, lpFile: LPCWSTR,
@ -94,16 +94,16 @@ proc FindExecutable*(lpFile: LPCSTR, lpDirectory: LPCSTR, lpResult: LPSTR): HIns
stdcall, dynlib: "shell32.dll", importc: "FindExecutableA".} stdcall, dynlib: "shell32.dll", importc: "FindExecutableA".}
proc FindExecutable*(lpFile: LPCWSTR, lpDirectory: LPCWSTR, lpResult: LPWSTR): HInst{. proc FindExecutable*(lpFile: LPCWSTR, lpDirectory: LPCWSTR, lpResult: LPWSTR): HInst{.
stdcall, dynlib: "shell32.dll", importc: "FindExecutableW".} stdcall, dynlib: "shell32.dll", importc: "FindExecutableW".}
proc CommandLineToArgvW*(lpCmdLine: LPCWSTR, pNumArgs: ptr int32): pLPWSTR{. proc CommandLineToArgvW*(lpCmdLine: LPCWSTR, pNumArgs: ptr int32): PLPWSTR{.
stdcall, dynlib: "shell32.dll", importc: "CommandLineToArgvW".} stdcall, dynlib: "shell32.dll", importc: "CommandLineToArgvW".}
proc ShellAboutA*(HWND: hWnd, szApp: LPCSTR, szOtherStuff: LPCSTR, HICON: hIcon): int32{. proc ShellAboutA*(hwnd: HWND, szApp: LPCSTR, szOtherStuff: LPCSTR, hIcon: HICON): int32{.
stdcall, dynlib: "shell32.dll", importc: "ShellAboutA".} stdcall, dynlib: "shell32.dll", importc: "ShellAboutA".}
proc ShellAboutW*(HWND: hWnd, szApp: LPCWSTR, szOtherStuff: LPCWSTR, proc ShellAboutW*(hwnd: HWND, szApp: LPCWSTR, szOtherStuff: LPCWSTR,
HICON: hIcon): int32{.stdcall, dynlib: "shell32.dll", hIcon: HICON): int32{.stdcall, dynlib: "shell32.dll",
importc: "ShellAboutW".} importc: "ShellAboutW".}
proc ShellAbout*(HWND: hWnd, szApp: LPCSTR, szOtherStuff: LPCSTR, HICON: hIcon): int32{. proc ShellAbout*(hwnd: HWND, szApp: LPCSTR, szOtherStuff: LPCSTR, hIcon: HICON): int32{.
stdcall, dynlib: "shell32.dll", importc: "ShellAboutA".} stdcall, dynlib: "shell32.dll", importc: "ShellAboutA".}
proc ShellAbout*(HWND: hWnd, szApp: LPCWSTR, szOtherStuff: LPCWSTR, HICON: hIcon): int32{. proc ShellAbout*(hwnd: HWND, szApp: LPCWSTR, szOtherStuff: LPCWSTR, hIcon: HICON): int32{.
stdcall, dynlib: "shell32.dll", importc: "ShellAboutW".} stdcall, dynlib: "shell32.dll", importc: "ShellAboutW".}
proc DuplicateIcon*(inst: HINST, icon: HICON): HIcon{.stdcall, proc DuplicateIcon*(inst: HINST, icon: HICON): HIcon{.stdcall,
dynlib: "shell32.dll", importc: "DuplicateIcon".} dynlib: "shell32.dll", importc: "DuplicateIcon".}
@ -115,29 +115,29 @@ proc ExtractAssociatedIcon*(hInst: HINST, lpIconPath: LPSTR, lpiIcon: LPWORD): H
stdcall, dynlib: "shell32.dll", importc: "ExtractAssociatedIconA".} stdcall, dynlib: "shell32.dll", importc: "ExtractAssociatedIconA".}
proc ExtractAssociatedIcon*(hInst: HINST, lpIconPath: LPWSTR, lpiIcon: LPWORD): HICON{. proc ExtractAssociatedIcon*(hInst: HINST, lpIconPath: LPWSTR, lpiIcon: LPWORD): HICON{.
stdcall, dynlib: "shell32.dll", importc: "ExtractAssociatedIconW".} stdcall, dynlib: "shell32.dll", importc: "ExtractAssociatedIconW".}
proc ExtractIconA*(hInst: HINST, lpszExeFileName: LPCSTR, nIconIndex: UINT): HICON{. proc ExtractIconA*(hInst: HINST, lpszExeFileName: LPCSTR, nIconIndex: uint32): HICON{.
stdcall, dynlib: "shell32.dll", importc: "ExtractIconA".} stdcall, dynlib: "shell32.dll", importc: "ExtractIconA".}
proc ExtractIconW*(hInst: HINST, lpszExeFileName: LPCWSTR, nIconIndex: UINT): HICON{. proc ExtractIconW*(hInst: HINST, lpszExeFileName: LPCWSTR, nIconIndex: uint32): HICON{.
stdcall, dynlib: "shell32.dll", importc: "ExtractIconW".} stdcall, dynlib: "shell32.dll", importc: "ExtractIconW".}
proc ExtractIcon*(hInst: HINST, lpszExeFileName: LPCSTR, nIconIndex: UINT): HICON{. proc ExtractIcon*(hInst: HINST, lpszExeFileName: LPCSTR, nIconIndex: uint32): HICON{.
stdcall, dynlib: "shell32.dll", importc: "ExtractIconA".} stdcall, dynlib: "shell32.dll", importc: "ExtractIconA".}
proc ExtractIcon*(hInst: HINST, lpszExeFileName: LPCWSTR, nIconIndex: UINT): HICON{. proc ExtractIcon*(hInst: HINST, lpszExeFileName: LPCWSTR, nIconIndex: uint32): HICON{.
stdcall, dynlib: "shell32.dll", importc: "ExtractIconW".} stdcall, dynlib: "shell32.dll", importc: "ExtractIconW".}
# if(WINVER >= 0x0400) # if(WINVER >= 0x0400)
type # init with sizeof(DRAGINFO) type # init with sizeof(DRAGINFO)
DRAGINFOA* {.final.} = object DRAGINFOA* {.final.} = object
uSize*: UINT uSize*: uint32
pt*: POINT pt*: POINT
fNC*: BOOL fNC*: bool
lpFileList*: LPSTR lpFileList*: LPSTR
grfKeyState*: DWORD grfKeyState*: DWORD
TDRAGINFOA* = DRAGINFOA TDRAGINFOA* = DRAGINFOA
LPDRAGINFOA* = ptr DRAGINFOA # init with sizeof(DRAGINFO) LPDRAGINFOA* = ptr DRAGINFOA # init with sizeof(DRAGINFO)
DRAGINFOW* {.final.} = object DRAGINFOW* {.final.} = object
uSize*: UINT uSize*: uint32
pt*: POINT pt*: POINT
fNC*: BOOL fNC*: bool
lpFileList*: LPWSTR lpFileList*: LPWSTR
grfKeyState*: DWORD grfKeyState*: DWORD
@ -184,8 +184,8 @@ type
AppBarData* {.final.} = object AppBarData* {.final.} = object
cbSize*: DWORD cbSize*: DWORD
hWnd*: HWND hWnd*: HWND
uCallbackMessage*: UINT uCallbackMessage*: uint32
uEdge*: UINT uEdge*: uint32
rc*: RECT rc*: RECT
lParam*: LPARAM # message specific lParam*: LPARAM # message specific
@ -197,41 +197,41 @@ proc SHAppBarMessage*(dwMessage: DWORD, pData: APPBARDATA): UINT_PTR{.stdcall,
# #
# EndAppBar # EndAppBar
# #
proc DoEnvironmentSubstA*(szString: LPSTR, cchString: UINT): DWORD{.stdcall, proc DoEnvironmentSubstA*(szString: LPSTR, cchString: uint32): DWORD{.stdcall,
dynlib: "shell32.dll", importc: "DoEnvironmentSubstA".} dynlib: "shell32.dll", importc: "DoEnvironmentSubstA".}
proc DoEnvironmentSubstW*(szString: LPWSTR, cchString: UINT): DWORD{.stdcall, proc DoEnvironmentSubstW*(szString: LPWSTR, cchString: uint32): DWORD{.stdcall,
dynlib: "shell32.dll", importc: "DoEnvironmentSubstW".} dynlib: "shell32.dll", importc: "DoEnvironmentSubstW".}
proc DoEnvironmentSubst*(szString: LPSTR, cchString: UINT): DWORD{.stdcall, proc DoEnvironmentSubst*(szString: LPSTR, cchString: uint32): DWORD{.stdcall,
dynlib: "shell32.dll", importc: "DoEnvironmentSubstA".} dynlib: "shell32.dll", importc: "DoEnvironmentSubstA".}
proc DoEnvironmentSubst*(szString: LPWSTR, cchString: UINT): DWORD{.stdcall, proc DoEnvironmentSubst*(szString: LPWSTR, cchString: uint32): DWORD{.stdcall,
dynlib: "shell32.dll", importc: "DoEnvironmentSubstW".} dynlib: "shell32.dll", importc: "DoEnvironmentSubstW".}
#Macro #Macro
proc EIRESID*(x: int32): int32 proc EIRESID*(x: int32): int32
proc ExtractIconExA*(lpszFile: LPCSTR, nIconIndex: int32, phiconLarge: pHICON, proc ExtractIconExA*(lpszFile: LPCSTR, nIconIndex: int32, phiconLarge: PHICON,
phiconSmall: pHIcon, nIcons: UINT): UINT{.stdcall, phiconSmall: PHICON, nIcons: uint32): uint32{.stdcall,
dynlib: "shell32.dll", importc: "ExtractIconExA".} dynlib: "shell32.dll", importc: "ExtractIconExA".}
proc ExtractIconExW*(lpszFile: LPCWSTR, nIconIndex: int32, phiconLarge: pHICON, proc ExtractIconExW*(lpszFile: LPCWSTR, nIconIndex: int32, phiconLarge: PHICON,
phiconSmall: pHIcon, nIcons: UINT): UINT{.stdcall, phiconSmall: PHICON, nIcons: uint32): uint32{.stdcall,
dynlib: "shell32.dll", importc: "ExtractIconExW".} dynlib: "shell32.dll", importc: "ExtractIconExW".}
proc ExtractIconExA*(lpszFile: LPCSTR, nIconIndex: int32, proc ExtractIconExA*(lpszFile: LPCSTR, nIconIndex: int32,
phiconLarge: var HICON, phiconSmall: var HIcon, phiconLarge: var HICON, phiconSmall: var HIcon,
nIcons: UINT): UINT{.stdcall, dynlib: "shell32.dll", nIcons: uint32): uint32{.stdcall, dynlib: "shell32.dll",
importc: "ExtractIconExA".} importc: "ExtractIconExA".}
proc ExtractIconExW*(lpszFile: LPCWSTR, nIconIndex: int32, proc ExtractIconExW*(lpszFile: LPCWSTR, nIconIndex: int32,
phiconLarge: var HICON, phiconSmall: var HIcon, phiconLarge: var HICON, phiconSmall: var HIcon,
nIcons: UINT): UINT{.stdcall, dynlib: "shell32.dll", nIcons: uint32): uint32{.stdcall, dynlib: "shell32.dll",
importc: "ExtractIconExW".} importc: "ExtractIconExW".}
proc ExtractIconEx*(lpszFile: LPCSTR, nIconIndex: int32, phiconLarge: pHICON, proc ExtractIconEx*(lpszFile: LPCSTR, nIconIndex: int32, phiconLarge: PHICON,
phiconSmall: pHIcon, nIcons: UINT): UINT{.stdcall, phiconSmall: PHICON, nIcons: uint32): uint32{.stdcall,
dynlib: "shell32.dll", importc: "ExtractIconExA".} dynlib: "shell32.dll", importc: "ExtractIconExA".}
proc ExtractIconEx*(lpszFile: LPCWSTR, nIconIndex: int32, phiconLarge: pHICON, proc ExtractIconEx*(lpszFile: LPCWSTR, nIconIndex: int32, phiconLarge: PHICON,
phiconSmall: pHIcon, nIcons: UINT): UINT{.stdcall, phiconSmall: PHICON, nIcons: uint32): uint32{.stdcall,
dynlib: "shell32.dll", importc: "ExtractIconExW".} dynlib: "shell32.dll", importc: "ExtractIconExW".}
proc ExtractIconEx*(lpszFile: LPCSTR, nIconIndex: int32, phiconLarge: var HICON, proc ExtractIconEx*(lpszFile: LPCSTR, nIconIndex: int32, phiconLarge: var HICON,
phiconSmall: var HIcon, nIcons: UINT): UINT{.stdcall, phiconSmall: var HIcon, nIcons: uint32): uint32{.stdcall,
dynlib: "shell32.dll", importc: "ExtractIconExA".} dynlib: "shell32.dll", importc: "ExtractIconExA".}
proc ExtractIconEx*(lpszFile: LPCWSTR, nIconIndex: int32, proc ExtractIconEx*(lpszFile: LPCWSTR, nIconIndex: int32,
phiconLarge: var HICON, phiconSmall: var HIcon, nIcons: UINT): UINT{. phiconLarge: var HICON, phiconSmall: var HIcon, nIcons: uint32): uint32{.
stdcall, dynlib: "shell32.dll", importc: "ExtractIconExW".} stdcall, dynlib: "shell32.dll", importc: "ExtractIconExW".}
# #
# Shell File Operations # Shell File Operations
@ -291,11 +291,11 @@ type
type type
SHFILEOPSTRUCTA* {.final.} = object SHFILEOPSTRUCTA* {.final.} = object
hwnd*: HWND hwnd*: HWND
wFunc*: UINT wFunc*: uint32
pFrom*: LPCSTR pFrom*: LPCSTR
pTo*: LPCSTR pTo*: LPCSTR
fFlags*: FILEOP_FLAGS fFlags*: FILEOP_FLAGS
fAnyOperationsAborted*: BOOL fAnyOperationsAborted*: bool
hNameMappings*: LPVOID hNameMappings*: LPVOID
lpszProgressTitle*: LPCSTR # only used if FOF_SIMPLEPROGRESS lpszProgressTitle*: LPCSTR # only used if FOF_SIMPLEPROGRESS
@ -303,11 +303,11 @@ type
LPSHFILEOPSTRUCTA* = ptr SHFILEOPSTRUCTA LPSHFILEOPSTRUCTA* = ptr SHFILEOPSTRUCTA
SHFILEOPSTRUCTW* {.final.} = object SHFILEOPSTRUCTW* {.final.} = object
hwnd*: HWND hwnd*: HWND
wFunc*: UINT wFunc*: uint32
pFrom*: LPCWSTR pFrom*: LPCWSTR
pTo*: LPCWSTR pTo*: LPCWSTR
fFlags*: FILEOP_FLAGS fFlags*: FILEOP_FLAGS
fAnyOperationsAborted*: BOOL fAnyOperationsAborted*: bool
hNameMappings*: LPVOID hNameMappings*: LPVOID
lpszProgressTitle*: LPCWSTR lpszProgressTitle*: LPCWSTR
@ -430,10 +430,10 @@ type
cbSize*: DWORD cbSize*: DWORD
fMask*: ULONG fMask*: ULONG
hwnd*: HWND hwnd*: HWND
lpVerb*: lpcwstr lpVerb*: LPCWSTR
lpFile*: lpcwstr lpFile*: LPCWSTR
lpParameters*: lpcwstr lpParameters*: LPCWSTR
lpDirectory*: lpcwstr lpDirectory*: LPCWSTR
nShow*: int32 nShow*: int32
hInstApp*: HINST hInstApp*: HINST
lpIDList*: LPVOID lpIDList*: LPVOID
@ -456,24 +456,24 @@ else:
SHELLEXECUTEINFO* = SHELLEXECUTEINFOA SHELLEXECUTEINFO* = SHELLEXECUTEINFOA
TSHELLEXECUTEINFO* = SHELLEXECUTEINFOA TSHELLEXECUTEINFO* = SHELLEXECUTEINFOA
LPSHELLEXECUTEINFO* = LPSHELLEXECUTEINFOA LPSHELLEXECUTEINFO* = LPSHELLEXECUTEINFOA
proc ShellExecuteExA*(lpExecInfo: LPSHELLEXECUTEINFOA): Bool{.stdcall, proc ShellExecuteExA*(lpExecInfo: LPSHELLEXECUTEINFOA): bool{.stdcall,
dynlib: "shell32.dll", importc: "ShellExecuteExA".} dynlib: "shell32.dll", importc: "ShellExecuteExA".}
proc ShellExecuteExW*(lpExecInfo: LPSHELLEXECUTEINFOW): Bool{.stdcall, proc ShellExecuteExW*(lpExecInfo: LPSHELLEXECUTEINFOW): bool{.stdcall,
dynlib: "shell32.dll", importc: "ShellExecuteExW".} dynlib: "shell32.dll", importc: "ShellExecuteExW".}
proc ShellExecuteEx*(lpExecInfo: LPSHELLEXECUTEINFOA): Bool{.stdcall, proc ShellExecuteEx*(lpExecInfo: LPSHELLEXECUTEINFOA): bool{.stdcall,
dynlib: "shell32.dll", importc: "ShellExecuteExA".} dynlib: "shell32.dll", importc: "ShellExecuteExA".}
proc ShellExecuteEx*(lpExecInfo: LPSHELLEXECUTEINFOW): Bool{.stdcall, proc ShellExecuteEx*(lpExecInfo: LPSHELLEXECUTEINFOW): bool{.stdcall,
dynlib: "shell32.dll", importc: "ShellExecuteExW".} dynlib: "shell32.dll", importc: "ShellExecuteExW".}
proc WinExecErrorA*(HWND: hwnd, error: int32, lpstrFileName: LPCSTR, proc WinExecErrorA*(hwnd: HWND, error: int32, lpstrFileName: LPCSTR,
lpstrTitle: LPCSTR){.stdcall, dynlib: "shell32.dll", lpstrTitle: LPCSTR){.stdcall, dynlib: "shell32.dll",
importc: "WinExecErrorA".} importc: "WinExecErrorA".}
proc WinExecErrorW*(HWND: hwnd, error: int32, lpstrFileName: LPCWSTR, proc WinExecErrorW*(hwnd: HWND, error: int32, lpstrFileName: LPCWSTR,
lpstrTitle: LPCWSTR){.stdcall, dynlib: "shell32.dll", lpstrTitle: LPCWSTR){.stdcall, dynlib: "shell32.dll",
importc: "WinExecErrorW".} importc: "WinExecErrorW".}
proc WinExecError*(HWND: hwnd, error: int32, lpstrFileName: LPCSTR, proc WinExecError*(hwnd: HWND, error: int32, lpstrFileName: LPCSTR,
lpstrTitle: LPCSTR){.stdcall, dynlib: "shell32.dll", lpstrTitle: LPCSTR){.stdcall, dynlib: "shell32.dll",
importc: "WinExecErrorA".} importc: "WinExecErrorA".}
proc WinExecError*(HWND: hwnd, error: int32, lpstrFileName: LPCWSTR, proc WinExecError*(hwnd: HWND, error: int32, lpstrFileName: LPCWSTR,
lpstrTitle: LPCWSTR){.stdcall, dynlib: "shell32.dll", lpstrTitle: LPCWSTR){.stdcall, dynlib: "shell32.dll",
importc: "WinExecErrorW".} importc: "WinExecErrorW".}
type type
@ -487,7 +487,7 @@ type
hUserToken*: HANDLE hUserToken*: HANDLE
lpProcessAttributes*: LPSECURITY_ATTRIBUTES lpProcessAttributes*: LPSECURITY_ATTRIBUTES
lpThreadAttributes*: LPSECURITY_ATTRIBUTES lpThreadAttributes*: LPSECURITY_ATTRIBUTES
bInheritHandles*: BOOL bInheritHandles*: bool
dwCreationFlags*: DWORD dwCreationFlags*: DWORD
lpStartupInfo*: LPSTARTUPINFOW lpStartupInfo*: LPSTARTUPINFOW
lpProcessInformation*: LPPROCESS_INFORMATION lpProcessInformation*: LPPROCESS_INFORMATION
@ -495,7 +495,7 @@ type
TSHCREATEPROCESSINFOW* = SHCREATEPROCESSINFOW TSHCREATEPROCESSINFOW* = SHCREATEPROCESSINFOW
PSHCREATEPROCESSINFOW* = ptr SHCREATEPROCESSINFOW PSHCREATEPROCESSINFOW* = ptr SHCREATEPROCESSINFOW
proc SHCreateProcessAsUserW*(pscpi: PSHCREATEPROCESSINFOW): Bool{.stdcall, proc SHCreateProcessAsUserW*(pscpi: PSHCREATEPROCESSINFOW): bool{.stdcall,
dynlib: "shell32.dll", importc: "SHCreateProcessAsUserW".} dynlib: "shell32.dll", importc: "SHCreateProcessAsUserW".}
# #
# End ShellExecuteEx and family } # End ShellExecuteEx and family }
@ -544,16 +544,16 @@ type
NOTIFYICONDATAA* {.final.} = object NOTIFYICONDATAA* {.final.} = object
cbSize*: DWORD cbSize*: DWORD
hWnd*: HWND hWnd*: HWND
uID*: UINT uID*: uint32
uFlags*: UINT uFlags*: uint32
uCallbackMessage*: UINT uCallbackMessage*: uint32
hIcon*: HICON hIcon*: HICON
szTip*: array[0..127, CHAR] szTip*: array[0..127, char]
dwState*: DWORD dwState*: DWORD
dwStateMask*: DWORD dwStateMask*: DWORD
szInfo*: array[0..255, CHAR] szInfo*: array[0..255, char]
uTimeout*: UINT # also: uVersion uTimeout*: uint32 # also: uVersion
szInfoTitle*: array[0..63, CHAR] szInfoTitle*: array[0..63, char]
dwInfoFlags*: DWORD dwInfoFlags*: DWORD
guidItem*: TGUID guidItem*: TGUID
@ -562,16 +562,16 @@ type
NOTIFYICONDATAW* {.final.} = object NOTIFYICONDATAW* {.final.} = object
cbSize*: DWORD cbSize*: DWORD
hWnd*: HWND hWnd*: HWND
uID*: UINT uID*: uint32
uFlags*: UINT uFlags*: uint32
uCallbackMessage*: UINT uCallbackMessage*: uint32
hIcon*: HICON hIcon*: HICON
szTip*: array[0..127, WCHAR] szTip*: array[0..127, Wchar]
dwState*: DWORD dwState*: DWORD
dwStateMask*: DWORD dwStateMask*: DWORD
szInfo*: array[0..255, WCHAR] szInfo*: array[0..255, Wchar]
uTimeout*: UINT # also uVersion : UINT uTimeout*: uint32 # also uVersion : UINT
szInfoTitle*: array[0..63, CHAR] szInfoTitle*: array[0..63, char]
dwInfoFlags*: DWORD dwInfoFlags*: DWORD
guidItem*: TGUID guidItem*: TGUID
@ -619,13 +619,13 @@ const
NIIF_ICON_MASK* = 0x0000000F NIIF_ICON_MASK* = 0x0000000F
NIIF_NOSOUND* = 0x00000010 NIIF_NOSOUND* = 0x00000010
proc Shell_NotifyIconA*(dwMessage: Dword, lpData: PNOTIFYICONDATAA): Bool{. proc Shell_NotifyIconA*(dwMessage: Dword, lpData: PNOTIFYICONDATAA): bool{.
stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconA".} stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconA".}
proc Shell_NotifyIconW*(dwMessage: Dword, lpData: PNOTIFYICONDATAW): Bool{. proc Shell_NotifyIconW*(dwMessage: Dword, lpData: PNOTIFYICONDATAW): bool{.
stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconW".} stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconW".}
proc Shell_NotifyIcon*(dwMessage: Dword, lpData: PNOTIFYICONDATAA): Bool{. proc Shell_NotifyIcon*(dwMessage: Dword, lpData: PNOTIFYICONDATAA): bool{.
stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconA".} stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconA".}
proc Shell_NotifyIcon*(dwMessage: Dword, lpData: PNOTIFYICONDATAW): Bool{. proc Shell_NotifyIcon*(dwMessage: Dword, lpData: PNOTIFYICONDATAW): bool{.
stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconW".} stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconW".}
# #
# The SHGetFileInfo API provides an easy way to get attributes # The SHGetFileInfo API provides an easy way to get attributes
@ -652,20 +652,20 @@ type
hIcon*: HICON # out: icon hIcon*: HICON # out: icon
iIcon*: int32 # out: icon index iIcon*: int32 # out: icon index
dwAttributes*: DWORD # out: SFGAO_ flags dwAttributes*: DWORD # out: SFGAO_ flags
szDisplayName*: array[0..(MAX_PATH) - 1, CHAR] # out: display name (or path) szDisplayName*: array[0..(MAX_PATH) - 1, char] # out: display name (or path)
szTypeName*: array[0..79, CHAR] # out: type name szTypeName*: array[0..79, char] # out: type name
TSHFILEINFOA* = SHFILEINFOA TSHFILEINFOA* = SHFILEINFOA
pSHFILEINFOA* = ptr SHFILEINFOA PSHFILEINFOA* = ptr SHFILEINFOA
SHFILEINFOW* {.final.} = object SHFILEINFOW* {.final.} = object
hIcon*: HICON # out: icon hIcon*: HICON # out: icon
iIcon*: int32 # out: icon index iIcon*: int32 # out: icon index
dwAttributes*: DWORD # out: SFGAO_ flags dwAttributes*: DWORD # out: SFGAO_ flags
szDisplayName*: array[0..(MAX_PATH) - 1, WCHAR] # out: display name (or path) szDisplayName*: array[0..(MAX_PATH) - 1, Wchar] # out: display name (or path)
szTypeName*: array[0..79, WCHAR] # out: type name szTypeName*: array[0..79, Wchar] # out: type name
TSHFILEINFOW* = SHFILEINFOW TSHFILEINFOW* = SHFILEINFOW
pSHFILEINFOW* = ptr SHFILEINFOW PSHFILEINFOW* = ptr SHFILEINFOW
when defined(UNICODE): when defined(UNICODE):
type type
@ -701,67 +701,67 @@ const
# in the upper 8 bits of the iIcon # in the upper 8 bits of the iIcon
proc SHGetFileInfoA*(pszPath: LPCSTR, dwFileAttributes: DWORD, proc SHGetFileInfoA*(pszPath: LPCSTR, dwFileAttributes: DWORD,
psfi: pSHFILEINFOA, cbFileInfo, UFlags: UINT): DWORD{. psfi: PSHFILEINFOA, cbFileInfo, UFlags: uint32): DWORD{.
stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".} stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".}
proc SHGetFileInfoW*(pszPath: LPCWSTR, dwFileAttributes: DWORD, proc SHGetFileInfoW*(pszPath: LPCWSTR, dwFileAttributes: DWORD,
psfi: pSHFILEINFOW, cbFileInfo, UFlags: UINT): DWORD{. psfi: PSHFILEINFOW, cbFileInfo, UFlags: uint32): DWORD{.
stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".} stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".}
proc SHGetFileInfo*(pszPath: LPCSTR, dwFileAttributes: DWORD, proc SHGetFileInfo*(pszPath: LPCSTR, dwFileAttributes: DWORD,
psfi: pSHFILEINFOA, cbFileInfo, UFlags: UINT): DWORD{. psfi: PSHFILEINFOA, cbFileInfo, UFlags: uint32): DWORD{.
stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".} stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".}
proc SHGetFileInfoA*(pszPath: LPCSTR, dwFileAttributes: DWORD, proc SHGetFileInfoA*(pszPath: LPCSTR, dwFileAttributes: DWORD,
psfi: var TSHFILEINFOA, cbFileInfo, UFlags: UINT): DWORD{. psfi: var TSHFILEINFOA, cbFileInfo, UFlags: uint32): DWORD{.
stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".} stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".}
proc SHGetFileInfoW*(pszPath: LPCWSTR, dwFileAttributes: DWORD, proc SHGetFileInfoW*(pszPath: LPCWSTR, dwFileAttributes: DWORD,
psfi: var TSHFILEINFOW, cbFileInfo, UFlags: UINT): DWORD{. psfi: var TSHFILEINFOW, cbFileInfo, UFlags: uint32): DWORD{.
stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".} stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".}
proc SHGetFileInfo*(pszPath: LPCSTR, dwFileAttributes: DWORD, proc SHGetFileInfo*(pszPath: LPCSTR, dwFileAttributes: DWORD,
psfi: var TSHFILEINFOA, cbFileInfo, UFlags: UINT): DWORD{. psfi: var TSHFILEINFOA, cbFileInfo, UFlags: uint32): DWORD{.
stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".} stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".}
proc SHGetFileInfo*(pszPath: LPCWSTR, dwFileAttributes: DWORD, proc SHGetFileInfo*(pszPath: LPCWSTR, dwFileAttributes: DWORD,
psfi: var TSHFILEINFOW, cbFileInfo, UFlags: UINT): DWORD{. psfi: var TSHFILEINFOW, cbFileInfo, UFlags: uint32): DWORD{.
stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".} stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".}
proc SHGetDiskFreeSpaceExA*(pszDirectoryName: LPCSTR, proc SHGetDiskFreeSpaceExA*(pszDirectoryName: LPCSTR,
pulFreeBytesAvailableToCaller: pULARGE_INTEGER, pulFreeBytesAvailableToCaller: PULARGE_INTEGER,
pulTotalNumberOfBytes: pULARGE_INTEGER, pulTotalNumberOfBytes: PULARGE_INTEGER,
pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{. pulTotalNumberOfFreeBytes: PULARGE_INTEGER): bool{.
stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExA".} stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExA".}
proc SHGetDiskFreeSpaceExW*(pszDirectoryName: LPCWSTR, proc SHGetDiskFreeSpaceExW*(pszDirectoryName: LPCWSTR,
pulFreeBytesAvailableToCaller: pULARGE_INTEGER, pulFreeBytesAvailableToCaller: PULARGE_INTEGER,
pulTotalNumberOfBytes: pULARGE_INTEGER, pulTotalNumberOfBytes: PULARGE_INTEGER,
pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{. pulTotalNumberOfFreeBytes: PULARGE_INTEGER): bool{.
stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExW".} stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExW".}
proc SHGetDiskFreeSpaceEx*(pszDirectoryName: LPCSTR, proc SHGetDiskFreeSpaceEx*(pszDirectoryName: LPCSTR,
pulFreeBytesAvailableToCaller: pULARGE_INTEGER, pulFreeBytesAvailableToCaller: PULARGE_INTEGER,
pulTotalNumberOfBytes: pULARGE_INTEGER, pulTotalNumberOfBytes: PULARGE_INTEGER,
pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{. pulTotalNumberOfFreeBytes: PULARGE_INTEGER): bool{.
stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExA".} stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExA".}
proc SHGetDiskFreeSpace*(pszDirectoryName: LPCSTR, proc SHGetDiskFreeSpace*(pszDirectoryName: LPCSTR,
pulFreeBytesAvailableToCaller: pULARGE_INTEGER, pulFreeBytesAvailableToCaller: PULARGE_INTEGER,
pulTotalNumberOfBytes: pULARGE_INTEGER, pulTotalNumberOfBytes: PULARGE_INTEGER,
pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{. pulTotalNumberOfFreeBytes: PULARGE_INTEGER): bool{.
stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExA".} stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExA".}
proc SHGetDiskFreeSpaceEx*(pszDirectoryName: LPCWSTR, proc SHGetDiskFreeSpaceEx*(pszDirectoryName: LPCWSTR,
pulFreeBytesAvailableToCaller: pULARGE_INTEGER, pulFreeBytesAvailableToCaller: PULARGE_INTEGER,
pulTotalNumberOfBytes: pULARGE_INTEGER, pulTotalNumberOfBytes: PULARGE_INTEGER,
pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{. pulTotalNumberOfFreeBytes: PULARGE_INTEGER): bool{.
stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExW".} stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExW".}
proc SHGetDiskFreeSpace*(pszDirectoryName: LPCWSTR, proc SHGetDiskFreeSpace*(pszDirectoryName: LPCWSTR,
pulFreeBytesAvailableToCaller: pULARGE_INTEGER, pulFreeBytesAvailableToCaller: PULARGE_INTEGER,
pulTotalNumberOfBytes: pULARGE_INTEGER, pulTotalNumberOfBytes: PULARGE_INTEGER,
pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{. pulTotalNumberOfFreeBytes: PULARGE_INTEGER): bool{.
stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExW".} stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExW".}
proc SHGetNewLinkInfoA*(pszLinkTo: LPCSTR, pszDir: LPCSTR, pszName: LPSTR, proc SHGetNewLinkInfoA*(pszLinkTo: LPCSTR, pszDir: LPCSTR, pszName: LPSTR,
pfMustCopy: pBool, uFlags: UINT): Bool{.stdcall, pfMustCopy: PBool, uFlags: uint32): bool{.stdcall,
dynlib: "shell32.dll", importc: "SHGetNewLinkInfoA".} dynlib: "shell32.dll", importc: "SHGetNewLinkInfoA".}
proc SHGetNewLinkInfoW*(pszLinkTo: LPCWSTR, pszDir: LPCWSTR, pszName: LPWSTR, proc SHGetNewLinkInfoW*(pszLinkTo: LPCWSTR, pszDir: LPCWSTR, pszName: LPWSTR,
pfMustCopy: pBool, uFlags: UINT): Bool{.stdcall, pfMustCopy: PBool, uFlags: uint32): bool{.stdcall,
dynlib: "shell32.dll", importc: "SHGetNewLinkInfoW".} dynlib: "shell32.dll", importc: "SHGetNewLinkInfoW".}
proc SHGetNewLinkInfo*(pszLinkTo: LPCSTR, pszDir: LPCSTR, pszName: LPSTR, proc SHGetNewLinkInfo*(pszLinkTo: LPCSTR, pszDir: LPCSTR, pszName: LPSTR,
pfMustCopy: pBool, uFlags: UINT): Bool{.stdcall, pfMustCopy: PBool, uFlags: uint32): bool{.stdcall,
dynlib: "shell32.dll", importc: "SHGetNewLinkInfoA".} dynlib: "shell32.dll", importc: "SHGetNewLinkInfoA".}
proc SHGetNewLinkInfo*(pszLinkTo: LPCWSTR, pszDir: LPCWSTR, pszName: LPWSTR, proc SHGetNewLinkInfo*(pszLinkTo: LPCWSTR, pszDir: LPCWSTR, pszName: LPWSTR,
pfMustCopy: pBool, uFlags: UINT): Bool{.stdcall, pfMustCopy: PBool, uFlags: uint32): bool{.stdcall,
dynlib: "shell32.dll", importc: "SHGetNewLinkInfoW".} dynlib: "shell32.dll", importc: "SHGetNewLinkInfoW".}
const const
SHGNLI_PIDL* = 0x00000001 # pszLinkTo is a pidl SHGNLI_PIDL* = 0x00000001 # pszLinkTo is a pidl
@ -777,17 +777,17 @@ const
PRINTACTION_DOCUMENTDEFAULTS* = 6 PRINTACTION_DOCUMENTDEFAULTS* = 6
PRINTACTION_SERVERPROPERTIES* = 7 PRINTACTION_SERVERPROPERTIES* = 7
proc SHInvokePrinterCommandA*(HWND: hwnd, uAction: UINT, lpBuf1: LPCSTR, proc SHInvokePrinterCommandA*(hwnd: HWND, uAction: uint32, lpBuf1: LPCSTR,
lpBuf2: LPCSTR, fModal: Bool): Bool{.stdcall, lpBuf2: LPCSTR, fModal: bool): bool{.stdcall,
dynlib: "shell32.dll", importc: "SHInvokePrinterCommandA".} dynlib: "shell32.dll", importc: "SHInvokePrinterCommandA".}
proc SHInvokePrinterCommandW*(HWND: hwnd, uAction: UINT, lpBuf1: LPCWSTR, proc SHInvokePrinterCommandW*(hwnd: HWND, uAction: uint32, lpBuf1: LPCWSTR,
lpBuf2: LPCWSTR, fModal: Bool): Bool{.stdcall, lpBuf2: LPCWSTR, fModal: bool): bool{.stdcall,
dynlib: "shell32.dll", importc: "SHInvokePrinterCommandW".} dynlib: "shell32.dll", importc: "SHInvokePrinterCommandW".}
proc SHInvokePrinterCommand*(HWND: hwnd, uAction: UINT, lpBuf1: LPCSTR, proc SHInvokePrinterCommand*(hwnd: HWND, uAction: uint32, lpBuf1: LPCSTR,
lpBuf2: LPCSTR, fModal: Bool): Bool{.stdcall, lpBuf2: LPCSTR, fModal: bool): bool{.stdcall,
dynlib: "shell32.dll", importc: "SHInvokePrinterCommandA".} dynlib: "shell32.dll", importc: "SHInvokePrinterCommandA".}
proc SHInvokePrinterCommand*(HWND: hwnd, uAction: UINT, lpBuf1: LPCWSTR, proc SHInvokePrinterCommand*(hwnd: HWND, uAction: uint32, lpBuf1: LPCWSTR,
lpBuf2: LPCWSTR, fModal: Bool): Bool{.stdcall, lpBuf2: LPCWSTR, fModal: bool): bool{.stdcall,
dynlib: "shell32.dll", importc: "SHInvokePrinterCommandW".} dynlib: "shell32.dll", importc: "SHInvokePrinterCommandW".}
proc SHLoadNonloadedIconOverlayIdentifiers*(): HResult{.stdcall, proc SHLoadNonloadedIconOverlayIdentifiers*(): HResult{.stdcall,
dynlib: "shell32.dll", importc: "SHInvokePrinterCommandW".} dynlib: "shell32.dll", importc: "SHInvokePrinterCommandW".}

File diff suppressed because it is too large Load diff

View file

@ -250,14 +250,14 @@
# SDL_GL_MULTISAMPLESAMPLES # SDL_GL_MULTISAMPLESAMPLES
# #
# Add DLL/Shared object functions # Add DLL/Shared object functions
# function SDL_LoadObject( const sofile : PChar ) : Pointer; # function SDL_LoadObject( const sofile : PChar ) : pointer;
# #
# function SDL_LoadFunction( handle : Pointer; const name : PChar ) : Pointer; # function SDL_LoadFunction( handle : pointer; const name : PChar ) : pointer;
# #
# procedure SDL_UnloadObject( handle : Pointer ); # procedure SDL_UnloadObject( handle : pointer );
# #
# Added function to create RWops from const memory: SDL_RWFromConstMem() # Added function to create RWops from const memory: SDL_RWFromConstMem()
# function SDL_RWFromConstMem(const mem: Pointer; size: Integer) : PSDL_RWops; # function SDL_RWFromConstMem(const mem: pointer; size: Integer) : PSDL_RWops;
# #
# Ported SDL_cpuinfo.h so Now you can test for Specific CPU types. # Ported SDL_cpuinfo.h so Now you can test for Specific CPU types.
# #
@ -756,9 +756,9 @@ type
sdlFALSE, sdlTRUE sdlFALSE, sdlTRUE
PUInt8Array* = ptr TUInt8Array PUInt8Array* = ptr TUInt8Array
TUInt8Array* = array[0..high(int) shr 1, byte] TUInt8Array* = array[0..high(int) shr 1, byte]
PUInt16* = ptr UInt16 PUInt16* = ptr uInt16
PUInt32* = ptr UInt32 PUInt32* = ptr uInt32
PUInt64* = ptr UInt64 PUInt64* = ptr uInt64
UInt64*{.final.} = object UInt64*{.final.} = object
hi*: int32 hi*: int32
lo*: int32 lo*: int32
@ -790,8 +790,8 @@ type
args*: array[0..ERR_MAX_ARGS - 1, TArg] args*: array[0..ERR_MAX_ARGS - 1, TArg]
TStdio*{.final.} = object TStdio*{.final.} = object
autoclose*: int # FILE * is only defined in Kylix so we use a simple Pointer autoclose*: int # FILE * is only defined in Kylix so we use a simple pointer
fp*: Pointer fp*: pointer
TMem*{.final.} = object TMem*{.final.} = object
base*: ptr byte base*: ptr byte
@ -800,9 +800,9 @@ type
PRWops* = ptr TRWops # now the pointer to function types PRWops* = ptr TRWops # now the pointer to function types
TSeek* = proc (context: PRWops, offset: int, whence: int): int{.cdecl.} TSeek* = proc (context: PRWops, offset: int, whence: int): int{.cdecl.}
TRead* = proc (context: PRWops, thePtr: Pointer, size: int, maxnum: int): int{. TRead* = proc (context: PRWops, thePtr: pointer, size: int, maxnum: int): int{.
cdecl.} cdecl.}
TWrite* = proc (context: PRWops, thePtr: Pointer, size: int, num: int): int{. TWrite* = proc (context: PRWops, thePtr: pointer, size: int, num: int): int{.
cdecl.} cdecl.}
TClose* = proc (context: PRWops): int{.cdecl.} # the variant record itself TClose* = proc (context: PRWops): int{.cdecl.} # the variant record itself
TRWops*{.final.} = object TRWops*{.final.} = object
@ -817,27 +817,27 @@ type
RWops* = TRWops # SDL_timer.h types RWops* = TRWops # SDL_timer.h types
# Function prototype for the timer callback function # Function prototype for the timer callback function
TTimerCallback* = proc (interval: int32): int32{.cdecl.} TTimerCallback* = proc (interval: int32): int32{.cdecl.}
TNewTimerCallback* = proc (interval: int32, param: Pointer): int32{.cdecl.} TNewTimerCallback* = proc (interval: int32, param: pointer): int32{.cdecl.}
PTimerID* = ptr TTimerID PTimerID* = ptr TTimerID
TTimerID*{.final.} = object TTimerID*{.final.} = object
interval*: int32 interval*: int32
callback*: TNewTimerCallback callback*: TNewTimerCallback
param*: Pointer param*: pointer
last_alarm*: int32 last_alarm*: int32
next*: PTimerID next*: PTimerID
TAudioSpecCallback* = proc (userdata: Pointer, stream: ptr byte, length: int){. TAudioSpecCallback* = proc (userdata: pointer, stream: ptr byte, length: int){.
cdecl.} # SDL_audio.h types cdecl.} # SDL_audio.h types
# The calculated values in this structure are calculated by SDL_OpenAudio() # The calculated values in this structure are calculated by SDL_OpenAudio()
PAudioSpec* = ptr TAudioSpec PAudioSpec* = ptr TAudioSpec
TAudioSpec*{.final.} = object # A structure to hold a set of audio conversion filters and buffers TAudioSpec*{.final.} = object # A structure to hold a set of audio conversion filters and buffers
freq*: int # DSP frequency -- samples per second freq*: int # DSP frequency -- samples per second
format*: UInt16 # Audio data format format*: uInt16 # Audio data format
channels*: byte # Number of channels: 1 mono, 2 stereo channels*: byte # Number of channels: 1 mono, 2 stereo
silence*: byte # Audio buffer silence value (calculated) silence*: byte # Audio buffer silence value (calculated)
samples*: UInt16 # Audio buffer size in samples samples*: uInt16 # Audio buffer size in samples
padding*: UInt16 # Necessary for some compile environments padding*: uInt16 # Necessary for some compile environments
size*: int32 # Audio buffer size in bytes (calculated) size*: int32 # Audio buffer size in bytes (calculated)
# This function is called when the audio device needs more data. # This function is called when the audio device needs more data.
# 'stream' is a pointer to the audio data buffer # 'stream' is a pointer to the audio data buffer
@ -845,20 +845,20 @@ type
# Once the callback returns, the buffer will no longer be valid. # Once the callback returns, the buffer will no longer be valid.
# Stereo samples are stored in a LRLRLR ordering. # Stereo samples are stored in a LRLRLR ordering.
callback*: TAudioSpecCallback callback*: TAudioSpecCallback
userdata*: Pointer userdata*: pointer
PAudioCVT* = ptr TAudioCVT PAudioCVT* = ptr TAudioCVT
PAudioCVTFilter* = ptr TAudioCVTFilter PAudioCVTFilter* = ptr TAudioCVTFilter
TAudioCVTFilter*{.final.} = object TAudioCVTFilter*{.final.} = object
cvt*: PAudioCVT cvt*: PAudioCVT
format*: UInt16 format*: uint16
PAudioCVTFilterArray* = ptr TAudioCVTFilterArray PAudioCVTFilterArray* = ptr TAudioCVTFilterArray
TAudioCVTFilterArray* = array[0..9, PAudioCVTFilter] TAudioCVTFilterArray* = array[0..9, PAudioCVTFilter]
TAudioCVT*{.final.} = object TAudioCVT*{.final.} = object
needed*: int # Set to 1 if conversion possible needed*: int # Set to 1 if conversion possible
src_format*: UInt16 # Source audio format src_format*: uint16 # Source audio format
dst_format*: UInt16 # Target audio format dst_format*: uint16 # Target audio format
rate_incr*: float64 # Rate conversion increment rate_incr*: float64 # Rate conversion increment
buf*: ptr byte # Buffer to hold entire audio data buf*: ptr byte # Buffer to hold entire audio data
length*: int # Length of original audio buffer length*: int # Length of original audio buffer
@ -876,7 +876,7 @@ type
TCDTrack*{.final.} = object # This structure is only current as of the last call to SDL_CDStatus() TCDTrack*{.final.} = object # This structure is only current as of the last call to SDL_CDStatus()
id*: byte # Track number id*: byte # Track number
theType*: byte # Data or audio track theType*: byte # Data or audio track
unused*: UInt16 unused*: uint16
len*: int32 # Length, in frames, of this track len*: int32 # Length, in frames, of this track
offset*: int32 # Offset, in frames, from start of disk offset*: int32 # Offset, in frames, from start of disk
@ -945,7 +945,7 @@ type
scancode*: byte # hardware specific scancode scancode*: byte # hardware specific scancode
sym*: TKey # SDL virtual keysym sym*: TKey # SDL virtual keysym
modifier*: TMod # current key modifiers modifier*: TMod # current key modifiers
unicode*: UInt16 # translated character unicode*: uint16 # translated character
TEventAction* = enum # Application visibility event structure TEventAction* = enum # Application visibility event structure
ADDEVENT, PEEKEVENT, GETEVENT ADDEVENT, PEEKEVENT, GETEVENT
@ -971,7 +971,7 @@ type
kind*: TEventKind kind*: TEventKind
which*: byte # The mouse device index which*: byte # The mouse device index
state*: byte # The current button state state*: byte # The current button state
x*, y*: UInt16 # The X/Y coordinates of the mouse x*, y*: uint16 # The X/Y coordinates of the mouse
xrel*: int16 # The relative motion in the X direction xrel*: int16 # The relative motion in the X direction
yrel*: int16 # The relative motion in the Y direction yrel*: int16 # The relative motion in the Y direction
@ -982,8 +982,8 @@ type
which*: byte # The mouse device index which*: byte # The mouse device index
button*: byte # The mouse button index button*: byte # The mouse button index
state*: byte # SDL_PRESSED or SDL_RELEASED state*: byte # SDL_PRESSED or SDL_RELEASED
x*: UInt16 # The X coordinates of the mouse at press time x*: uint16 # The X coordinates of the mouse at press time
y*: UInt16 # The Y coordinates of the mouse at press time y*: uint16 # The Y coordinates of the mouse at press time
PJoyAxisEvent* = ptr TJoyAxisEvent PJoyAxisEvent* = ptr TJoyAxisEvent
TJoyAxisEvent*{.final.} = object # SDL_JOYAXISMOTION TJoyAxisEvent*{.final.} = object # SDL_JOYAXISMOTION
@ -1036,8 +1036,8 @@ type
TUserEvent*{.final.} = object # SDL_USEREVENT through SDL_NUMEVENTS-1 TUserEvent*{.final.} = object # SDL_USEREVENT through SDL_NUMEVENTS-1
kind*: TEventKind kind*: TEventKind
code*: cint # User defined event code code*: cint # User defined event code
data1*: Pointer # User defined data pointer data1*: pointer # User defined data pointer
data2*: Pointer # User defined data pointer data2*: pointer # User defined data pointer
when defined(Unix): when defined(Unix):
@ -1090,8 +1090,8 @@ elif defined(Unix):
# any X11 functions using the display variable. # any X11 functions using the display variable.
# They lock the event thread, so should not be # They lock the event thread, so should not be
# called around event functions or from event filters. # called around event functions or from event filters.
lock_func*: Pointer lock_func*: pointer
unlock_func*: Pointer # Introduced in SDL 1.0.2 unlock_func*: pointer # Introduced in SDL 1.0.2
fswindow*: TWindow # The X11 fullscreen window fswindow*: TWindow # The X11 fullscreen window
wmwindow*: TWindow # The X11 managed input window wmwindow*: TWindow # The X11 managed input window
@ -1135,7 +1135,7 @@ type
PRect* = ptr TRect PRect* = ptr TRect
TRect*{.final.} = object TRect*{.final.} = object
x*, y*: int16 x*, y*: int16
w*, h*: UInt16 w*, h*: uint16
Rect* = TRect Rect* = TRect
PColor* = ptr TColor PColor* = ptr TColor
@ -1182,7 +1182,7 @@ type
d_width*: int d_width*: int
d_height*: int d_height*: int
d_skip*: int d_skip*: int
aux_data*: Pointer aux_data*: pointer
src*: PPixelFormat src*: PPixelFormat
table*: ptr byte table*: ptr byte
dst*: PPixelFormat dst*: PPixelFormat
@ -1194,17 +1194,17 @@ type
flags*: int32 # Read-only flags*: int32 # Read-only
format*: PPixelFormat # Read-only format*: PPixelFormat # Read-only
w*, h*: cint # Read-only w*, h*: cint # Read-only
pitch*: UInt16 # Read-only pitch*: uint16 # Read-only
pixels*: Pointer # Read-write pixels*: pointer # Read-write
offset*: cint # Private offset*: cint # Private
hwdata*: Pointer #TPrivate_hwdata; Hardware-specific surface info hwdata*: pointer #TPrivate_hwdata; Hardware-specific surface info
# clipping information: # clipping information:
clip_rect*: TRect # Read-only clip_rect*: TRect # Read-only
unused1*: int32 # for binary compatibility unused1*: int32 # for binary compatibility
# Allow recursive locks # Allow recursive locks
locked*: int32 # Private locked*: int32 # Private
# info for fast blit mapping to other surfaces # info for fast blit mapping to other surfaces
Blitmap*: Pointer # PSDL_BlitMap; // Private Blitmap*: pointer # PSDL_BlitMap; // Private
# format version, bumped at every change to invalidate blit maps # format version, bumped at every change to invalidate blit maps
format_version*: cint # Private format_version*: cint # Private
refcount*: cint refcount*: cint
@ -1241,7 +1241,7 @@ type
data*: ptr byte # B/W cursor data data*: ptr byte # B/W cursor data
mask*: ptr byte # B/W cursor mask mask*: ptr byte # B/W cursor mask
save*: array[1..2, ptr byte] # Place to save cursor area save*: array[1..2, ptr byte] # Place to save cursor area
wm_cursor*: Pointer # Window-manager cursor wm_cursor*: pointer # Window-manager cursor
type type
@ -1268,7 +1268,7 @@ type # This is the system-independent thread info struc
handle*: TSYS_ThreadHandle handle*: TSYS_ThreadHandle
status*: int status*: int
errbuf*: TError errbuf*: TError
data*: Pointer data*: pointer
PKeyStateArr* = ptr TKeyStateArr PKeyStateArr* = ptr TKeyStateArr
TKeyStateArr* = array[0..65000, byte] # Types required so we don't need to use Windows.pas TKeyStateArr* = array[0..65000, byte] # Types required so we don't need to use Windows.pas
@ -1326,7 +1326,7 @@ proc WasInit*(flags: int32): int32{.cdecl, importc: "SDL_WasInit",
proc Quit*(){.cdecl, importc: "SDL_Quit", dynlib: LibName.} proc Quit*(){.cdecl, importc: "SDL_Quit", dynlib: LibName.}
when defined(WINDOWS): when defined(WINDOWS):
# This should be called from your WinMain() function, if any # This should be called from your WinMain() function, if any
proc RegisterApp*(name: cstring, style: int32, h_Inst: Pointer): int{.cdecl, proc RegisterApp*(name: cstring, style: int32, h_Inst: pointer): int{.cdecl,
importc: "SDL_RegisterApp", dynlib: LibName.} importc: "SDL_RegisterApp", dynlib: LibName.}
proc TableSize*(table: cstring): int proc TableSize*(table: cstring): int
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -1347,17 +1347,17 @@ proc RWFromFile*(filename, mode: cstring): PRWops{.cdecl,
importc: "SDL_RWFromFile", dynlib: LibName.} importc: "SDL_RWFromFile", dynlib: LibName.}
proc FreeRW*(area: PRWops){.cdecl, importc: "SDL_FreeRW", dynlib: LibName.} proc FreeRW*(area: PRWops){.cdecl, importc: "SDL_FreeRW", dynlib: LibName.}
#fp is FILE *fp ??? #fp is FILE *fp ???
proc RWFromFP*(fp: Pointer, autoclose: int): PRWops{.cdecl, proc RWFromFP*(fp: pointer, autoclose: int): PRWops{.cdecl,
importc: "SDL_RWFromFP", dynlib: LibName.} importc: "SDL_RWFromFP", dynlib: LibName.}
proc RWFromMem*(mem: Pointer, size: int): PRWops{.cdecl, proc RWFromMem*(mem: pointer, size: int): PRWops{.cdecl,
importc: "SDL_RWFromMem", dynlib: LibName.} importc: "SDL_RWFromMem", dynlib: LibName.}
proc RWFromConstMem*(mem: Pointer, size: int): PRWops{.cdecl, proc RWFromConstMem*(mem: pointer, size: int): PRWops{.cdecl,
importc: "SDL_RWFromConstMem", dynlib: LibName.} importc: "SDL_RWFromConstMem", dynlib: LibName.}
proc AllocRW*(): PRWops{.cdecl, importc: "SDL_AllocRW", dynlib: LibName.} proc AllocRW*(): PRWops{.cdecl, importc: "SDL_AllocRW", dynlib: LibName.}
proc RWSeek*(context: PRWops, offset: int, whence: int): int proc RWSeek*(context: PRWops, offset: int, whence: int): int
proc RWTell*(context: PRWops): int proc RWTell*(context: PRWops): int
proc RWRead*(context: PRWops, theptr: Pointer, size: int, n: int): int proc RWRead*(context: PRWops, theptr: pointer, size: int, n: int): int
proc RWWrite*(context: PRWops, theptr: Pointer, size: int, n: int): int proc RWWrite*(context: PRWops, theptr: pointer, size: int, n: int): int
proc RWClose*(context: PRWops): int proc RWClose*(context: PRWops): int
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# time-handling # time-handling
@ -1369,7 +1369,7 @@ proc GetTicks*(): int32{.cdecl, importc: "SDL_GetTicks", dynlib: LibName.}
proc Delay*(msec: int32){.cdecl, importc: "SDL_Delay", dynlib: LibName.} proc Delay*(msec: int32){.cdecl, importc: "SDL_Delay", dynlib: LibName.}
# Add a new timer to the pool of timers already running. # Add a new timer to the pool of timers already running.
# Returns a timer ID, or NULL when an error occurs. # Returns a timer ID, or NULL when an error occurs.
proc AddTimer*(interval: int32, callback: TNewTimerCallback, param: Pointer): PTimerID{. proc AddTimer*(interval: int32, callback: TNewTimerCallback, param: pointer): PTimerID{.
cdecl, importc: "SDL_AddTimer", dynlib: LibName.} cdecl, importc: "SDL_AddTimer", dynlib: LibName.}
# Remove one of the multiple timers knowing its ID. # Remove one of the multiple timers knowing its ID.
# Returns a boolean value indicating success. # Returns a boolean value indicating success.
@ -1387,7 +1387,7 @@ proc AudioInit*(driver_name: cstring): int{.cdecl, importc: "SDL_AudioInit",
dynlib: LibName.} dynlib: LibName.}
proc AudioQuit*(){.cdecl, importc: "SDL_AudioQuit", dynlib: LibName.} proc AudioQuit*(){.cdecl, importc: "SDL_AudioQuit", dynlib: LibName.}
# This function fills the given character buffer with the name of the # This function fills the given character buffer with the name of the
# current audio driver, and returns a Pointer to it if the audio driver has # current audio driver, and returns a pointer to it if the audio driver has
# been initialized. It returns NULL if no driver has been initialized. # been initialized. It returns NULL if no driver has been initialized.
proc AudioDriverName*(namebuf: cstring, maxlen: int): cstring{.cdecl, proc AudioDriverName*(namebuf: cstring, maxlen: int): cstring{.cdecl,
importc: "SDL_AudioDriverName", dynlib: LibName.} importc: "SDL_AudioDriverName", dynlib: LibName.}
@ -1470,8 +1470,8 @@ proc FreeWAV*(audio_buf: ptr byte){.cdecl, importc: "SDL_FreeWAV", dynlib: LibNa
# by SDL_ConvertAudio() to convert a buffer of audio data from one format # by SDL_ConvertAudio() to convert a buffer of audio data from one format
# to the other. # to the other.
# This function returns 0, or -1 if there was an error. # This function returns 0, or -1 if there was an error.
proc BuildAudioCVT*(cvt: PAudioCVT, src_format: UInt16, src_channels: byte, proc BuildAudioCVT*(cvt: PAudioCVT, src_format: uint16, src_channels: byte,
src_rate: int, dst_format: UInt16, dst_channels: byte, src_rate: int, dst_format: uint16, dst_channels: byte,
dst_rate: int): int{.cdecl, importc: "SDL_BuildAudioCVT", dst_rate: int): int{.cdecl, importc: "SDL_BuildAudioCVT",
dynlib: LibName.} dynlib: LibName.}
# Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(), # Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(),
@ -1937,12 +1937,12 @@ proc AllocSurface*(flags: int32, width, height, depth: int,
proc CreateRGBSurface*(flags: int32, width, height, depth: int, proc CreateRGBSurface*(flags: int32, width, height, depth: int,
RMask, GMask, BMask, AMask: int32): PSurface{.cdecl, RMask, GMask, BMask, AMask: int32): PSurface{.cdecl,
importc: "SDL_CreateRGBSurface", dynlib: LibName.} importc: "SDL_CreateRGBSurface", dynlib: LibName.}
proc CreateRGBSurfaceFrom*(pixels: Pointer, width, height, depth, pitch: int, proc CreateRGBSurfaceFrom*(pixels: pointer, width, height, depth, pitch: int,
RMask, GMask, BMask, AMask: int32): PSurface{.cdecl, RMask, GMask, BMask, AMask: int32): PSurface{.cdecl,
importc: "SDL_CreateRGBSurfaceFrom", dynlib: LibName.} importc: "SDL_CreateRGBSurfaceFrom", dynlib: LibName.}
proc FreeSurface*(surface: PSurface){.cdecl, importc: "SDL_FreeSurface", proc FreeSurface*(surface: PSurface){.cdecl, importc: "SDL_FreeSurface",
dynlib: LibName.} dynlib: LibName.}
proc MustLock*(Surface: PSurface): bool proc MustLock*(surface: PSurface): bool
# SDL_LockSurface() sets up a surface for directly accessing the pixels. # SDL_LockSurface() sets up a surface for directly accessing the pixels.
# Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write # Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write
# to and read from 'surface->pixels', using the pixel format stored in # to and read from 'surface->pixels', using the pixel format stored in
@ -2178,7 +2178,7 @@ proc FreeYUVOverlay*(Overlay: POverlay){.cdecl, importc: "SDL_FreeYUVOverlay",
proc GL_LoadLibrary*(filename: cstring): int{.cdecl, proc GL_LoadLibrary*(filename: cstring): int{.cdecl,
importc: "SDL_GL_LoadLibrary", dynlib: LibName.} importc: "SDL_GL_LoadLibrary", dynlib: LibName.}
# Get the address of a GL function (for extension functions) # Get the address of a GL function (for extension functions)
proc GL_GetProcAddress*(procname: cstring): Pointer{.cdecl, proc GL_GetProcAddress*(procname: cstring): pointer{.cdecl,
importc: "SDL_GL_GetProcAddress", dynlib: LibName.} importc: "SDL_GL_GetProcAddress", dynlib: LibName.}
# Set an attribute of the OpenGL subsystem before intialization. # Set an attribute of the OpenGL subsystem before intialization.
proc GL_SetAttribute*(attr: TGLAttr, value: int): int{.cdecl, proc GL_SetAttribute*(attr: TGLAttr, value: int): int{.cdecl,
@ -2255,7 +2255,7 @@ proc GetMouseState*(x: var int, y: var int): byte{.cdecl,
proc GetRelativeMouseState*(x: var int, y: var int): byte{.cdecl, proc GetRelativeMouseState*(x: var int, y: var int): byte{.cdecl,
importc: "SDL_GetRelativeMouseState", dynlib: LibName.} importc: "SDL_GetRelativeMouseState", dynlib: LibName.}
# Set the position of the mouse cursor (generates a mouse motion event) # Set the position of the mouse cursor (generates a mouse motion event)
proc WarpMouse*(x, y: UInt16){.cdecl, importc: "SDL_WarpMouse", dynlib: LibName.} proc WarpMouse*(x, y: uint16){.cdecl, importc: "SDL_WarpMouse", dynlib: LibName.}
# Create a cursor using the specified data and mask (in MSB format). # Create a cursor using the specified data and mask (in MSB format).
# The cursor width must be a multiple of 8 bits. # The cursor width must be a multiple of 8 bits.
# #
@ -2402,7 +2402,7 @@ proc CondWaitTimeout*(cond: Pcond, mut: Pmutex, ms: int32): int{.cdecl,
# Condition variable functions # Condition variable functions
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# Create a thread # Create a thread
proc CreateThread*(fn, data: Pointer): PThread{.cdecl, proc CreateThread*(fn, data: pointer): PThread{.cdecl,
importc: "SDL_CreateThread", dynlib: LibName.} importc: "SDL_CreateThread", dynlib: LibName.}
# Get the 32-bit thread identifier for the current thread # Get the 32-bit thread identifier for the current thread
proc ThreadID*(): int32{.cdecl, importc: "SDL_ThreadID", dynlib: LibName.} proc ThreadID*(): int32{.cdecl, importc: "SDL_ThreadID", dynlib: LibName.}
@ -2435,16 +2435,16 @@ proc GetWMInfo*(info: PSysWMinfo): int{.cdecl, importc: "SDL_GetWMInfo",
# * to the object handle (or NULL if there was an error). # * to the object handle (or NULL if there was an error).
# * The 'sofile' parameter is a system dependent name of the object file. # * The 'sofile' parameter is a system dependent name of the object file.
# * # *
proc LoadObject*(sofile: cstring): Pointer{.cdecl, importc: "SDL_LoadObject", proc LoadObject*(sofile: cstring): pointer{.cdecl, importc: "SDL_LoadObject",
dynlib: LibName.} dynlib: LibName.}
#* Given an object handle, this function looks up the address of the #* Given an object handle, this function looks up the address of the
# * named function in the shared object and returns it. This address # * named function in the shared object and returns it. This address
# * is no longer valid after calling SDL_UnloadObject(). # * is no longer valid after calling SDL_UnloadObject().
# * # *
proc LoadFunction*(handle: Pointer, name: cstring): Pointer{.cdecl, proc LoadFunction*(handle: pointer, name: cstring): pointer{.cdecl,
importc: "SDL_LoadFunction", dynlib: LibName.} importc: "SDL_LoadFunction", dynlib: LibName.}
#* Unload a shared object from memory * #* Unload a shared object from memory *
proc UnloadObject*(handle: Pointer){.cdecl, importc: "SDL_UnloadObject", proc UnloadObject*(handle: pointer){.cdecl, importc: "SDL_UnloadObject",
dynlib: LibName.} dynlib: LibName.}
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
proc Swap32*(D: int32): int32 proc Swap32*(D: int32): int32
@ -2455,32 +2455,32 @@ proc TurnBitOff*(value: int, bit: int8): int
# implementation # implementation
proc TABLESIZE(table: cstring): int = proc TABLESIZE(table: cstring): int =
Result = SizeOf(table) div SizeOf(table[0]) result = sizeOf(table) div sizeOf(table[0])
proc OutOfMemory() = proc OutOfMemory() =
when not (defined(WINDOWS)): Error(ENOMEM) when not (defined(WINDOWS)): Error(ENOMEM)
proc RWSeek(context: PRWops, offset: int, whence: int): int = proc RWSeek(context: PRWops, offset: int, whence: int): int =
Result = context.seek(context, offset, whence) result = context.seek(context, offset, whence)
proc RWTell(context: PRWops): int = proc RWTell(context: PRWops): int =
Result = context.seek(context, 0, 1) result = context.seek(context, 0, 1)
proc RWRead(context: PRWops, theptr: Pointer, size: int, n: int): int = proc RWRead(context: PRWops, theptr: pointer, size: int, n: int): int =
Result = context.read(context, theptr, size, n) result = context.read(context, theptr, size, n)
proc RWWrite(context: PRWops, theptr: Pointer, size: int, n: int): int = proc RWWrite(context: PRWops, theptr: pointer, size: int, n: int): int =
Result = context.write(context, theptr, size, n) result = context.write(context, theptr, size, n)
proc RWClose(context: PRWops): int = proc RWClose(context: PRWops): int =
Result = context.closeFile(context) result = context.closeFile(context)
proc LoadWAV(filename: cstring, spec: PAudioSpec, audio_buf: ptr byte, proc LoadWAV(filename: cstring, spec: PAudioSpec, audio_buf: ptr byte,
audiolen: PUInt32): PAudioSpec = audiolen: PUInt32): PAudioSpec =
Result = LoadWAV_RW(RWFromFile(filename, "rb"), 1, spec, audio_buf, audiolen) result = LoadWAV_RW(RWFromFile(filename, "rb"), 1, spec, audio_buf, audiolen)
proc CDInDrive(status: TCDStatus): bool = proc CDInDrive(status: TCDStatus): bool =
Result = ord(status) > ord(CD_ERROR) result = ord(status) > ord(CD_ERROR)
proc FRAMES_TO_MSF(frames: int, M: var int, S: var int, F: var int) = proc FRAMES_TO_MSF(frames: int, M: var int, S: var int, F: var int) =
var value: int var value: int
@ -2492,7 +2492,7 @@ proc FRAMES_TO_MSF(frames: int, M: var int, S: var int, F: var int) =
M = value M = value
proc MSF_TO_FRAMES(M: int, S: int, F: int): int = proc MSF_TO_FRAMES(M: int, S: int, F: int): int =
Result = M * 60 * CD_FPS + S * CD_FPS + F result = M * 60 * CD_FPS + S * CD_FPS + F
proc VERSION(X: var TVersion) = proc VERSION(X: var TVersion) =
X.major = MAJOR_VERSION X.major = MAJOR_VERSION
@ -2500,43 +2500,43 @@ proc VERSION(X: var TVersion) =
X.patch = PATCHLEVEL X.patch = PATCHLEVEL
proc VERSIONNUM(X, Y, Z: int): int = proc VERSIONNUM(X, Y, Z: int): int =
Result = X * 1000 + Y * 100 + Z result = X * 1000 + Y * 100 + Z
proc COMPILEDVERSION(): int = proc COMPILEDVERSION(): int =
Result = VERSIONNUM(MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL) result = VERSIONNUM(MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL)
proc VERSION_ATLEAST(X, Y, Z: int): bool = proc VERSION_ATLEAST(X, Y, Z: int): bool =
Result = (COMPILEDVERSION() >= VERSIONNUM(X, Y, Z)) result = (COMPILEDVERSION() >= VERSIONNUM(X, Y, Z))
proc LoadBMP(filename: cstring): PSurface = proc LoadBMP(filename: cstring): PSurface =
Result = LoadBMP_RW(RWFromFile(filename, "rb"), 1) result = LoadBMP_RW(RWFromFile(filename, "rb"), 1)
proc SaveBMP(surface: PSurface, filename: cstring): int = proc SaveBMP(surface: PSurface, filename: cstring): int =
Result = SaveBMP_RW(surface, RWFromFile(filename, "wb"), 1) result = SaveBMP_RW(surface, RWFromFile(filename, "wb"), 1)
proc BlitSurface(src: PSurface, srcrect: PRect, dst: PSurface, dstrect: PRect): int = proc BlitSurface(src: PSurface, srcrect: PRect, dst: PSurface, dstrect: PRect): int =
Result = UpperBlit(src, srcrect, dst, dstrect) result = UpperBlit(src, srcrect, dst, dstrect)
proc AllocSurface(flags: int32, width, height, depth: int, proc AllocSurface(flags: int32, width, height, depth: int,
RMask, GMask, BMask, AMask: int32): PSurface = RMask, GMask, BMask, AMask: int32): PSurface =
Result = CreateRGBSurface(flags, width, height, depth, RMask, GMask, BMask, result = CreateRGBSurface(flags, width, height, depth, RMask, GMask, BMask,
AMask) AMask)
proc MustLock(Surface: PSurface): bool = proc MustLock(surface: PSurface): bool =
Result = ((surface[].offset != 0) or result = ((surface.offset != 0) or
((surface[].flags and (HWSURFACE or ASYNCBLIT or RLEACCEL)) != 0)) ((surface.flags and (HWSURFACE or ASYNCBLIT or RLEACCEL)) != 0))
proc LockMutex(mutex: Pmutex): int = proc LockMutex(mutex: Pmutex): int =
Result = mutexP(mutex) result = mutexP(mutex)
proc UnlockMutex(mutex: Pmutex): int = proc UnlockMutex(mutex: Pmutex): int =
Result = mutexV(mutex) result = mutexV(mutex)
proc BUTTON(Button: int): int = proc BUTTON(Button: int): int =
Result = PRESSED shl (Button - 1) result = PRESSED shl (Button - 1)
proc Swap32(D: int32): int32 = proc Swap32(D: int32): int32 =
Result = ((D shl 24) or ((D shl 8) and 0x00FF0000) or result = ((D shl 24) or ((D shl 8) and 0x00FF0000) or
((D shr 8) and 0x0000FF00) or (D shr 24)) ((D shr 8) and 0x0000FF00) or (D shr 24))
proc IsBitOn(value: int, bit: int8): bool = proc IsBitOn(value: int, bit: int8): bool =