Summary: Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs. find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$ replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree. Reviewed By: TheSavior, yungsters Differential Revision: D7007050 fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
138 lines
4.3 KiB
C++
138 lines
4.3 KiB
C++
/*
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <jni.h>
|
|
|
|
#include <fb/visibility.h>
|
|
|
|
namespace facebook {
|
|
|
|
/**
|
|
* Instructs the JNI environment to throw an exception.
|
|
*
|
|
* @param pEnv JNI environment
|
|
* @param szClassName class name to throw
|
|
* @param szFmt sprintf-style format string
|
|
* @param ... sprintf-style args
|
|
* @return 0 on success; a negative value on failure
|
|
*/
|
|
FBEXPORT jint throwException(JNIEnv* pEnv, const char* szClassName, const char* szFmt, va_list va_args);
|
|
|
|
/**
|
|
* Instructs the JNI environment to throw a NoClassDefFoundError.
|
|
*
|
|
* @param pEnv JNI environment
|
|
* @param szFmt sprintf-style format string
|
|
* @param ... sprintf-style args
|
|
* @return 0 on success; a negative value on failure
|
|
*/
|
|
FBEXPORT jint throwNoClassDefError(JNIEnv* pEnv, const char* szFmt, ...);
|
|
|
|
/**
|
|
* Instructs the JNI environment to throw a RuntimeException.
|
|
*
|
|
* @param pEnv JNI environment
|
|
* @param szFmt sprintf-style format string
|
|
* @param ... sprintf-style args
|
|
* @return 0 on success; a negative value on failure
|
|
*/
|
|
FBEXPORT jint throwRuntimeException(JNIEnv* pEnv, const char* szFmt, ...);
|
|
|
|
/**
|
|
* Instructs the JNI environment to throw a IllegalArgumentException.
|
|
*
|
|
* @param pEnv JNI environment
|
|
* @param szFmt sprintf-style format string
|
|
* @param ... sprintf-style args
|
|
* @return 0 on success; a negative value on failure
|
|
*/
|
|
FBEXPORT jint throwIllegalArgumentException(JNIEnv* pEnv, const char* szFmt, ...);
|
|
|
|
/**
|
|
* Instructs the JNI environment to throw a IllegalStateException.
|
|
*
|
|
* @param pEnv JNI environment
|
|
* @param szFmt sprintf-style format string
|
|
* @param ... sprintf-style args
|
|
* @return 0 on success; a negative value on failure
|
|
*/
|
|
FBEXPORT jint throwIllegalStateException(JNIEnv* pEnv, const char* szFmt, ...);
|
|
|
|
/**
|
|
* Instructs the JNI environment to throw an IOException.
|
|
*
|
|
* @param pEnv JNI environment
|
|
* @param szFmt sprintf-style format string
|
|
* @param ... sprintf-style args
|
|
* @return 0 on success; a negative value on failure
|
|
*/
|
|
FBEXPORT jint throwIOException(JNIEnv* pEnv, const char* szFmt, ...);
|
|
|
|
/**
|
|
* Instructs the JNI environment to throw an AssertionError.
|
|
*
|
|
* @param pEnv JNI environment
|
|
* @param szFmt sprintf-style format string
|
|
* @param ... sprintf-style args
|
|
* @return 0 on success; a negative value on failure
|
|
*/
|
|
FBEXPORT jint throwAssertionError(JNIEnv* pEnv, const char* szFmt, ...);
|
|
|
|
/**
|
|
* Instructs the JNI environment to throw an OutOfMemoryError.
|
|
*
|
|
* @param pEnv JNI environment
|
|
* @param szFmt sprintf-style format string
|
|
* @param ... sprintf-style args
|
|
* @return 0 on success; a negative value on failure
|
|
*/
|
|
FBEXPORT jint throwOutOfMemoryError(JNIEnv* pEnv, const char* szFmt, ...);
|
|
|
|
/**
|
|
* Finds the specified class. If it's not found, instructs the JNI environment to throw an
|
|
* exception.
|
|
*
|
|
* @param pEnv JNI environment
|
|
* @param szClassName the classname to find in JNI format (e.g. "java/lang/String")
|
|
* @return the class or NULL if not found (in which case a pending exception will be queued). This
|
|
* returns a global reference (JNIEnv::NewGlobalRef).
|
|
*/
|
|
FBEXPORT jclass findClassOrThrow(JNIEnv *pEnv, const char* szClassName);
|
|
|
|
/**
|
|
* Finds the specified field of the specified class. If it's not found, instructs the JNI
|
|
* environment to throw an exception.
|
|
*
|
|
* @param pEnv JNI environment
|
|
* @param clazz the class to lookup the field in
|
|
* @param szFieldName the name of the field to find
|
|
* @param szSig the signature of the field
|
|
* @return the field or NULL if not found (in which case a pending exception will be queued)
|
|
*/
|
|
FBEXPORT jfieldID getFieldIdOrThrow(JNIEnv* pEnv, jclass clazz, const char* szFieldName, const char* szSig);
|
|
|
|
/**
|
|
* Finds the specified method of the specified class. If it's not found, instructs the JNI
|
|
* environment to throw an exception.
|
|
*
|
|
* @param pEnv JNI environment
|
|
* @param clazz the class to lookup the method in
|
|
* @param szMethodName the name of the method to find
|
|
* @param szSig the signature of the method
|
|
* @return the method or NULL if not found (in which case a pending exception will be queued)
|
|
*/
|
|
FBEXPORT jmethodID getMethodIdOrThrow(
|
|
JNIEnv* pEnv,
|
|
jclass clazz,
|
|
const char* szMethodName,
|
|
const char* szSig);
|
|
|
|
} // namespace facebook
|
|
|