| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "core/dom/ExceptionCode.h" | 37 #include "core/dom/ExceptionCode.h" |
| 38 #include "modules/webdatabase/sqlite/SQLValue.h" | 38 #include "modules/webdatabase/sqlite/SQLValue.h" |
| 39 #include "modules/webdatabase/DatabaseSync.h" | 39 #include "modules/webdatabase/DatabaseSync.h" |
| 40 #include "modules/webdatabase/SQLResultSet.h" | 40 #include "modules/webdatabase/SQLResultSet.h" |
| 41 #include "wtf/Vector.h" | 41 #include "wtf/Vector.h" |
| 42 | 42 |
| 43 using namespace WTF; | 43 using namespace WTF; |
| 44 | 44 |
| 45 namespace WebCore { | 45 namespace WebCore { |
| 46 | 46 |
| 47 void V8SQLTransactionSync::executeSqlMethodCustom(const v8::FunctionCallbackInfo
<v8::Value>& args) | 47 void V8SQLTransactionSync::executeSqlMethodCustom(const v8::FunctionCallbackInfo
<v8::Value>& info) |
| 48 { | 48 { |
| 49 if (!args.Length()) { | 49 if (!info.Length()) { |
| 50 setDOMException(SyntaxError, args.GetIsolate()); | 50 setDOMException(SyntaxError, info.GetIsolate()); |
| 51 return; | 51 return; |
| 52 } | 52 } |
| 53 | 53 |
| 54 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, statement, args[0])
; | 54 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, statement, info[0])
; |
| 55 | 55 |
| 56 Vector<SQLValue> sqlValues; | 56 Vector<SQLValue> sqlValues; |
| 57 | 57 |
| 58 if (args.Length() > 1 && !isUndefinedOrNull(args[1])) { | 58 if (info.Length() > 1 && !isUndefinedOrNull(info[1])) { |
| 59 if (!args[1]->IsObject()) { | 59 if (!info[1]->IsObject()) { |
| 60 setDOMException(TypeMismatchError, args.GetIsolate()); | 60 setDOMException(TypeMismatchError, info.GetIsolate()); |
| 61 return; | 61 return; |
| 62 } | 62 } |
| 63 | 63 |
| 64 uint32_t sqlArgsLength = 0; | 64 uint32_t sqlArgsLength = 0; |
| 65 v8::Local<v8::Object> sqlArgsObject = args[1]->ToObject(); | 65 v8::Local<v8::Object> sqlArgsObject = info[1]->ToObject(); |
| 66 V8TRYCATCH_VOID(v8::Local<v8::Value>, length, sqlArgsObject->Get(v8::Str
ing::New("length"))); | 66 V8TRYCATCH_VOID(v8::Local<v8::Value>, length, sqlArgsObject->Get(v8::Str
ing::New("length"))); |
| 67 | 67 |
| 68 if (isUndefinedOrNull(length)) | 68 if (isUndefinedOrNull(length)) |
| 69 sqlArgsLength = sqlArgsObject->GetPropertyNames()->Length(); | 69 sqlArgsLength = sqlArgsObject->GetPropertyNames()->Length(); |
| 70 else | 70 else |
| 71 sqlArgsLength = length->Uint32Value(); | 71 sqlArgsLength = length->Uint32Value(); |
| 72 | 72 |
| 73 for (unsigned int i = 0; i < sqlArgsLength; ++i) { | 73 for (unsigned int i = 0; i < sqlArgsLength; ++i) { |
| 74 v8::Handle<v8::Integer> key = v8::Integer::New(i, args.GetIsolate())
; | 74 v8::Handle<v8::Integer> key = v8::Integer::New(i, info.GetIsolate())
; |
| 75 V8TRYCATCH_VOID(v8::Local<v8::Value>, value, sqlArgsObject->Get(key)
); | 75 V8TRYCATCH_VOID(v8::Local<v8::Value>, value, sqlArgsObject->Get(key)
); |
| 76 | 76 |
| 77 if (value.IsEmpty() || value->IsNull()) | 77 if (value.IsEmpty() || value->IsNull()) |
| 78 sqlValues.append(SQLValue()); | 78 sqlValues.append(SQLValue()); |
| 79 else if (value->IsNumber()) { | 79 else if (value->IsNumber()) { |
| 80 V8TRYCATCH_VOID(double, sqlValue, value->NumberValue()); | 80 V8TRYCATCH_VOID(double, sqlValue, value->NumberValue()); |
| 81 sqlValues.append(SQLValue(sqlValue)); | 81 sqlValues.append(SQLValue(sqlValue)); |
| 82 } else { | 82 } else { |
| 83 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, sqlValu
e, value); | 83 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, sqlValu
e, value); |
| 84 sqlValues.append(SQLValue(sqlValue)); | 84 sqlValues.append(SQLValue(sqlValue)); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 SQLTransactionSync* transaction = V8SQLTransactionSync::toNative(args.Holder
()); | 89 SQLTransactionSync* transaction = V8SQLTransactionSync::toNative(info.Holder
()); |
| 90 | 90 |
| 91 ExceptionState es(args.GetIsolate()); | 91 ExceptionState es(info.GetIsolate()); |
| 92 v8::Handle<v8::Value> result = toV8(transaction->executeSQL(statement, sqlVa
lues, es), args.Holder(), args.GetIsolate()); | 92 v8::Handle<v8::Value> result = toV8(transaction->executeSQL(statement, sqlVa
lues, es), info.Holder(), info.GetIsolate()); |
| 93 if (es.throwIfNeeded()) | 93 if (es.throwIfNeeded()) |
| 94 return; | 94 return; |
| 95 | 95 |
| 96 v8SetReturnValue(args, result); | 96 v8SetReturnValue(info, result); |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace WebCore | 99 } // namespace WebCore |
| OLD | NEW |