I use sokol-nim, more object and member name are too longer ,
var passAction = PassAction(
colors: [
ColorAttachmentAction( loadAction: loadActionClear, storeAction: storeActionStore, clearValue: (1, 0, 0, 0)),
ColorAttachmentAction( loadAction: loadActionClear, storeAction: storeActionStore, clearValue: (10, 0, 10, 0)),
ColorAttachmentAction( loadAction: loadActionClear, storeAction: storeActionStore, clearValue: (10, 10, 10, 10)),
]
)
Must write full member name and value, Really don't like this why can't like tuple easy get a object (aaa, bbb)
I assume you mean https://github.com/floooh/sokol-nim ? And yeah, that seems annoying, but why not write a constructor-proc then?
The following is pseudo-code I wrote on the fly and did not try to compile, should be enough to get the idea across though
proc newColorAttachmentAction(loadAction: LoadActionType, storeAction: StoreActionType, clearValue: ClearValueType): ColorAttachmentAction =
return ColorAttachmentAction(loadAction: loadAction, storeAction: storeAction, clearValue: clearValue)
And then you can use
var passAction = PassAction(
colors: [
newColorAttachementAction(loadActionClear, storeActionStore, (1, 0, 0, 0)),
newColorAttachementAction(loadActionClear, storeActionStore, (10, 0, 10, 0)),
newColorAttachementAction(loadActionClear, storeActionStore, (10, 10, 10, 10)),
]
)
To automatically have those generated for you, you can try and use https://github.com/beef331/constructor
It look like well,
I can often easy get object when I use importc pragma and c language struct all small, So many people want to simply get object even without "importc pragma" can easy get object too
type xxx = object {.importc "...".}
a,b,c:int
f: float
var x = xxx(10,20,30,2.2f)