Skip to content

Commit

Permalink
Fix type conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
tishion committed Sep 25, 2023
1 parent bf0827d commit aa4b742
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/CefWing/CefRenderApp/RenderDelegates/CefViewClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,19 +261,28 @@ CefViewClient::V8ValueToCefValue(CefV8Value* v8Value)
* logD("isUnint: %d", isUnint); // true
* auto isInt = v->IsInt();
* logD("isInt: %d", isInt); // true
*
* auto v = CefV8Value::CreateDouble(0.1);
* auto isDouble = v->IsDouble();
* logD("isDouble: %d", isDouble); // true
* auto isUnint = v->IsUInt();
* logD("isUnint: %d", isUnint); // false
* auto isInt = v->IsInt();
* logD("isInt: %d", isInt); // false
*
* so we need to keep the testing order, Double - Uint - Int
* so we need to keep the testing order, IsInt/IsUint - IsDouble
* since there is no Uint type in JavaScript, we just ignore it.
* Please refer to this test souce:
* https://github.com/svn2github/cef/blob/master/tests/cefclient/binding_test.cpp
*/
if (v8Value->IsNull() || v8Value->IsUndefined())
cefValue->SetNull();
else if (v8Value->IsBool())
cefValue->SetBool(v8Value->GetBoolValue());
else if (v8Value->IsDouble())
cefValue->SetDouble(v8Value->GetDoubleValue());
else if (v8Value->IsUInt())
cefValue->SetDouble(v8Value->GetUIntValue());
else if (v8Value->IsInt())
cefValue->SetInt(v8Value->GetIntValue());
else if (v8Value->IsDouble())
cefValue->SetDouble(v8Value->GetDoubleValue());
else if (v8Value->IsString())
cefValue->SetString(v8Value->GetStringValue());
else if (v8Value->IsArrayBuffer()) {
Expand Down

0 comments on commit aa4b742

Please sign in to comment.