Home | History | Annotate | Download | only in tests
      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
      3 // found in the LICENSE file.
      4 
      5 module mojo.test;
      6 
      7 enum AnEnum {
      8   FIRST, SECOND
      9 };
     10 
     11 [Extensible]
     12 enum AnExtensibleEnum {
     13   FIRST, SECOND, THIRD
     14 };
     15 
     16 union PodUnion {
     17   int8   f_int8;
     18   int8   f_int8_other;
     19   uint8  f_uint8;
     20   int16  f_int16;
     21   uint16 f_uint16;
     22   int32  f_int32;
     23   uint32 f_uint32;
     24   int64  f_int64;
     25   uint64 f_uint64;
     26   float  f_float;
     27   double f_double;
     28   bool   f_bool;
     29   AnEnum f_enum;
     30   AnExtensibleEnum f_extensible_enum;
     31 };
     32 
     33 union ObjectUnion {
     34   int8   f_int8;
     35   string f_string;
     36   DummyStruct f_dummy;
     37   DummyStruct? f_nullable;
     38   array<int8> f_array_int8;
     39   map<string, int8> f_map_int8;
     40   PodUnion f_pod_union;
     41   // Test that Clone() is defined after SmallStruct is declared.
     42   array<SmallStruct> f_small_structs;
     43 };
     44 
     45 union HandleUnion {
     46   handle f_handle;
     47   handle<message_pipe> f_message_pipe;
     48   handle<data_pipe_consumer> f_data_pipe_consumer;
     49   handle<data_pipe_producer> f_data_pipe_producer;
     50   handle<shared_buffer> f_shared_buffer;
     51   SmallCache f_small_cache;
     52   SmallCache& f_small_cache_request;
     53 };
     54 
     55 struct WrapperStruct {
     56   ObjectUnion? object_union;
     57   PodUnion? pod_union;
     58   HandleUnion? handle_union;
     59 };
     60 
     61 struct DummyStruct {
     62   int8 f_int8;
     63 };
     64 
     65 struct SmallStruct {
     66   DummyStruct? dummy_struct;
     67   PodUnion? pod_union;
     68   array<PodUnion>? pod_union_array;
     69   array<PodUnion?>? nullable_pod_union_array;
     70   array<DummyStruct>? s_array;
     71   map<string, PodUnion>? pod_union_map;
     72   map<string, PodUnion?>? nullable_pod_union_map;
     73 };
     74 
     75 struct SmallStructNonNullableUnion {
     76   PodUnion pod_union;
     77 };
     78 
     79 struct SmallObjStruct {
     80   ObjectUnion obj_union;
     81   int8 f_int8;
     82 };
     83 
     84 interface SmallCache {
     85   SetIntValue(int64 int_value);
     86   GetIntValue() => (int64 int_value);
     87 };
     88 
     89 interface UnionInterface {
     90   Echo(PodUnion in_val) => (PodUnion out_val);
     91 };
     92 
     93 struct TryNonNullStruct {
     94   DummyStruct? nullable;
     95   DummyStruct non_nullable;
     96 };
     97 
     98 union OldUnion {
     99   int8 f_int8;
    100 };
    101 
    102 union NewUnion {
    103   int8 f_int8;
    104   int16 f_int16;
    105 };
    106