public static function init() { self::$CLASS_TO_VALUE_READER = new IdentityHashMap(); self::$CLASS_TO_VECTOR_READER = new IdentityHashMap(); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Boolean::typeClass()), new SSSR_VectorReader_Boolean()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Byte::typeClass()), new SSSR_VectorReader_Byte()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Character::typeClass()), new SSSR_VectorReader_Char()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Double::typeClass()), new SSSR_VectorReader_Double()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Float::typeClass()), new SSSR_VectorReader_Float()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Integer::typeClass()), new SSSR_VectorReader_Int()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Long::typeClass()), new SSSR_VectorReader_Long()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Object::clazz()), new SSSR_VectorReader_Object()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(Short::typeClass()), new SSSR_VectorReader_Short()); self::$CLASS_TO_VECTOR_READER->put(ArrayType::clazz(String::clazz()), new SSSR_VectorReader_String()); self::$CLASS_TO_VALUE_READER->put(Boolean::typeClass(), new SSSR_ValueReader_Boolean()); self::$CLASS_TO_VALUE_READER->put(Byte::typeClass(), new SSSR_ValueReader_Byte()); self::$CLASS_TO_VALUE_READER->put(Character::typeClass(), new SSSR_ValueReader_Char()); self::$CLASS_TO_VALUE_READER->put(Double::typeClass(), new SSSR_ValueReader_Double()); self::$CLASS_TO_VALUE_READER->put(Float::typeClass(), new SSSR_ValueReader_Float()); self::$CLASS_TO_VALUE_READER->put(Integer::typeClass(), new SSSR_ValueReader_Int()); self::$CLASS_TO_VALUE_READER->put(Long::typeClass(), new SSSR_ValueReader_Long()); self::$CLASS_TO_VALUE_READER->put(Object::clazz(), new SSSR_ValueReader_Object()); self::$CLASS_TO_VALUE_READER->put(Short::typeClass(), new SSSR_ValueReader_Short()); self::$CLASS_TO_VALUE_READER->put(String::clazz(), new SSSR_ValueReader_String()); }
private function constructorFunctionArray(ArrayValueCommand $x) { $targetClass = ArrayType::clazz($x->getComponentType()); $functionName = $this->constructorFunctions->get($targetClass); if (!is_null($functionName)) { return $functionName; } $initValuesId = $this->clientOracle->getMethodIdByClassName('com.google.gwt.lang.Array', 'initValues', array('Ljava/lang/Class;', 'Lcom/google/gwt/core/client/JavaScriptObject;', 'I', 'Lcom/google/gwt/lang/Array;')); assert(!is_null($initValuesId)); $classLitId = $this->clientOracle->getFieldIdByClassName('com.google.gwt.lang.ClassLiteralHolder', $this->getJavahSignatureName($x->getComponentType()) . '_classLit'); assert(!is_null($classLitId)); $functionName = $this->clientOracle->createUnusedIdent($classLitId); $this->constructorFunctions->put($targetClass, $functionName); $castableTypeData = $this->clientOracle->getCastableTypeData($targetClass); if (is_null($castableTypeData)) { $castableTypeData = $this->clientOracle->getCastableTypeData(Classes::classOf('Object[]')); } $queryId = $this->clientOracle->getQueryId($x->getComponentType()); if ($queryId == 0) { $queryId = $this->clientOracle->getQueryId(Classes::classOf('Object')); } $ident = '_0'; // function foo(_0) {return initValues(classLid, castableTypeData, queryId, _0)} $this->_function(); $this->push($functionName); $this->lparen(); $this->push($ident); $this->rparen(); $this->lbrace(); $this->_return(); $this->push($initValuesId); $this->lparen(); $this->push($classLitId); $this->comma(); $this->push($castableTypeData->toJs()); $this->comma(); $this->push(String::valueOf($queryId)); $this->comma(); $this->push($ident); $this->rparen(); $this->rbrace(); $this->flush($x); return $functionName; }
private function findClass($token) { if (isset($this->classCache[$token])) { return $this->classCache[$token]; } $className = $this->clientOracle->getTypeName($token); if ($className == null) { $className = $token; } if (strstr($className, '[]') !== false) { $firstIndex = -1; $j = -1; $dims = 0; while (($j = strpos($className, '[')) !== false) { if ($dims++ == 0) { $firstIndex = $j; } } $componentType = $this->findClass(substr($className, 0, $firstIndex)); assert($componentType != null); $clazz = ArrayType::clazz($componentType, $dims); } else { $clazz = Classes::classOf($className); } $this->classCache[$token] = $clazz; return $clazz; }
protected function createFields() { list($fields, $decl) = parent::createFields(); $temp = array(); $constants = $this->getEnumValues(); foreach ($constants as $value) { $temp[$value] = new VirtualField($this, $value, $this, 0, VirtualField::FLAG_STATIC); } $temp['ENUM$VALUES'] = new VirtualField($this, 'ENUM$VALUES', ArrayType::clazz($this), 0, VirtualField::FLAG_STATIC); return array(array_merge($fields, $temp), array_merge($decl, $temp)); }