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

Side by Side Diff: lib/protobuf/runtime/DynamicGeneratedMessage.dart

Issue 10595002: Protocol Buffer runtime library and 'protoc' plugin (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Work around http://code.google.com/p/dart/issues/detail?id=3806 Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/protobuf/runtime/DynamicBuilder.dart ('k') | lib/protobuf/runtime/Extension.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * Provides an implementation of 'noSuchMethod' that may be used as a
7 * substitute for fixed getter and setter methods.
8 */
9 class DynamicGeneratedMessage extends GeneratedMessage {
10
11 /**
12 * Implement getXxx and hasXxx methods dynamically.
13 */
14 Dynamic noSuchMethod(String name, List args) {
15 if (name.startsWith("get:")) {
16 int tagNumber = getTagNumber(name.substring(4));
17 if (tagNumber != null) {
18 return getField(tagNumber);
19 }
20 } else if (name.startsWith("has") && name.length > 3) {
21 String fieldName = "${name[3].toLowerCase()}${name.substring(4)}";
22 int tagNumber = getTagNumber(fieldName);
23 if (tagNumber != null) {
24 return hasField(tagNumber);
25 }
26 }
27 throw "NoSuchMethod: $name";
28 }
29 }
OLDNEW
« no previous file with comments | « lib/protobuf/runtime/DynamicBuilder.dart ('k') | lib/protobuf/runtime/Extension.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698