use of php.runtime.memory.StringMemory in project jphp by jphp-compiler.
the class Stream method setPath.
public void setPath(String path) {
__class__.setProperty(this, "path", new StringMemory(path));
this.path = path;
}
use of php.runtime.memory.StringMemory in project jphp by jphp-compiler.
the class Stream method of.
@Signature({ @Arg("path"), @Arg(value = "mode", optional = @Optional("r")) })
public static Memory of(Environment env, Memory... args) throws Throwable {
String path = args[0].toString();
String protocol = "file";
int pos = path.indexOf("://");
if (pos > -1) {
protocol = path.substring(0, pos);
path = path.substring(pos + 3);
}
String className = env.getUserValue(Stream.class.getName() + "#" + protocol, String.class);
if (className == null) {
throw new IOException("Unregistered protocol - " + protocol + "://");
}
ClassEntity classEntity = env.fetchClass(className);
if (classEntity.getNativeClass().getAnnotation(UsePathWithProtocols.class) != null) {
path = protocol + "://" + path;
}
return new ObjectMemory(classEntity.newObject(env, env.trace(), true, new StringMemory(path), args[1]));
}
use of php.runtime.memory.StringMemory in project jphp by jphp-compiler.
the class NumUtils method format.
@FastMethod
@Signature({ @Arg("number"), @Arg("pattern"), @Arg(value = "decSep", optional = @Optional(".")), @Arg(value = "groupSep", optional = @Optional(",")) })
public static Memory format(Environment env, Memory... args) {
try {
char decSep = args[2].toChar();
char groupSep = args[3].toChar();
DecimalFormat decimalFormat;
if (decSep == '.' && groupSep == ',')
decimalFormat = new DecimalFormat(args[1].toString(), DEFAULT_DECIMAL_FORMAT_SYMBOLS);
else {
DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols();
formatSymbols.setZeroDigit('0');
formatSymbols.setDecimalSeparator(decSep);
formatSymbols.setGroupingSeparator(groupSep);
decimalFormat = new DecimalFormat(args[1].toString(), formatSymbols);
}
return new StringMemory(decimalFormat.format(args[0].toDouble()));
} catch (IllegalArgumentException e) {
return Memory.FALSE;
}
}
use of php.runtime.memory.StringMemory in project jphp by jphp-compiler.
the class UIAbstractButton method __getButtonGroup.
@Signature
protected Memory __getButtonGroup(Environment env, Memory... args) {
ComponentProperties properties = SwingExtension.getProperties(getComponent());
String val = properties.getData("buttonGroup", String.class);
if (val == null)
return Memory.CONST_EMPTY_STRING;
return new StringMemory(val);
}
use of php.runtime.memory.StringMemory in project jphp by jphp-compiler.
the class UIElement method __getAnchors.
@Signature
protected Memory __getAnchors(Environment env, Memory... args) {
ArrayMemory result = new ArrayMemory();
ComponentProperties properties = SwingExtension.getProperties(getComponent());
if (properties != null)
for (Anchor anchor : properties.anchors) {
result.add(new StringMemory(anchor.name()));
}
return result.toConstant();
}
Aggregations