| 148 | } |
| 149 | |
| 150 | JavaObject toJavaObject(JavaEnv env, const Valdi::Value& weakValue) { |
| 151 | switch (weakValue.getType()) { |
| 152 | case Valdi::ValueType::Null: |
| 153 | return JavaObject(env); |
| 154 | case Valdi::ValueType::Undefined: |
| 155 | return undefinedValueJavaObject(env); |
| 156 | case Valdi::ValueType::InternedString: |
| 157 | return toJavaObject(env, weakValue.toStringBox()); |
| 158 | case Valdi::ValueType::StaticString: |
| 159 | return toJavaObject(env, *weakValue.getStaticString()); |
| 160 | case Valdi::ValueType::Int: |
| 161 | return toJavaObject(env, weakValue.toInt()); |
| 162 | case Valdi::ValueType::Long: |
| 163 | return toJavaObject(env, weakValue.toLong()); |
| 164 | case Valdi::ValueType::Double: |
| 165 | return toJavaObject(env, weakValue.toDouble()); |
| 166 | case Valdi::ValueType::Bool: |
| 167 | return toJavaObject(env, weakValue.toBool()); |
| 168 | case Valdi::ValueType::Map: |
| 169 | return toJavaObject(env, weakValue.getMapRef()); |
| 170 | case Valdi::ValueType::Array: |
| 171 | return toJavaObject(env, weakValue.getArrayRef()); |
| 172 | case Valdi::ValueType::TypedArray: |
| 173 | return toJavaObject(env, weakValue.getTypedArrayRef()); |
| 174 | case Valdi::ValueType::Function: |
| 175 | return toJavaObject(env, weakValue.getFunctionRef()); |
| 176 | case Valdi::ValueType::TypedObject: |
| 177 | return toJavaObject(env, weakValue.getTypedObjectRef()); |
| 178 | case Valdi::ValueType::ProxyTypedObject: |
| 179 | return toJavaObject(env, weakValue.getTypedProxyObjectRef()); |
| 180 | case Valdi::ValueType::ValdiObject: |
| 181 | return javaObjectFromValdiObject(weakValue.getValdiObject(), true); |
| 182 | case Valdi::ValueType::Error: |
| 183 | return toJavaObject(env, weakValue.getError()); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | JavaObject undefinedValueJavaObject(JavaEnv /* env */) { |
| 188 | return JavaCache::getUndefinedValueClassInstance(); |