Home | History | Annotate | Download | only in test_gen_pnacl
      1 /*
      2  * Copyright (c) 2011 The Chromium Authors. All rights reserved.
      3  * Use of this source code is governed by a BSD-style license that can be
      4  * found in the LICENSE file.
      5  */
      6 
      7 /**
      8  * This file will test that the pnacl-generated wrapper functions match
      9  * the comments in this IDL.
     10  */
     11 
     12 label Chrome {
     13   M13 = 0.0,
     14   M14 = 1.0,
     15   M15 = 2.0
     16 };
     17 
     18 describe {
     19   void;
     20   mem_t;
     21   int32_t;
     22 };
     23 
     24 [passByValue, returnByValue] struct some_struct {
     25   mem_t X;
     26   int32_t Y;
     27 };
     28 
     29 struct some_struct2 {
     30   mem_t X;
     31   int32_t Y;
     32 };
     33 
     34 [union, passByValue, returnByValue] struct some_union {
     35   mem_t X;
     36   int32_t Y;
     37 };
     38 
     39 /*
     40  * static int32_t
     41  * Pnacl_M15_PPB_Iface_struct_wrap_foo1(int32_t a, struct some_struct* b) {
     42  *   const struct PPB_Iface_struct_wrap_2_0 *iface =
     43  *     Pnacl_WrapperInfo_PPB_Iface_struct_wrap_2_0.real_iface;
     44  *   return iface->foo1(a, *b);
     45  * }
     46  */
     47 [version=2.0]
     48 interface PPB_Iface_struct_wrap {
     49   int32_t foo1(int32_t a, [in] some_struct b);
     50 };
     51 
     52 /*
     53  * static int32_t
     54  * Pnacl_M15_PPB_Iface_union_wrap_foo1(int32_t a, union some_union* b) {
     55  *   const struct PPB_Iface_union_wrap_2_0 *iface =
     56  *     Pnacl_WrapperInfo_PPB_Iface_union_wrap_2_0.real_iface;
     57  *   return iface->foo1(a, *b);
     58  * }
     59  */
     60 [version=2.0]
     61 interface PPB_Iface_union_wrap {
     62   int32_t foo1(int32_t a, [in] some_union b);
     63 };
     64 
     65 
     66 [version=2.0]
     67 interface PPB_Iface_nowrap {
     68   int32_t foo1(int32_t a, [in] some_struct2 b);
     69 };
     70 
     71 
     72 /*
     73  * static
     74  * int32_t Pnacl_M13_PPB_SomeWrap_foo1(struct some_struct* a) {
     75  *   const struct PPB_SomeWrap_0_0 *iface =
     76  *     Pnacl_WrapperInfo_PPB_SomeWrap_0_0.real_iface;
     77  *   return iface->foo1(*a);
     78  * }
     79  *
     80  * static
     81  * void Pnacl_M13_PPB_SomeWrap_foo2(struct some_struct* _struct_result,
     82  *                                  int32_t a) {
     83  *   const struct PPB_SomeWrap_0_0 *iface =
     84  *     Pnacl_WrapperInfo_PPB_SomeWrap_0_0.real_iface;
     85  *   *_struct_result = iface->foo2(a);
     86  * }
     87  */
     88 [version=0.0]
     89 interface PPB_SomeWrap {
     90   int32_t foo1([in] some_struct a);
     91   some_struct foo2([in] int32_t a);
     92 
     93   /* Not generating wrapper methods for PPB_SomeWrap_1_0 */
     94   [version=1.0]
     95   int32_t foo1([in] some_struct[] a);
     96   [version=1.0]
     97   void foo2([in] int32_t a, [out] some_struct b);
     98 
     99   /* Not generating wrapper methods for PPB_SomeWrap */
    100   [version=2.0]
    101   int32_t foo1([in] some_struct2 a);
    102 };
    103 
    104 
    105 /*
    106  * static int32_t Pnacl_M13_PPP_SomeWrap_foo1(struct some_struct a) {
    107  *   const struct PPP_SomeWrap_0_0 *iface =
    108  *     Pnacl_WrapperInfo_PPP_SomeWrap_0_0.real_iface;
    109  *   int32_t (*temp_fp)(struct some_struct* a) =
    110  *     ((int32_t (*)(struct some_struct* a))iface->foo1);
    111  *   return temp_fp(&a);
    112  * }
    113  *
    114  * static struct some_struct Pnacl_M13_PPP_SomeWrap_foo2(int32_t a) {
    115  *   const struct PPP_SomeWrap_0_0 *iface =
    116  *     Pnacl_WrapperInfo_PPP_SomeWrap_0_0.real_iface;
    117  *   void (*temp_fp)(struct some_struct* _struct_result, int32_t a) =
    118  *     ((void (*)(struct some_struct* _struct_result, int32_t a))iface->foo2);
    119  *   struct some_struct _struct_result;
    120  *   temp_fp(&_struct_result, a);
    121  *   return _struct_result;
    122  * }
    123  *
    124  * static struct some_struct Pnacl_M14_PPP_SomeWrap_foo2(int32_t a) {
    125  *   const struct PPP_SomeWrap_1_0 *iface =
    126  *     Pnacl_WrapperInfo_PPP_SomeWrap_1_0.real_iface;
    127  *   void (*temp_fp)(struct some_struct* _struct_result, int32_t a) =
    128  *     ((void (*)(struct some_struct* _struct_result, int32_t a))iface->foo2);
    129  *   struct some_struct _struct_result;
    130  *   temp_fp(&_struct_result, a);
    131  *   return _struct_result;
    132  * }
    133  *
    134  * static int32_t Pnacl_M14_PPP_SomeWrap_foo1(const struct some_struct a[]) {
    135  *   const struct PPP_SomeWrap_1_0 *iface =
    136  *     Pnacl_WrapperInfo_PPP_SomeWrap_1_0.real_iface;
    137  *   int32_t (*temp_fp)(const struct some_struct a[]) =
    138  *     ((int32_t (*)(const struct some_struct a[]))iface->foo1);
    139  *   return temp_fp(a);
    140  * }
    141  */
    142 [version=0.0]
    143 interface PPP_SomeWrap {
    144   int32_t foo1([in] some_struct a);
    145   some_struct foo2([in] int32_t a);
    146 
    147   [version=1.0]
    148   int32_t foo1([in] some_struct[] a);
    149 
    150   /* Not generating wrapper interface for PPP_SomeWrap */
    151   [version=2.0]
    152   int32_t foo1([in] some_struct2 a);
    153   [version=2.0]
    154   void foo2([in] int32_t a);
    155 };
    156 
    157 [no_interface_string]
    158 interface PPP_NoIFString {
    159   int32_t Dummy([in] some_struct a);
    160 };
    161 
    162