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