Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //my own primitive form of contiguous dynamic arrays
- #include "../include/kit_sdl2/kit_core.h"
- #include "../_private/include/_kit_privmacro.h"
- //(MAYBE at some point replace <x/y/z>_new with <x/y/z>_old when axes aren't updated)
- //(so i can choose whether or not to actually print here)
- #define _vectorLogOP(...) kit_coreLog(__VA_ARGS__)
- //#define _vectorLogOP(...) ;
- //#define _vectorLogT(...) kit_coreLog(__VA_ARGS__)
- #define _vectorLogT(...) ;
- extern void _kit_coreVectorPrintInt(kit_coreVector* Vector, const char* prefix);
- extern void _kit_coreVectorPrintLens(kit_coreVector* Vector, const char* prefix);
- //(like kit_coreRealloc, and added memory is initialized to 0)
- int _kit_coreVectorRealloc(void* ptr_p, char axis,
- lens_t osize, lens_t nsize)
- {
- if(osize==nsize) return 0;
- void* _ptr=SDL_realloc(*(void**)ptr_p,nsize);
- if(_ptr==NULL){
- if(axis!=0) SDL_SetError("%c realloc",axis);
- return -1;
- }
- if(nsize>osize) SDL_memset(_ptr+osize, 0, /*size_difference=*/nsize-osize);
- *(void**)ptr_p=_ptr;
- return 0;
- }
- void _kit_coreVectorFreeZinY(kit_coreVector* Vector,
- lens_t x_start, lens_t x_end,
- lens_t y_start, lens_t y_end)
- {
- if((Vector->_dims&3)<3) return; //z doesn't exist in 1d or 2d array
- void*** p3d=Vector->p3d;
- for(lens_t xi=x_start; xi<x_end; ++xi){ void** p2d=p3d[xi];
- if(p2d==NULL) continue;
- for(lens_t yi=y_start; yi<y_end; ++yi){ void* p1d=p2d[yi];
- if(p1d==NULL) continue;
- SDL_free(p1d); p2d[yi]=NULL;
- }
- }
- }
- void _kit_coreVectorFreeYinX(kit_coreVector* Vector,
- lens_t x_start, lens_t x_end)
- {
- if((Vector->_dims&3)<2) return; //y doesn't exist in 1d array (nor does z)
- void** p2d=Vector->p2d;
- for(lens_t xi=x_start; xi<x_end; ++xi){ void* p1d=p2d[xi];
- if(p1d==NULL) continue;
- SDL_free(p1d); p2d[xi]=NULL;
- }
- }
- int _kit_coreVectorResizeX(kit_coreVector** Vector_p,
- lens_t x_osize, lens_t x_nsize, lens_t x_new)
- {
- //(x axis is contiguous with the vector struct itself)
- x_osize+=sizeof(kit_coreVector); x_nsize+=sizeof(kit_coreVector);
- if(_kit_coreVectorRealloc(Vector_p,'x', x_osize,x_nsize)) return -12;
- kit_coreVector* Vector=*Vector_p;
- Vector->ptr=(void*)Vector+sizeof(kit_coreVector);
- Vector->x=x_new; *Vector_p=Vector;
- return 0;
- }
- int _kit_coreVectorResizeY(kit_coreVector* Vector,
- lens_t x_start, lens_t x_end,
- lens_t y_osize, lens_t y_nsize, lens_t y_new)
- {
- if((Vector->_dims&3)<2) return 0; //y doesn't exist in 1d array (nor does z)
- void** p2d=Vector->p2d;
- for(lens_t xi=x_start; xi<x_end; ++xi)
- if(_kit_coreVectorRealloc(&p2d[xi],'y', y_osize,y_nsize)) return -13;
- Vector->y=y_new;
- return 0;
- }
- int _kit_coreVectorResizeZ(kit_coreVector* Vector,
- lens_t x_start, lens_t x_end,
- lens_t y_start, lens_t y_end,
- lens_t z_osize, lens_t z_nsize, lens_t z_new)
- {
- if((Vector->_dims&3)<3) return 0; //z doesn't exist in 1d or 2d array
- void*** p3d=Vector->p3d;
- for(lens_t xi=x_start; xi<x_end; ++xi){ void** p2d=p3d[xi];
- for(lens_t yi=y_start; yi<y_end; ++yi)
- if(_kit_coreVectorRealloc(&p2d[yi],'z', z_osize,z_nsize)) return -14;
- }
- Vector->z=z_new;
- return 0;
- }
- void _kit_coreVectorFreeLensYinX(kit_coreVector* Vector,
- lens_t x_start, lens_t x_end)
- {
- //since this is freeing heap memory,
- //y is only allocated memory when vector is 3d
- if((Vector->_dims&3)<3) return;
- lens_t** r3D=Vector->lens.r3D;
- if(r3D == NULL) return;
- for(lens_t xi=x_start; xi<x_end; ++xi){ lens_t* r2D=r3D[xi];
- if(r2D==NULL) continue;
- SDL_free(r2D); r3D[xi]=NULL;
- }
- }
- int _kit_coreVectorResizeLensX(kit_coreVector* Vector,
- lens_t x_old, lens_t x_new)
- {
- int dims=Vector->_dims&3;
- if(Vector->lens.r3D==NULL) return 0;
- if(dims<=1){
- //real length must be <= allocated length
- if(Vector->lens.r1D>x_new) Vector->lens.r1D=x_new;
- return 0;
- } else if(dims==2){
- x_old*=sizeof(lens_t);
- x_new*=sizeof(lens_t);
- } else if(dims==3){
- x_old*=sizeof(lens_t*);
- x_new*=sizeof(lens_t*);
- }
- if(_kit_coreVectorRealloc(&Vector->lens.r3D,'x', x_old,x_new)) return -12;
- return 0;
- }
- int _kit_coreVectorResizeLensY(kit_coreVector* Vector,
- lens_t x_start, lens_t x_end,
- lens_t y_old, lens_t y_new)
- {
- int dims=Vector->_dims&3;
- if(dims<2) return 0; //y doesn't exist in 1d array (nor does z)
- if(Vector->lens.r3D==NULL) return 0;
- else if(dims==2){
- lens_t* r2D=Vector->lens.r2D;
- for(lens_t xi=x_start; xi<x_end; ++xi)
- if(r2D[xi]>y_new) r2D[xi]=y_new; //real length must be <= allocated length
- } else if(dims==3){
- kit_coreLog("xs,xe=%u,%u, yo,yn=%u,%u", x_start,x_end, y_old,y_new);
- y_old*=sizeof(lens_t*);
- y_new*=sizeof(lens_t*);
- lens_t** r3D=Vector->lens.r3D;
- for(lens_t xi=x_start; xi<x_end; ++xi)
- if(_kit_coreVectorRealloc(&r3D[xi],'y', y_old,y_new)) return -13;
- }
- return 0;
- }
- void _kit_coreVectorResizeLensZ(kit_coreVector* Vector,
- lens_t x_start, lens_t x_end,
- lens_t y_start, lens_t y_end,
- lens_t z_new)
- {
- if((Vector->_dims&3)<3) return; //z doesn't exist in 1d or 2d array
- if(Vector->lens.r3D==NULL) return;
- lens_t** r3D=Vector->lens.r3D;
- for(lens_t xi=x_start; xi<x_end; ++xi){ lens_t* r2D=r3D[xi];
- for(lens_t yi=y_start; yi<y_end; ++yi)
- if(r2D[yi]>z_new) r2D[yi]=z_new; //real length must be <= allocated length
- }
- }
- //(remember, <xyz>_old and <xyz>_new are sometimes flipped when used as a parameter when freeing)
- static inline int _kit_coreVectorSubX(kit_coreVector** Vector_p,
- lens_t x_new, lens_t x_old, lens_t y_new,
- lens_t x_osize, lens_t x_nsize)
- { _vectorLogOP(" SubX");
- kit_coreVector* Vector=*Vector_p; int rS; //(r)eturn(S)tatus
- _kit_coreVectorFreeZinY(Vector, x_new,x_old, 0,y_new);
- _kit_coreVectorFreeYinX(Vector, x_new,x_old);
- if((rS=_kit_coreVectorResizeX(Vector_p, x_osize,x_nsize, x_new))) return rS;
- //lens
- _kit_coreVectorFreeLensYinX(Vector, x_new,x_old);
- if((rS=_kit_coreVectorResizeLensX(Vector, x_old,x_new))) return rS;
- return 0;
- }
- static inline int _kit_coreVectorSubY(kit_coreVector* Vector,
- lens_t x_new, lens_t y_new, lens_t y_old,
- lens_t y_osize, lens_t y_nsize)
- { _vectorLogOP(" SubY");
- int rS; //(r)eturn(S)tatus
- _kit_coreVectorFreeZinY(Vector, 0,x_new, y_new,y_old);
- if((rS=_kit_coreVectorResizeY(Vector, 0,x_new, y_osize,y_nsize, y_new))) return rS;
- //lens
- if((rS=_kit_coreVectorResizeLensY(Vector, 0,x_new, y_old,y_new))) return rS;
- return 0;
- }
- static inline int _kit_coreVectorSubZ(kit_coreVector* Vector,
- lens_t x_new, lens_t y_new, lens_t z_osize,
- lens_t z_nsize, lens_t z_new)
- { _vectorLogOP(" SubZ");
- int rS; //(r)eturn(S)tatus
- if((rS=_kit_coreVectorResizeZ(Vector, 0,x_new, 0,y_new, z_osize,z_nsize, z_new))) return rS;
- //lens
- _kit_coreVectorResizeLensZ(Vector, 0,x_new, 0,y_new, z_new); //returns void
- return 0;
- }
- static inline int _kit_coreVectorSubXY(kit_coreVector** Vector_p,
- lens_t x_new, lens_t x_old, lens_t y_old,
- lens_t x_osize, lens_t x_nsize,
- lens_t y_new, lens_t y_osize, lens_t y_nsize)
- { _vectorLogOP("SubXY");
- kit_coreVector* Vector=*Vector_p; int rS; //(r)eturn(S)tatus
- _kit_coreVectorFreeZinY(Vector, x_new,x_old, 0,y_old);
- _kit_coreVectorFreeYinX(Vector, x_new,x_old);
- if((rS=_kit_coreVectorResizeX(Vector_p, x_osize,x_nsize, x_new))) return rS;
- _kit_coreVectorFreeZinY(Vector, 0,x_new, y_new,y_old);
- return _kit_coreVectorResizeY(Vector, 0,x_new, y_osize,y_nsize, y_new);
- }
- static inline int _kit_coreVectorSubYZ(kit_coreVector* Vector,
- lens_t x_new, lens_t y_new, lens_t y_old,
- lens_t y_osize, lens_t y_nsize,
- lens_t z_osize, lens_t z_nsize, lens_t z_new)
- { _vectorLogOP("SubYZ");
- int rS; //(r)eturn(S)tatus
- _kit_coreVectorFreeZinY(Vector, 0,x_new, y_new,y_old);
- if((rS=_kit_coreVectorResizeY(Vector, 0,x_new, y_osize,y_nsize, y_new))) return rS;
- return _kit_coreVectorResizeZ(Vector, 0,x_new, 0,y_new, z_osize,z_nsize, z_new);
- }
- static inline int _kit_coreVectorSubXZ(kit_coreVector** Vector_p,
- lens_t x_new, lens_t x_old, lens_t y_new,
- lens_t x_osize, lens_t x_nsize,
- lens_t z_osize, lens_t z_nsize, lens_t z_new)
- { _vectorLogOP("SubXZ");
- kit_coreVector* Vector=*Vector_p; int rS; //(r)eturn(S)tatus
- _kit_coreVectorFreeZinY(Vector, x_new,x_old, 0,y_new);
- _kit_coreVectorFreeYinX(Vector, x_new,x_old);
- if((rS=_kit_coreVectorResizeX(Vector_p, x_osize,x_nsize, x_new))) return rS;
- return _kit_coreVectorResizeZ(Vector, 0,x_new, 0,y_new, z_osize,z_nsize, z_new);
- }
- static inline int _kit_coreVectorSubXYZ(kit_coreVector** Vector_p,
- lens_t x_new, lens_t x_old, lens_t y_old,
- lens_t x_osize, lens_t x_nsize,
- lens_t y_new, lens_t y_osize, lens_t y_nsize,
- lens_t z_osize, lens_t z_nsize, lens_t z_new)
- { _vectorLogOP("SubXYZ");
- kit_coreVector* Vector=*Vector_p; int rS; //(r)eturn(S)tatus
- _kit_coreVectorFreeZinY(Vector, x_new,x_old, 0,y_old);
- _kit_coreVectorFreeYinX(Vector, x_new,x_old);
- if((rS=_kit_coreVectorResizeX(Vector_p, x_osize,x_nsize, x_new))) return rS;
- _kit_coreVectorFreeZinY(Vector, 0,x_new, y_new,y_old);
- if((rS=_kit_coreVectorResizeY(Vector, 0,x_new, y_osize,y_nsize, y_new))) return rS;
- return _kit_coreVectorResizeZ(Vector, 0,x_new, 0,y_new, z_osize,z_nsize, z_new);
- }
- static inline int _kit_coreVectorAddX(kit_coreVector** Vector_p,
- lens_t x_old, lens_t x_new, lens_t x_osize, lens_t x_nsize,
- lens_t y_new, lens_t y_nsize,
- lens_t z_new, lens_t z_nsize)
- { _vectorLogOP(" AddX");
- int rS; //(r)eturn(S)tatus
- if((rS=_kit_coreVectorResizeX(Vector_p, x_osize,x_nsize, x_new))) return rS;
- kit_coreVector* Vector=*Vector_p;
- if((rS=_kit_coreVectorResizeY(Vector, x_old,x_new, 0,y_nsize, y_new))) return rS;
- if((rS=_kit_coreVectorResizeZ(Vector, x_old,x_new, 0,y_new, 0,z_nsize, z_new))) return rS;
- //lens
- if((rS=_kit_coreVectorResizeLensX(Vector, x_old,x_new))) return rS;
- if((rS=_kit_coreVectorResizeLensY(Vector, x_old,x_new, 0,y_new))) return rS;
- //(lens z resize unnecessary for addition)
- return 0;
- }
- static inline int _kit_coreVectorAddY(kit_coreVector* Vector,
- lens_t x_new,
- lens_t y_old, lens_t y_new, lens_t y_osize, lens_t y_nsize,
- lens_t z_new, lens_t z_nsize)
- { _vectorLogOP(" AddY");
- int rS; //(r)eturn(S)tatus
- if((rS=_kit_coreVectorResizeY(Vector, 0,x_new, y_osize,y_nsize, y_new))) return rS;
- if((rS=_kit_coreVectorResizeZ(Vector, 0,x_new, y_old,y_new, 0,z_nsize, z_new))) return rS;
- //lens
- if((rS=_kit_coreVectorResizeLensY(Vector, 0,x_new, y_old,y_new))) return rS;
- //(lens z resize unnecessary for addition)
- return 0;
- }
- static inline int _kit_coreVectorAddZ(kit_coreVector* Vector,
- lens_t x_new,
- lens_t y_new,
- lens_t z_new, lens_t z_osize, lens_t z_nsize)
- { _vectorLogOP(" AddZ");
- int rS; //(r)eturn(S)tatus
- if((rS=_kit_coreVectorResizeZ(Vector, 0,x_new, 0,y_new, z_osize,z_nsize, z_new))) return rS;
- //(lens z resize unnecessary for addition)
- return 0;
- }
- static inline int _kit_coreVectorAddXY(kit_coreVector** Vector_p,
- lens_t x_old, lens_t x_new, lens_t x_osize, lens_t x_nsize,
- lens_t y_old, lens_t y_new, lens_t y_osize, lens_t y_nsize,
- lens_t z_new, lens_t z_nsize)
- { _vectorLogOP("AddXY");
- kit_coreVector* Vector=*Vector_p; int rS; //(r)eturn(S)tatus
- if((rS=_kit_coreVectorAddY(Vector, x_new, y_osize,y_nsize,
- y_new,y_old, z_nsize, z_new))) return rS;
- if((rS=_kit_coreVectorAddX(Vector_p, x_osize,x_nsize, x_new,x_old,
- y_nsize,y_new, z_nsize, z_new))) return rS;
- return 0;
- }
- static inline int _kit_coreVectorAddYZ(kit_coreVector* Vector,
- lens_t x_new,
- lens_t y_old, lens_t y_new, lens_t y_osize, lens_t y_nsize,
- lens_t z_new, lens_t z_osize, lens_t z_nsize)
- { _vectorLogOP("AddYZ");
- int rS; //(r)eturn(S)tatus
- if((rS=_kit_coreVectorAddY(Vector, x_new, y_osize,y_nsize,
- y_new,y_old, z_nsize, z_new))) return rS;
- if((rS=_kit_coreVectorAddZ(Vector, x_new, y_new, z_osize,z_nsize, z_new))) return rS;
- return 0;
- }
- static inline int _kit_coreVectorAddXZ(kit_coreVector** Vector_p,
- lens_t x_old, lens_t x_new, lens_t x_osize, lens_t x_nsize,
- lens_t y_new, lens_t y_nsize,
- lens_t z_new, lens_t z_osize, lens_t z_nsize)
- { _vectorLogOP("AddXZ");
- kit_coreVector* Vector=*Vector_p; int rS; //(r)eturn(S)tatus
- if((rS=_kit_coreVectorAddX(Vector_p, x_osize,x_nsize, x_new,x_old,
- y_nsize,y_new, z_nsize, z_new))) return rS;
- if((rS=_kit_coreVectorAddZ(Vector, x_new, y_new, z_osize,z_nsize, z_new))) return rS;
- return 0;
- }
- static inline int _kit_coreVectorAddXYZ(kit_coreVector** Vector_p,
- lens_t x_old, lens_t x_new, lens_t x_osize, lens_t x_nsize,
- lens_t y_old, lens_t y_new, lens_t y_osize, lens_t y_nsize,
- lens_t z_new, lens_t z_osize, lens_t z_nsize)
- { _vectorLogOP("AddXYZ");
- kit_coreVector* Vector=*Vector_p; int rS; //(r)eturn(S)tatus
- if((rS=_kit_coreVectorAddX(Vector_p, x_osize,x_nsize, x_new,x_old,
- y_nsize,y_new, z_nsize, z_new))) return rS;
- if((rS=_kit_coreVectorAddY(Vector, x_new, y_osize,y_nsize,
- y_new,y_old, z_nsize, z_new))) return rS;
- if((rS=_kit_coreVectorAddZ(Vector, x_new, y_new, z_osize,z_nsize, z_new))) return rS;
- }
- //_<0(unchanged)/N(egative)/P(ositive)><X/Y/Z>
- #define _0X (0x0000)
- #define _NX (0x1000)
- #define _PX (0x3000)
- #define _0Y (0x0000)
- #define _NY (0x0100)
- #define _PY (0x0300)
- #define _0Z (0x0000)
- #define _NZ (0x0010)
- #define _PZ (0x0030)
- #define _VADECISION(_action) \
- if((returnStatus=_action)){ goto _error_; }
- #define _VADECISION_B(_action) _VADECISION(_action) break;
- //add to or subtract from size
- int kit_coreVectorAdd(kit_coreVector** Vector_p, diffs_t x_add, diffs_t y_add, diffs_t z_add){
- if(!x_add && !y_add && !z_add) return 0;
- int returnStatus=0;
- _IF_SDLERR_I(Vector_p==NULL,-1,;,"!Vector_p")
- kit_coreVector* Vector=*Vector_p;
- _IF_SDLERR_I(Vector==NULL,-2,;,"!*Vector_p")
- lens_t unit=Vector->unit;
- lens_t x_old=Vector->x, y_old=Vector->y, z_old=Vector->z;
- _IF_SDLERR_I( (!z_old)&&(z_add!=0) ,-3,;,"z!=0&& !3D")
- else _IF_SDLERR_I( (!y_old)&&(y_add!=0) ,-4,;,"y!=0 && 1D")
- lens_t x_new=x_old+x_add, y_new=y_old+y_add, z_new=z_old+z_add;
- _IF_SDLERR_I( (!z_old)!=(!z_new) ,-5,;,"z axis flp")
- else _IF_SDLERR_I( (!y_old)!=(!y_new) ,-6,;,"y axis flp")
- //check for any underflows and overflows respectively (and some dimension error checks)
- //x
- _IF_SDLERR_I( ((x_add<0)&&(x_new>x_old)) || !x_new ,-7,;,"x==0")
- _IF_SDLERR_I( (x_add>0)&&(x_new<x_old) ,-8,;,"x overflow")
- //y
- if(y_add<0 && (y_new>y_old)) y_new=0; //set to 0 in event of underflow
- else _IF_SDLERR_I( (y_add>0)&&(y_new<y_old) ,-9,;,"y overflow")
- else _IF_SDLERR_I( (y_new==0)&&(z_new>0) ,-10,;,"y==0&& z>0")
- //z
- if((z_add<0) && (z_new>z_old)) z_new=0; //set to 0 in event of underflow
- else _IF_SDLERR_I( (z_add>0)&&(z_new<z_old) ,-11,;,"z overflow")
- lens_t x_unit, y_unit, z_unit;
- x_unit=y_unit=z_unit = sizeof(void*);
- int dims=(x_new!=0)+(y_new!=0)+(z_new!=0); //dim(ension)s
- if(dims==1) x_unit=unit;
- else if(dims==2) y_unit=unit;
- else /*(dims==3)*/ z_unit=unit;
- lens_t x_osize=x_unit*x_old, y_osize=y_unit*y_old, z_osize=z_unit*z_old;
- lens_t x_nsize=x_unit*x_new, y_nsize=y_unit*y_new, z_nsize=z_unit*z_new;
- int decision;
- decision =( ((x_add>0)<<1)|(x_add!=0) )<<12; //0x0000 -> 0x3000
- decision|=( ((y_add>0)<<1)|(y_add!=0) )<< 8; //0x0000 -> 0x0300
- decision|=( ((z_add>0)<<1)|(z_add!=0) )<< 4; //0x0000 -> 0x0030
- switch(decision){
- //SUB
- case (_NX|_0Y|_0Z): //_NX_0Y_0Z; technically a superset of: (n/a)
- _VADECISION_B(_kit_coreVectorSubX(&Vector,x_new,x_old,y_new,x_osize,x_nsize))
- case (_0X|_NY|_0Z): //_0X_NY_0Z; technically a superset of: (n/a)
- _VADECISION_B(_kit_coreVectorSubY(Vector,x_new,y_new,y_old,y_osize,y_nsize))
- case (_0X|_0Y|_NZ): //_0X_0Y_NZ; technically a superset of: (n/a)
- _VADECISION_B(_kit_coreVectorSubZ(Vector,x_new,y_new,z_osize,z_nsize,z_new))
- /*
- case (_NX|_NY|_0Z): //_NX_NY_0Z; technically a superset of: (_NX_0Y_0Z,_0X_NY_0Z)
- _VADECISION_B(_kit_coreVectorSubXY(&Vector,x_new,x_old,y_old,x_osize,x_nsize,y_new,y_osize,y_nsize))
- case (_0X|_NY|_NZ): //_0X_NY_NZ; technically a superset of: (_0X_NY_0Z,_0X_0Y_NZ)
- _VADECISION_B(_kit_coreVectorSubYZ(Vector,x_new,y_new,y_old,y_osize,y_nsize,z_osize,z_nsize,z_new))
- case (_NX|_0Y|_NZ): //_NX_0Y_NZ; technically a superset of: (_NX_0Y_0Z,_0X_0Y_NZ)
- _VADECISION_B(_kit_coreVectorSubXZ(&Vector,x_new,x_old,y_new,x_osize,x_nsize,z_osize,z_nsize,z_new))
- case (_NX|_NY|_NZ): //_NX_NY_NZ; technically a superset of: (_NX_NY_0Z,_0X_0Y_NZ)
- _VADECISION_B(_kit_coreVectorSubXYZ(&Vector,x_new,x_old,y_old,x_osize,x_nsize,y_new,y_osize,y_nsize,z_osize,z_nsize,z_new))
- */
- //ADD
- case (_PX|_0Y|_0Z): //_PX_0Y_0Z; technically a superset of: (n/a)
- _VADECISION_B(_kit_coreVectorAddX(&Vector, x_old,x_new,x_osize,x_nsize, y_new,y_nsize, z_new,z_nsize))
- case (_0X|_PY|_0Z): //_0X_PY_0Z; technically a superset of: (n/a)
- _VADECISION_B(_kit_coreVectorAddY(Vector, x_new, y_old,y_new, y_osize,y_nsize, z_new,z_nsize))
- case (_0X|_0Y|_PZ): //_0X_0Y_PZ; technically a superset of: (n/a)
- _VADECISION_B(_kit_coreVectorAddZ(Vector, x_new, y_new, z_new,z_osize,z_nsize))
- case (_PX|_PY|_0Z): //_PX_PY_0Z; technically a superset of: (_PX_0Y_0Z,_0X_PY_0Z)
- _VADECISION_B(_kit_coreVectorAddXY(&Vector, x_old,x_new,x_osize,x_nsize, y_old,y_new,y_osize,y_nsize, z_new,z_nsize))
- /*
- case (_0X|_PY|_PZ): //_0X_PY_PZ; technically a superset of: (_0X_PY_0Z,_0X_0Y_PZ)
- _VADECISION_B(_kit_coreVectorAddYZ())
- case (_PX|_0Y|_PZ): //_PX_0Y_PZ; technically a superset of: (_PX_0Y_0Z,_0X_0Y_PZ)
- _VADECISION_B(_kit_coreVectorAddXZ())
- case (_PX|_PY|_PZ): //_PX_PY_PZ; technically a superset of: (_PX_PY_0Z,_0X_0Y_PZ)
- _VADECISION_B(_kit_coreVectorAddXYZ())
- //SUBX ADDYZ
- case (_NX|_PY|_0Z): //_NX_PY_0Z; technically a superset of: (_NX_0Y_0Z, _0X_PY_0Z)
- _VADECISION( _kit_coreVectorSubX())
- _VADECISION_B(_kit_coreVectorAddY())
- case (_NX|_0Y|_PZ): //_NX_0Y_PZ; technically a superset of: (_NX_0Y_0Z, _0X_0Y_PZ)
- _VADECISION( _kit_coreVectorSubX())
- _VADECISION_B(_kit_coreVectorAddZ())
- case (_NX|_PY|_PZ): //_NX_PY_PZ; technically a superset of: (_NX_0Y_0Z, _0X_PY_PZ)
- _VADECISION( _kit_coreVectorSubX())
- _VADECISION_B(_kit_coreVectorAddYZ())
- //SUBY ADDXZ
- case (_PX|_NY|_0Z): //_PX_NY_0Z; technically a superset of: (_0X_NY_0Z, _PX_0Y_0Z)
- //x_new is swapped for x_old here (see line 5)
- _VADECISION( _kit_coreVectorSubY())
- _VADECISION_B(_kit_coreVectorAddX())
- case (_0X|_NY|_PZ): //_0X_NY_PZ; technically a superset of: (_0X_NY_0Z, _0X_0Y_PZ)
- _VADECISION( _kit_coreVectorSubY())
- _VADECISION_B(_kit_coreVectorAddZ())
- case (_PX|_NY|_PZ): //_PX_NY_PZ; technically a superset of: (_0X_NY_0Z, _PX_0Y_PZ)
- //x_new is swapped for x_old here (see line 5)
- _VADECISION( _kit_coreVectorSubY())
- _VADECISION_B(_kit_coreVectorAddXZ())
- //SUBZ ADDXY
- case (_PX|_0Y|_NZ): //_PX_0Y_NZ; technically a superset of: (_0X_0Y_NZ, _PX_0Y_0Z)
- //x_new is swapped for x_old here (see line 5)
- _VADECISION( _kit_coreVectorSubZ())
- _VADECISION_B(_kit_coreVectorAddX())
- case (_0X|_PY|_NZ): //_0X_PY_NZ; technically a superset of: (_0X_0Y_NZ, _0X_PY_0Z)
- //y_new is swapped for y_old here (see line 5)
- _VADECISION( _kit_coreVectorSubZ())
- _VADECISION_B(_kit_coreVectorAddY())
- case (_PX|_PY|_NZ): //_PX_PY_NZ; technically a superset of: (_0X_0Y_NZ, _PX_PY_0Z)
- //x_new,y_new is swapped for x_old,y_old here respectively (see line 5)
- _VADECISION( _kit_coreVectorSubZ())
- _VADECISION_B(_kit_coreVectorAddXY())
- //SUBXYZ ADDXYZ
- case (_NX|_NY|_PZ): //_NX_NY_PZ; technically a superset of: (_NX_NY_0Z, _0X_0Y_PZ)
- _VADECISION( _kit_coreVectorSubXY())
- _VADECISION_B(_kit_coreVectorAddZ())
- case (_PX|_NY|_NZ): //_PX_NY_NZ; technically a superset of: (_0X_NY_NZ, _PX_0Y_0Z)
- //x_new is swapped for x_old here (see line 5)
- _VADECISION( _kit_coreVectorSubYZ())
- _VADECISION_B(_kit_coreVectorAddX())
- case (_NX|_PY|_NZ): //_NX_PY_NZ; technically a superset of: (_NX_0Y_NZ, _0X_PY_0Z)
- //y_new is swapped for y_old here (see line 5)
- _VADECISION( _kit_coreVectorSubXZ())
- _VADECISION_B(_kit_coreVectorAddY())
- */
- default: _IS_SDLERR_I(-15,;,"deflt:%X",decision)
- } *Vector_p=Vector;
- _error_:
- return returnStatus;
- }
- //set new size (if an axis == 0, then leave that axis unchanged)
- //also, if the new axis length is the same as the old one, leave it unchanged also
- int kit_coreVectorSet(kit_coreVector** Vector_p, lens_t x_new, lens_t y_new, lens_t z_new){
- int returnStatus=-1;
- _IF_SDLERR(Vector_p==NULL,;,"!Vector_p")
- kit_coreVector* Vector=*Vector_p;
- _IF_SDLERR(Vector==NULL,;,"!*Vector_p")
- diffs_t x_diff=(x_new==0) ? 0 : x_new-Vector->x;
- diffs_t y_diff=(y_new==0) ? 0 : y_new-Vector->y;
- diffs_t z_diff=(z_new==0) ? 0 : z_new-Vector->z;
- returnStatus=kit_coreVectorAdd(Vector_p, x_diff,y_diff,z_diff);
- _error_:
- return returnStatus;
- }
- lens_t kit_coreVectorAppend1D(kit_coreVector** Vector_p, void* src){ //TBD
- lens_t newIndex=-1;
- _IF_SDLERR(Vector_p==NULL,;,"!Vector_p")
- kit_coreVector* Vector=*Vector_p;
- _IF_SDLERR(Vector==NULL,;,"!*Vector_p")
- _IF_SDLERR((Vector->_dims&3)!=1,;,"vector!=1D")
- _IF_GOTO_ERROR(kit_coreVectorAdd(&Vector, 1,0,0),;)
- newIndex=Vector->x-1; lens_t unitSize=Vector->unit;
- void* dst=Vector->p1d + newIndex*unitSize;
- SDL_memcpy(dst, src, unitSize);
- *Vector_p=Vector;
- _error_:
- return newIndex;
- }
- lens_t kit_coreVectorAppend2D(kit_coreVector** Vector_p, void* src, lens_t x_pos){ //TBD
- lens_t newIndex=-1;
- _IF_SDLERR(Vector_p==NULL,;,"!Vector_p")
- kit_coreVector* Vector=*Vector_p;
- _IF_SDLERR(Vector==NULL,;,"!*Vector_p")
- _IF_SDLERR((Vector->_dims&3)!=2,;,"vector!=2D")
- /*
- newIndex=y_lengths[x_pos]; lens_t unitSize=Vector->unit;
- if(newIndex > (Vector->y-1)) _IF_GOTO_ERROR(kit_coreVectorAdd(&Vector, 0,1,0),newIndex=-1)
- void* dst=Vector->p2d[x_pos] + newIndex*unitSize;
- SDL_memcpy(dst, src, unitSize);
- ++y_lengths[x_pos];
- *Vector_p=Vector;
- */
- _error_:
- return newIndex;
- }
- lens_t kit_coreVectorAppend3D(kit_coreVector** Vector_p, void* src, lens_t x_pos, lens_t y_pos){ //TBD
- lens_t newIndex=-1;
- _IF_SDLERR(Vector_p==NULL,;,"!Vector_p")
- kit_coreVector* Vector=*Vector_p;
- _IF_SDLERR(Vector==NULL,;,"!*Vector_p")
- _IF_SDLERR((Vector->_dims&3)!=3,;,"vector!=3D")
- /*
- newIndex=yz_lengths[x_pos][y_pos]; lens_t unitSize=Vector->unit;
- if(newIndex > (Vector->z-1)) _IF_GOTO_ERROR(kit_coreVectorAdd(&Vector, 0,0,1),newIndex=-1)
- void* dst=Vector->p3d[x_pos][y_pos] + newIndex*unitSize;
- SDL_memcpy(dst, src, unitSize);
- ++yz_lengths[x_pos][y_pos];
- *Vector_p=Vector;
- */
- _error_:
- return newIndex;
- }
- lens_t kit_coreVectorAppend(kit_coreVector** Vector_p, void* src, lens_t x_pos, lens_t y_pos){ //TBD
- lens_t newIndex=-1;
- _IF_SDLERR(Vector_p==NULL,;,"!Vector_p")
- kit_coreVector* Vector=*Vector_p;
- _IF_SDLERR(Vector==NULL,;,"!*Vector_p")
- _IF_SDLERR((Vector->_dims&3)==0,;,"vector==0D")
- lens_t dimensions=Vector->_dims&3;
- if( dimensions==1) newIndex=kit_coreVectorAppend1D(Vector_p, src);
- else if(dimensions==2) newIndex=kit_coreVectorAppend2D(Vector_p, src, x_pos);
- else if(dimensions==3) newIndex=kit_coreVectorAppend3D(Vector_p, src, x_pos, y_pos);
- _error_:
- return newIndex;
- }
- int kit_coreVectorDestroy(kit_coreVector** Vector_p){
- int returnStatus=0;
- _IF_SDLERR_I(Vector_p==NULL,-1,;,"!Vector_p")
- kit_coreVector* Vector=*Vector_p;
- _IF_SDLERR_I(Vector==NULL,-2,;,"!*Vector_p")
- int x=Vector->x, y=Vector->y; //z=Vector->z;
- int condition = Vector->_dims&=3;
- if(!condition) condition = (x!=0)+(y!=0)+(Vector->z!=0);
- _IF_SDLERR_I(!condition,-3,;,"vector=0D")
- //condition must be equal to the number of dimensions (1=1d,2=2d,3=3d)
- switch(condition){
- case 3: _kit_coreVectorFreeZinY(Vector, 0,x, 0,y);
- _kit_coreVectorFreeLensYinX(Vector, 0,x); SDL_FALLTHROUGH;
- case 2: _kit_coreVectorFreeYinX(Vector, 0,x);
- if(Vector->lens.r2D != NULL) SDL_free(Vector->lens.r2D); SDL_FALLTHROUGH;
- case 1: SDL_free(Vector); //frees Vector->p1d too
- } *Vector_p=NULL;
- _error_: return returnStatus;
- }
- kit_coreVector* kit_coreVectorCreate(lens_t x, lens_t y, lens_t z, lens_t unit, Uint64 type_n){
- kit_coreVector* Vector=NULL;
- _IF_SDLERR(x==0,;,"x==0")
- _IF_SDLERR(unit==0,;,"unit==0")
- //x axis
- size_t x_size=(!y && !z) ? unit*x : sizeof(void*)*x;
- _IF_SDLERR(_kit_coreVectorRealloc(&Vector,0, 0,sizeof(kit_coreVector)+x_size),;,"!x axis")
- Vector->p1d=(void*)Vector + sizeof(kit_coreVector); //actual array is ahead by this many bytes
- Vector->_dims=U64_MSb; //sign bit will be unset on success
- ++Vector->_dims; //vector now contains an x axis
- //y axis
- _IF_SDLERR(y==0 && z>0,;,"y==0&& z>0")
- if(y>0){ ++Vector->_dims; //vector now contains a y axis
- size_t y_size=(!z) ? unit*y : sizeof(void*)*y;
- _IF_SDLERR(_kit_coreVectorResizeY(Vector, 0,x, 0,y_size, y),;,"!y axis")
- }
- //z axis
- if(z>0){ ++Vector->_dims; //vector now contains a z axis
- _IF_SDLERR(_kit_coreVectorResizeZ(Vector, 0,x, 0,y, 0,unit*z, z),;,"!z axis")
- }
- /*
- //tbd: test for 1d and 2d VectorAdd ops
- //allocate lens
- //(if vector is 1D, lens.r1D is already set to 0 with the previous memset)
- int dims=Vector->_dims&3;
- if(dims==2){ //2D
- _IF_SDLERR(_kit_coreVectorRealloc(&Vector->lens.r2D,0, 0,x*sizeof(lens_t)),;,"!r2D")
- } else if(dims==3){ //3D
- _IF_SDLERR(_kit_coreVectorRealloc(&Vector->lens.r3D,0, 0,x*sizeof(lens_t*)),;,"!r3D")
- lens_t** r3D=Vector->lens.r3D;
- for(lens_t xi=0; xi<x; ++xi){
- _IF_SDLERR(_kit_coreVectorRealloc(&r3D[xi],0, 0,y*sizeof(lens_t)),;,"!r2D")
- }
- }*/
- Vector->_dims&=U64_MSbC; //unset sign bit to indicate success
- Vector->type.n=type_n&U64_MSBC; //set last byte to 0 for interpretation as string
- Vector->x=x, Vector->y=y, Vector->z=z;
- Vector->unit=unit;
- _error_:
- if((Vector!=NULL) && (Vector->_dims<0)) kit_coreVectorDestroy(&Vector);
- return Vector;
- }
- #if defined(_KIT_CORE_DEBUG) || defined(_KIT_ALL_DEBUG)
- extern int printf(const char*,...);
- void _kit_coreVectorPrintInt(kit_coreVector* Vector,const char* prefix){
- if(Vector==NULL && prefix!=NULL){ kit_coreLog("%s: Vector cannot be NULL", prefix); return; }
- lens_t x_s=Vector->x, y_s=Vector->y, z_s=Vector->z; void* ptr=Vector->ptr;
- Sint32 *i1d=ptr, **i2d=ptr, ***i3d=ptr, dims=Vector->_dims&3;
- lens_t xi=0, yi=0, zi=0;
- //test fill
- if(dims!=3) goto _n3d_fs;
- for(zi=0; zi<z_s; ++zi){ _n3d_fs: if(dims==1) goto _n2d_fs;
- for(yi=0; yi<y_s; ++yi){ _n2d_fs:
- for(xi=0; xi<x_s; ++xi){
- switch(dims){
- case 1: i1d[xi] =xi; break;
- case 2: i2d[xi][yi] =(xi<<4)|yi; break;
- case 3: i3d[xi][yi][zi]=((xi+zi)<<4)|(yi+zi); }
- } if(dims==1) goto _n2d_fe;
- } _n2d_fe: if(dims!=3) goto _n3d_fe;
- } _n3d_fe:
- //print
- if(prefix==NULL) return; //now printing is optional!
- printf("%s: %u,%u,%u (%uD)\n", prefix, x_s,y_s,z_s, dims);
- if(dims!=3) goto _n3d_ps;
- for(zi=0; zi<z_s; ++zi){ _n3d_ps: if(dims==1) goto _n2d_ps;
- for(yi=0; yi<y_s; ++yi){ _n2d_ps: if(!zi) printf("0");
- for(xi=0; xi<x_s; ++xi){
- switch(dims){
- case 1: printf("%X,",i1d[xi]); break;
- case 2: printf("%X,",i2d[xi][yi]); break;
- case 3: printf("%X,",i3d[xi][yi][zi]); }
- } if(dims==1) goto _n2d_pe;
- printf("\n");
- } _n2d_pe: if(dims!=3) goto _n3d_pe;
- printf("\n");
- } _n3d_pe: printf("\n");
- }
- void _kit_coreVectorPrintLens(kit_coreVector* Vector, const char* prefix){
- if(Vector==NULL && prefix!=NULL){ kit_coreLog("%s: Vector cannot be NULL", prefix); return; }
- lens_t x_s=Vector->x, y_s=Vector->y; void* r_D=Vector->lens.r3D;
- if(r_D == NULL) return;
- int dims=Vector->_dims&3;
- if(dims<=1) return;
- if(dims==2){
- //test fill
- lens_t* r2D=r_D;
- for(lens_t xi=0; xi<y_s; ++xi) r2D[xi]=xi;
- //print
- if(prefix==NULL) return;
- printf("%s: %u (%uD)\n", prefix, x_s, dims);
- for(lens_t xi=0; xi<y_s; ++xi) printf("%02X,",r2D[xi]);
- } else {
- //test fill
- lens_t** r3D=r_D;
- for(lens_t xi=0; xi<x_s; ++xi){
- for(lens_t yi=0; yi<y_s; ++yi){
- r3D[xi][yi]=(xi<<4)|yi;
- }
- }
- //print
- if(prefix==NULL) return;
- printf("%s: %u,%u (%uD)\n", prefix, x_s,y_s, dims);
- for(lens_t xi=0; xi<x_s; ++xi){
- for(lens_t yi=0; yi<y_s; ++yi){
- printf("%02X,",r3D[xi][yi]);
- } printf("\n");
- }
- }
- printf("\n");
- }
- int kit_coreVectorTest(){
- int returnStatus=0;
- kit_coreVector* Vector=NULL; SDL_SetError("(no error)");
- //(x,y,z) test creation and destruction
- //0,0,0 (should error)
- _vectorLogT("testing creation of vector of size 0,0,0 (should error):");
- Vector=kit_coreVectorCreate(0,0,0, sizeof(Uint32),STR_U64("U32"));
- _IF_GOTO_ERROR(Vector!=NULL,;)
- _vectorLogT(" error = \"%s\"",SDL_GetError());
- //0,0,2 (should error)
- _vectorLogT("testing creation of vector of size 0,0,2 (should error):");
- Vector=kit_coreVectorCreate(0,0,2, sizeof(Uint32),STR_U64("U32"));
- _IF_GOTO_ERROR(Vector!=NULL,;)
- _vectorLogT(" error = \"%s\"",SDL_GetError());
- //0,2,0 (should error)
- _vectorLogT("testing creation of vector of size 0,2,0 (should error):");
- Vector=kit_coreVectorCreate(0,2,0, sizeof(Uint32),STR_U64("U32"));
- _IF_GOTO_ERROR(Vector!=NULL,;)
- _vectorLogT(" error = \"%s\"",SDL_GetError());
- //0,2,2 (should error)
- _vectorLogT("testing creation of vector of size 0,2,2 (should error):");
- Vector=kit_coreVectorCreate(0,2,2, sizeof(Uint32),STR_U64("U32"));
- _IF_GOTO_ERROR(Vector!=NULL,;)
- _vectorLogT(" error = \"%s\"",SDL_GetError());
- //2,0,0
- _vectorLogT("testing creation of vector of size 2,0,0:");
- Vector=kit_coreVectorCreate(2,0,0, sizeof(Uint32),STR_U64("U32"));
- _IF_GOTO_ERROR(Vector==NULL,;)
- _kit_coreVectorPrintInt(Vector,NULL); //test fill
- _vectorLogT(" attempting to destroy vector");
- _IF_GOTO_ERROR(kit_coreVectorDestroy(&Vector),;)
- //2,0,2 (should error)
- _vectorLogT("testing creation of vector of size 2,0,2 (should error):");
- Vector=kit_coreVectorCreate(2,0,2, sizeof(Uint32),STR_U64("U32"));
- _IF_GOTO_ERROR(Vector!=NULL,;)
- _vectorLogT(" error = \"%s\"",SDL_GetError());
- //2,2,0
- _vectorLogT("testing creation of vector of size 2,2,0:");
- Vector=kit_coreVectorCreate(2,2,0, sizeof(Uint32),STR_U64("U32"));
- _IF_GOTO_ERROR(Vector==NULL,;)
- _kit_coreVectorPrintInt(Vector,NULL); //test fill
- _vectorLogT(" attempting to destroy vector");
- _IF_GOTO_ERROR(kit_coreVectorDestroy(&Vector),;)
- //2,2,2
- _vectorLogT("testing creation of vector of size 2,2,2:");
- Vector=kit_coreVectorCreate(2,2,2, sizeof(Uint32),STR_U64("U32"));
- _IF_GOTO_ERROR(Vector==NULL,;)
- _kit_coreVectorPrintInt(Vector,NULL); //test fill
- _vectorLogT(" attempting to destroy vector");
- _IF_GOTO_ERROR(kit_coreVectorDestroy(&Vector),;)
- //test array 1D->3D accesses
- for(Uint32 dims=1; dims<=3; ++dims){
- _vectorLogT("testing %uD array accesses...",dims);
- //test multiple times each to (hopefully) catch any undefined behavior
- Vector=kit_coreVectorCreate(4,4*(dims>=2),4*(dims==3), sizeof(Uint32),STR_U64("U32"));
- _IF_GOTO_ERROR(Vector==NULL,;)
- //(will in theory throw something like an access violation error on failure)
- for(Uint32 i=0; i<20; ++i) _kit_coreVectorPrintInt(Vector,NULL);
- _vectorLogT(" attempting to destroy vector");
- _IF_GOTO_ERROR(kit_coreVectorDestroy(&Vector),;)
- }
- //test 1D -> 3D VectorAdd resizing
- for(Uint32 dims=1; dims<=3; ++dims){
- for(Sint32 x0=-1; x0<=1; ++x0){
- for(Sint32 y0=-1; y0<=1; ++y0){
- for(Sint32 z0=-1; z0<=1; ++z0){
- for(Sint32 x1=-1; x1<=1; ++x1){
- for(Sint32 y1=-1; y1<=1; ++y1){
- for(Sint32 z1=-1; z1<=1; ++z1){
- _vectorLogT("(%u,%u,%u) (%uD):", 5,5*(dims>=2),5*(dims==3), dims);
- kit_coreVector* v=kit_coreVectorCreate(5,5*(dims>=2),5*(dims==3),sizeof(Uint32),0);
- //first x0
- if(kit_coreVectorAdd(&v, x0,y0,z0)){
- _vectorLogT("0: (%2i,%2i,%2i) -> (%2i,%2i,%2i): \"%s\"",
- x0,y0,z0, x1,y1,z1, SDL_GetError());
- } else {
- _vectorLogT("0: (%2i,%2i,%2i) -> (%2i,%2i,%2i)", x0,y0,z0, x1,y1,z1);
- _kit_coreVectorPrintInt(v,NULL);
- _kit_coreVectorPrintLens(v,NULL);
- }
- //second x0
- if(kit_coreVectorAdd(&v, x0,y0,z0)){
- _vectorLogT("1: (%2i,%2i,%2i) -> (%2i,%2i,%2i): \"%s\"",
- x0,y0,z0, x1,y1,z1, SDL_GetError());
- } else {
- _vectorLogT("1: (%2i,%2i,%2i) -> (%2i,%2i,%2i)", x0,y0,z0, x1,y1,z1);
- _kit_coreVectorPrintInt(v,NULL);
- _kit_coreVectorPrintLens(v,NULL);
- }
- //first x1
- if(kit_coreVectorAdd(&v, x1,y1,z1)){
- _vectorLogT("0: (%2i,%2i,%2i) -> (%2i,%2i,%2i): \"%s\"",
- x0,y0,z0, x1,y1,z1, SDL_GetError());
- } else {
- _vectorLogT("0: (%2i,%2i,%2i) -> (%2i,%2i,%2i)", x0,y0,z0, x1,y1,z1);
- _kit_coreVectorPrintInt(v,NULL);
- _kit_coreVectorPrintLens(v,NULL);
- }
- //second x1
- if(kit_coreVectorAdd(&v, x1,y1,z1)){
- _vectorLogT("1: (%2i,%2i,%2i) -> (%2i,%2i,%2i): \"%s\"",
- x0,y0,z0, x1,y1,z1, SDL_GetError());
- } else {
- _vectorLogT("1: (%2i,%2i,%2i) -> (%2i,%2i,%2i)", x0,y0,z0, x1,y1,z1);
- _kit_coreVectorPrintInt(v,NULL);
- _kit_coreVectorPrintLens(v,NULL);
- }
- kit_coreVectorDestroy(&v);
- }}}
- }}}
- }
- //test 1D -> 3D VectorSet resizing (maybe)
- //test copy (TBD)
- //test append (TBD)
- //1D
- //2D
- //3D
- ++returnStatus;
- _error_:
- --returnStatus;
- if(returnStatus){
- _vectorLogT("failed; error = \"%s\"",SDL_GetError());
- } else if(Vector != NULL){
- _vectorLogT("attempting to destroy vector");
- if(kit_coreVectorDestroy(&Vector))
- _vectorLogT("failed; error = \"%s\"",SDL_GetError());
- }
- return returnStatus;
- }
- #else
- void _kit_coreVectorPrintInt(kit_coreVector* Vector,const char* prefix){
- kit_coreLog("%s: \"_KIT_CORE_DEBUG\" was not defined during compilation of kit_core",prefix);
- }
- int kit_coreVectorTest(){
- kit_coreLog("\"_KIT_CORE_DEBUG\" was not defined during compilation of kit_core");
- SDL_SetError("!defined(_KIT_CORE_DEBUG)");
- return -1;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement