Bug 491196 don't implement static functions in headers

r=sdwilsh
Moving JSValStorageStatementBinder to mozStoragePrivateHelpers as bindJSValue

storage/src/mozStorageStatementParams.h: At global scope:
storage/src/mozStorageStatementParams.h:78: warning: ‘PRBool mozilla::storage::JSValStorageStatementBinder(JSContext*, mozIStorageStatement*, int, jsval)’ defined but not used
storage/src/mozStorageStatementParams.h:78: warning: ‘PRBool mozilla::storage::JSValStorageStatementBinder(JSContext*, mozIStorageStatement*, int, jsval)’ defined but not used

You get this once for each file that includes a header that defines a static function which is not used in that file.
This commit is contained in:
timeless@mozdev.org 2009-07-22 17:31:03 -05:00
Родитель eaa72f0137
Коммит 015f42221e
8 изменённых файлов: 83 добавлений и 62 удалений

Просмотреть файл

@ -40,11 +40,15 @@
#include "sqlite3.h"
#include "jsapi.h"
#include "jsdate.h"
#include "nsPrintfCString.h"
#include "nsString.h"
#include "nsError.h"
#include "mozStoragePrivateHelpers.h"
#include "mozIStorageStatement.h"
namespace mozilla {
namespace storage {
@ -116,5 +120,61 @@ checkAndLogStatementPerformance(sqlite3_stmt *aStatement)
NS_WARNING(message.get());
}
bool
bindJSValue(JSContext *aCtx,
mozIStorageStatement *aStatement,
int aIdx,
jsval aValue)
{
if (JSVAL_IS_INT(aValue)) {
int v = JSVAL_TO_INT(aValue);
(void)aStatement->BindInt32Parameter(aIdx, v);
return true;
}
if (JSVAL_IS_DOUBLE(aValue)) {
double d = *JSVAL_TO_DOUBLE(aValue);
(void)aStatement->BindDoubleParameter(aIdx, d);
return true;
}
if (JSVAL_IS_STRING(aValue)) {
JSString *str = JSVAL_TO_STRING(aValue);
nsDependentString value(
reinterpret_cast<PRUnichar *>(::JS_GetStringChars(str)),
::JS_GetStringLength(str)
);
(void)aStatement->BindStringParameter(aIdx, value);
return true;
}
if (JSVAL_IS_BOOLEAN(aValue)) {
(void)aStatement->BindInt32Parameter(aIdx, (aValue == JSVAL_TRUE) ? 1 : 0);
return true;
}
if (JSVAL_IS_NULL(aValue)) {
(void)aStatement->BindNullParameter(aIdx);
return true;
}
if (JSVAL_IS_OBJECT(aValue)) {
JSObject *obj = JSVAL_TO_OBJECT(aValue);
// some special things
if (!::js_DateIsValid(aCtx, obj))
return false;
double msecd = ::js_DateGetMsecSinceEpoch(aCtx, obj);
msecd *= 1000.0;
PRInt64 msec;
LL_D2L(msec, msecd);
(void)aStatement->BindInt64Parameter(aIdx, msec);
return true;
}
return false;
}
} // namespace storage
} // namespace mozilla

Просмотреть файл

