df-structures
df-structures copied to clipboard
extending codegen to support instantiations of arbitrary templates
at the moment i'm looking at something akin to this:
<template-instance template-name='name'>
contents are then either
<type-parameter>
a simple type
or
a compound (which will be redued to a T_
type and used as the parameter)
or
a subordinate template-instance (for nested template instances)
</type-parameter>
or
<type-parameter type-name='...'/>
which is a shorthand
this is repeated as many times as appropriate
</template-instance>
<stl-variant>
would then be an alias for <template-instance template-name='std::variant'>
there's a further extension (to be done later) for dealing with function types (which is what the type parameter of std::function
is) that i'm thinking will be repurposing the existing vmethod
tag
we'll probably eventually want to be able to declare templates as well; there is at least one template type in g_src
now -- we're ignoring that it's a template because all of the instances are binary-compatible so we can pretend they're all the same type, but this can't be counted on being the case forever, but this isn't immediately needed so that's a future thought
anyway, thoughts welcome none of this is set in stone, and i got nowhere when i tried a first pass at implementing this yesterday so i'm still at square one in this regard
Originally posted by @ab9rf in https://github.com/DFHack/df-structures/issues/686#issuecomment-1926402886
a compound (which will be redued to a T_ type and used as the parameter)
My guess is that this can be a lower priority. We can always define our own types, and defining types inline in template arguments isn't valid like it is for class fields - neither of these compile:
std::vector<struct { field a; }>
std::variant<struct { field a; }, struct { field b; }>