use of php.runtime.annotation.Reflection.Signature in project jphp by jphp-compiler.
the class WrapXmlProcessor method format.
@Override
@Signature
public Memory format(Environment environment, Memory... args) {
if (!args[0].instanceOf(WrapDomDocument.class)) {
throw new IllegalArgumentException("Argument #1 must be instance of " + ReflectionUtils.getClassName(WrapDomDocument.class));
}
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
try {
transformer.transform(new DOMSource(args[0].toObject(WrapDomDocument.class).getWrappedObject()), result);
return StringMemory.valueOf(writer.toString());
} catch (TransformerException e) {
environment.exception(ProcessorException.class, e.getMessage());
return Memory.NULL;
}
}
use of php.runtime.annotation.Reflection.Signature in project jphp by jphp-compiler.
the class WrapXmlProcessor method formatTo.
@Override
@Signature
public Memory formatTo(Environment environment, Memory... args) {
if (!args[0].instanceOf(WrapDomDocument.class)) {
throw new IllegalArgumentException("Argument #1 must be instance of " + ReflectionUtils.getClassName(WrapDomDocument.class));
}
OutputStream output = Stream.getOutputStream(environment, args[1]);
StreamResult result = new StreamResult(output);
try {
transformer.transform(new DOMSource(args[0].toObject(WrapDomDocument.class).getWrappedObject()), result);
} catch (TransformerException e) {
environment.exception(ProcessorException.class, e.getMessage());
return Memory.NULL;
} finally {
Stream.closeStream(environment, output);
}
return Memory.NULL;
}
use of php.runtime.annotation.Reflection.Signature in project jphp by jphp-compiler.
the class WrapHyperlinkEvent method __getAttributes.
@Signature
protected Memory __getAttributes(Environment env, Memory... args) {
AttributeSet attrs = event.getSourceElement().getAttributes();
List<?> keys = Collections.list(attrs.getAttributeNames());
ArrayMemory result = new ArrayMemory();
for (Object key : keys) {
result.put(key.toString(), new StringMemory(attrs.getAttribute(key).toString()));
}
return result.toConstant();
}
use of php.runtime.annotation.Reflection.Signature in project jphp by jphp-compiler.
the class WrapSourceMap method toArray.
@Signature
public Memory toArray(Environment env, Memory... args) {
Map<Integer, SourceMap.Item> itemsByLine = getWrappedObject().getItemsByCompiled();
ArrayMemory r = new ArrayMemory();
for (Map.Entry<Integer, SourceMap.Item> entry : itemsByLine.entrySet()) {
r.refOfIndex(entry.getKey()).assign(entry.getValue().sourceLine);
}
return r.toConstant();
}
use of php.runtime.annotation.Reflection.Signature in project jphp by jphp-compiler.
the class WrapSourceMap method insertLines.
@Signature({ @Arg(value = "inserts", type = HintType.ARRAY), @Arg("allCountLines") })
public Memory insertLines(Environment env, Memory... args) {
ArrayMemory _inserts = args[0].toValue(ArrayMemory.class);
int[][] inserts = new int[_inserts.size()][];
ForeachIterator iterator = _inserts.getNewIterator(env);
int i = 0;
while (iterator.next()) {
Memory value = iterator.getValue();
inserts[i++] = new int[] { value.valueOfIndex(0).toInteger(), value.valueOfIndex(1).toInteger() };
}
getWrappedObject().insertLines(inserts, args[1].toInteger());
return Memory.NULL;
}
Aggregations