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

Side by Side Diff: third_party/protobuf/ruby/src/main/java/com/google/protobuf/jruby/RubyMap.java

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Protocol Buffers - Google's data interchange format 2 * Protocol Buffers - Google's data interchange format
3 * Copyright 2014 Google Inc. All rights reserved. 3 * Copyright 2014 Google Inc. All rights reserved.
4 * https://developers.google.com/protocol-buffers/ 4 * https://developers.google.com/protocol-buffers/
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 /* 141 /*
142 * call-seq: 142 * call-seq:
143 * Map.[]=(key, value) => value 143 * Map.[]=(key, value) => value
144 * 144 *
145 * Inserts or overwrites the value at the given key with the given new value . 145 * Inserts or overwrites the value at the given key with the given new value .
146 * Throws an exception if the key type is incorrect. Returns the new value t hat 146 * Throws an exception if the key type is incorrect. Returns the new value t hat
147 * was just inserted. 147 * was just inserted.
148 */ 148 */
149 @JRubyMethod(name = "[]=") 149 @JRubyMethod(name = "[]=")
150 public IRubyObject indexSet(ThreadContext context, IRubyObject key, IRubyObj ect value) { 150 public IRubyObject indexSet(ThreadContext context, IRubyObject key, IRubyObj ect value) {
151 Utils.checkType(context, keyType, key, (RubyModule) valueTypeClass); 151 key = Utils.checkType(context, keyType, key, (RubyModule) valueTypeClass );
152 Utils.checkType(context, valueType, value, (RubyModule) valueTypeClass); 152 value = Utils.checkType(context, valueType, value, (RubyModule) valueTyp eClass);
153 IRubyObject symbol; 153 IRubyObject symbol;
154 if (valueType == Descriptors.FieldDescriptor.Type.ENUM && 154 if (valueType == Descriptors.FieldDescriptor.Type.ENUM &&
155 Utils.isRubyNum(value) && 155 Utils.isRubyNum(value) &&
156 ! (symbol = RubyEnum.lookup(context, valueTypeClass, value)).isN il()) { 156 ! (symbol = RubyEnum.lookup(context, valueTypeClass, value)).isN il()) {
157 value = symbol; 157 value = symbol;
158 } 158 }
159 this.table.put(key, value); 159 this.table.put(key, value);
160 return value; 160 return value;
161 } 161 }
162 162
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 default: 425 default:
426 return false; 426 return false;
427 } 427 }
428 } 428 }
429 429
430 private Descriptors.FieldDescriptor.Type keyType; 430 private Descriptors.FieldDescriptor.Type keyType;
431 private Descriptors.FieldDescriptor.Type valueType; 431 private Descriptors.FieldDescriptor.Type valueType;
432 private IRubyObject valueTypeClass; 432 private IRubyObject valueTypeClass;
433 private Map<IRubyObject, IRubyObject> table; 433 private Map<IRubyObject, IRubyObject> table;
434 } 434 }
OLDNEW
« no previous file with comments | « third_party/protobuf/ruby/pom.xml ('k') | third_party/protobuf/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698