Search in sources :

Example 21 with ArrayMemory

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

the class PSqlConnection method getMetaData.

@Signature
public Memory getMetaData() throws SQLException {
    ArrayMemory r = new ArrayMemory();
    r.refOfIndex("userName").assign(metaData.getUserName());
    r.refOfIndex("driverName").assign(metaData.getDriverName());
    r.refOfIndex("driverVersion").assign(metaData.getDriverVersion());
    r.refOfIndex("databaseName").assign(metaData.getDatabaseProductName());
    r.refOfIndex("databaseVersion").assign(metaData.getDatabaseProductVersion());
    r.refOfIndex("catalogSeparator").assign(metaData.getCatalogSeparator());
    r.refOfIndex("catalogTerm").assign(metaData.getCatalogTerm());
    r.refOfIndex("schemaTerm").assign(metaData.getSchemaTerm());
    r.refOfIndex("procedureTerm").assign(metaData.getProcedureTerm());
    r.refOfIndex("searchStringEscape").assign(metaData.getSearchStringEscape());
    r.refOfIndex("numericFunctions").assign(metaData.getNumericFunctions());
    r.refOfIndex("stringFunctions").assign(metaData.getStringFunctions());
    r.refOfIndex("timeDateFunctions").assign(metaData.getTimeDateFunctions());
    r.refOfIndex("systemFunctions").assign(metaData.getSystemFunctions());
    r.refOfIndex("defaultTransactionIsolation").assign(metaData.getDefaultTransactionIsolation());
    r.refOfIndex("identifierQuoteString").assign(metaData.getIdentifierQuoteString());
    r.refOfIndex("maxBinaryLiteralLength").assign(metaData.getMaxBinaryLiteralLength());
    r.refOfIndex("maxCatalogNameLength").assign(metaData.getMaxCatalogNameLength());
    r.refOfIndex("maxCharLiteralLength").assign(metaData.getMaxCharLiteralLength());
    r.refOfIndex("maxConnections").assign(metaData.getMaxConnections());
    r.refOfIndex("maxColumnNameLength").assign(metaData.getMaxColumnNameLength());
    r.refOfIndex("maxColumnsInGroupBy").assign(metaData.getMaxColumnsInGroupBy());
    r.refOfIndex("maxColumnsInIndex").assign(metaData.getMaxColumnsInIndex());
    r.refOfIndex("maxColumnsInOrderBy").assign(metaData.getMaxColumnsInOrderBy());
    r.refOfIndex("maxColumnsInSelect").assign(metaData.getMaxColumnsInSelect());
    r.refOfIndex("maxColumnsInTable").assign(metaData.getMaxColumnsInTable());
    r.refOfIndex("maxCursorNameLength").assign(metaData.getMaxCursorNameLength());
    r.refOfIndex("maxIndexLength").assign(metaData.getMaxIndexLength());
    r.refOfIndex("maxProcedureNameLength").assign(metaData.getMaxProcedureNameLength());
    r.refOfIndex("maxRowSize").assign(metaData.getMaxRowSize());
    r.refOfIndex("maxSchemaNameLength").assign(metaData.getMaxSchemaNameLength());
    r.refOfIndex("maxStatementLength").assign(metaData.getMaxStatementLength());
    r.refOfIndex("maxTableNameLength").assign(metaData.getMaxTableNameLength());
    r.refOfIndex("maxTablesInSelect").assign(metaData.getMaxTablesInSelect());
    return r.toConstant();
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory)

Example 22 with ArrayMemory

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

the class DeserializerTest method testArrays.

@Test
public void testArrays() {
    Memory value = unserialize("a:0:{}");
    Assert.assertTrue(value instanceof ArrayMemory);
    Assert.assertEquals(0, ((ArrayMemory) value).size());
    value = unserialize("a:2:{i:0;i:100;i:1;i:500;}");
    Assert.assertTrue(value instanceof ArrayMemory);
    Assert.assertEquals(2, ((ArrayMemory) value).size());
    Assert.assertEquals(100, value.valueOfIndex(0).toLong());
    Assert.assertEquals(500, value.valueOfIndex(1).toLong());
    value = unserialize("a:2:{s:1:\"x\";i:100;s:1:\"y\";i:500;}");
    Assert.assertTrue(value instanceof ArrayMemory);
    Assert.assertEquals(2, ((ArrayMemory) value).size());
    Assert.assertEquals(100, value.valueOfIndex("x").toLong());
    Assert.assertEquals(500, value.valueOfIndex("y").toLong());
    value = unserialize("a:2:{i:0;a:2:{i:0;i:100;i:1;i:500;}i:1;a:2:{i:0;i:200;i:1;i:600;}}");
    Assert.assertTrue(value instanceof ArrayMemory);
    Assert.assertEquals(2, ((ArrayMemory) value).size());
    Assert.assertTrue(value.valueOfIndex(0).toValue() instanceof ArrayMemory);
    Assert.assertTrue(value.valueOfIndex(1).toValue() instanceof ArrayMemory);
    Assert.assertEquals(100, value.valueOfIndex(0).toValue(ArrayMemory.class).valueOfIndex(0).toLong());
    Assert.assertEquals(500, value.valueOfIndex(0).toValue(ArrayMemory.class).valueOfIndex(1).toLong());
    Assert.assertEquals(200, value.valueOfIndex(1).toValue(ArrayMemory.class).valueOfIndex(0).toLong());
    Assert.assertEquals(600, value.valueOfIndex(1).toValue(ArrayMemory.class).valueOfIndex(1).toLong());
    value = unserialize("a:2:{s:1:\"a\";s:4:\"test\";s:1:\"b\";N;}");
    Assert.assertTrue(value instanceof ArrayMemory);
    Assert.assertEquals(2, ((ArrayMemory) value).size());
    Assert.assertEquals("test", value.valueOfIndex("a").toString());
    Assert.assertEquals(Memory.NULL, value.valueOfIndex("b").toValue());
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) Memory(php.runtime.Memory) ArrayMemory(php.runtime.memory.ArrayMemory) ObjectMemory(php.runtime.memory.ObjectMemory) Test(org.junit.Test)

