Search in sources :

Example 21 with StringMemory

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

Example 22 with StringMemory

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]));
}
Also used : ClassEntity(php.runtime.reflection.ClassEntity) ObjectMemory(php.runtime.memory.ObjectMemory) StringMemory(php.runtime.memory.StringMemory)

Example 23 with StringMemory

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;
    }
}
Also used : DecimalFormatSymbols(java.text.DecimalFormatSymbols) DecimalFormat(java.text.DecimalFormat) StringMemory(php.runtime.memory.StringMemory) FastMethod(php.runtime.annotation.Runtime.FastMethod)

Example 24 with StringMemory

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

Example 25 with StringMemory

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();
}
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)

Aggregations

StringMemory (php.runtime.memory.StringMemory)47 ArrayMemory (php.runtime.memory.ArrayMemory)14 Memory (php.runtime.Memory)11 ObjectMemory (php.runtime.memory.ObjectMemory)8 ReferenceMemory (php.runtime.memory.ReferenceMemory)7 BigDecimal (java.math.BigDecimal)5 Invoker (php.runtime.invoke.Invoker)4 ClassEntity (php.runtime.reflection.ClassEntity)4 TraceInfo (php.runtime.env.TraceInfo)3 IObject (php.runtime.lang.IObject)3 LongMemory (php.runtime.memory.LongMemory)3 StringWriter (java.io.StringWriter)2 ComponentProperties (org.develnext.jphp.swing.ComponentProperties)2 UIReader (org.develnext.jphp.swing.loader.UIReader)2 Signature (php.runtime.annotation.Reflection.Signature)2 CallStackItem (php.runtime.env.CallStackItem)2 ConcurrentEnvironment (php.runtime.env.ConcurrentEnvironment)2 CriticalException (php.runtime.exceptions.CriticalException)2 MethodEntity (php.runtime.reflection.MethodEntity)2 BigInteger (java.math.BigInteger)1