Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: third_party/grpc/tools/codegen/core/gen_legal_metadata_characters.c

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/grpc/tools/codegen/core/gen_legal_metadata_characters.c
diff --git a/third_party/WebKit/Source/core/animation/animatable/AnimatableValue.cpp b/third_party/grpc/tools/codegen/core/gen_legal_metadata_characters.c
similarity index 58%
copy from third_party/WebKit/Source/core/animation/animatable/AnimatableValue.cpp
copy to third_party/grpc/tools/codegen/core/gen_legal_metadata_characters.c
index dba8160fdbcb0dd88bae2cd9ea8cf2a103dba336..10605d52bfa7bb07aaae36fa734321505b8a8951 100644
--- a/third_party/WebKit/Source/core/animation/animatable/AnimatableValue.cpp
+++ b/third_party/grpc/tools/codegen/core/gen_legal_metadata_characters.c
@@ -1,5 +1,7 @@
/*
- * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Copyright 2015-2016, Google Inc.
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -26,33 +28,54 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
*/
-#include "core/animation/animatable/AnimatableValue.h"
+/* generates constant table for metadata.c */
-#include "core/animation/animatable/AnimatableNeutral.h"
-#include "wtf/StdLibExtras.h"
-#include <algorithm>
+#include <stdio.h>
+#include <string.h>
-namespace blink {
+static unsigned char legal_bits[256 / 8];
-PassRefPtr<AnimatableValue> AnimatableValue::neutralValue()
-{
- DEFINE_STATIC_REF(AnimatableNeutral, neutralSentinelValue, (AnimatableNeutral::create()));
- return neutralSentinelValue;
+static void legal(int x) {
+ int byte = x / 8;
+ int bit = x % 8;
+ /* NB: the following integer arithmetic operation needs to be in its
+ * expanded form due to the "integral promotion" performed (see section
+ * 3.2.1.1 of the C89 draft standard). A cast to the smaller container type
+ * is then required to avoid the compiler warning */
+ legal_bits[byte] =
+ (unsigned char)((legal_bits[byte] | (unsigned char)(1 << bit)));
}
-PassRefPtr<AnimatableValue> AnimatableValue::interpolate(const AnimatableValue* left, const AnimatableValue* right, double fraction)
-{
- ASSERT(left);
- ASSERT(right);
- ASSERT(!left->isNeutral());
- ASSERT(!right->isNeutral());
+static void dump(void) {
+ int i;
- if (fraction && fraction != 1 && left->isSameType(right))
- return left->interpolateTo(right, fraction);
-
- return defaultInterpolateTo(left, right, fraction);
+ printf("static const uint8_t legal_header_bits[256/8] = ");
+ for (i = 0; i < 256 / 8; i++)
+ printf("%c 0x%02x", i ? ',' : '{', legal_bits[i]);
+ printf(" };\n");
}
-} // namespace blink
+static void clear(void) { memset(legal_bits, 0, sizeof(legal_bits)); }
+
+int main(void) {
+ int i;
+
+ clear();
+ for (i = 'a'; i <= 'z'; i++) legal(i);
+ for (i = '0'; i <= '9'; i++) legal(i);
+ legal('-');
+ legal('_');
+ legal('.');
+ dump();
+
+ clear();
+ for (i = 32; i <= 126; i++) {
+ legal(i);
+ }
+ dump();
+
+ return 0;
+}

Powered by Google App Engine
This is Rietveld 408576698