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

Side by Side Diff: mojo/public/dart/src/codec.dart

Issue 959993002: Dart: Removes name conflicts from generated bindings. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Removes unused constructors Created 5 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 part of bindings; 5 part of bindings;
6 6
7 int align(int size) => size + (kAlignment - (size % kAlignment)) % kAlignment; 7 int align(int size) => size + (kAlignment - (size % kAlignment)) % kAlignment;
8 8
9 const int kAlignment = 8; 9 const int kAlignment = 8;
10 const int kSerializedHandleSize = 4; 10 const int kSerializedHandleSize = 4;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 void encodeInterface(Stub interface, int offset, bool nullable) { 201 void encodeInterface(Stub interface, int offset, bool nullable) {
202 if (interface == null) { 202 if (interface == null) {
203 encodeInvalideHandle(offset, nullable); 203 encodeInvalideHandle(offset, nullable);
204 return; 204 return;
205 } 205 }
206 var pipe = new core.MojoMessagePipe(); 206 var pipe = new core.MojoMessagePipe();
207 interface.bind(pipe.endpoints[0]); 207 interface.bind(pipe.endpoints[0]);
208 encodeMessagePipeHandle(pipe.endpoints[1], offset, nullable); 208 encodeMessagePipeHandle(pipe.endpoints[1], offset, nullable);
209 } 209 }
210 210
211 void encodeInterfaceRequest(Proxy client, int offset, bool nullable) { 211 void encodeInterfaceRequest(ProxyBase client, int offset, bool nullable) {
212 if (client == null) { 212 if (client == null) {
213 encodeInvalideHandle(offset, nullable); 213 encodeInvalideHandle(offset, nullable);
214 return; 214 return;
215 } 215 }
216 var pipe = new core.MojoMessagePipe(); 216 var pipe = new core.MojoMessagePipe();
217 client.bind(pipe.endpoints[0]); 217 client.impl.bind(pipe.endpoints[0]);
218 encodeMessagePipeHandle(pipe.endpoints[1], offset, nullable); 218 encodeMessagePipeHandle(pipe.endpoints[1], offset, nullable);
219 } 219 }
220 220
221 void encodeNullPointer(int offset, bool nullable) { 221 void encodeNullPointer(int offset, bool nullable) {
222 if (!nullable) { 222 if (!nullable) {
223 throw new MojoCodecError( 223 throw new MojoCodecError(
224 'Trying to encode a null pointer for a non-nullable type'); 224 'Trying to encode a null pointer for a non-nullable type');
225 } 225 }
226 _buffer.buffer.setUint64(_base + offset, 0, Endianness.LITTLE_ENDIAN); 226 _buffer.buffer.setUint64(_base + offset, 0, Endianness.LITTLE_ENDIAN);
227 } 227 }
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 594
595 core.MojoDataPipeConsumer decodeConsumerHandle(int offset, bool nullable) => 595 core.MojoDataPipeConsumer decodeConsumerHandle(int offset, bool nullable) =>
596 new core.MojoDataPipeConsumer(decodeHandle(offset, nullable)); 596 new core.MojoDataPipeConsumer(decodeHandle(offset, nullable));
597 597
598 core.MojoDataPipeProducer decodeProducerHandle(int offset, bool nullable) => 598 core.MojoDataPipeProducer decodeProducerHandle(int offset, bool nullable) =>
599 new core.MojoDataPipeProducer(decodeHandle(offset, nullable)); 599 new core.MojoDataPipeProducer(decodeHandle(offset, nullable));
600 600
601 core.MojoSharedBuffer decodeSharedBufferHandle(int offset, bool nullable) => 601 core.MojoSharedBuffer decodeSharedBufferHandle(int offset, bool nullable) =>
602 new core.MojoSharedBuffer(decodeHandle(offset, nullable)); 602 new core.MojoSharedBuffer(decodeHandle(offset, nullable));
603 603
604 Proxy decodeServiceInterface( 604 ProxyBase decodeServiceInterface(
605 int offset, bool nullable, Function clientFactory) { 605 int offset, bool nullable, Function clientFactory) {
606 var endpoint = decodeMessagePipeHandle(offset, nullable); 606 var endpoint = decodeMessagePipeHandle(offset, nullable);
607 return endpoint.handle.isValid ? clientFactory(endpoint) : null; 607 return endpoint.handle.isValid ? clientFactory(endpoint) : null;
608 } 608 }
609 609
610 Stub decodeInterfaceRequest( 610 Stub decodeInterfaceRequest(
611 int offset, bool nullable, Function interfaceFactory) { 611 int offset, bool nullable, Function interfaceFactory) {
612 var endpoint = decodeMessagePipeHandle(offset, nullable); 612 var endpoint = decodeMessagePipeHandle(offset, nullable);
613 return endpoint.handle.isValid ? interfaceFactory(endpoint) : null; 613 return endpoint.handle.isValid ? interfaceFactory(endpoint) : null;
614 } 614 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 result[boolIndex] = (bytes[i] & (1 << j)) != 0; 690 result[boolIndex] = (bytes[i] & (1 << j)) != 0;
691 } 691 }
692 } 692 }
693 } 693 }
694 return result; 694 return result;
695 } 695 }
696 696
697 ArrayDataHeader decodeDataHeaderForArray(int elementSize, 697 ArrayDataHeader decodeDataHeaderForArray(int elementSize,
698 int expectedLength) { 698 int expectedLength) {
699 var header = decodeArrayDataHeader(); 699 var header = decodeArrayDataHeader();
700 var arrayByteCount = 700 var arrayByteCount =
701 ArrayDataHeader.kHeaderSize + header.numElements * elementSize; 701 ArrayDataHeader.kHeaderSize + header.numElements * elementSize;
702 if (header.size < arrayByteCount) { 702 if (header.size < arrayByteCount) {
703 throw new MojoCodecError( 703 throw new MojoCodecError(
704 'Array header is incorrect: $header, elementSize = $elementSize'); 704 'Array header is incorrect: $header, elementSize = $elementSize');
705 } 705 }
706 if ((expectedLength != kUnspecifiedArrayLength) && 706 if ((expectedLength != kUnspecifiedArrayLength) &&
707 (header.numElements != expectedLength)) { 707 (header.numElements != expectedLength)) {
708 throw new MojoCodecError( 708 throw new MojoCodecError(
709 'Incorrect array length. Expected $expectedLength, but got ' 709 'Incorrect array length. Expected $expectedLength, but got '
710 '${header.numElements}'); 710 '${header.numElements}');
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 throw new MojoCodecError( 862 throw new MojoCodecError(
863 'Incorrect header for map. The size is incorrect.'); 863 'Incorrect header for map. The size is incorrect.');
864 } 864 }
865 if (header.version != kMapStructHeader.version) { 865 if (header.version != kMapStructHeader.version) {
866 throw new MojoCodecError( 866 throw new MojoCodecError(
867 'Incorrect header for map. The version is incorrect.'); 867 'Incorrect header for map. The version is incorrect.');
868 } 868 }
869 return header; 869 return header;
870 } 870 }
871 } 871 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698