@ -48,6 +48,9 @@
#include "sqlite3.h"
#include "nsIVariant.h"
#include "mozStorage.h"
#include "jsapi.h"
class mozIStorageStatement;
namespace mozilla {
namespace storage {
@ -81,6 +84,15 @@ nsresult convertResultCode(int aSQLiteResultCode);
*/
void checkAndLogStatementPerformance(sqlite3_stmt *aStatement);
/**
*
*/
bool
bindJSValue(JSContext *aCtx,
mozIStorageStatement *aStatement,
int aIdx,
jsval aValue);
/**
* Used to convert an nsIVariant to the proper SQLite type.
*/

Просмотреть файл

@ -620,7 +620,7 @@ Statement::EscapeStringForLIKE(const nsAString &aValue,
_escapedString.Truncate(0);
for (PRInt32 i = 0; i < aValue.Length(); i++) {
for (PRUint32 i = 0; i < aValue.Length(); i++) {
if (aValue[i] == aEscapeChar || aValue[i] == MATCH_ALL ||
aValue[i] == MATCH_ONE)
_escapedString += aEscapeChar;

Просмотреть файл

@ -41,7 +41,9 @@
#include "nsMemory.h"
#include "nsString.h"
#include "mozStoragePrivateHelpers.h"
#include "mozStorageStatementParams.h"
#include "mozIStorageStatement.h"
namespace mozilla {
namespace storage {
@ -86,7 +88,7 @@ StatementParams::SetProperty(nsIXPConnectWrappedNative *aWrapper,
if (JSVAL_IS_INT(aId)) {
int idx = JSVAL_TO_INT(aId);
PRBool res = JSValStorageStatementBinder(aCtx, mStatement, idx, *_vp);
PRBool res = bindJSValue(aCtx, mStatement, idx, *_vp);
NS_ENSURE_TRUE(res, NS_ERROR_UNEXPECTED);
}
else if (JSVAL_IS_STRING(aId)) {
@ -99,7 +101,7 @@ StatementParams::SetProperty(nsIXPConnectWrappedNative *aWrapper,
nsresult rv = mStatement->GetParameterIndex(name, &index);
NS_ENSURE_SUCCESS(rv, rv);
PRBool res = JSValStorageStatementBinder(aCtx, mStatement, index, *_vp);
PRBool res = bindJSValue(aCtx, mStatement, index, *_vp);
NS_ENSURE_TRUE(res, NS_ERROR_UNEXPECTED);
}
else {

Просмотреть файл

@ -43,9 +43,6 @@
#include "mozIStorageStatementWrapper.h"
#include "nsIXPCScriptable.h"
#include "jsapi.h"
#include "jsdate.h"
class mozIStorageStatement;
namespace mozilla {
@ -71,57 +68,6 @@ protected:
friend class Statement;
};
static
PRBool
JSValStorageStatementBinder(JSContext *aCtx,
mozIStorageStatement *aStatement,
int aIdx,
jsval aValue)
{
if (JSVAL_IS_INT(aValue)) {
int v = JSVAL_TO_INT(aValue);
(void)aStatement->BindInt32Parameter(aIdx, v);
}
else if (JSVAL_IS_DOUBLE(aValue)) {
double d = *JSVAL_TO_DOUBLE(aValue);
(void)aStatement->BindDoubleParameter(aIdx, d);
}
else if (JSVAL_IS_STRING(aValue)) {
JSString *str = JSVAL_TO_STRING(aValue);
nsDependentString value(
reinterpret_cast<PRUnichar *>(::JS_GetStringChars(str)),
::JS_GetStringLength(str)
);
(void)aStatement->BindStringParameter(aIdx, value);
}
else if (JSVAL_IS_BOOLEAN(aValue)) {
(void)aStatement->BindInt32Parameter(aIdx, (aValue == JSVAL_TRUE) ? 1 : 0);
}
else if (JSVAL_IS_NULL(aValue)) {
(void)aStatement->BindNullParameter(aIdx);
}
else if (JSVAL_IS_OBJECT(aValue)) {
JSObject *obj = JSVAL_TO_OBJECT(aValue);
// some special things
if (::js_DateIsValid (aCtx, obj)) {
double msecd = ::js_DateGetMsecSinceEpoch(aCtx, obj);
msecd *= 1000.0;
PRInt64 msec;
LL_D2L(msec, msecd);
(void)aStatement->BindInt64Parameter(aIdx, msec);
}
else {
return PR_FALSE;
}
}
else {
return PR_FALSE;
}
return PR_TRUE;
}
} // namespace storage
} // namespace mozilla

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsString.h"
#include "mozStoragePrivateHelpers.h"
#include "mozStorageStatementWrapper.h"
#include "mozStorageStatementParams.h"
#include "mozStorageStatementRow.h"
@ -202,7 +203,7 @@ StatementWrapper::Call(nsIXPConnectWrappedNative *aWrapper,
// bind parameters
for (int i = 0; i < (int)aArgc; i++) {
if (!JSValStorageStatementBinder(aCtx, mStatement, i, aArgv[i])) {
if (!bindJSValue(aCtx, mStatement, i, aArgv[i])) {
*_retval = PR_FALSE;
return NS_ERROR_INVALID_ARG;
}

Просмотреть файл

@ -179,8 +179,8 @@ function run_test()
{
setup();
// Static function JSValStorageStatementBinder in
// storage/src/mozStorageStatementParams.h tells us that the following types
// function JSValStorageStatementBinder in
// storage/src/mozStorageStatementParams.cpp tells us that the following types
// and only the following types are valid as statement parameters:
var vals = [
1337, // int

Просмотреть файл

@ -188,8 +188,8 @@ function run_test()
{
setup();
// Static function JSValStorageStatementBinder in
// storage/src/mozStorageStatementParams.h tells us that the following types
// function JSValStorageStatementBinder in
// storage/src/mozStorageStatementParams.cpp tells us that the following types
// and only the following types are valid as statement parameters:
var vals = [
1337, // int