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