Search in sources :

Example 41 with ObjectMemory

use of php.runtime.memory.ObjectMemory in project jphp by jphp-compiler.

the class UIContainer method getComponentsByGroup.

@Signature(@Arg("group"))
public Memory getComponentsByGroup(Environment env, Memory... args) {
    java.util.List<Component> components = getComponents(getContainer(), args[0].toString());
    ArrayMemory result = new ArrayMemory();
    for (Component el : components) result.add(new ObjectMemory(UIElement.of(env, el)));
    return result.toConstant();
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ObjectMemory(php.runtime.memory.ObjectMemory)

Example 42 with ObjectMemory

use of php.runtime.memory.ObjectMemory in project jphp by jphp-compiler.

the class WrapUIReader method onTranslate.

@Signature(@Arg(value = "handler", type = HintType.CALLABLE, optional = @Optional("NULL")))
public Memory onTranslate(final Environment env, Memory... args) {
    if (args[0].isNull())
        reader.setTranslateHandler(null);
    else {
        final Invoker invoker = Invoker.valueOf(env, null, args[0]);
        UIReader.TranslateHandler handler = new UIReader.TranslateHandler() {

            @Override
            public Value onTranslate(Component component, Value var) {
                return new Value(invoker.callNoThrow(new ObjectMemory(UIElement.of(env, component)), var == null ? Memory.NULL : new StringMemory(var.asString())).toString());
            }
        };
        reader.setTranslateHandler(handler);
    }
    return Memory.NULL;
}
Also used : UIReader(org.develnext.jphp.swing.loader.UIReader) Invoker(php.runtime.invoke.Invoker) ObjectMemory(php.runtime.memory.ObjectMemory) Value(org.develnext.jphp.swing.loader.support.Value) StringMemory(php.runtime.memory.StringMemory)

Example 43 with ObjectMemory

use of php.runtime.memory.ObjectMemory in project jphp by jphp-compiler.

the class WrapUIReader method onRead.

@Signature(@Arg(value = "handler", type = HintType.CALLABLE, optional = @Optional("NULL")))
public Memory onRead(final Environment env, Memory... args) {
    if (args[0].isNull())
        reader.setReadHandler(null);
    else {
        final Invoker invoker = Invoker.valueOf(env, null, args[0]);
        UIReader.ReadHandler handler = new UIReader.ReadHandler() {

            @Override
            public void onRead(Component component, String var) {
                invoker.callNoThrow(new ObjectMemory(UIElement.of(env, component)), var == null ? Memory.NULL : new StringMemory(var));
            }
        };
        reader.setReadHandler(handler);
    }
    return Memory.NULL;
}
Also used : UIReader(org.develnext.jphp.swing.loader.UIReader) Invoker(php.runtime.invoke.Invoker) ObjectMemory(php.runtime.memory.ObjectMemory) StringMemory(php.runtime.memory.StringMemory)

Example 44 with ObjectMemory

use of php.runtime.memory.ObjectMemory in project jphp by jphp-compiler.

the class WrapTime method today.

@Signature({ @Arg(value = "timeZone", nativeType = WrapTimeZone.class, optional = @Optional("NULL")), @Arg(value = "locale", nativeType = WrapLocale.class, optional = @Optional("NULL")) })
public static Memory today(Environment env, Memory... args) {
    Date date1 = new Date();
    Locale aLocale = args[1].isNull() ? Locale.ENGLISH : args[1].toObject(WrapLocale.class).getLocale();
    Calendar calendar = Calendar.getInstance(WrapTimeZone.getTimeZone(env, args[0]), aLocale);
    calendar.setTime(date1);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    return new ObjectMemory(new WrapTime(env, calendar.getTime(), calendar.getTimeZone(), aLocale));
}
Also used : WrapLocale(php.runtime.ext.core.classes.util.WrapLocale) Locale(java.util.Locale) ObjectMemory(php.runtime.memory.ObjectMemory) Calendar(java.util.Calendar) Date(java.util.Date)

Example 45 with ObjectMemory

use of php.runtime.memory.ObjectMemory in project jphp by jphp-compiler.

the class WrapTime method now.

@Signature({ @Arg(value = "timeZone", nativeType = WrapTimeZone.class, optional = @Optional("null")), @Arg(value = "locale", nativeType = WrapLocale.class, optional = @Optional("NULL")) })
public static Memory now(Environment env, Memory... args) {
    Locale aLocale = args[1].isNull() ? Locale.ENGLISH : args[1].toObject(WrapLocale.class).getLocale();
    TimeZone zone = WrapTimeZone.getTimeZone(env, args[0]);
    return new ObjectMemory(new WrapTime(env, Calendar.getInstance(zone, aLocale).getTime(), zone, aLocale));
}
Also used : WrapLocale(php.runtime.ext.core.classes.util.WrapLocale) Locale(java.util.Locale) TimeZone(java.util.TimeZone) ObjectMemory(php.runtime.memory.ObjectMemory)

Aggregations

ObjectMemory (php.runtime.memory.ObjectMemory)55 ArrayMemory (php.runtime.memory.ArrayMemory)24 Memory (php.runtime.Memory)19 ClassEntity (php.runtime.reflection.ClassEntity)17 StringMemory (php.runtime.memory.StringMemory)14 IObject (php.runtime.lang.IObject)11 Invoker (php.runtime.invoke.Invoker)6 LongMemory (php.runtime.memory.LongMemory)6 Environment (php.runtime.env.Environment)5 MethodEntity (php.runtime.reflection.MethodEntity)5 Calendar (java.util.Calendar)4 Closure (php.runtime.lang.Closure)4 Locale (java.util.Locale)3 Test (org.junit.Test)3 WrapLocale (php.runtime.ext.core.classes.util.WrapLocale)3 PropertyEntity (php.runtime.reflection.PropertyEntity)3 AbstractFunctionEntity (php.runtime.reflection.support.AbstractFunctionEntity)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Date (java.util.Date)2 TimeZone (java.util.TimeZone)2