Search in sources :

Example 56 with ArrayMemory

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;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory)

Example 57 with ArrayMemory

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;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory)

Example 58 with ArrayMemory

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();
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) Anchor(org.develnext.jphp.swing.misc.Anchor) ComponentProperties(org.develnext.jphp.swing.ComponentProperties) StringMemory(php.runtime.memory.StringMemory)

Example 59 with ArrayMemory

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;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ForeachIterator(php.runtime.lang.ForeachIterator)

Example 60 with ArrayMemory

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;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ForeachIterator(php.runtime.lang.ForeachIterator)

Aggregations

ArrayMemory (php.runtime.memory.ArrayMemory)148 Memory (php.runtime.Memory)60 ForeachIterator (php.runtime.lang.ForeachIterator)41 ObjectMemory (php.runtime.memory.ObjectMemory)35 LongMemory (php.runtime.memory.LongMemory)31 StringMemory (php.runtime.memory.StringMemory)29 ReferenceMemory (php.runtime.memory.ReferenceMemory)25 KeyValueMemory (php.runtime.memory.KeyValueMemory)17 Invoker (php.runtime.invoke.Invoker)9 ClassEntity (php.runtime.reflection.ClassEntity)9 Signature (php.runtime.annotation.Reflection.Signature)6 IObject (php.runtime.lang.IObject)6 Map (java.util.Map)4 Test (org.junit.Test)4 DoubleMemory (php.runtime.memory.DoubleMemory)4 ConcurrentEnvironment (php.runtime.env.ConcurrentEnvironment)3 TraceInfo (php.runtime.env.TraceInfo)3 ModuleEntity (php.runtime.reflection.ModuleEntity)3 ParameterEntity (php.runtime.reflection.ParameterEntity)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2