MCPcopy Create free account
hub / github.com/d1ll0n/stack-packer / applyGroupAccessCoder

Function applyGroupAccessCoder

src/code-gen/fields.ts:78–97  ·  view source on GitHub ↗
(
  group: GroupType,
  fields: ProcessedField[],
  groupCoderLocation: 'get' | 'set'
)

Source from the content-addressed store, hash-verified

76}
77
78export const applyGroupAccessCoder = (
79 group: GroupType,
80 fields: ProcessedField[],
81 groupCoderLocation: 'get' | 'set'
82) => {
83 const groupCoderType = groupCoderLocation === 'get'
84 ? group.accessors?.getterCoderType
85 : group.accessors?.setterCoderType;
86
87 for (let i = 0; i < fields.length; i++) {
88 const field = fields[i]
89 const member = group.members[i]
90 // If group member defines coder type, it will override the group's coder type
91 // and the coder type of the original field in the struct.
92 // If group defines coder type, it will override the coder type of the original
93 // field in the struct.
94 if (member.coderType) applyCoderType(field, member.coderType);
95 else if (groupCoderType) applyCoderType(field, groupCoderType);
96 }
97}
98
99export const applyCoderType = (field: ProcessedField, coderType: CoderType) => {
100 field.coderType = coderType;

Callers 2

getDecodeGroupFunctionFunction · 0.90
getEncodeGroupFunctionFunction · 0.90

Calls 1

applyCoderTypeFunction · 0.85

Tested by

no test coverage detected