[macro] add setter in @:provide macro
This commit is contained in:
@@ -34,7 +34,7 @@ class ProvideMacro {
|
||||
name: field.name,
|
||||
access: [Access.APublic],
|
||||
pos: field.pos,
|
||||
kind: FieldType.FProp('get', 'never', type)
|
||||
kind: FieldType.FProp('get', 'set', type)
|
||||
});
|
||||
result.push({
|
||||
name: 'get_${field.name}',
|
||||
@@ -47,6 +47,17 @@ class ProvideMacro {
|
||||
ret: type
|
||||
})
|
||||
});
|
||||
result.push({
|
||||
name: 'set_${field.name}',
|
||||
access: [Access.APrivate, Access.AInline],
|
||||
pos: field.pos,
|
||||
kind: FieldType.FFun({
|
||||
args: [{name: 'value', type: type}],
|
||||
expr: Context.parse('{haxework.provider.Provider.set(${name}, value); return value;}', field.pos),
|
||||
params: [],
|
||||
ret: type
|
||||
})
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user