use of php.runtime.Memory in project jphp by jphp-compiler.
the class UICombobox method onCellRender.
@Signature(@Arg(value = "handler", optional = @Optional("null")))
public Memory onCellRender(final Environment env, Memory... args) {
if (args[0].isNull())
component.setRenderer(defaultRenderer);
else {
final Invoker invoker = Invoker.valueOf(env, null, args[0]);
final ObjectMemory self = new ObjectMemory(this);
component.setRenderer(new ListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel template = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
Memory _value = MemoryUtils.valueOf(value);
Memory _index = LongMemory.valueOf(index);
Memory _isSelected = TrueMemory.valueOf(isSelected);
Memory _cellHasFocus = TrueMemory.valueOf(cellHasFocus);
Memory r = invoker.callNoThrow(self, new ObjectMemory(new UILabel(env, template)), _value, _index, _isSelected, _cellHasFocus);
if (r.isObject() && r.instanceOf(UIElement.class)) {
return r.toObject(UIElement.class).getComponent();
}
return template;
}
});
}
return Memory.NULL;
}
use of php.runtime.Memory in project jphp by jphp-compiler.
the class UIFileChooser method __setSelectedFiles.
@Signature(@Arg(value = "value", type = HintType.ARRAY))
protected Memory __setSelectedFiles(Environment env, Memory... args) {
ArrayMemory value = args[0].toValue(ArrayMemory.class);
File[] files = new File[value.size()];
ForeachIterator iterator = value.foreachIterator(false, false);
int i = 0;
while (iterator.next()) {
Memory el = iterator.getValue();
if (el.instanceOf(FileObject.class)) {
files[i] = el.toObject(FileObject.class).getFile();
} else {
files[i] = new File(el.toString());
}
i++;
}
component.setSelectedFiles(files);
return Memory.NULL;
}
use of php.runtime.Memory in project jphp by jphp-compiler.
the class VarVarValueCompiler method write.
@Override
public void write(GetVarExprToken getVar, boolean returnValue) {
if (!methodStatement.isDynamicLocal())
throw new ExpressionStmtCompiler.UnsupportedTokenException(getVar);
Memory result = expr.writeExpression(getVar.getName(), true, true, false);
if (result != null && result.isString()) {
String name = result.toString();
LocalVariable variable = method.getLocalVariable(name);
if (variable != null) {
if (returnValue)
expr.writeVarLoad(variable);
return;
}
}
expr.writePushLocal();
expr.writeExpression(getVar.getName(), true, false);
expr.writePopBoxing();
expr.writeSysDynamicCall(Memory.class, "refOfIndex", Memory.class, Memory.class);
if (!returnValue)
expr.writePopAll(1);
}
use of php.runtime.Memory in project jphp by jphp-compiler.
the class ArraysTest method testComplex.
@Test
public void testComplex() {
Memory memory = includeResource("arrays/complex.php");
Assert.assertEquals("success", memory.toString());
}
use of php.runtime.Memory in project jphp by jphp-compiler.
the class ArraysTest method testArrayReference.
@Test
public void testArrayReference() {
Memory memory = includeResource("arrays/array_reference.php");
Assert.assertEquals(100, memory.toLong());
}
Aggregations