Added projects and basic build scripts. Project for scripting engine, API, Main 1.7 version and one for each mod supported in 1.7.

This commit is contained in:
Stan Hebben committed 2014-06-09 20:33:30 +02:00
1 parent 219106f392
commit 38b78ce305
281 files changed
+25090 -49

No files matched your search

@@ -0,0 +1,73 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package stanhebben.zenscript.value;
import java.util.Iterator;
/**
*
* @author Stanneke
*/
public interface IAny {
public IAny not();
public IAny neg();
public IAny add(IAny value);
public IAny sub(IAny value);
public IAny cat(IAny value);
public IAny mul(IAny value);
public IAny div(IAny value);
public IAny mod(IAny value);
public IAny and(IAny value);
public IAny or(IAny value);
public IAny xor(IAny value);
public IAny range(IAny value);
public int compareTo(IAny value);
public boolean contains(IAny value);
public IAny member(String value);
public IAny indexGet(IAny key);
public void indexSet(IAny key, IAny value);
public IAny call(IAny... values);
public boolean asBool();
public byte asByte();
public short asShort();
public int asInt();
public long asLong();
public float asFloat();
public double asDouble();
public String asString();
public <T> T as(Class<T> cls);
public Iterator<IAny> iteratorSingle();
public Iterator<IAny[]> iteratorMulti(int n);
}
@@ -0,0 +1,177 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package stanhebben.zenscript.value.builtin;
import java.util.Iterator;
import stanhebben.zenscript.ZenRuntimeException;
import stanhebben.zenscript.value.IAny;
/**
*
* @author Stanneke
*/
public class AnyByte implements IAny {
public static AnyByte valueOf(byte value) {
return new AnyByte(value);
}
private final byte value;
public AnyByte(byte value) {
this.value = value;
}
@Override
public IAny not() {
return new AnyByte((byte) ~value);
}
@Override
public IAny neg() {
return new AnyByte((byte) -value);
}
@Override
public IAny add(IAny value) {
return new AnyByte((byte) (this.value + value.asByte()));
}
@Override
public IAny sub(IAny value) {
return new AnyByte((byte) (this.value - value.asByte()));
}
@Override
public IAny cat(IAny value) {
return new AnyString(Byte.toString(this.value) + value.asString());
}
@Override
public IAny mul(IAny value) {
return new AnyByte((byte) (this.value * value.asByte()));
}
@Override
public IAny div(IAny value) {
return new AnyByte((byte) (this.value / value.asByte()));
}
@Override
public IAny mod(IAny value) {
return new AnyByte((byte) (this.value % value.asByte()));
}
@Override
public IAny and(IAny value) {
return new AnyByte((byte) (this.value & value.asByte()));
}
@Override
public IAny or(IAny value) {
return new AnyByte((byte) (this.value | value.asByte()));
}
@Override
public IAny xor(IAny value) {
return new AnyByte((byte) (this.value ^ value.asByte()));
}
@Override
public IAny range(IAny value) {
//return new AnyIntRange(this.value, value.asInt());
return null; // TODO
}
@Override
public int compareTo(IAny value) {
return Integer.compare(this.value, value.asByte());
}
@Override
public boolean contains(IAny value) {
throw new ZenRuntimeException("byte has no in operator");
}
@Override
public IAny member(String value) {
if (value.equals("abs")) {
return new AnyByte((byte) (Math.abs(this.value)));
} else {
throw new ZenRuntimeException("no such member in byte: " + value);
}
}
@Override
public IAny indexGet(IAny key) {
throw new ZenRuntimeException("cannot index a byte value");
}
@Override
public void indexSet(IAny key, IAny value) {
throw new ZenRuntimeException("cannot index a byte value");
}
@Override
public IAny call(IAny... values) {
throw new ZenRuntimeException("cannot index a byte value");
}
@Override
public boolean asBool() {
throw new ZenRuntimeException("cannot convert a byte to a bool");
}
@Override
public byte asByte() {
return value;
}
@Override
public short asShort() {
return value;
}
@Override
public int asInt() {
return value;
}
@Override
public long asLong() {
return value;
}
@Override
public float asFloat() {
return value;
}
@Override
public double asDouble() {
return value;
}
@Override
public String asString() {
return Byte.toString(value);
}
@Override
public <T> T as(Class<T> cls) {
throw new ZenRuntimeException("cannot convert a byte to an object");
}
@Override
public Iterator<IAny> iteratorSingle() {
throw new ZenRuntimeException("cannot iterate over a byte value");
}
@Override
public Iterator<IAny[]> iteratorMulti(int n) {
throw new ZenRuntimeException("cannot iterate over a byte value");
}
}
@@ -0,0 +1,163 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package stanhebben.zenscript.value.builtin;
import java.util.Iterator;
import stanhebben.zenscript.value.IAny;
/**
*
* @author Stanneke
*/
public class AnyIntRange implements IAny {
@Override
public IAny not() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public IAny neg() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public IAny add(IAny value) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public IAny sub(IAny value) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public IAny cat(IAny value) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public IAny mul(IAny value) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public IAny div(IAny value) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public IAny mod(IAny value) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public IAny and(IAny value) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public IAny or(IAny value) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public IAny xor(IAny value) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public IAny range(IAny value) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public int compareTo(IAny value) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean contains(IAny value) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public IAny member(String value) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public IAny indexGet(IAny key) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void indexSet(IAny key, IAny value) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public IAny call(IAny... values) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean asBool() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public byte asByte() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public short asShort() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public int asInt() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public long asLong() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public float asFloat() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public double asDouble() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public String asString() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public <T> T as(Class<T> cls) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Iterator<IAny> iteratorSingle() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Iterator<IAny[]> iteratorMulti(int n) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
@@ -0,0 +1,192 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package stanhebben.zenscript.value.builtin;
import java.util.Iterator;
import stanhebben.zenscript.ZenRuntimeException;
import stanhebben.zenscript.value.IAny;
/**
*
* @author Stanneke
*/
public class AnyString implements IAny {
private final String value;
public AnyString(String value) {
this.value = value;
}
@Override
public IAny not() {
throw new ZenRuntimeException("cannot invert a string value");
}
@Override
public IAny neg() {
throw new ZenRuntimeException("cannot negate a string value");
}
@Override
public IAny add(IAny value) {
throw new ZenRuntimeException("cannot add to a string value (did you intend to use ~ instead?)");
}
@Override
public IAny sub(IAny value) {
throw new ZenRuntimeException("cannot subtract from a string");
}
@Override
public IAny cat(IAny value) {
return new AnyString(this.value + value.asString());
}
@Override
public IAny mul(IAny value) {
throw new ZenRuntimeException("cannot multiply a string value");
}
@Override
public IAny div(IAny value) {
throw new ZenRuntimeException("cannot divide a string value");
}
@Override
public IAny mod(IAny value) {
throw new ZenRuntimeException("cannot modulo a string value");
}
@Override
public IAny and(IAny value) {
throw new ZenRuntimeException("cannot and with a string value");
}
@Override
public IAny or(IAny value) {
throw new ZenRuntimeException("cannot or with a string value");
}
@Override
public IAny xor(IAny value) {
throw new ZenRuntimeException("cannot xor with a string value");
}
@Override
public IAny range(IAny value) {
throw new ZenRuntimeException("cannot range a string value");
}
@Override
public int compareTo(IAny value) {
return this.value.compareTo(value.asString());
}
@Override
public boolean contains(IAny value) {
return this.value.indexOf(value.asString()) >= 0;
}
@Override
public IAny member(String value) {
throw new ZenRuntimeException("strings have no members (yet)");
}
@Override
public IAny indexGet(IAny key) {
throw new ZenRuntimeException("cannot index a string (yet)");
}
@Override
public void indexSet(IAny key, IAny value) {
throw new ZenRuntimeException("cannot modify a string");
}
@Override
public IAny call(IAny... values) {
throw new ZenRuntimeException("cannot call a string");
}
@Override
public boolean asBool() {
return value != null;
}
@Override
public byte asByte() {
try {
return Byte.parseByte(value);
} catch (NumberFormatException ex) {
throw new ZenRuntimeException("Cannot convert " + value + " to a byte value");
}
}
@Override
public short asShort() {
try {
return Short.parseShort(value);
} catch (NumberFormatException ex) {
throw new ZenRuntimeException("Cannot convert " + value + " to a short value");
}
}
@Override
public int asInt() {
try {
return Integer.parseInt(value);
} catch (NumberFormatException ex) {
throw new ZenRuntimeException("Cannot convert " + value + " to an int value");
}
}
@Override
public long asLong() {
try {
return Long.parseLong(value);
} catch (NumberFormatException ex) {
throw new ZenRuntimeException("Cannot convert " + value + " to a long value");
}
}
@Override
public float asFloat() {
try {
return Float.parseFloat(value);
} catch (NumberFormatException ex) {
throw new ZenRuntimeException("Cannot convert " + value + " to a float value");
}
}
@Override
public double asDouble() {
try {
return Double.parseDouble(value);
} catch (NumberFormatException ex) {
throw new ZenRuntimeException("Cannot convert " + value + " to a double value");
}
}
@Override
public String asString() {
return value;
}
@Override
public <T> T as(Class<T> cls) {
throw new ZenRuntimeException("Cannot convert a string to an object");
}
@Override
public Iterator<IAny> iteratorSingle() {
throw new ZenRuntimeException("Cannot iterate over a string (yet)");
}
@Override
public Iterator<IAny[]> iteratorMulti(int n) {
throw new ZenRuntimeException("Cannot iterate over a string (yet)");
}
}