Bug 327846 - Method names conflicting with Java keywords should have underscore prepended, not appended. Expand list of Java keywords. General cleanup. r=bsmedberg. xulrunner only
git-svn-id: svn://10.0.0.236/trunk@193284 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -106,33 +106,35 @@ while (<STDIN>) {
|
||||
if (/^\s*#define\s+(NS_[A-Z_]+)\s+(0x)?([0-9a-fA-F]+)\s*$/) {
|
||||
#define NS_ERROR_MODULE_XPCOM 1
|
||||
#define NS_ERROR_MODULE_BASE_OFFSET 0x45
|
||||
print " public static final long $1 = $2$3L;\n";
|
||||
print " long $1 = $2$3L;\n";
|
||||
}
|
||||
elsif (/^\s*#define\s+(NS_[A-Z_]+)\s+\((NS_[A-Z_]+)\s+\+\s+(0x)?([0-9a-fA-F]+)\s*\)\s*/) {
|
||||
#define NS_ERROR_NOT_INITIALIZED (NS_ERROR_BASE + 1)
|
||||
#define NS_ERROR_FACTORY_EXISTS (NS_ERROR_BASE + 0x100)
|
||||
print " public static final long $1 = $2 + $3$4L;\n";
|
||||
print " long $1 = $2 + $3$4L;\n";
|
||||
}
|
||||
elsif (/^\s*#define\s+(NS_[A-Z_]+)\s+(NS_[A-Z_]+)\s\s*/) {
|
||||
#define NS_ERROR_NO_INTERFACE NS_NOINTERFACE
|
||||
print " public static final long $1 = $2;\n";
|
||||
print " long $1 = $2;\n";
|
||||
}
|
||||
elsif (/^\s*#define\s+(NS_[A-Z_]+)\s+\(\(nsresult\)\s*(0x)?([0-9a-fA-F]+)L?\)\s*$/) {
|
||||
#define NS_ERROR_BASE ((nsresult) 0xC1F30000)
|
||||
#define NS_ERROR_ABORT ((nsresult) 0x80004004L)
|
||||
print " public static final long $1 = $2$3L;\n";
|
||||
print " long $1 = $2$3L;\n";
|
||||
}
|
||||
elsif (/^\s*#define\s+(NS_[A-Z_]+)\s+NS_ERROR_GENERATE_FAILURE\s*\(\s*(NS_[A-Z_]+)\s*,\s*([0-9]+)\s*\)\s*$/) {
|
||||
#define NS_BASE_STREAM_CLOSED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 2)
|
||||
$module = $2;
|
||||
$code = $3;
|
||||
print " public static final long $1 = ((NS_ERROR_SEVERITY_ERROR<<31) | (($module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | $code);\n";
|
||||
print " long $1 = ((NS_ERROR_SEVERITY_ERROR<<31) |\n";
|
||||
print " (($module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | $code);\n";
|
||||
}
|
||||
elsif (/^\s*#define\s+(NS_[A-Z_]+)\s+NS_ERROR_GENERATE_SUCCESS\s*\(\s*(NS_[A-Z_]+)\s*,\s*([0-9]+)\s*\)\s*$/) {
|
||||
#define NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_XPCOM, 1)
|
||||
$module = $2;
|
||||
$code = $3;
|
||||
print " public static final long $1 = ((NS_ERROR_SEVERITY_SUCCESS<<31) | (($module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | $code);\n";
|
||||
print " long $1 = ((NS_ERROR_SEVERITY_SUCCESS<<31) |\n";
|
||||
print " (($module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | $code);\n";
|
||||
}
|
||||
elsif (/^\s*\/\*(.*)\*\/\s*$/ && !/^\s*\/\*@[\{\}]\*\/\s*$/ &&
|
||||
!/^\s*\/\*\ -\*- Mode:/) {
|
||||
|
||||
@@ -76,7 +76,7 @@ public interface IAppFileLocProvider {
|
||||
*
|
||||
* @return the file represented by the property
|
||||
*/
|
||||
public File getFile(String prop, boolean[] persistent);
|
||||
File getFile(String prop, boolean[] persistent);
|
||||
|
||||
/**
|
||||
* Directory Service calls this when it gets a request for
|
||||
@@ -86,7 +86,7 @@ public interface IAppFileLocProvider {
|
||||
*
|
||||
* @return an array of file locations
|
||||
*/
|
||||
public File[] getFiles(String prop);
|
||||
File[] getFiles(String prop);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public interface IGRE {
|
||||
*
|
||||
* @throws XPCOMException if a failure occurred during initialization
|
||||
*/
|
||||
public void initEmbedding(File aLibXULDirectory, File aAppDirectory,
|
||||
void initEmbedding(File aLibXULDirectory, File aAppDirectory,
|
||||
IAppFileLocProvider aAppDirProvider) throws XPCOMException;
|
||||
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ public interface IGRE {
|
||||
*
|
||||
* @throws XPCOMException if a failure occurred during initialization
|
||||
*/
|
||||
public void termEmbedding() throws XPCOMException;
|
||||
void termEmbedding() throws XPCOMException;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public interface IXPCOM {
|
||||
* <li> Other error codes indicate a failure during initialisation. </li>
|
||||
* </ul>
|
||||
*/
|
||||
public nsIServiceManager initXPCOM(File aMozBinDirectory,
|
||||
nsIServiceManager initXPCOM(File aMozBinDirectory,
|
||||
IAppFileLocProvider aAppFileLocProvider) throws XPCOMException;
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ public interface IXPCOM {
|
||||
*
|
||||
* @exception XPCOMException if a failure occurred during termination
|
||||
*/
|
||||
public void shutdownXPCOM(nsIServiceManager aServMgr) throws XPCOMException;
|
||||
void shutdownXPCOM(nsIServiceManager aServMgr) throws XPCOMException;
|
||||
|
||||
/**
|
||||
* Public Method to access to the service manager.
|
||||
@@ -86,7 +86,7 @@ public interface IXPCOM {
|
||||
*
|
||||
* @exception XPCOMException
|
||||
*/
|
||||
public nsIServiceManager getServiceManager() throws XPCOMException;
|
||||
nsIServiceManager getServiceManager() throws XPCOMException;
|
||||
|
||||
/**
|
||||
* Public Method to access to the component manager.
|
||||
@@ -95,7 +95,7 @@ public interface IXPCOM {
|
||||
*
|
||||
* @exception XPCOMException
|
||||
*/
|
||||
public nsIComponentManager getComponentManager() throws XPCOMException;
|
||||
nsIComponentManager getComponentManager() throws XPCOMException;
|
||||
|
||||
/**
|
||||
* Public Method to access to the component registration manager.
|
||||
@@ -104,7 +104,7 @@ public interface IXPCOM {
|
||||
*
|
||||
* @exception XPCOMException
|
||||
*/
|
||||
public nsIComponentRegistrar getComponentRegistrar() throws XPCOMException;
|
||||
nsIComponentRegistrar getComponentRegistrar() throws XPCOMException;
|
||||
|
||||
/**
|
||||
* Public Method to create an instance of a nsILocalFile.
|
||||
@@ -124,7 +124,7 @@ public interface IXPCOM {
|
||||
* or relative paths (must supply full file path) </li>
|
||||
* </ul>
|
||||
*/
|
||||
public nsILocalFile newLocalFile(String aPath, boolean aFollowLinks)
|
||||
nsILocalFile newLocalFile(String aPath, boolean aFollowLinks)
|
||||
throws XPCOMException;
|
||||
|
||||
}
|
||||
|
||||
@@ -855,7 +855,8 @@ SetupParams(JNIEnv *env, const jobject aParam, PRUint8 aType, PRBool aIsOut,
|
||||
{
|
||||
LOG(("long (void*)\n"));
|
||||
if (!aIsOut && !aIsArrayElement) { // 'in'
|
||||
aVariant.val.p = (void*) env->CallLongMethod(aParam, longValueMID);
|
||||
aVariant.val.p =
|
||||
NS_REINTERPRET_CAST(void*, env->CallLongMethod(aParam, longValueMID));
|
||||
} else { // 'inout' & 'array'
|
||||
jlong value;
|
||||
if (aParam) {
|
||||
@@ -871,7 +872,8 @@ SetupParams(JNIEnv *env, const jobject aParam, PRUint8 aType, PRBool aIsOut,
|
||||
}
|
||||
aVariant.SetPtrIsData();
|
||||
} else { // 'array'
|
||||
NS_STATIC_CAST(void**, aVariant.val.p)[aIndex] = (void*) value;
|
||||
NS_STATIC_CAST(void**, aVariant.val.p)[aIndex] =
|
||||
NS_REINTERPRET_CAST(void*, value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1284,6 +1286,53 @@ FinalizeParams(JNIEnv *env, const nsXPTParamInfo &aParamInfo, PRUint8 aType,
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
QueryAttributeInfo(nsIInterfaceInfo* aIInfo, const char* aMethodName,
|
||||
PRBool aCapitalizedAttr, PRUint16* aMethodIndex,
|
||||
const nsXPTMethodInfo** aMethodInfo)
|
||||
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
// An 'attribute' will start with either "get" or "set". But first,
|
||||
// we check the length, in order to skip over method names that match exactly
|
||||
// "get" or "set".
|
||||
if (strlen(aMethodName) > 3) {
|
||||
if (strncmp("get", aMethodName, 3) == 0) {
|
||||
char* getterName = strdup(aMethodName + 3);
|
||||
if (!aCapitalizedAttr) {
|
||||
getterName[0] = tolower(getterName[0]);
|
||||
}
|
||||
rv = aIInfo->GetMethodInfoForName(getterName, aMethodIndex, aMethodInfo);
|
||||
free(getterName);
|
||||
} else if (strncmp("set", aMethodName, 3) == 0) {
|
||||
char* setterName = strdup(aMethodName + 3);
|
||||
if (!aCapitalizedAttr) {
|
||||
setterName[0] = tolower(setterName[0]);
|
||||
}
|
||||
rv = aIInfo->GetMethodInfoForName(setterName, aMethodIndex, aMethodInfo);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// If this succeeded, GetMethodInfoForName will have returned the
|
||||
// method info for the 'getter'. We want the 'setter', so increase
|
||||
// method index by one ('setter' immediately follows the 'getter'),
|
||||
// and get its method info.
|
||||
(*aMethodIndex)++;
|
||||
rv = aIInfo->GetMethodInfo(*aMethodIndex, aMethodInfo);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Double check that this methodInfo matches the given method.
|
||||
if (!(*aMethodInfo)->IsSetter() ||
|
||||
strcmp(setterName, (*aMethodInfo)->name) != 0) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(setterName);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an interface info struct and a method name, returns the method info
|
||||
* and index, if that method exists.
|
||||
@@ -1296,84 +1345,39 @@ nsresult
|
||||
QueryMethodInfo(nsIInterfaceInfo* aIInfo, const char* aMethodName,
|
||||
PRUint16* aMethodIndex, const nsXPTMethodInfo** aMethodInfo)
|
||||
{
|
||||
// Skip over any leading underscores, since these are methods that conflicted
|
||||
// with existing Java keywords
|
||||
const char* methodName = aMethodName;
|
||||
if (methodName[0] == '_') {
|
||||
methodName++;
|
||||
}
|
||||
|
||||
// The common case is that the method name is lower case, so we check
|
||||
// that first.
|
||||
nsresult rv;
|
||||
rv = aIInfo->GetMethodInfoForName(aMethodName, aMethodIndex, aMethodInfo);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return rv;
|
||||
|
||||
// If there is no method called <aMethodName>, then maybe it is an
|
||||
// 'attribute'. An 'attribute' will start with "get" or "set". But first,
|
||||
// we check the length, in order to skip over method names that match exactly
|
||||
// "get" or "set".
|
||||
if (strlen(aMethodName) > 3) {
|
||||
if (strncmp("get", aMethodName, 3) == 0) {
|
||||
char* getterName = strdup(aMethodName + 3);
|
||||
getterName[0] = tolower(getterName[0]);
|
||||
rv = aIInfo->GetMethodInfoForName(getterName, aMethodIndex, aMethodInfo);
|
||||
free(getterName);
|
||||
} else if (strncmp("set", aMethodName, 3) == 0) {
|
||||
char* setterName = strdup(aMethodName + 3);
|
||||
setterName[0] = tolower(setterName[0]);
|
||||
rv = aIInfo->GetMethodInfoForName(setterName, aMethodIndex, aMethodInfo);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// If this succeeded, GetMethodInfoForName will have returned the
|
||||
// method info for the 'getter'. We want the 'setter', so increase
|
||||
// method index by one ('setter' immediately follows the 'getter'),
|
||||
// and get its method info.
|
||||
(*aMethodIndex)++;
|
||||
rv = aIInfo->GetMethodInfo(*aMethodIndex, aMethodInfo);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Double check that this methodInfo matches the given method.
|
||||
if (!(*aMethodInfo)->IsSetter() ||
|
||||
strcmp(setterName, (*aMethodInfo)->name) != 0) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(setterName);
|
||||
}
|
||||
}
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return rv;
|
||||
|
||||
// If we get here, then maybe the method name is capitalized.
|
||||
char* methodName = strdup(aMethodName);
|
||||
methodName[0] = toupper(methodName[0]);
|
||||
rv = aIInfo->GetMethodInfoForName(methodName, aMethodIndex, aMethodInfo);
|
||||
free(methodName);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return rv;
|
||||
|
||||
// If there is no method called <aMethodName>, then maybe it is an
|
||||
// 'attribute'.
|
||||
if (strlen(aMethodName) > 3) {
|
||||
if (strncmp("get", aMethodName, 3) == 0) {
|
||||
char* getterName = strdup(aMethodName + 3);
|
||||
rv = aIInfo->GetMethodInfoForName(getterName, aMethodIndex, aMethodInfo);
|
||||
free(getterName);
|
||||
} else if (strncmp("set", aMethodName, 3) == 0) {
|
||||
char* setterName = strdup(aMethodName + 3);
|
||||
rv = aIInfo->GetMethodInfoForName(setterName, aMethodIndex, aMethodInfo);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// If this succeeded, GetMethodInfoForName will have returned the
|
||||
// method info for the 'getter'. We want the 'setter', so increase
|
||||
// method index by one ('setter' immediately follows the 'getter'),
|
||||
// and get its method info.
|
||||
(*aMethodIndex)++;
|
||||
rv = aIInfo->GetMethodInfo(*aMethodIndex, aMethodInfo);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Double check that this methodInfo matches the given method.
|
||||
if (!(*aMethodInfo)->IsSetter() ||
|
||||
strcmp(setterName, (*aMethodInfo)->name) != 0) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(setterName);
|
||||
}
|
||||
}
|
||||
rv = QueryAttributeInfo(aIInfo, methodName, PR_FALSE, aMethodIndex,
|
||||
aMethodInfo);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return rv;
|
||||
|
||||
// If we get here, then maybe the method name is capitalized.
|
||||
char* name = strdup(methodName);
|
||||
name[0] = toupper(name[0]);
|
||||
rv = aIInfo->GetMethodInfoForName(name, aMethodIndex, aMethodInfo);
|
||||
free(name);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return rv;
|
||||
|
||||
// If there is no method called <aMethodName>, then maybe it is an
|
||||
// 'attribute'.
|
||||
rv = QueryAttributeInfo(aIInfo, methodName, PR_TRUE, aMethodIndex,
|
||||
aMethodInfo);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -95,6 +95,34 @@ JavaToXPTCStubMap* gJavaToXPTCStubMap = nsnull;
|
||||
PRBool gJavaXPCOMInitialized = PR_FALSE;
|
||||
PRLock* gJavaXPCOMLock = nsnull;
|
||||
|
||||
static const char* kJavaKeywords[] = {
|
||||
"abstract", "default" , "if" , "private" , "throw" ,
|
||||
"boolean" , "do" , "implements", "protected" , "throws" ,
|
||||
"break" , "double" , "import", "public" , "transient" ,
|
||||
"byte" , "else" , "instanceof", "return" , "try" ,
|
||||
"case" , "extends" , "int" , "short" , "void" ,
|
||||
"catch" , "final" , "interface" , "static" , "volatile" ,
|
||||
"char" , "finally" , "long" , "super" , "while" ,
|
||||
"class" , "float" , "native" , "switch" ,
|
||||
"const" , "for" , "new" , "synchronized",
|
||||
"continue", "goto" , "package" , "this" ,
|
||||
/* added in Java 1.2 */
|
||||
"strictfp",
|
||||
/* added in Java 1.4 */
|
||||
"assert" ,
|
||||
/* added in Java 5.0 */
|
||||
"enum" ,
|
||||
/* Java constants */
|
||||
"true" , "false" , "null" ,
|
||||
/* java.lang.Object methods *
|
||||
* - don't worry about "toString", since it does the same thing *
|
||||
* as Object's "toString" */
|
||||
"clone" , "equals" , "finalize" , "getClass" , "hashCode" ,
|
||||
"notify" , "notifyAll", /*"toString" ,*/ "wait"
|
||||
};
|
||||
|
||||
nsTHashtable<nsDepCharHashKey>* gJavaKeywords = nsnull;
|
||||
|
||||
|
||||
/******************************
|
||||
* InitializeJavaGlobals
|
||||
@@ -245,16 +273,35 @@ InitializeJavaGlobals(JNIEnv *env)
|
||||
#endif
|
||||
|
||||
gNativeToJavaProxyMap = new NativeToJavaProxyMap();
|
||||
if (NS_FAILED(gNativeToJavaProxyMap->Init())) {
|
||||
if (!gNativeToJavaProxyMap || NS_FAILED(gNativeToJavaProxyMap->Init())) {
|
||||
NS_WARNING("Problem creating NativeToJavaProxyMap");
|
||||
goto init_error;
|
||||
}
|
||||
gJavaToXPTCStubMap = new JavaToXPTCStubMap();
|
||||
if (NS_FAILED(gJavaToXPTCStubMap->Init())) {
|
||||
if (!gJavaToXPTCStubMap || NS_FAILED(gJavaToXPTCStubMap->Init())) {
|
||||
NS_WARNING("Problem creating JavaToXPTCStubMap");
|
||||
goto init_error;
|
||||
}
|
||||
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRUint32 size = NS_ARRAY_LENGTH(kJavaKeywords);
|
||||
gJavaKeywords = new nsTHashtable<nsDepCharHashKey>();
|
||||
if (!gJavaKeywords || NS_FAILED(gJavaKeywords->Init(size))) {
|
||||
NS_WARNING("Failed to init JavaKeywords HashSet");
|
||||
goto init_error;
|
||||
}
|
||||
for (PRUint32 i = 0; i < size && NS_SUCCEEDED(rv); i++) {
|
||||
if (!gJavaKeywords->PutEntry(kJavaKeywords[i])) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to populate JavaKeywords hash");
|
||||
goto init_error;
|
||||
}
|
||||
}
|
||||
|
||||
gJavaXPCOMLock = PR_NewLock();
|
||||
gJavaXPCOMInitialized = PR_TRUE;
|
||||
return PR_TRUE;
|
||||
@@ -346,6 +393,11 @@ FreeJavaGlobals(JNIEnv* env)
|
||||
xpcomJavaProxyClass = nsnull;
|
||||
}
|
||||
|
||||
if (gJavaKeywords) {
|
||||
delete gJavaKeywords;
|
||||
gJavaKeywords = nsnull;
|
||||
}
|
||||
|
||||
if (tempLock) {
|
||||
PR_Unlock(tempLock);
|
||||
PR_DestroyLock(tempLock);
|
||||
|
||||
@@ -45,6 +45,8 @@
|
||||
#include "pldhash.h"
|
||||
#include "nsJavaXPTCStub.h"
|
||||
#include "nsAutoLock.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
|
||||
//#define DEBUG_JAVAXPCOM
|
||||
//#define DEBUG_JAVAXPCOM_REFCNT
|
||||
@@ -110,6 +112,8 @@ extern NativeToJavaProxyMap* gNativeToJavaProxyMap;
|
||||
class JavaToXPTCStubMap;
|
||||
extern JavaToXPTCStubMap* gJavaToXPTCStubMap;
|
||||
|
||||
extern nsTHashtable<nsDepCharHashKey>* gJavaKeywords;
|
||||
|
||||
// The Java garbage collector runs in a separate thread. Since it calls the
|
||||
// finalizeProxy() function in nsJavaWrapper.cpp, we need to make sure that
|
||||
// all the structures touched by finalizeProxy() are multithread aware.
|
||||
|
||||
@@ -390,7 +390,6 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
JNIEnv* env = GetJNIEnv();
|
||||
|
||||
jobject javaObject = env->NewLocalRef(mJavaWeakRef);
|
||||
|
||||
nsCAutoString methodSig("(");
|
||||
@@ -447,6 +446,10 @@ nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
|
||||
methodName.AppendASCII(aMethodInfo->GetName());
|
||||
methodName.SetCharAt(tolower(methodName[0]), 0);
|
||||
}
|
||||
// If it's a Java keyword, then prepend an underscore
|
||||
if (gJavaKeywords->GetEntry(methodName.get())) {
|
||||
methodName.Insert('_', 0);
|
||||
}
|
||||
|
||||
jclass clazz = env->GetObjectClass(javaObject);
|
||||
if (clazz)
|
||||
@@ -849,7 +852,7 @@ nsJavaXPTCStub::SetupJavaParams(const nsXPTParamInfo &aParamInfo,
|
||||
iid = *variant;
|
||||
}
|
||||
|
||||
jobject str;
|
||||
jobject str = nsnull;
|
||||
if (iid) {
|
||||
char* iid_str = iid->ToString();
|
||||
if (iid_str) {
|
||||
@@ -860,8 +863,6 @@ nsJavaXPTCStub::SetupJavaParams(const nsXPTParamInfo &aParamInfo,
|
||||
break;
|
||||
}
|
||||
PR_Free(iid_str);
|
||||
} else {
|
||||
str = nsnull;
|
||||
}
|
||||
|
||||
if (!aParamInfo.IsOut()) { // 'in'
|
||||
@@ -1030,7 +1031,7 @@ nsJavaXPTCStub::SetupJavaParams(const nsXPTParamInfo &aParamInfo,
|
||||
case nsXPTType::T_VOID:
|
||||
{
|
||||
if (!aParamInfo.IsOut()) { // 'in'
|
||||
aJValue.j = (jlong) aVariant.val.p;
|
||||
aJValue.j = NS_REINTERPRET_CAST(jlong, aVariant.val.p);
|
||||
aMethodSig.Append('J');
|
||||
} else { // 'inout' & 'out'
|
||||
if (aVariant.val.p) {
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include "xptcall.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
@@ -151,20 +150,29 @@ public:
|
||||
|
||||
|
||||
static const char* kJavaKeywords[] = {
|
||||
"abstract", "default", "if" , "private" , "this" ,
|
||||
"boolean" , "do" , "implements", "protected" , "throw" ,
|
||||
"break" , "double" , "import", "public" , "throws" ,
|
||||
"byte" , "else" , "instanceof", "return" , "transient",
|
||||
"case" , "extends", "int" , "short" , "try" ,
|
||||
"catch" , "final" , "interface" , "static" , "void" ,
|
||||
"char" , "finally", "long" , "strictfp" , "volatile" ,
|
||||
"class" , "float" , "native" , "super" , "while" ,
|
||||
"const" , "for" , "new" , "switch" ,
|
||||
"continue", "goto" , "package" , "synchronized",
|
||||
"assert" , /* added in Java 1.4 */
|
||||
"enum" , /* added in Java 5.0 */
|
||||
"clone" , /* clone is a member function of java.lang.Object */
|
||||
"finalize" /* finalize is a member function of java.lang.Object */
|
||||
"abstract", "default" , "if" , "private" , "throw" ,
|
||||
"boolean" , "do" , "implements", "protected" , "throws" ,
|
||||
"break" , "double" , "import", "public" , "transient" ,
|
||||
"byte" , "else" , "instanceof", "return" , "try" ,
|
||||
"case" , "extends" , "int" , "short" , "void" ,
|
||||
"catch" , "final" , "interface" , "static" , "volatile" ,
|
||||
"char" , "finally" , "long" , "super" , "while" ,
|
||||
"class" , "float" , "native" , "switch" ,
|
||||
"const" , "for" , "new" , "synchronized",
|
||||
"continue", "goto" , "package" , "this" ,
|
||||
/* added in Java 1.2 */
|
||||
"strictfp",
|
||||
/* added in Java 1.4 */
|
||||
"assert" ,
|
||||
/* added in Java 5.0 */
|
||||
"enum" ,
|
||||
/* Java constants */
|
||||
"true" , "false" , "null" ,
|
||||
/* java.lang.Object methods *
|
||||
* - don't worry about "toString", since it does the same thing *
|
||||
* as Object's "toString" */
|
||||
"clone" , "equals" , "finalize" , "getClass" , "hashCode" ,
|
||||
"notify" , "notifyAll", /*"toString" ,*/ "wait"
|
||||
};
|
||||
|
||||
static void ToUpperCase(nsACString& aString)
|
||||
@@ -412,7 +420,7 @@ public:
|
||||
|
||||
nsresult WriteIID(nsIOutputStream* out, nsIInterfaceInfo* aIInfo)
|
||||
{
|
||||
static const char kIIDDecl1[] = " public static final String ";
|
||||
static const char kIIDDecl1[] = " String ";
|
||||
static const char kIIDDecl2[] = " =\n \"";
|
||||
static const char kIIDDecl3[] = "\";\n\n";
|
||||
|
||||
@@ -460,9 +468,8 @@ public:
|
||||
nsresult WriteConstants(nsIOutputStream* out, nsIInterfaceInfo* aIInfo,
|
||||
PRUint16 aParentConstCount)
|
||||
{
|
||||
static const char kConstDecl1[] = " public static final ";
|
||||
static const char kConstDecl2[] = " = ";
|
||||
static const char kConstDecl3[] = ";\n\n";
|
||||
static const char kConstDecl1[] = " = ";
|
||||
static const char kConstDecl2[] = ";\n\n";
|
||||
|
||||
PRUint16 constCount;
|
||||
nsresult rv = aIInfo->GetConstantCount(&constCount);
|
||||
@@ -474,7 +481,7 @@ public:
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRUint32 count;
|
||||
rv = out->Write(kConstDecl1, sizeof(kConstDecl1) - 1, &count);
|
||||
rv = out->Write(" ", 2, &count);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
const nsXPTType &type = constInfo->GetType();
|
||||
rv = WriteType(out, &type, aIInfo, nsnull, nsnull);
|
||||
@@ -484,12 +491,12 @@ public:
|
||||
const char* name = constInfo->GetName();
|
||||
rv = out->Write(name, strlen(name), &count);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = out->Write(kConstDecl2, sizeof(kConstDecl2) - 1, &count);
|
||||
rv = out->Write(kConstDecl1, sizeof(kConstDecl1) - 1, &count);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = WriteConstantValue(out, &type, constInfo->GetValue());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = out->Write(kConstDecl3, sizeof(kConstDecl3) - 1, &count);
|
||||
rv = out->Write(kConstDecl2, sizeof(kConstDecl2) - 1, &count);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@@ -610,13 +617,12 @@ public:
|
||||
const nsXPTMethodInfo* aMethodInfo,
|
||||
PRUint16 aMethodIndex)
|
||||
{
|
||||
static const char kMethodDecl1[] = " public ";
|
||||
static const char kVoidReturn[] = "void";
|
||||
static const char kParamSeparator[] = ", ";
|
||||
static const char kMethodDecl2[] = ");\n\n";
|
||||
static const char kMethodEnd[] = ");\n\n";
|
||||
|
||||
PRUint32 count;
|
||||
nsresult rv = out->Write(kMethodDecl1, sizeof(kMethodDecl1) - 1, &count);
|
||||
nsresult rv = out->Write(" ", 2, &count);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// write return type
|
||||
@@ -649,9 +655,10 @@ public:
|
||||
} else {
|
||||
method_name.Append(tolower(name[0]));
|
||||
method_name.Append(name + 1);
|
||||
// don't use Java keywords as method names
|
||||
if (mJavaKeywords.Get(method_name, nsnull))
|
||||
method_name.Append('_');
|
||||
}
|
||||
// don't use Java keywords as method names
|
||||
if (mJavaKeywords.Get(method_name, nsnull)) {
|
||||
method_name.Insert('_', 0);
|
||||
}
|
||||
rv = out->Write(" ", 1, &count);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@@ -675,7 +682,7 @@ public:
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = out->Write(kMethodDecl2, sizeof(kMethodDecl2) - 1, &count);
|
||||
rv = out->Write(kMethodEnd, sizeof(kMethodEnd) - 1, &count);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user