0 cost template instantiation

jfondren julian.fondren at gmail.com
Thu Sep 30 03:13:28 UTC 2021


On Thursday, 30 September 2021 at 02:31:50 UTC, Hipreme wrote:
> https://github.com/MrcSnm/HipremeEngine/tree/hotload/api
>
> You may try messing at the module api.graphics.g2d.renderer2d
>
> There is a function called initG2D
>
> Try changing it from loadSymbols to each one loadSymbol.
>
> You can just dub at the folder api.

The version I checked out, 2874073b54, doesn't have a loadSymbols.

As provided, loadSymbol without the "static if":

965K libhipengine_api.a

with `mixin(loadSymbol("name"))` instead of a template:

749K libhipengine_api.a

https://gist.github.com/jrfondren/d776ccffb105f464b53c53712656a1d3

That's probably disappointing, since it's a much less pleasant 
interface, but what you could do is take the both entire 
`extern(C) void function() beginSprite; ... 
loadSymbol!beginSprite;` blocks and put them in one string 
literal that you process with a function and mixin once. Now 
instead of an annoying macro alternative you have a DSL for 
DLL-extern functions.


More information about the Digitalmars-d-learn mailing list