Changeset 1315 for cpp/frams/param/param.h
- Timestamp:
- 07/11/24 17:26:06 (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified cpp/frams/param/param.h ¶
r1184 r1315 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-202 2Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2024 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 216 216 // implementations: 217 217 218 extern char MakeCodeGuardHappy;219 220 218 #define PROCOFFSET(_proc_) ( (void (*)(void*,ExtValue*,ExtValue*)) &(FIELDSTRUCT :: _proc_ ## _statrick)) 221 219 #define STATICPROCOFFSET(_proc_) ( (void (*)(void*,ExtValue*,ExtValue*)) &(FIELDSTRUCT :: _proc_)) … … 223 221 #define SETOFFSET(_proc_) ( (int (*)(void*,const ExtValue*)) &(FIELDSTRUCT :: _proc_ ## _statrick)) 224 222 225 #define FIELDOFFSET(_fld_) ((intptr_t) ((char*)(&((FIELDSTRUCT*)&MakeCodeGuardHappy)->_fld_)-((char*)((FIELDSTRUCT*)&MakeCodeGuardHappy))))223 #define FIELDOFFSET(_fld_) ((intptr_t)offsetof(FIELDSTRUCT, _fld_)) // https://stackoverflow.com/questions/177885/looking-for-something-similar-to-offsetof-for-non-pod-types , https://stackoverflow.com/questions/713963/why-does-this-implementation-of-offsetof-work 226 224 227 225 #ifdef _DEBUG … … 349 347 350 348 #ifdef CHECK_PARAMENTRY_COUNT 351 349 352 350 template <int COUNT> 353 Param(ParamEntry (&t)[COUNT],void* o = 0, const char*n = 0) :SimpleAbstractParam(o, n), tab(t)351 Param(ParamEntry(&t)[COUNT], void* o = 0, const char*n = 0) :SimpleAbstractParam(o, n), tab(t) 354 352 { 355 if (!n &&tab) myname = tab[0].name;353 if (!n && tab) myname = tab[0].name; 356 354 //printf("Param(ParamEntry t[%d]) %s\n",COUNT,myname?myname:"unknown name"); 357 355 if (tab) 358 359 int in_array = COUNT -1-tab[0].group;356 { 357 int in_array = COUNT - 1 - tab[0].group; 360 358 if (tab[0].flags != in_array) 361 printf("\nCHECK_PARAMENTRY_COUNT: %d items in ParamEntry[] array, declared %d (%s)\n\n", in_array, tab[0].flags, myname?myname:"unknown name");362 if (in_array >0 && tab[COUNT-1].id != NULL) //in_array>0 -> completely empty paramtab can't end with the usual zero row because that's also its first row363 printf("\nCHECK_PARAMENTRY_COUNT: last entry is not null (%s)\n\n", myname?myname:"unknown name");364 359 printf("\nCHECK_PARAMENTRY_COUNT: %d items in ParamEntry[] array, declared %d (%s)\n\n", in_array, tab[0].flags, myname ? myname : "unknown name"); 360 if (in_array > 0 && tab[COUNT - 1].id != NULL) //in_array>0 -> completely empty paramtab can't end with the usual zero row because that's also its first row 361 printf("\nCHECK_PARAMENTRY_COUNT: last entry is not null (%s)\n\n", myname ? myname : "unknown name"); 362 } 365 363 } 366 364 367 template<typename T, typename std::enable_if_t<std::is_same<ParamEntry*, T>::value>* = nullptr > //SFINAE-fu because the normal ParamEntry* overload would be also called for ParamEntry[COUNT] argument365 template<typename T, typename std::enable_if_t<std::is_same<ParamEntry*, T>::value>* = nullptr > //SFINAE-fu because the normal ParamEntry* overload would be also called for ParamEntry[COUNT] argument 368 366 Param(T t, void* o = 0, const char*n = 0) :SimpleAbstractParam(o, n), tab(t) 369 367 { 370 368 //printf("Param(ParamEntry* t) %s\n",tab?tab[0].name:""); 371 if (!n &&tab) myname = tab[0].name;369 if (!n && tab) myname = tab[0].name; 372 370 } 373 371 … … 378 376 379 377 #else // CHECK_PARAMENTRY_COUNT 380 381 Param(ParamEntry *t = 0, void* o = 0, const char*n = 0) : SimpleAbstractParam(o, n), tab(t)378 379 Param(ParamEntry *t = 0, void* o = 0, const char*n = 0) : SimpleAbstractParam(o, n), tab(t) 382 380 { 383 if (!n &&tab) myname = tab[0].name;381 if (!n && tab) myname = tab[0].name; 384 382 } 385 383 386 384 #endif // CHECK_PARAMENTRY_COUNT 387 385 388 386 Param(const Param& p) :SimpleAbstractParam(p.object, p.myname), tab(p.tab) {} 389 387 void operator=(const Param&p) { object = p.object; myname = p.myname; tab = p.tab; }
Note: See TracChangeset
for help on using the changeset viewer.