Permalink
Browse files

This still doesn't work, due to a bug in the compiler

There is a bug in ForceImplements that doesn't respect the fact that
it's an interface.
  • Loading branch information...
LadyCailin committed Nov 16, 2018
1 parent 0923fef commit 8041089ad634d60230d8efa2d8d487817a95fd2b
@@ -41,6 +41,7 @@
import com.laytonsmith.core.exceptions.ConfigCompileException;
import com.laytonsmith.core.exceptions.ConfigRuntimeException;
import com.laytonsmith.core.natives.interfaces.MEnumType;
import com.laytonsmith.core.natives.interfaces.MEnumTypeValue;
import com.laytonsmith.core.natives.interfaces.Mixed;
import com.laytonsmith.persistence.DataSourceFactory;
import com.laytonsmith.persistence.PersistenceNetwork;
@@ -193,13 +194,16 @@ public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntime
for(ClassMirror<? extends Enum> e : enums) {
if(e.getAnnotation(MEnum.class).getValue("value").equals(enumName)) {
MEnumType type = MEnumType.FromEnum(enumName, (Class<Enum<?>>) e.loadClass(), null, null);
a.push(type, t);
break;
for(MEnumTypeValue v : type.values()) {
a.push(v, t);
}
return a;
}
}
for(ClassMirror<? extends DynamicEnum> d : dEnums) {
if(d.getAnnotation(MDynamicEnum.class).getValue("value").equals(enumName)) {
for(DynamicEnum ee : (Collection<DynamicEnum>) ReflectionUtils.invokeMethod(d.loadClass(), null, "values")) {
// TODO: Not sure how to handle this now...
a.push(new CString(ee.name(), t), t);
}
break;
@@ -11,6 +11,7 @@
import com.laytonsmith.core.FullyQualifiedClassName;
import com.laytonsmith.core.SimpleDocumentation;
import com.laytonsmith.core.constructs.CClassType;
import com.laytonsmith.core.constructs.Construct;
import com.laytonsmith.core.constructs.Target;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -121,7 +122,7 @@ public boolean isInstanceOf(Class<? extends Mixed> type) {
@Override
public CClassType typeof() {
return CClassType.get(fqcn);
return CClassType.TYPE;
}
@Override
@@ -214,6 +215,69 @@ public String toString() {
return v.toString();
}
@Override
public CClassType typeof() {
return CClassType.get(fqcn);
}
@Override
public boolean isInstanceOf(CClassType type) throws ClassNotFoundException {
return Construct.isInstanceof(this, type);
}
@Override
public boolean isInstanceOf(Class<? extends Mixed> type) {
// This call doesn't make any sense?
throw new UnsupportedOperationException();
}
@Override
public CClassType getContainingClass() {
return null;
}
@Override
public Set<ObjectModifier> getObjectModifiers() {
return EnumSet.of(ObjectModifier.FINAL, ObjectModifier.STATIC, ObjectModifier.PUBLIC,
ObjectModifier.ABSTRACT);
}
@Override
public ObjectType getObjectType() {
return ObjectType.ENUM;
}
@Override
public CClassType[] getInterfaces() {
return new CClassType[0];
}
@Override
public CClassType[] getSuperclasses() {
return new CClassType[]{MEnumType.TYPE};
}
@Override
public Mixed clone() throws CloneNotSupportedException {
return this;
}
private Target t = Target.UNKNOWN;
@Override
public Target getTarget() {
return t;
}
@Override
public void setTarget(Target target) {
t = target;
}
@Override
public String val() {
return getName();
}
};
}
@@ -302,7 +366,8 @@ public Version since() {
@Override
public ObjectType getObjectType() {
return ObjectType.ENUM;
// The individual values in the enum are ENUM, but the container is a class
return ObjectType.CLASS;
}
@Override
@@ -6,7 +6,7 @@
*
* @author caismith
*/
public interface MEnumTypeValue extends Documentation {
public interface MEnumTypeValue extends Documentation, Mixed {
/**
* Returns the ordinal value for this entry. The ordinal value goes from 0 to size-1, and is defined by the

0 comments on commit 8041089

Please sign in to comment.