diff --git a/dscanner.ini b/dscanner.ini index ccdefb8..1463aac 100644 --- a/dscanner.ini +++ b/dscanner.ini @@ -94,3 +94,5 @@ unused_result="disabled" cyclomatic_complexity="disabled" ; Maximum cyclomatic complexity after which to issue warnings max_cyclomatic_complexity="15" +[analysis.config.ModuleFilters] +undocumented_declaration_check = "-shapes" diff --git a/dub.json b/dub.json index b64c6a0..c411fdf 100644 --- a/dub.json +++ b/dub.json @@ -6,11 +6,11 @@ ], "license": "MIT", "copyright": "Copyright © 2022, Chance Snow", - "targetType": "sourceLibrary", - "systemDependencies": "Playdate SDK >= 1.12.1", "subPackages": [ "./examples/shapes" ], + "systemDependencies": "Playdate SDK >= 1.12.1", + "targetType": "sourceLibrary", "configurations": [ { "name": "library", diff --git a/examples/shapes/source/app.d b/examples/shapes/source/app.d index c8c2a6c..cd1431e 100644 --- a/examples/shapes/source/app.d +++ b/examples/shapes/source/app.d @@ -17,6 +17,8 @@ mixin EventHandlerShim; @nogc nothrow: int eventHandler(PlaydateAPI* playdate, PDSystemEvent event, uint arg) { + assert(arg >= 0); + final switch (event) { case PDSystemEvent.init: pd = playdate; diff --git a/source/playdate/allocator.d b/source/playdate/allocator.d index e7bfef3..06c28ff 100644 --- a/source/playdate/allocator.d +++ b/source/playdate/allocator.d @@ -10,18 +10,18 @@ import playdate : PlaydateAPI; /// static PlaydateAPI* pd; -shared static this() { - import std.experimental.allocator: allocatorObject, theAllocator; - theAllocator = allocatorObject(PDAllocator.instance); -} +/// The global instance of this allocator +static PDAllocator theAllocator; /// Playdate heap allocator. /// Remarks: Adapted from std.experimental.allocator.mallocator struct PDAllocator { - import std.experimental.allocator.common: platformAlignment; + import std.algorithm : max; /// The alignment is a static constant equal to `platformAlignment`, which ensures proper alignment for any D data type. - enum uint alignment = platformAlignment; + /// + /// The alignment that is guaranteed to accommodate any D object allocation on the current platform. + enum uint alignment = max(double.alignof, real.alignof); @nogc nothrow: @@ -54,7 +54,4 @@ struct PDAllocator { b = p[0 .. s]; return true; } - - /// Returns: The global instance of this allocator type. - static PDAllocator instance; } diff --git a/source/playdate/package.d b/source/playdate/package.d index 1cd79f7..ddfb901 100644 --- a/source/playdate/package.d +++ b/source/playdate/package.d @@ -620,9 +620,7 @@ struct Graphics { } /// -int drawText( - Graphics* gfx, string text, int x, int y, PDStringEncoding encoding = PDStringEncoding.asciiEncoding -) { +int drawText(Graphics* gfx, string text, int x, int y, PDStringEncoding encoding = PDStringEncoding.utf8Encoding) { return gfx.drawText(text.ptr, text.length, encoding, x, y); } @@ -631,7 +629,7 @@ version (unittest) { extern (C) int drawTextTest(const void* text, size_t len, PDStringEncoding encoding, int x, int y) { assert(text == txt.ptr); assert(len == txt.length); - assert(encoding == PDStringEncoding.asciiEncoding); + assert(encoding == PDStringEncoding.utf8Encoding); assert(x >= 0); assert(y >= 0); return 0;