Skip to content

Commit c25c05c

Browse files
committed
inc: Fix various #defines in fbfrog-based bindings
(cherry picked from commit 47056bf)
1 parent 360ea0c commit c25c05c

File tree

9 files changed

+36
-17
lines changed

9 files changed

+36
-17
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Version 1.02.1
99
- 1.02.0 regression: win/winuser.bi: Renamed INPUT typedef to INPUT_ to avoid conflicts with the quirk keyword (due to bug #730)
1010
- 1.02.0 regression: OpenGL binding: glGetString() and some others use ZString Ptr instead of GLubyte Ptr again
1111
- 1.02.0 regression: Windows API binding: REFIID and some other REF* types were missing
12+
- bindings: Various previously untranslated (or wrongly translated) #defines in SDL2, X11, crt/pthread, Windows API
1213

1314

1415
Version 1.02.0

inc/SDL2/SDL.bi

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,12 @@ declare sub SDL_SetMainReady()
183183
#endif
184184

185185
const SDL_ASSERT_LEVEL = 2
186-
#define SDL_TriggerBreakpoint() '' TODO: __asm__ __volatile__ ( "int $3\n\t" )
187-
#define SDL_FUNCTION __func__
186+
#define SDL_TriggerBreakpoint() asm int 3
187+
#define SDL_FUNCTION __FUNCTION__
188188
#define SDL_FILE __FILE__
189189
#define SDL_LINE __LINE__
190190
const SDL_NULL_WHILE_LOOP_CONDITION = 0
191-
#define SDL_disabled_assert(condition) '' TODO: do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION)
191+
#define SDL_disabled_assert(condition) scope : end scope
192192

193193
type SDL_assert_state as long
194194
enum
@@ -210,7 +210,21 @@ type SDL_assert_data
210210
end type
211211

212212
declare function SDL_ReportAssertion(byval as SDL_assert_data ptr, byval as const zstring ptr, byval as const zstring ptr, byval as long) as SDL_assert_state
213-
#define SDL_enabled_assert(condition) '' TODO: do { while ( !(condition) ) { static struct SDL_assert_data assert_data = { 0, 0, #condition, 0, 0, 0, 0 }; const SDL_assert_state state = SDL_ReportAssertion(&assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); if (state == SDL_ASSERTION_RETRY) { continue; } else if (state == SDL_ASSERTION_BREAK) { SDL_TriggerBreakpoint(); } break; } } while (SDL_NULL_WHILE_LOOP_CONDITION)
213+
#macro SDL_enabled_assert(condition)
214+
scope
215+
while (condition) = 0
216+
static as SDL_assert_data assert_data = ( 0, 0, @#condition, 0, 0, 0, 0 )
217+
dim as const SDL_assert_state state = SDL_ReportAssertion(@assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE)
218+
select case state
219+
case SDL_ASSERTION_RETRY
220+
continue while
221+
case SDL_ASSERTION_BREAK
222+
SDL_TriggerBreakpoint()
223+
end select
224+
exit while
225+
wend
226+
end scope
227+
#endmacro
214228
#define SDL_assert(condition) SDL_enabled_assert(condition)
215229
#define SDL_assert_release(condition) SDL_enabled_assert(condition)
216230
#define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
@@ -227,8 +241,7 @@ type SDL_SpinLock as long
227241
declare function SDL_AtomicTryLock(byval lock as SDL_SpinLock ptr) as SDL_bool
228242
declare sub SDL_AtomicLock(byval lock as SDL_SpinLock ptr)
229243
declare sub SDL_AtomicUnlock(byval lock as SDL_SpinLock ptr)
230-
231-
#define SDL_CompilerBarrier() '' TODO: __asm__ __volatile__ ("" : : : "memory")
244+
#define SDL_CompilerBarrier() asm nop
232245
#define SDL_MemoryBarrierRelease() SDL_CompilerBarrier()
233246
#define SDL_MemoryBarrierAcquire() SDL_CompilerBarrier()
234247

inc/X11/Intrinsic.bi

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,12 @@ declare sub XtSetMappedWhenManaged(byval as Widget, byval as byte)
343343
declare function XtNameToWidget(byval as Widget, byval as const zstring ptr) as Widget
344344
declare function XtWindowToWidget(byval as Display ptr, byval as Window) as Widget
345345
declare function XtGetClassExtension(byval as WidgetClass, byval as Cardinal, byval as XrmQuark, byval as clong, byval as Cardinal) as XtPointer
346-
#define XtSetArg(arg, n, d) '' TODO: ((void)( (arg).name = (n), (arg).value = (XtArgVal)(d) ))
346+
#macro XtSetArg(arg, n, d)
347+
scope
348+
(arg).name = (n)
349+
(arg).value = cast(XtArgVal, d)
350+
end scope
351+
#endmacro
347352
declare function XtMergeArgLists(byval as ArgList, byval as Cardinal, byval as ArgList, byval as Cardinal) as ArgList
348353
#define XtVaNestedList "XtVaNestedList"
349354
#define XtVaTypedArg "XtVaTypedArg"
@@ -431,8 +436,8 @@ const XtUnspecifiedShellInt = -1
431436
#define XtDefaultBackground "XtDefaultBackground"
432437
#define XtDefaultFont "XtDefaultFont"
433438
#define XtDefaultFontSet "XtDefaultFontSet"
434-
#define XtOffset(p_type, field) '' TODO: ((Cardinal) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
435-
#define XtOffsetOf(s_type, field) '' TODO: XtOffset(s_type*,field)
439+
#define XtOffset(p_type, field) cast(Cardinal, cptr(byte ptr, @cast(p_type, NULL)->field) - cptr(byte ptr, NULL))
440+
#define XtOffsetOf(s_type, field) XtOffset(s_type ptr, field)
436441

437442
type _XtCheckpointTokenRec
438443
save_type as long

inc/crt/bits/pthreadtypes.bi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ end union
110110

111111
#ifdef __FB_64BIT__
112112
const __PTHREAD_MUTEX_HAVE_PREV = 1
113-
#define __PTHREAD_SPINS '' TODO: 0, 0
113+
#define __PTHREAD_SPINS 0, 0
114114
#else
115115
#define __spins __elision_data.__espins
116116
#define __elision __elision_data.__elision
@@ -186,7 +186,7 @@ union pthread_rwlock_t
186186
end union
187187

188188
#ifdef __FB_64BIT__
189-
#define __PTHREAD_RWLOCK_ELISION_EXTRA '' TODO: 0, { 0, 0, 0, 0, 0, 0, 0 }
189+
#define __PTHREAD_RWLOCK_ELISION_EXTRA 0, { 0, 0, 0, 0, 0, 0, 0 }
190190
const __PTHREAD_RWLOCK_INT_FLAGS_SHARED = 1
191191
#else
192192
const __PTHREAD_RWLOCK_ELISION_EXTRA = 0

inc/win/apiset.bi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const API_SET_RELEASE_SCHEMA_ORDINAL = 3
2323
#define API_SET_STRING_U_X(s) API_SET_STRING_U_Y(s)
2424
#define API_SET_STRING_U(s) API_SET_STRING_U_X(API_SET_STRING(s))
2525
#define API_SET_OVERRIDE(X) X##Implementation
26-
#define API_SET_LEGACY_OVERRIDE_DEF(X) '' TODO: X = API_SET_OVERRIDE(X)
27-
#define API_SET_OVERRIDE_DEF(X) '' TODO: API_SET_LEGACY_OVERRIDE_DEF(X) PRIVATE
26+
'' TODO: #define API_SET_LEGACY_OVERRIDE_DEF(X) X = API_SET_OVERRIDE(X)
27+
'' TODO: #define API_SET_OVERRIDE_DEF(X) API_SET_LEGACY_OVERRIDE_DEF(X) PRIVATE
2828
#define API_SET_PRIVATE(X) X PRIVATE
2929
#define API_SET_LIBRARY(X) LIBRARY X
3030
#define API_SET(X) X

inc/win/dshow.bi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
#define __DSHOW_INCLUDED__
2020
#define AM_NOVTABLE
2121
#define NO_SHLWAPI_STRFCNS
22-
#define NUMELMS(array) (sizeof((array)) / sizeof((array)[0]))
22+
#define NUMELMS(array) (ubound(array) - lbound(array) + 1)
2323
const OATRUE = -1
2424
const OAFALSE = 0

inc/win/ntdef.bi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ type PGROUP_AFFINITY as _GROUP_AFFINITY ptr
400400
#define RTL_FIELD_SIZE(type, field) sizeof(cptr(type ptr, 0)->field)
401401
#define RTL_SIZEOF_THROUGH_FIELD(type, field) (FIELD_OFFSET(type, field) + RTL_FIELD_SIZE(type, field))
402402
#define RTL_CONTAINS_FIELD(Struct, Size, Field) ((cast(PCHAR, @(Struct)->Field) + sizeof((Struct)->Field)) <= (cast(PCHAR, (Struct)) + (Size)))
403-
#define RTL_NUMBER_OF_V1(A) (sizeof((A)) / sizeof((A)[0]))
403+
#define RTL_NUMBER_OF_V1(A) (ubound(A) - lbound(A) + 1)
404404
#define RTL_NUMBER_OF_V2(A) RTL_NUMBER_OF_V1(A)
405405
#define RTL_NUMBER_OF(A) RTL_NUMBER_OF_V1(A)
406406
#define ARRAYSIZE(A) RTL_NUMBER_OF_V2(A)

inc/win/snmp.bi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ const SNMP_OUTPUT_TO_EVENTLOG = &h4
184184
const SNMP_OUTPUT_TO_DEBUGGER = &h8
185185
declare sub SnmpUtilDbgPrint cdecl(byval nLogLevel as INT_, byval szFormat as LPSTR, ...)
186186
#define SNMPDBG(_x_)
187-
#define DEFINE_SIZEOF(Array) (sizeof((Array)) / sizeof((Array)[0]))
187+
#define DEFINE_SIZEOF(Array) (ubound(Array) - lbound(Array) + 1)
188188
#define DEFINE_OID(SubIdArray) (DEFINE_SIZEOF(SubIdArray), (SubIdArray))
189189
#define DEFINE_NULLOID() (0, NULL)
190190
#define DEFINE_NULLOCTETS() (NULL, 0, FALSE)

inc/win/winnt.bi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ const MAXDWORD = &hffffffff
349349
#define RTL_FIELD_SIZE(type, field) sizeof(cptr(type ptr, 0)->field)
350350
#define RTL_SIZEOF_THROUGH_FIELD(type, field) (FIELD_OFFSET(type, field) + RTL_FIELD_SIZE(type, field))
351351
#define RTL_CONTAINS_FIELD(Struct, Size, Field) ((cast(PCHAR, @(Struct)->Field) + sizeof((Struct)->Field)) <= (cast(PCHAR, (Struct)) + (Size)))
352-
#define RTL_NUMBER_OF_V1(A) (sizeof((A)) / sizeof((A)[0]))
352+
#define RTL_NUMBER_OF_V1(A) (ubound(A) - lbound(A) + 1)
353353
#define RTL_NUMBER_OF_V2(A) RTL_NUMBER_OF_V1(A)
354354
#define RTL_NUMBER_OF(A) RTL_NUMBER_OF_V1(A)
355355
#define ARRAYSIZE(A) RTL_NUMBER_OF_V2(A)

0 commit comments

Comments
 (0)