Fix alignment/ids output
This commit is contained in:
@@ -4252,6 +4252,20 @@ func (r *valueResolver) resolveValue(row map[string]any, field string, value any
|
||||
return tlkCompiledValue{Value: value}, nil
|
||||
}
|
||||
}
|
||||
if _, hasAlignments := typed["alignments"]; hasAlignments {
|
||||
encoded, err := encodeConfiguredAlignmentSetMask(typed, defaultExplicitAlignmentSetMaskEncoding())
|
||||
if err != nil {
|
||||
return tlkCompiledValue{}, fmt.Errorf("field %s: %w", field, err)
|
||||
}
|
||||
return tlkCompiledValue{Value: encoded}, nil
|
||||
}
|
||||
if _, hasIDs := typed["ids"]; hasIDs {
|
||||
value, err := r.encodeConfiguredIDHexList(typed, defaultExplicitIDHexListEncoding())
|
||||
if err != nil {
|
||||
return tlkCompiledValue{}, fmt.Errorf("field %s: %w", field, err)
|
||||
}
|
||||
return tlkCompiledValue{Value: value}, nil
|
||||
}
|
||||
if refID, ok := typed["id"]; ok {
|
||||
if refKey, ok := refID.(string); ok && strings.Contains(refKey, ":") {
|
||||
id, ok := r.keyToID[refKey]
|
||||
@@ -4413,6 +4427,24 @@ func encodeConfiguredAlignmentSetMask(raw any, encoding project.TopDataValueEnco
|
||||
return "0x" + fmt.Sprintf("%0*X", encoding.HexWidth, mask), nil
|
||||
}
|
||||
|
||||
func defaultExplicitAlignmentSetMaskEncoding() project.TopDataValueEncodingConfig {
|
||||
return project.TopDataValueEncodingConfig{
|
||||
Mode: "alignment_set_mask",
|
||||
Min: 0,
|
||||
Max: 511,
|
||||
HexWidth: 3,
|
||||
}
|
||||
}
|
||||
|
||||
func defaultExplicitIDHexListEncoding() project.TopDataValueEncodingConfig {
|
||||
return project.TopDataValueEncodingConfig{
|
||||
Mode: "id_hex_list",
|
||||
Min: 0,
|
||||
Max: 65535,
|
||||
HexWidth: 4,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *valueResolver) encodeConfiguredIDHexList(obj map[string]any, encoding project.TopDataValueEncodingConfig) (string, error) {
|
||||
mode := strings.TrimSpace(encoding.Mode)
|
||||
if mode != "id_hex_list" {
|
||||
|
||||
Reference in New Issue
Block a user