Support final access on haxe4. Resolves #17.
This commit is contained in:
@@ -40,6 +40,22 @@ abstract Member(Field) from Field to Field {
|
||||
public var isStatic(get, set):Bool;
|
||||
public var isPublic(get, set):Null<Bool>;
|
||||
public var isBound(get, set):Null<Bool>;
|
||||
#if haxe4
|
||||
/**
|
||||
* Setting this to true will erase any getters/setters.
|
||||
*/
|
||||
public var isFinal(get, set):Bool;
|
||||
function get_isFinal() return hasAccess(AFinal);
|
||||
function set_isFinal(param) {
|
||||
if (setAccess(AFinal, param)) //TODO: perhaps also do something about AInline
|
||||
switch kind {
|
||||
case FProp(_, _, t, e):
|
||||
kind = FVar(t, e);
|
||||
default:
|
||||
}
|
||||
return param;
|
||||
}
|
||||
#end
|
||||
|
||||
public function getFunction()
|
||||
return
|
||||
@@ -111,21 +127,10 @@ abstract Member(Field) from Field to Field {
|
||||
inline function set_pos(param) return this.pos = param;
|
||||
|
||||
inline function get_overrides() return hasAccess(AOverride);
|
||||
inline function set_overrides(param) {
|
||||
changeAccess(
|
||||
param ? AOverride : null,
|
||||
param ? null : AOverride
|
||||
);
|
||||
return param;
|
||||
}
|
||||
inline function set_overrides(param) return setAccess(AOverride, param);
|
||||
|
||||
inline function get_isStatic() return hasAccess(AStatic);
|
||||
function set_isStatic(param) {
|
||||
changeAccess(
|
||||
param ? AStatic : null,
|
||||
param ? null : AStatic
|
||||
);
|
||||
return param;
|
||||
}
|
||||
inline function set_isStatic(param) return setAccess(AStatic, param);
|
||||
|
||||
function get_isPublic() {
|
||||
if (this.access != null)
|
||||
@@ -180,6 +185,15 @@ abstract Member(Field) from Field to Field {
|
||||
return false;
|
||||
}
|
||||
|
||||
function setAccess(a:Access, isset:Bool) {
|
||||
changeAccess(
|
||||
isset ? a : null,
|
||||
isset ? null : a
|
||||
);
|
||||
return isset;
|
||||
}
|
||||
|
||||
|
||||
function changeAccess(add:Access, remove:Access) {
|
||||
var i = 0;
|
||||
if (this.access == null)
|
||||
|
@@ -23,14 +23,22 @@ class Sisyphus {
|
||||
if (cf.params.length == 0) {
|
||||
name: cf.name,
|
||||
doc: cf.doc,
|
||||
access: cf.isPublic ? [ APublic ] : [ APrivate ],
|
||||
access:
|
||||
(cf.isPublic ? [ APublic ] : [ APrivate ])
|
||||
#if haxe4 .concat(if (cf.isFinal) [AFinal] else []) #end
|
||||
,
|
||||
kind: switch([ cf.kind, cf.type ]) {
|
||||
#if haxe4
|
||||
case [ FVar(_, _), ret ] if (cf.isFinal):
|
||||
FVar(toComplexType(ret), null);
|
||||
#end
|
||||
case [ FVar(read, write), ret ]:
|
||||
FProp(
|
||||
varAccessToString(read, "get"),
|
||||
varAccessToString(write, "set"),
|
||||
toComplexType(ret),
|
||||
null);
|
||||
null
|
||||
);
|
||||
case [ FMethod(_), TFun(args, ret) ]:
|
||||
FFun({
|
||||
args: [
|
||||
|
Reference in New Issue
Block a user