Example 23 with ArrayMemory

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

the class Environment method __import.

/*public Memory __getConstant(String name, String lowerName, TraceInfo trace){
        Memory constant = findConstant(name, lowerName);

        if (constant == null){
            error(trace, E_NOTICE, Messages.ERR_USE_UNDEFINED_CONSTANT, name, name);
            int p = name.lastIndexOf(Information.NAMESPACE_SEP_CHAR);

            if (p > -1) // for global scope
                return StringMemory.valueOf(name.substring(p + 1));
            else
                return StringMemory.valueOf(name);
        }

        return constant;
    }*/
private Memory __import(String path, ArrayMemory locals, TraceInfo trace, String funcName, boolean once, Callback<Void, Void> callback) throws Throwable {
    synchronized (moduleManager) {
        if (once && moduleManager.hasModule(path)) {
            return Memory.TRUE;
        }
        ModuleEntity module = moduleManager.fetchCachedModule(path, path.endsWith(".phb"));
        if (module == null) {
            callback.call(null);
            return Memory.FALSE;
        }
        pushCall(trace, null, new Memory[] { StringMemory.valueOf(path) }, funcName, null, null);
        try {
            if (locals == null) {
                locals = new ArrayMemory();
            }
            return module.include(this, locals);
        } finally {
            popCall();
        }
    }
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory)

Example 24 with ArrayMemory

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

the class HttpClientExtension method cookieToArray.

public static ArrayMemory cookieToArray(HttpCookie cookie) {
    ArrayMemory memory = new ArrayMemory();
    memory.refOfIndex("value").assign(cookie.getValue());
    memory.refOfIndex("name").assign(cookie.getName());
    memory.refOfIndex("domain").assign(cookie.getDomain());
    memory.refOfIndex("path").assign(cookie.getPath());
    memory.refOfIndex("secure").assign(cookie.getSecure());
    memory.refOfIndex("maxAge").assign(cookie.getMaxAge());
    memory.refOfIndex("comment").assign(cookie.getComment());
    memory.refOfIndex("discard").assign(cookie.getDiscard());
    memory.refOfIndex("ports").assign(cookie.getPortlist());
    memory.refOfIndex("version").assign(cookie.getVersion());
    memory.refOfIndex("httpOnly").assign(cookie.isHttpOnly());
    return memory;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory)

Example 25 with ArrayMemory

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

the class PHttpResponse method setRawCookies.

@Signature
public void setRawCookies(ArrayMemory rawCookies) {
    this.rawCookies = rawCookies;
    ArrayMemory cookies = new ArrayMemory();
    ForeachIterator iterator = rawCookies.foreachIterator(false, false);
    while (iterator.next()) {
        cookies.putAsKeyString(iterator.getStringKey(), iterator.getValue().valueOfIndex("value").toImmutable());
    }
    this.cookies = cookies;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ForeachIterator(php.runtime.lang.ForeachIterator) Signature(php.runtime.annotation.Reflection.Signature)

Aggregations

ArrayMemory (php.runtime.memory.ArrayMemory)148 Memory (php.runtime.Memory)60 ForeachIterator (php.runtime.lang.ForeachIterator)41 ObjectMemory (php.runtime.memory.ObjectMemory)35 LongMemory (php.runtime.memory.LongMemory)31 StringMemory (php.runtime.memory.StringMemory)29 ReferenceMemory (php.runtime.memory.ReferenceMemory)25 KeyValueMemory (php.runtime.memory.KeyValueMemory)17 Invoker (php.runtime.invoke.Invoker)9 ClassEntity (php.runtime.reflection.ClassEntity)9 Signature (php.runtime.annotation.Reflection.Signature)6 IObject (php.runtime.lang.IObject)6 Map (java.util.Map)4 Test (org.junit.Test)4 DoubleMemory (php.runtime.memory.DoubleMemory)4 ConcurrentEnvironment (php.runtime.env.ConcurrentEnvironment)3 TraceInfo (php.runtime.env.TraceInfo)3 ModuleEntity (php.runtime.reflection.ModuleEntity)3 ParameterEntity (php.runtime.reflection.ParameterEntity)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2