diff options
author | Elliott Hughes <enh@google.com> | 2010-08-12 17:27:27 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2010-08-12 17:27:27 -0700 |
commit | e22935d3c7040c22b48d53bd18878844f381287c (patch) | |
tree | 71112ac81c7141ba029dc036d4f59edef36bbec5 /luni/src/main/native/java_lang_Character.cpp | |
parent | 24144d482dcd5deac58a5dca7042379c05b56b5e (diff) | |
download | libcore-e22935d3c7040c22b48d53bd18878844f381287c.zip libcore-e22935d3c7040c22b48d53bd18878844f381287c.tar.gz libcore-e22935d3c7040c22b48d53bd18878844f381287c.tar.bz2 |
Remove most of our C-style casts.
After being burned by an incorrect C-style cast that cast away const, I've been
keen to remove them all and turn on -Wold-style-cast. This patch doesn't get us
that far, but it does kill the majority of our C-style casts. In turn, the
majority of the casts that it removes are the ones from our tables of native
methods to be registered.
The new NATIVE_METHOD macro also _enforces_ our convention of using the
"Class_nativeMethod" style of naming. Mostly this works out fine. In some
cases (most notably ExpatParser and ExpatAttributes) I've had to un-overload
a few functions, but I don't like overloading anyway, and in the particular
case of a native method, where the stack trace doesn't show a line number,
overloading makes it one step harder to work out which native method you're
actually in. So good riddance to that. The only unfortunate case is
Math.copySign, where there are two overloads corresponding to copysign(3)
and copysignf(3). I had to add an extra layer of indirection there. In my
defense, we've never shipped these functions before, they're unlikely to
become anyone's hotspot, and the right fix is to be doing such trivial work
on the Java side anyway, with intrinsics making the conversion between
float/double and int/long cheap.
This patch also replaces other C-style casts, primarily in
"OSNetworkSystem.cpp".
This patch also removes unnecessary uses of the "struct" keyword.
This patch also fixes a "may be used uninitialized" warning (now error) in
the sim build for "ICU.cpp".
The remaining C-style casts are in the hairy float-parsing code. That stuff --
and turning on -Wold-style-cast -- will have to wait for another day.
Change-Id: I9b3ee14aefd4676f980f6a7ca757595d78d80e6a
Diffstat (limited to 'luni/src/main/native/java_lang_Character.cpp')
-rw-r--r-- | luni/src/main/native/java_lang_Character.cpp | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/luni/src/main/native/java_lang_Character.cpp b/luni/src/main/native/java_lang_Character.cpp index b2563e4..d433269 100644 --- a/luni/src/main/native/java_lang_Character.cpp +++ b/luni/src/main/native/java_lang_Character.cpp @@ -17,6 +17,7 @@ #define LOG_TAG "Character" #include "JNIHelp.h" +#include "JniConstants.h" #include "ScopedUtfChars.h" #include "unicode/uchar.h" #include <math.h> @@ -151,28 +152,28 @@ static int Character_ofImpl(JNIEnv*, jclass, jint codePoint) { } static JNINativeMethod gMethods[] = { - { "digitImpl", "(II)I", (void*) Character_digitImpl }, - { "forNameImpl", "(Ljava/lang/String;)I", (void*) Character_forNameImpl }, - { "getDirectionalityImpl", "(I)B", (void*) Character_getDirectionalityImpl }, - { "getNumericValueImpl", "(I)I", (void*) Character_getNumericValueImpl }, - { "getTypeImpl", "(I)I", (void*) Character_getTypeImpl }, - { "isDefinedImpl", "(I)Z", (void*) Character_isDefinedImpl }, - { "isDigitImpl", "(I)Z", (void*) Character_isDigitImpl }, - { "isIdentifierIgnorableImpl", "(I)Z", (void*) Character_isIdentifierIgnorableImpl }, - { "isLetterImpl", "(I)Z", (void*) Character_isLetterImpl }, - { "isLetterOrDigitImpl", "(I)Z", (void*) Character_isLetterOrDigitImpl }, - { "isLowerCaseImpl", "(I)Z", (void*) Character_isLowerCaseImpl }, - { "isMirroredImpl", "(I)Z", (void*) Character_isMirroredImpl }, - { "isSpaceCharImpl", "(I)Z", (void*) Character_isSpaceCharImpl }, - { "isTitleCaseImpl", "(I)Z", (void*) Character_isTitleCaseImpl }, - { "isUnicodeIdentifierPartImpl", "(I)Z", (void*) Character_isUnicodeIdentifierPartImpl }, - { "isUnicodeIdentifierStartImpl", "(I)Z", (void*) Character_isUnicodeIdentifierStartImpl }, - { "isUpperCaseImpl", "(I)Z", (void*) Character_isUpperCaseImpl }, - { "isWhitespaceImpl", "(I)Z", (void*) Character_isWhitespaceImpl }, - { "ofImpl", "(I)I", (void*) Character_ofImpl }, - { "toLowerCaseImpl", "(I)I", (void*) Character_toLowerCaseImpl }, - { "toTitleCaseImpl", "(I)I", (void*) Character_toTitleCaseImpl }, - { "toUpperCaseImpl", "(I)I", (void*) Character_toUpperCaseImpl }, + NATIVE_METHOD(Character, digitImpl, "(II)I"), + NATIVE_METHOD(Character, forNameImpl, "(Ljava/lang/String;)I"), + NATIVE_METHOD(Character, getDirectionalityImpl, "(I)B"), + NATIVE_METHOD(Character, getNumericValueImpl, "(I)I"), + NATIVE_METHOD(Character, getTypeImpl, "(I)I"), + NATIVE_METHOD(Character, isDefinedImpl, "(I)Z"), + NATIVE_METHOD(Character, isDigitImpl, "(I)Z"), + NATIVE_METHOD(Character, isIdentifierIgnorableImpl, "(I)Z"), + NATIVE_METHOD(Character, isLetterImpl, "(I)Z"), + NATIVE_METHOD(Character, isLetterOrDigitImpl, "(I)Z"), + NATIVE_METHOD(Character, isLowerCaseImpl, "(I)Z"), + NATIVE_METHOD(Character, isMirroredImpl, "(I)Z"), + NATIVE_METHOD(Character, isSpaceCharImpl, "(I)Z"), + NATIVE_METHOD(Character, isTitleCaseImpl, "(I)Z"), + NATIVE_METHOD(Character, isUnicodeIdentifierPartImpl, "(I)Z"), + NATIVE_METHOD(Character, isUnicodeIdentifierStartImpl, "(I)Z"), + NATIVE_METHOD(Character, isUpperCaseImpl, "(I)Z"), + NATIVE_METHOD(Character, isWhitespaceImpl, "(I)Z"), + NATIVE_METHOD(Character, ofImpl, "(I)I"), + NATIVE_METHOD(Character, toLowerCaseImpl, "(I)I"), + NATIVE_METHOD(Character, toTitleCaseImpl, "(I)I"), + NATIVE_METHOD(Character, toUpperCaseImpl, "(I)I"), }; int register_java_lang_Character(JNIEnv* env) { return jniRegisterNativeMethods(env, "java/lang/Character", gMethods, NELEM(gMethods)); |