Import Cobalt 16.162639

Change-Id: I48e550078c1c834849999becacaafe9e12e81803
diff --git a/src/third_party/QR-Code-generator/cpp/BitBuffer.cpp b/src/third_party/QR-Code-generator/cpp/BitBuffer.cpp
index d6e8cb2..4dc9f7b 100644
--- a/src/third_party/QR-Code-generator/cpp/BitBuffer.cpp
+++ b/src/third_party/QR-Code-generator/cpp/BitBuffer.cpp
@@ -23,6 +23,9 @@
 
 #include "BitBuffer.hpp"
 
+#include "starboard/log.h"
+
+#define throw SB_CHECK(false) <<
 
 namespace qrcodegen {
 
diff --git a/src/third_party/QR-Code-generator/cpp/QrCode.cpp b/src/third_party/QR-Code-generator/cpp/QrCode.cpp
index 75a5473..c73cf9c 100644
--- a/src/third_party/QR-Code-generator/cpp/QrCode.cpp
+++ b/src/third_party/QR-Code-generator/cpp/QrCode.cpp
@@ -30,6 +30,10 @@
 #include "BitBuffer.hpp"
 #include "QrCode.hpp"
 
+#include "starboard/log.h"
+
+#define throw SB_CHECK(false) <<
+
 using std::int8_t;
 using std::uint8_t;
 using std::size_t;
@@ -46,6 +50,7 @@
 		case Ecc::HIGH    :  return 2;
 		default:  throw "Assertion error";
 	}
+	return 0;
 }
 
 
@@ -490,11 +495,12 @@
 
 
 vector<int> QrCode::getAlignmentPatternPositions(int ver) {
-	if (ver < MIN_VERSION || ver > MAX_VERSION)
+	if (ver < MIN_VERSION || ver > MAX_VERSION) {
 		throw "Version number out of range";
-	else if (ver == 1)
 		return vector<int>();
-	else {
+	} else if (ver == 1) {
+		return vector<int>();
+	} else {
 		int numAlign = ver / 7 + 2;
 		int step;
 		if (ver != 32) {
diff --git a/src/third_party/QR-Code-generator/cpp/QrCodeGeneratorWorker.cpp b/src/third_party/QR-Code-generator/cpp/QrCodeGeneratorWorker.cpp
index 2e14607..aba5a24 100644
--- a/src/third_party/QR-Code-generator/cpp/QrCodeGeneratorWorker.cpp
+++ b/src/third_party/QR-Code-generator/cpp/QrCodeGeneratorWorker.cpp
@@ -33,6 +33,8 @@
 #include <vector>
 #include "QrCode.hpp"
 
+#include "starboard/string.h"
+
 using qrcodegen::QrCode;
 using qrcodegen::QrSegment;
 
@@ -92,7 +94,7 @@
 			}
 			
 		} catch (const char *msg) {
-			if (strcmp(msg, "Data too long") != 0) {
+			if (SbStringCompare(msg, "Data too long") != 0) {
 				std::cerr << msg << std::endl;
 				return EXIT_FAILURE;
 			}
diff --git a/src/third_party/QR-Code-generator/cpp/QrSegment.cpp b/src/third_party/QR-Code-generator/cpp/QrSegment.cpp
index f711461..4accb09 100644
--- a/src/third_party/QR-Code-generator/cpp/QrSegment.cpp
+++ b/src/third_party/QR-Code-generator/cpp/QrSegment.cpp
@@ -26,6 +26,10 @@
 #include <utility>
 #include "QrSegment.hpp"
 
+#include "starboard/log.h"
+
+#define throw SB_CHECK(false) <<
+
 using std::uint8_t;
 using std::vector;
 
@@ -50,6 +54,7 @@
 	else if (10 <= ver && ver <= 26)  return numBitsCharCount[1];
 	else if (27 <= ver && ver <= 40)  return numBitsCharCount[2];
 	else  throw "Version number out of range";
+	return 0;
 }
 
 
diff --git a/src/third_party/QR-Code-generator/qr_code_generator.gyp b/src/third_party/QR-Code-generator/qr_code_generator.gyp
new file mode 100644
index 0000000..29cdd4a
--- /dev/null
+++ b/src/third_party/QR-Code-generator/qr_code_generator.gyp
@@ -0,0 +1,34 @@
+# Copyright 2018 Google Inc. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+{
+  'targets': [
+    {
+      'target_name': 'qr_code_generator',
+      'type': 'static_library',
+      'include_dirs': ['.'],
+      'sources': [
+        'cpp/BitBuffer.cpp',
+        'cpp/BitBuffer.hpp',
+        'cpp/QrCode.cpp',
+        'cpp/QrCode.hpp',
+        'cpp/QrSegment.cpp',
+        'cpp/QrSegment.hpp',
+      ],
+      'dependencies': [
+        '<(DEPTH)/starboard/starboard.gyp:starboard',
+      ],
+    },
+  ],
+}