| OLD | NEW |
| 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 Loading... |
| 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 key = Utils.checkType(context, keyType, key, (RubyModule) valueTypeClass
); | 151 Utils.checkType(context, keyType, key, (RubyModule) valueTypeClass); |
| 152 value = Utils.checkType(context, valueType, value, (RubyModule) valueTyp
eClass); | 152 Utils.checkType(context, valueType, value, (RubyModule) valueTypeClass); |
| 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 Loading... |
| 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 } |
| OLD | NEW |