use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class UITree method __setSelectedNodes.
@Signature(@Arg(value = "node", type = HintType.ARRAY, optional = @Optional("NULL")))
protected Memory __setSelectedNodes(Environment env, Memory... args) {
if (args[0].isNull())
component.getContent().setSelectionPaths(null);
else {
ArrayMemory arr = args[0].toValue(ArrayMemory.class);
TreePath[] paths = new TreePath[arr.size()];
int i = 0;
for (WrapTreeNode e : arr.toObjectArray(WrapTreeNode.class)) {
paths[i] = new TreePath(e.getNode());
}
component.getContent().setSelectionPaths(paths);
}
return Memory.NULL;
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class UIUnknown method __debugInfo.
@Reflection.Signature
public Memory __debugInfo(Environment env, Memory... args) {
ArrayMemory r = super.__debugInfo(env).toValue(ArrayMemory.class);
r.refOfIndex("*java_class").assign(component.getClass().getName());
return r;
}
use of php.runtime.memory.ArrayMemory 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();
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class ArrayFunctions method prev.
public static Memory prev(Environment env, TraceInfo trace, @Reference Memory array) {
if (expectingReference(env, trace, array, "prev")) {
if (expecting(env, trace, 1, array, ARRAY)) {
ArrayMemory memory = array.toValue(ArrayMemory.class);
ForeachIterator iterator = memory.getCurrentIterator();
if (iterator.prev())
return iterator.getValue().toImmutable();
else
return Memory.FALSE;
}
}
return Memory.FALSE;
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class ArrayFunctions method array_chunk.
public static Memory array_chunk(Environment env, TraceInfo trace, Memory input, int size, boolean saveKeys) {
if (expecting(env, trace, 1, input, ARRAY)) {
if (size < 1) {
env.warning(trace, "array_chunk(): Size parameter expected to be greater than 0");
return Memory.NULL;
}
ArrayMemory result = new ArrayMemory();
ArrayMemory item = null;
ForeachIterator iterator = input.getNewIterator(env, false, false);
int i = 0;
while (iterator.next()) {
if (i == 0) {
item = new ArrayMemory();
result.add(item);
}
if (saveKeys) {
item.put(iterator.getKey(), iterator.getValue().toImmutable());
} else
item.add(iterator.getValue().toImmutable());
if (++i == size)
i = 0;
}
return result.toConstant();
} else
return Memory.NULL;
}
Aggregations