diff options
Diffstat (limited to 'tests/manyloc/keineschweine/dependencies')
8 files changed, 118 insertions, 127 deletions
diff --git a/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim b/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim index d079a2e72..493a2106c 100644 --- a/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim +++ b/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim @@ -74,7 +74,7 @@ type contacts*: PContact stamp*: TTimestamp handler*: PCollisionHandler - swappedColl*: bool32 + swappedColl*: Bool32 state*: TArbiterState PCollisionHandler* = ptr TCollisionHandler TCollisionHandler*{.pf.} = object @@ -108,7 +108,7 @@ type #/ Collision begin event function callback type. #/ Returning false from a begin callback causes the collision to be ignored until #/ the the separate callback is called when the objects stop colliding. - TCollisionBeginFunc* = proc (arb: PArbiter; space: PSpace; data: pointer): Bool{. + TCollisionBeginFunc* = proc (arb: PArbiter; space: PSpace; data: pointer): bool{. cdecl.} #/ Collision pre-solve event function callback type. #/ Returning false from a pre-step callback causes the collision to be ignored until the next step. @@ -142,14 +142,14 @@ type PSpatialIndex = ptr TSpatialIndex TSpatialIndex{.pf.} = object klass: PSpatialIndexClass - bbfunc: TSpatialIndexBBFunc + bbfun: TSpatialIndexBBFunc staticIndex: PSpatialIndex dynamicIndex: PSpatialIndex TSpatialIndexDestroyImpl* = proc (index: PSpatialIndex){.cdecl.} TSpatialIndexCountImpl* = proc (index: PSpatialIndex): cint{.cdecl.} TSpatialIndexEachImpl* = proc (index: PSpatialIndex; - func: TSpatialIndexIteratorFunc; data: pointer){. + fun: TSpatialIndexIteratorFunc; data: pointer){. cdecl.} TSpatialIndexContainsImpl* = proc (index: PSpatialIndex; obj: pointer; hashid: THashValue): Bool32 {.cdecl.} @@ -161,15 +161,15 @@ type TSpatialIndexReindexObjectImpl* = proc (index: PSpatialIndex; obj: pointer; hashid: THashValue){.cdecl.} TSpatialIndexReindexQueryImpl* = proc (index: PSpatialIndex; - func: TSpatialIndexQueryFunc; data: pointer){.cdecl.} + fun: TSpatialIndexQueryFunc; data: pointer){.cdecl.} TSpatialIndexPointQueryImpl* = proc (index: PSpatialIndex; point: TVector; - func: TSpatialIndexQueryFunc; + fun: TSpatialIndexQueryFunc; data: pointer){.cdecl.} TSpatialIndexSegmentQueryImpl* = proc (index: PSpatialIndex; obj: pointer; - a: TVector; b: TVector; t_exit: CpFloat; func: TSpatialIndexSegmentQueryFunc; + a: TVector; b: TVector; t_exit: CpFloat; fun: TSpatialIndexSegmentQueryFunc; data: pointer){.cdecl.} TSpatialIndexQueryImpl* = proc (index: PSpatialIndex; obj: pointer; - bb: TBB; func: TSpatialIndexQueryFunc; + bb: TBB; fun: TSpatialIndexQueryFunc; data: pointer){.cdecl.} PSpatialIndexClass* = ptr TSpatialIndexClass TSpatialIndexClass*{.pf.} = object @@ -279,14 +279,14 @@ type PSegmentQueryInfo* = ptr TSegmentQueryInfo #/ Segment query info struct. TSegmentQueryInfo*{.pf.} = object - shape*: PShape #/ The shape that was hit, NULL if no collision occured. + shape*: PShape #/ The shape that was hit, NULL if no collision occurred. t*: CpFloat #/ The normalized distance along the query segment in the range [0, 1]. n*: TVector #/ The normal of the surface hit. TShapeType*{.size: sizeof(cint).} = enum CP_CIRCLE_SHAPE, CP_SEGMENT_SHAPE, CP_POLY_SHAPE, CP_NUM_SHAPES TShapeCacheDataImpl* = proc (shape: PShape; p: TVector; rot: TVector): TBB{.cdecl.} TShapeDestroyImpl* = proc (shape: PShape){.cdecl.} - TShapePointQueryImpl* = proc (shape: PShape; p: TVector): bool32 {.cdecl.} + TShapePointQueryImpl* = proc (shape: PShape; p: TVector): Bool32 {.cdecl.} TShapeSegmentQueryImpl* = proc (shape: PShape; a: TVector; b: TVector; info: PSegmentQueryInfo){.cdecl.} PShapeClass* = ptr TShapeClass @@ -427,7 +427,7 @@ defGetter(PSpace, CpFloat, currDt, CurrentTimeStep) #/ returns true from inside a callback and objects cannot be added/removed. -proc isLocked*(space: PSpace): Bool{.inline.} = +proc isLocked*(space: PSpace): bool{.inline.} = result = space.locked.bool #/ Set a default collision handler for this space. @@ -478,24 +478,24 @@ proc removeBody*(space: PSpace; body: PBody){. proc RemoveConstraint*(space: PSpace; constraint: PConstraint){. cdecl, importc: "cpSpaceRemoveConstraint", dynlib: Lib.} #/ Test if a collision shape has been added to the space. -proc containsShape*(space: PSpace; shape: PShape): Bool{. +proc containsShape*(space: PSpace; shape: PShape): bool{. cdecl, importc: "cpSpaceContainsShape", dynlib: Lib.} #/ Test if a rigid body has been added to the space. -proc containsBody*(space: PSpace; body: PBody): Bool{. +proc containsBody*(space: PSpace; body: PBody): bool{. cdecl, importc: "cpSpaceContainsBody", dynlib: Lib.} #/ Test if a constraint has been added to the space. -proc containsConstraint*(space: PSpace; constraint: PConstraint): Bool{. +proc containsConstraint*(space: PSpace; constraint: PConstraint): bool{. cdecl, importc: "cpSpaceContainsConstraint", dynlib: Lib.} #/ Schedule a post-step callback to be called when cpSpaceStep() finishes. #/ @c obj is used a key, you can only register one callback per unique value for @c obj -proc addPostStepCallback*(space: PSpace; func: TPostStepFunc; +proc addPostStepCallback*(space: PSpace; fun: TPostStepFunc; obj: pointer; data: pointer){. cdecl, importc: "cpSpaceAddPostStepCallback", dynlib: Lib.} #/ Query the space at a point and call @c func for each shape found. proc pointQuery*(space: PSpace; point: TVector; layers: TLayers; - group: TGroup; func: TSpacePointQueryFunc; data: pointer){. + group: TGroup; fun: TSpacePointQueryFunc; data: pointer){. cdecl, importc: "cpSpacePointQuery", dynlib: Lib.} #/ Query the space at a point and return the first shape found. Returns NULL if no shapes were found. @@ -506,7 +506,7 @@ proc pointQueryFirst*(space: PSpace; point: TVector; layers: TLayers; #/ Perform a directed line segment query (like a raycast) against the space calling @c func for each shape intersected. proc segmentQuery*(space: PSpace; start: TVector; to: TVector; layers: TLayers; group: TGroup; - func: TSpaceSegmentQueryFunc; data: pointer){. + fun: TSpaceSegmentQueryFunc; data: pointer){. cdecl, importc: "cpSpaceSegmentQuery", dynlib: Lib.} #/ Perform a directed line segment query (like a raycast) against the space and return the first shape hit. Returns NULL if no shapes were hit. proc segmentQueryFirst*(space: PSpace; start: TVector; to: TVector; @@ -517,26 +517,26 @@ proc segmentQueryFirst*(space: PSpace; start: TVector; to: TVector; #/ Perform a fast rectangle query on the space calling @c func for each shape found. #/ Only the shape's bounding boxes are checked for overlap, not their full shape. proc BBQuery*(space: PSpace; bb: TBB; layers: TLayers; group: TGroup; - func: TSpaceBBQueryFunc; data: pointer){. + fun: TSpaceBBQueryFunc; data: pointer){. cdecl, importc: "cpSpaceBBQuery", dynlib: Lib.} #/ Query a space for any shapes overlapping the given shape and call @c func for each shape found. -proc shapeQuery*(space: PSpace; shape: PShape; func: TSpaceShapeQueryFunc; data: pointer): Bool {. +proc shapeQuery*(space: PSpace; shape: PShape; fun: TSpaceShapeQueryFunc; data: pointer): bool {. cdecl, importc: "cpSpaceShapeQuery", dynlib: Lib.} #/ Call cpBodyActivate() for any shape that is overlaps the given shape. proc activateShapesTouchingShape*(space: PSpace; shape: PShape){. cdecl, importc: "cpSpaceActivateShapesTouchingShape", dynlib: Lib.} #/ Call @c func for each body in the space. -proc eachBody*(space: PSpace; func: TSpaceBodyIteratorFunc; data: pointer){. +proc eachBody*(space: PSpace; fun: TSpaceBodyIteratorFunc; data: pointer){. cdecl, importc: "cpSpaceEachBody", dynlib: Lib.} #/ Call @c func for each shape in the space. -proc eachShape*(space: PSpace; func: TSpaceShapeIteratorFunc; +proc eachShape*(space: PSpace; fun: TSpaceShapeIteratorFunc; data: pointer){. cdecl, importc: "cpSpaceEachShape", dynlib: Lib.} #/ Call @c func for each shape in the space. -proc eachConstraint*(space: PSpace; func: TSpaceConstraintIteratorFunc; +proc eachConstraint*(space: PSpace; fun: TSpaceConstraintIteratorFunc; data: pointer){. cdecl, importc: "cpSpaceEachConstraint", dynlib: Lib.} #/ Update the collision detection info for the static shapes in the space. @@ -674,7 +674,7 @@ proc dist*(v1, v2: TVector): CpFloat {.inline.} = proc distsq*(v1, v2: TVector): CpFloat {.inline.} = result = (v1 - v2).lenSq #vlengthsq(vsub(v1, v2)) #/ Returns true if the distance between v1 and v2 is less than dist. -proc near*(v1, v2: TVector; dist: CpFloat): Bool{.inline.} = +proc near*(v1, v2: TVector; dist: CpFloat): bool{.inline.} = result = v1.distSq(v2) < dist * dist @@ -706,13 +706,13 @@ proc Sleep*(body: PBody){.importc: "cpBodySleep", dynlib: Lib.} proc SleepWithGroup*(body: PBody; group: PBody){. importc: "cpBodySleepWithGroup", dynlib: Lib.} #/ Returns true if the body is sleeping. -proc isSleeping*(body: PBody): Bool {.inline.} = +proc isSleeping*(body: PBody): bool {.inline.} = return body.node.root != nil #/ Returns true if the body is static. proc isStatic*(body: PBody): bool {.inline.} = return body.node.idleTime == CpInfinity #/ Returns true if the body has not been added to a space. -proc isRogue*(body: PBody): Bool {.inline.} = +proc isRogue*(body: PBody): bool {.inline.} = return body.space == nil # #define CP_DefineBodyStructGetter(type, member, name) \ @@ -808,15 +808,15 @@ proc kineticEnergy*(body: PBOdy): CpFloat = result = (body.v.dot(body.v) * body.m) + (body.w * body.w * body.i) #/ Call @c func once for each shape attached to @c body and added to the space. -proc eachShape*(body: PBody; func: TBodyShapeIteratorFunc; +proc eachShape*(body: PBody; fun: TBodyShapeIteratorFunc; data: pointer){. cdecl, importc: "cpBodyEachShape", dynlib: Lib.} #/ Call @c func once for each constraint attached to @c body and added to the space. -proc eachConstraint*(body: PBody; func: TBodyConstraintIteratorFunc; +proc eachConstraint*(body: PBody; fun: TBodyConstraintIteratorFunc; data: pointer) {. cdecl, importc: "cpBodyEachConstraint", dynlib: Lib.} #/ Call @c func once for each arbiter that is currently active on the body. -proc eachArbiter*(body: PBody; func: TBodyArbiterIteratorFunc; +proc eachArbiter*(body: PBody; fun: TBodyArbiterIteratorFunc; data: pointer){. cdecl, importc: "cpBodyEachArbiter", dynlib: Lib.} #/ Allocate a spatial hash. @@ -824,10 +824,10 @@ proc SpaceHashAlloc*(): PSpaceHash{. cdecl, importc: "cpSpaceHashAlloc", dynlib: Lib.} #/ Initialize a spatial hash. proc SpaceHashInit*(hash: PSpaceHash; celldim: CpFloat; numcells: cint; - bbfunc: TSpatialIndexBBFunc; staticIndex: PSpatialIndex): PSpatialIndex{. + bbfun: TSpatialIndexBBFunc; staticIndex: PSpatialIndex): PSpatialIndex{. cdecl, importc: "cpSpaceHashInit", dynlib: Lib.} #/ Allocate and initialize a spatial hash. -proc SpaceHashNew*(celldim: CpFloat; cells: cint; bbfunc: TSpatialIndexBBFunc; +proc SpaceHashNew*(celldim: CpFloat; cells: cint; bbfun: TSpatialIndexBBFunc; staticIndex: PSpatialIndex): PSpatialIndex{. cdecl, importc: "cpSpaceHashNew", dynlib: Lib.} #/ Change the cell dimensions and table size of the spatial hash to tune it. @@ -842,18 +842,18 @@ proc SpaceHashResize*(hash: PSpaceHash; celldim: CpFloat; numcells: cint){. #/ Allocate a bounding box tree. proc BBTreeAlloc*(): PBBTree{.cdecl, importc: "cpBBTreeAlloc", dynlib: Lib.} #/ Initialize a bounding box tree. -proc BBTreeInit*(tree: PBBTree; bbfunc: TSpatialIndexBBFunc; +proc BBTreeInit*(tree: PBBTree; bbfun: TSpatialIndexBBFunc; staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{.cdecl, importc: "cpBBTreeInit", dynlib: Lib.} #/ Allocate and initialize a bounding box tree. -proc BBTreeNew*(bbfunc: TSpatialIndexBBFunc; staticIndex: PSpatialIndex): PSpatialIndex{. +proc BBTreeNew*(bbfun: TSpatialIndexBBFunc; staticIndex: PSpatialIndex): PSpatialIndex{. cdecl, importc: "cpBBTreeNew", dynlib: Lib.} #/ Perform a static top down optimization of the tree. proc BBTreeOptimize*(index: PSpatialIndex){. cdecl, importc: "cpBBTreeOptimize", dynlib: Lib.} #/ Set the velocity function for the bounding box tree to enable temporal coherence. -proc BBTreeSetVelocityFunc*(index: PSpatialIndex; func: TBBTreeVelocityFunc){. +proc BBTreeSetVelocityFunc*(index: PSpatialIndex; fun: TBBTreeVelocityFunc){. cdecl, importc: "cpBBTreeSetVelocityFunc", dynlib: Lib.} #MARK: Single Axis Sweep @@ -864,12 +864,12 @@ proc Sweep1DAlloc*(): ptr TSweep1D{.cdecl, importc: "cpSweep1DAlloc", dynlib: Lib.} #/ Initialize a 1D sort and sweep broadphase. -proc Sweep1DInit*(sweep: ptr TSweep1D; bbfunc: TSpatialIndexBBFunc; +proc Sweep1DInit*(sweep: ptr TSweep1D; bbfun: TSpatialIndexBBFunc; staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{.cdecl, importc: "cpSweep1DInit", dynlib: Lib.} #/ Allocate and initialize a 1D sort and sweep broadphase. -proc Sweep1DNew*(bbfunc: TSpatialIndexBBFunc; staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{. +proc Sweep1DNew*(bbfun: TSpatialIndexBBFunc; staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{. cdecl, importc: "cpSweep1DNew", dynlib: Lib.} @@ -1359,7 +1359,7 @@ defCProp(SlideJoint, TVector, anchr2, Anchr2) defCProp(SlideJoint, CpFloat, min, Min) defCProp(SlideJoint, CpFloat, max, Max) -proc pivotJointGetClass*(): PConstraintClass {. +proc PivotJointGetClass*(): PConstraintClass {. cdecl, importc: "cpPivotJointGetClass", dynlib: Lib.} #/ Allocate a pivot joint diff --git a/tests/manyloc/keineschweine/dependencies/enet/enet.nim b/tests/manyloc/keineschweine/dependencies/enet/enet.nim index df1b743ee..93857207a 100644 --- a/tests/manyloc/keineschweine/dependencies/enet/enet.nim +++ b/tests/manyloc/keineschweine/dependencies/enet/enet.nim @@ -20,7 +20,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. const Lib = "libenet.so.1(|.0.3)" -{.deadCodeElim: ON.} +{.deadCodeElim: on.} const ENET_VERSION_MAJOR* = 1 ENET_VERSION_MINOR* = 3 diff --git a/tests/manyloc/keineschweine/dependencies/genpacket/genpacket.nim b/tests/manyloc/keineschweine/dependencies/genpacket/genpacket.nim index ae9dfb39f..3026cc4b9 100644 --- a/tests/manyloc/keineschweine/dependencies/genpacket/genpacket.nim +++ b/tests/manyloc/keineschweine/dependencies/genpacket/genpacket.nim @@ -18,9 +18,9 @@ proc `$`*[T](x: seq[T]): string = result.add($x[i]) result.add ']' -macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = +macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = result = newNimNode(nnkStmtList) - let + let typeName = quoted2ident(typeNameN) packetID = ^"p" streamID = ^"s" @@ -66,7 +66,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = readBody = newNimNode(nnkStmtList) lenNames = 0 for i in 0.. typeFields.len - 1: - let + let name = typeFields[i][0] dotName = packetID.dot(name) resName = newIdentNode(!"result").dot(name) @@ -91,11 +91,11 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = newNimNode(nnkDiscardStmt).und( newCall("readData", streamID, newNimNode(nnkAddr).und(resName), newCall("sizeof", resName)))) packBody.add( - newCall("writeData", streamID, newNimNode(nnkAddr).und(dotName), newCall("sizeof", dotName))) + newCall("writeData", streamID, newNimNode(nnkAddr).und(dotName), newCall("sizeof", dotName))) of "seq": ## let lenX = readInt16(s) newLenName() - let + let item = ^"item" ## item name in our iterators seqType = typeFields[i][1][1] ## type of seq readName = newIdentNode("read"& $seqType.ident) @@ -107,7 +107,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = readBody.add( ## result.name = @[] resName := ("@".prefix(newNimNode(nnkBracket))), newNimNode(nnkForStmt).und( ## for item in 1..len: - item, + item, infix(1.lit, "..", lenName), newNimNode(nnkStmtList).und( newCall( ## add(result.name, unpack[seqType](stream)) @@ -117,7 +117,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = newNimNode(nnkVarSection).und(newNimNode(nnkIdentDefs).und( lenName, ## var lenName = int16(len(p.name)) newIdentNode("int16"), - newCall("int16", newCall("len", dotName)))), + newCall("int16", newCall("len", dotName)))), newCall("writeData", streamID, newNimNode(nnkAddr).und(lenName), 2.lit), newNimNode(nnkForStmt).und( ## for item in 0..length - 1: pack(p.name[item], stream) item, @@ -143,8 +143,8 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = readBody.add(resName := newCall("read"& $typeFields[i][1].ident, streamID)) else: error("I dont know what to do with: "& treerepr(typeFields[i])) - - var + + var toStringFunc = newNimNode(nnkProcDef).und( newNimNode(nnkPostfix).und( ^"*", @@ -161,12 +161,12 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = emptyNode(), newNimNode(nnkStmtList).und(#[6] newNimNode(nnkAsgn).und( - ^"result", ## result = + ^"result", ## result = newNimNode(nnkCall).und(#[6][0][1] ^"format", ## format emptyNode())))) ## "[TypeName $1 $2]" formatStr = "["& $typeName.ident - + const emptyFields = {nnkEmpty, nnkNilLit} var objFields = newNimNode(nnkRecList) for i in 0.. < len(typeFields): @@ -186,10 +186,10 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = prefix("$", packetID.dot(fname))) formatStr.add " $" formatStr.add($(i + 1)) - + formatStr.add ']' toStringFunc[6][0][1][1] = formatStr.lit() - + result.add( newNimNode(nnkTypeSection).und( newNimNode(nnkTypeDef).und( @@ -206,15 +206,15 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = when defined(GenPacketShowOutput): echo(repr(result)) -proc `->`(a: string, b: string): PNimrodNode {.compileTime.} = +proc `->`(a: string, b: string): NimNode {.compileTime.} = result = newNimNode(nnkIdentDefs).und(^a, ^b, newNimNode(nnkEmpty)) -proc `->`(a: string, b: PNimrodNode): PNimrodNode {.compileTime.} = +proc `->`(a: string, b: NimNode): NimNode {.compileTime.} = result = newNimNode(nnkIdentDefs).und(^a, b, newNimNode(nnkEmpty)) -proc `->`(a, b: PNimrodNode): PNimrodNode {.compileTime.} = +proc `->`(a, b: NimNode): NimNode {.compileTime.} = a[2] = b result = a -proc newProc*(name: string, params: varargs[PNimrodNode], resultType: PNimrodNode): PNimrodNode {.compileTime.} = +proc newProc*(name: string, params: varargs[NimNode], resultType: NimNode): NimNode {.compileTime.} = result = newNimNode(nnkProcDef).und( ^name, emptyNode(), @@ -227,7 +227,7 @@ proc newProc*(name: string, params: varargs[PNimrodNode], resultType: PNimrodNod macro forwardPacket*(typeName: expr, underlyingType: typedesc): stmt {.immediate.} = result = newNimNode(nnkStmtList).und( newProc( - "read"& $typeName.ident, + "read"& $typeName.ident, ["s" -> "PStream" -> newNimNode(nnkNilLit)], typeName), newProc( @@ -258,21 +258,21 @@ when isMainModule: A = 0'i8, B, C forwardPacket(SomeEnum, int8) - - + + defPacket(Foo, tuple[x: array[0..4, int8]]) var f = newFoo([4'i8, 3'i8, 2'i8, 1'i8, 0'i8]) var s2 = newStringStream("") f.pack(s2) assert s2.data == "\4\3\2\1\0" - + var s = newStringStream() s.flushImpl = proc(s: PStream) = var z = PStringStream(s) z.setPosition(0) z.data.setLen(0) - - + + s.setPosition(0) s.data.setLen(0) var o = B @@ -283,7 +283,7 @@ when isMainModule: o.pack(s) assert s.data == "\1\0\2" s.flush - + defPacket(Y, tuple[z: int8]) proc `$`(z: Y): string = result = "Y("& $z.z &")" defPacket(TestPkt, tuple[x: seq[Y]]) @@ -292,4 +292,4 @@ when isMainModule: for itm in test.x: echo(itm) test.pack(s) - echo(repr(s.data)) \ No newline at end of file + echo(repr(s.data)) diff --git a/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim b/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim index 44d00db53..7cfd67c49 100644 --- a/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim +++ b/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim @@ -9,18 +9,9 @@ template defPacketImports*(): stmt {.immediate, dirty.} = import macros, macro_dsl, estreams from strutils import format -proc `$`*[T](x: seq[T]): string = - result = "[seq len=" - result.add($x.len) - result.add ':' - for i in 0.. <len(x): - result.add " " - result.add($x[i]) - result.add ']' - -macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = +macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = result = newNimNode(nnkStmtList) - let + let typeName = quoted2ident(typeNameN) packetID = ^"p" streamID = ^"s" @@ -66,7 +57,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = readBody = newNimNode(nnkStmtList) lenNames = 0 for i in 0.. typeFields.len - 1: - let + let name = typeFields[i][0] dotName = packetID.dot(name) resName = newIdentNode(!"result").dot(name) @@ -76,7 +67,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = of "seq": ## let lenX = readInt16(s) newLenName() - let + let item = ^"item" ## item name in our iterators seqType = typeFields[i][1][1] ## type of seq readName = newIdentNode("read"& $seqType.ident) @@ -88,7 +79,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = readBody.add( ## result.name = @[] resName := ("@".prefix(newNimNode(nnkBracket))), newNimNode(nnkForStmt).und( ## for item in 1..len: - item, + item, infix(1.lit, "..", lenName), newNimNode(nnkStmtList).und( newCall( ## add(result.name, unpack[seqType](stream)) @@ -98,7 +89,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = newNimNode(nnkVarSection).und(newNimNode(nnkIdentDefs).und( lenName, ## var lenName = int16(len(p.name)) newIdentNode("int16"), - newCall("int16", newCall("len", dotName)))), + newCall("int16", newCall("len", dotName)))), newCall("writeBE", streamID, lenName), newNimNode(nnkForStmt).und( ## for item in 0..length - 1: pack(p.name[item], stream) item, @@ -124,8 +115,8 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = readBody.add(resName := newCall("read"& $typeFields[i][1].ident, streamID)) else: error("I dont know what to do with: "& treerepr(typeFields[i])) - - var + + var toStringFunc = newNimNode(nnkProcDef).und( newNimNode(nnkPostfix).und( ^"*", @@ -142,12 +133,12 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = emptyNode(), newNimNode(nnkStmtList).und(#[6] newNimNode(nnkAsgn).und( - ^"result", ## result = + ^"result", ## result = newNimNode(nnkCall).und(#[6][0][1] ^"format", ## format emptyNode())))) ## "[TypeName $1 $2]" formatStr = "["& $typeName.ident - + const emptyFields = {nnkEmpty, nnkNilLit} var objFields = newNimNode(nnkRecList) for i in 0.. < len(typeFields): @@ -167,10 +158,10 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = prefix("$", packetID.dot(fname))) formatStr.add " $" formatStr.add($(i + 1)) - + formatStr.add ']' toStringFunc[6][0][1][1] = formatStr.lit() - + result.add( newNimNode(nnkTypeSection).und( newNimNode(nnkTypeDef).und( @@ -187,7 +178,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = when defined(GenPacketShowOutput): echo(repr(result)) -proc newProc*(name: PNimrodNode; params: varargs[PNimrodNode]; resultType: PNimrodNode): PNimrodNode {.compileTime.} = +proc newProc*(name: NimNode; params: varargs[NimNode]; resultType: NimNode): NimNode {.compileTime.} = result = newNimNode(nnkProcDef).und( name, emptyNode(), @@ -198,15 +189,15 @@ proc newProc*(name: PNimrodNode; params: varargs[PNimrodNode]; resultType: PNimr newNimNode(nnkStmtList)) result[3].add(params) -proc body*(procNode: PNimrodNode): PNimrodNode {.compileTime.} = +proc body*(procNode: NimNode): NimNode {.compileTime.} = assert procNode.kind == nnkProcDef and procNode[6].kind == nnkStmtList result = procNode[6] -proc iddefs*(a, b: string; c: PNimrodNode): PNimrodNode {.compileTime.} = +proc iddefs*(a, b: string; c: NimNode): NimNode {.compileTime.} = result = newNimNode(nnkIdentDefs).und(^a, ^b, c) -proc iddefs*(a: string; b: PNimrodNode): PNimrodNode {.compileTime.} = +proc iddefs*(a: string; b: NimNode): NimNode {.compileTime.} = result = newNimNode(nnkIdentDefs).und(^a, b, emptyNode()) -proc varTy*(a: PNimrodNode): PNimrodNode {.compileTime.} = +proc varTy*(a: NimNode): NimNode {.compileTime.} = result = newNimNode(nnkVarTy).und(a) macro forwardPacket*(typeName: expr, underlyingType: expr): stmt {.immediate.} = @@ -215,7 +206,7 @@ macro forwardPacket*(typeName: expr, underlyingType: expr): stmt {.immediate.} = streamID = ^"s" result = newNimNode(nnkStmtList).und( newProc( - (^("read"& $typeName.ident)).postfix("*"), + (^("read"& $typeName.ident)).postfix("*"), [ iddefs("s", "PBuffer", newNimNode(nnkNilLit)) ], typeName), newProc( @@ -227,7 +218,7 @@ macro forwardPacket*(typeName: expr, underlyingType: expr): stmt {.immediate.} = readBody = result[0][6] packBody = result[1][6] resName = ^"result" - + case underlyingType.kind of nnkBracketExpr: case $underlyingType[0].ident @@ -259,21 +250,21 @@ when isMainModule: A = 0'i8, B, C forwardPacket(SomeEnum, int8) - - + + defPacket(Foo, tuple[x: array[0..4, int8]]) var f = newFoo([4'i8, 3'i8, 2'i8, 1'i8, 0'i8]) var s2 = newStringStream("") f.pack(s2) assert s2.data == "\4\3\2\1\0" - + var s = newStringStream() s.flushImpl = proc(s: PStream) = var z = PStringStream(s) z.setPosition(0) z.data.setLen(0) - - + + s.setPosition(0) s.data.setLen(0) var o = B @@ -284,7 +275,7 @@ when isMainModule: o.pack(s) assert s.data == "\1\0\2" s.flush - + defPacket(Y, tuple[z: int8]) proc `$`(z: Y): string = result = "Y("& $z.z &")" defPacket(TestPkt, tuple[x: seq[Y]]) @@ -293,4 +284,4 @@ when isMainModule: for itm in test.x: echo(itm) test.pack(s) - echo(repr(s.data)) \ No newline at end of file + echo(repr(s.data)) diff --git a/tests/manyloc/keineschweine/dependencies/genpacket/macro_dsl.nim b/tests/manyloc/keineschweine/dependencies/genpacket/macro_dsl.nim index c7b577b3d..d3a0c701d 100644 --- a/tests/manyloc/keineschweine/dependencies/genpacket/macro_dsl.nim +++ b/tests/manyloc/keineschweine/dependencies/genpacket/macro_dsl.nim @@ -1,42 +1,42 @@ import macros {.deadCodeElim: on.} #Inline macro.add() to allow for easier nesting -proc und*(a: PNimrodNode; b: PNimrodNode): PNimrodNode {.compileTime.} = +proc und*(a: NimNode; b: NimNode): NimNode {.compileTime.} = a.add(b) result = a -proc und*(a: PNimrodNode; b: varargs[PNimrodNode]): PNimrodNode {.compileTime.} = +proc und*(a: NimNode; b: varargs[NimNode]): NimNode {.compileTime.} = a.add(b) result = a -proc `^`*(a: string): PNimrodNode {.compileTime.} = +proc `^`*(a: string): NimNode {.compileTime.} = ## new ident node result = newIdentNode(!a) -proc `[]`*(a, b: PNimrodNode): PNimrodNode {.compileTime.} = +proc `[]`*(a, b: NimNode): NimNode {.compileTime.} = ## new bracket expression: node[node] not to be confused with node[indx] result = newNimNode(nnkBracketExpr).und(a, b) -proc `:=`*(left, right: PNimrodNode): PNimrodNode {.compileTime.} = +proc `:=`*(left, right: NimNode): NimNode {.compileTime.} = ## new Asgn node: left = right result = newNimNode(nnkAsgn).und(left, right) -proc lit*(a: string): PNimrodNode {.compileTime.} = +proc lit*(a: string): NimNode {.compileTime.} = result = newStrLitNode(a) -proc lit*(a: int): PNimrodNode {.compileTime.} = +proc lit*(a: int): NimNode {.compileTime.} = result = newIntLitNode(a) -proc lit*(a: float): PNimrodNode {.compileTime.} = +proc lit*(a: float): NimNode {.compileTime.} = result = newFloatLitNode(a) -proc lit*(a: char): PNimrodNode {.compileTime.} = +proc lit*(a: char): NimNode {.compileTime.} = result = newNimNode(nnkCharLit) result.intval = a.ord -proc emptyNode*(): PNimrodNode {.compileTime.} = +proc emptyNode*(): NimNode {.compileTime.} = result = newNimNode(nnkEmpty) -proc dot*(left, right: PNimrodNode): PNimrodNode {.compileTime.} = +proc dot*(left, right: NimNode): NimNode {.compileTime.} = result = newNimNode(nnkDotExpr).und(left, right) -proc prefix*(a: string, b: PNimrodNode): PNimrodNode {.compileTime.} = +proc prefix*(a: string, b: NimNode): NimNode {.compileTime.} = result = newNimNode(nnkPrefix).und(newIdentNode(!a), b) -proc quoted2ident*(a: PNimrodNode): PNimrodNode {.compileTime.} = +proc quoted2ident*(a: NimNode): NimNode {.compileTime.} = if a.kind != nnkAccQuoted: return a var pname = "" diff --git a/tests/manyloc/keineschweine/dependencies/genpacket/streams_enh.nim b/tests/manyloc/keineschweine/dependencies/genpacket/streams_enh.nim index a9759687f..3c5a7835c 100644 --- a/tests/manyloc/keineschweine/dependencies/genpacket/streams_enh.nim +++ b/tests/manyloc/keineschweine/dependencies/genpacket/streams_enh.nim @@ -1,5 +1,5 @@ import streams -from strutils import repeatChar +from strutils import repeat proc readPaddedStr*(s: PStream, length: int, padChar = '\0'): TaintedString = var lastChr = length @@ -10,7 +10,7 @@ proc readPaddedStr*(s: PStream, length: int, padChar = '\0'): TaintedString = proc writePaddedStr*(s: PStream, str: string, length: int, padChar = '\0') = if str.len < length: s.write(str) - s.write(repeatChar(length - str.len, padChar)) + s.write(repeat(padChar, length - str.len)) elif str.len > length: s.write(str.substr(0, length - 1)) else: @@ -37,7 +37,7 @@ when isMainModule: testStream.setPosition 0 testStream.writePaddedStr("Sup", 10) echo(repr(testStream), testStream.data.len) - doAssert testStream.data == "Sup"&repeatChar(7, '\0') + doAssert testStream.data == "Sup"&repeat('\0', 7) testStream.setPosition 0 res = testStream.readPaddedStr(10) diff --git a/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim b/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim index 0d09d40e3..1071ec767 100644 --- a/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim +++ b/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim @@ -221,10 +221,10 @@ type TTransform* {.pf.} = object matrix*: array[0..8, cfloat] TColor* {.pf.} = object - r*: Uint8 - g*: Uint8 - b*: Uint8 - a*: Uint8 + r*: uint8 + g*: uint8 + b*: uint8 + a*: uint8 PFloatRect* = ptr TFloatRect TFloatRect*{.pf.} = object left*: cfloat @@ -306,7 +306,7 @@ proc close*(window: PRenderWindow) {. proc isOpen*(window: PRenderWindow): bool {. cdecl, importc: "sfRenderWindow_isOpen", dynlib: LibG.} -#void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfUint8* pixels); +#void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfuint8* pixels); #proc setIcon*(window: PRenderWindow, width, height: cint, pixels: seq[uint8]) {. # cdecl, importc: "sfRenderWindow_setIcon", dynlib: LibG.} @@ -395,7 +395,7 @@ proc capture*(window: PRenderWindow): PImage {. cdecl, importc: "sfRenderWindow_capture", dynlib: LibG.} #Construct a new render texture -proc newRenderTexture*(width, height: cint; depthBuffer: Bool): PRenderTexture {. +proc newRenderTexture*(width, height: cint; depthBuffer: bool): PRenderTexture {. cdecl, importc: "sfRenderTexture_create", dynlib: LibG.} #Destroy an existing render texture proc destroy*(renderTexture: PRenderTexture){. @@ -522,9 +522,9 @@ proc copy*(font: PFont): PFont {. cdecl, importc: "sfFont_copy", dynlib: LibG.} proc destroy*(font: PFont) {. cdecl, importc: "sfFont_destroy", dynlib: LibG.} -proc getGlyph*(font: PFont, codePoint: Uint32, characterSize: cint, bold: bool): TGlyph{. +proc getGlyph*(font: PFont, codePoint: uint32, characterSize: cint, bold: bool): TGlyph{. cdecl, importc: "sfFont_getGlyph", dynlib: LibG.} -proc getKerning*(font: PFont, first: Uint32, second: Uint32, characterSize: cint): cint {. +proc getKerning*(font: PFont, first: uint32, second: uint32, characterSize: cint): cint {. cdecl, importc: "sfFont_getKerning", dynlib: LibG.} proc getLineSpacing*(font: PFont, characterSize: cint): cint {. cdecl, importc: "sfFont_getLineSpacing", dynlib: LibG.} @@ -882,7 +882,7 @@ proc getInverseTransform*(text: PText): TTransform {. cdecl, importc: "sfText_getInverseTransform", dynlib: LibG.} proc setString*(text: PText, string: cstring) {. cdecl, importc: "sfText_setString", dynlib: LibG.} -proc setUnicodeString*(text: PText, string: ptr Uint32) {. +proc setUnicodeString*(text: PText, string: ptr uint32) {. cdecl, importc: "sfText_setUnicodeString", dynlib: LibG.} proc setFont*(text: PText, font: PFont) {. cdecl, importc: "sfText_setFont", dynlib: LibG.} @@ -894,13 +894,13 @@ proc setColor*(text: PText, color: TColor) {. cdecl, importc: "sfText_setColor", dynlib: LibG.} proc getString*(text: PText): cstring {. cdecl, importc: "sfText_getString", dynlib: LibG.} -proc getUnicodeString*(text: PText): ptr Uint32 {.cdecl, +proc getUnicodeString*(text: PText): ptr uint32 {.cdecl, importc: "sfText_getUnicodeString", dynlib: LibG.} proc getFont*(text: PText): PFont {. cdecl, importc: "sfText_getFont", dynlib: LibG.} proc getCharacterSize*(text: PText): cint {. cdecl, importc: "sfText_getCharacterSize", dynlib: LibG.} -proc getStyle*(text: PText): Uint32 {. +proc getStyle*(text: PText): uint32 {. cdecl, importc: "sfText_getStyle", dynlib: LibG.} proc getColor*(text: PText): TColor {. cdecl, importc: "sfText_getColor", dynlib: LibG.} diff --git a/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim b/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim index 3cfd33c02..5aa017ac4 100644 --- a/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim +++ b/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim @@ -284,7 +284,7 @@ proc newSoundBuffer*(stream: PInputStream): PSoundBuffer{. #/ \brief Create a new sound buffer and load it from an array of samples in memory #/ #/ The assumed format of the audio samples is 16 bits signed integer -#/ (sfInt16). +#/ (sfint16). #/ #/ \param samples Pointer to the array of samples in memory #/ \param sampleCount Number of samples in the array @@ -334,7 +334,7 @@ proc saveToFile*(soundBuffer: PSoundBuffer; filename: cstring): bool {. #/ \brief Get the array of audio samples stored in a sound buffer #/ #/ The format of the returned samples is 16 bits signed integer -#/ (sfInt16). The total number of samples in this array +#/ (sfint16). The total number of samples in this array #/ is given by the sfSoundBuffer_getSampleCount function. #/ #/ \param soundBuffer Sound buffer object @@ -342,7 +342,7 @@ proc saveToFile*(soundBuffer: PSoundBuffer; filename: cstring): bool {. #/ \return Read-only pointer to the array of sound samples #/ #////////////////////////////////////////////////////////// -proc sfSoundBuffer_getSamples*(soundBuffer: PSoundBuffer): ptr Int16{. +proc sfSoundBuffer_getSamples*(soundBuffer: PSoundBuffer): ptr int16{. cdecl, importc: "sfSoundBuffer_getSamples", dynlib: Lib.} #////////////////////////////////////////////////////////// #/ \brief Get the number of samples stored in a sound buffer |