use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class WrapThread method __debugInfo.
@Signature
public Memory __debugInfo(Environment env, Memory... args) {
ArrayMemory r = new ArrayMemory();
r.refOfIndex("*id").assign(thread.getId());
r.refOfIndex("*name").assign(thread.getName());
if (thread.getThreadGroup() != null)
r.refOfIndex("*group").assign(thread.getThreadGroup().getName());
else
r.refOfIndex("*group");
r.refOfIndex("*priority").assign(thread.getPriority());
return r.toConstant();
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class WrapDomDocument method createElement.
@Signature
public Element createElement(String tagName, @Nullable ArrayMemory _model) {
Element element = getWrappedObject().createElement(tagName);
ForeachIterator model = _model.foreachIterator(false, false);
while (model != null && model.next()) {
String key = model.getKey().toString();
Memory value = model.getValue();
if (key.startsWith("@")) {
element.setAttribute(key.substring(1), value.toString());
} else {
Element subElement = getWrappedObject().createElement(key);
if (value.isArray()) {
for (Memory el : value.toValue(ArrayMemory.class)) {
Element sub = getWrappedObject().createElement("item");
if (el.isArray()) {
sub = createElement("item", el.toValue(ArrayMemory.class));
} else {
sub.setTextContent(el.toString());
}
subElement.appendChild(sub);
}
} else {
subElement.setTextContent(value.toString());
}
element.appendChild(subElement);
}
}
return element;
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class WrapDomNode method toModel.
protected static Memory toModel(Node node) {
if (node.getNodeType() == Node.TEXT_NODE) {
return StringMemory.valueOf(node.getTextContent());
}
ArrayMemory result = new ArrayMemory(true);
NamedNodeMap attrs = node.getAttributes();
for (int i = 0; i < attrs.getLength(); i++) {
Node attr = attrs.item(i);
result.refOfIndex("@" + attr.getNodeName()).assign(attr.getNodeValue());
}
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node el = children.item(i);
if (el.getNodeType() == Node.TEXT_NODE) {
continue;
}
if (el.hasAttributes() || el.hasChildNodes()) {
if (el.getChildNodes().getLength() == 1 && el.getFirstChild().getNodeType() == Node.TEXT_NODE) {
ReferenceMemory one = result.getByScalar(el.getNodeName());
if (one != null) {
if (!one.isArray()) {
ArrayMemory tmp = new ArrayMemory();
tmp.refOfPush().assign(one.toValue());
one.assign(tmp);
}
one.refOfPush().assign(el.getFirstChild().getTextContent());
result.refOfIndex(el.getNodeName()).assignRef(one.toValue());
} else {
result.refOfIndex(el.getNodeName()).assign(el.getFirstChild().getTextContent());
}
} else {
result.refOfIndex(el.getNodeName()).assign(toModel(el).toImmutable());
}
} else {
result.refOfIndex(el.getNodeName()).assign(el.getTextContent());
}
}
if (result.size() == 1) {
Memory tmp = result.getByScalar("item");
if (tmp != null) {
if (tmp.isArray()) {
return tmp.toValue(ArrayMemory.class).toConstant();
} else {
ArrayMemory m = new ArrayMemory();
m.add(tmp.toValue());
return m.toConstant();
}
}
}
return result.toConstant();
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class UISlider method __getLabelTable.
@Signature
protected Memory __getLabelTable(Environment env, Memory... args) {
Dictionary dictionary = component.getLabelTable();
ArrayMemory result = new ArrayMemory();
for (Object key : Collections.list(dictionary.keys())) {
JLabel label = (JLabel) dictionary.get(key);
result.refOfIndex((Integer) key).assign(label.getText());
}
return result.toConstant();
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class UIElement method __debugInfo.
@Signature
public Memory __debugInfo(Environment env, Memory... args) {
ArrayMemory result = new ArrayMemory();
result.refOfIndex("uid").assign(getComponent().getName());
result.refOfIndex("position").assign(ArrayMemory.ofIntegers(getComponent().getX(), getComponent().getY()));
result.refOfIndex("size").assign(ArrayMemory.ofIntegers(getComponent().getWidth(), getComponent().getHeight()));
ComponentProperties properties = SwingExtension.getProperties(getComponent());
if (properties.getOriginGroups() != null)
result.refOfIndex("group").assign(properties.getOriginGroups());
return result.toConstant();
}
Aggregations