use of org.robolectric.res.android.ResXMLParser in project robolectric by robolectric.
the class ShadowArscAssetManager9 method nativeRetrieveAttributes.
// static jboolean NativeRetrieveAttributes(JNIEnv* env, jclass /*clazz*/, jlong ptr,
// jlong xml_parser_ptr, jintArray java_attrs,
// jintArray out_java_values, jintArray out_java_indices)
// {
@Implementation(minSdk = P)
protected static boolean nativeRetrieveAttributes(long ptr, long xml_parser_ptr, @NonNull int[] java_attrs, @NonNull int[] out_java_values, @NonNull int[] out_java_indices) {
int attrs_len = java_attrs.length;
int out_values_len = out_java_values.length;
if (out_values_len < (attrs_len * STYLE_NUM_ENTRIES)) {
throw new IndexOutOfBoundsException("outValues too small");
}
int[] attrs = // reinterpret_cast<int*>(env.GetPrimitiveArrayCritical(java_attrs, null));
java_attrs;
if (attrs == null) {
return JNI_FALSE;
}
int[] out_values = out_java_values;
// reinterpret_cast<int*>(env.GetPrimitiveArrayCritical(out_java_values, null));
if (out_values == null) {
// env.ReleasePrimitiveArrayCritical(java_attrs, attrs, JNI_ABORT);
return JNI_FALSE;
}
int[] out_indices = null;
if (out_java_indices != null) {
int out_indices_len = out_java_indices.length;
if (out_indices_len > attrs_len) {
out_indices = out_java_indices;
// reinterpret_cast<int*>(env.GetPrimitiveArrayCritical(out_java_indices, null));
if (out_indices == null) {
// env.ReleasePrimitiveArrayCritical(out_java_values, out_values, JNI_ABORT);
return JNI_FALSE;
}
}
}
CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
ResXMLParser xml_parser = NATIVE_RES_XML_PARSERS.getNativeObject(xml_parser_ptr);
boolean result = RetrieveAttributes(assetmanager, xml_parser, attrs, attrs_len, out_values, out_indices);
// env.ReleasePrimitiveArrayCritical(java_attrs, attrs, JNI_ABORT);
return result;
}
use of org.robolectric.res.android.ResXMLParser in project robolectric by robolectric.
the class ShadowXmlBlock method nativeCreateParseState.
@Implementation(minSdk = VERSION_CODES.Q)
protected static long nativeCreateParseState(long obj, int resid) {
ResXMLTree osb = Registries.NATIVE_RES_XML_TREES.getNativeObject(obj);
// if (osb == NULL) {
// jniThrowNullPointerException(env, NULL);
// return 0;
// }
ResXMLParser st = new ResXMLParser(osb);
// if (st == NULL) {
// jniThrowException(env, "java/lang/OutOfMemoryError", NULL);
// return 0;
// }
st.setSourceResourceId(resid);
st.restart();
return Registries.NATIVE_RES_XML_PARSERS.register(st);
}
use of org.robolectric.res.android.ResXMLParser in project robolectric by robolectric.
the class ShadowXmlBlock method nativeGetIdAttribute.
@Implementation(minSdk = VERSION_CODES.LOLLIPOP)
protected static int nativeGetIdAttribute(long state) {
ResXMLParser resXMLParser = getResXMLParser(state);
int idx = resXMLParser.indexOfID();
return idx >= 0 ? resXMLParser.getAttributeValueStringID(idx) : -1;
}
use of org.robolectric.res.android.ResXMLParser in project robolectric by robolectric.
the class ShadowXmlBlock method nativeGetStyleAttribute.
@Implementation(minSdk = VERSION_CODES.LOLLIPOP)
protected static int nativeGetStyleAttribute(long state) {
ResXMLParser resXMLParser = getResXMLParser(state);
int idx = resXMLParser.indexOfStyle();
if (idx < 0) {
return 0;
}
final Ref<Res_value> valueRef = new Ref<>(new Res_value());
if (resXMLParser.getAttributeValue(idx, valueRef) < 0) {
return 0;
}
Res_value value = valueRef.get();
return value.dataType == org.robolectric.res.android.ResourceTypes.Res_value.TYPE_REFERENCE || value.dataType == org.robolectric.res.android.ResourceTypes.Res_value.TYPE_ATTRIBUTE ? value.data : 0;
}
use of org.robolectric.res.android.ResXMLParser in project robolectric by robolectric.
the class ShadowXmlBlock method nativeGetClassAttribute.
@Implementation(minSdk = VERSION_CODES.LOLLIPOP)
protected static int nativeGetClassAttribute(long state) {
ResXMLParser resXMLParser = getResXMLParser(state);
int idx = resXMLParser.indexOfClass();
return idx >= 0 ? resXMLParser.getAttributeValueStringID(idx) : -1;
}
Aggregations