Search in sources :

Example 26 with Signature

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;
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) StreamResult(javax.xml.transform.stream.StreamResult) Signature(php.runtime.annotation.Reflection.Signature)

Example 27 with Signature

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;
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) StreamResult(javax.xml.transform.stream.StreamResult) Signature(php.runtime.annotation.Reflection.Signature)

Example 28 with Signature

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();
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) AttributeSet(javax.swing.text.AttributeSet) StringMemory(php.runtime.memory.StringMemory) Signature(php.runtime.annotation.Reflection.Signature)

Example 29 with Signature

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();
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) Map(java.util.Map) SourceMap(php.runtime.loader.sourcemap.SourceMap) Signature(php.runtime.annotation.Reflection.Signature)

Example 30 with Signature

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;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ForeachIterator(php.runtime.lang.ForeachIterator) Memory(php.runtime.Memory) ArrayMemory(php.runtime.memory.ArrayMemory) LongMemory(php.runtime.memory.LongMemory) StringMemory(php.runtime.memory.StringMemory) Signature(php.runtime.annotation.Reflection.Signature)

Aggregations

Signature (php.runtime.annotation.Reflection.Signature)30 ArrayMemory (php.runtime.memory.ArrayMemory)8 InputStream (java.io.InputStream)4 Memory (php.runtime.Memory)4 ForeachIterator (php.runtime.lang.ForeachIterator)4 StringMemory (php.runtime.memory.StringMemory)4 ZipEntry (java.util.zip.ZipEntry)2 DOMSource (javax.xml.transform.dom.DOMSource)2 StreamResult (javax.xml.transform.stream.StreamResult)2 Stream (php.runtime.ext.core.classes.stream.Stream)2 WrapTime (php.runtime.ext.core.classes.time.WrapTime)2 LongMemory (php.runtime.memory.LongMemory)2 Intent (android.content.Intent)1 Button (android.widget.Button)1 EditText (android.widget.EditText)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 HikariConfig (com.zaxxer.hikari.HikariConfig)1 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1