002.phpt 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. --TEST--
  2. FFI 002: Check C declaration parser
  3. --EXTENSIONS--
  4. ffi
  5. --INI--
  6. ffi.enable=1
  7. --FILE--
  8. <?php
  9. echo "Empty declaration\n";
  10. $ffi = FFI::cdef(<<<EOF
  11. EOF
  12. );
  13. echo " ok\n";
  14. echo "Various declarations\n";
  15. $ffi = FFI::cdef(<<<EOF
  16. /* allowed storage classes */
  17. typedef int type1;
  18. // extern int var2;
  19. static int var3;
  20. auto int var4;
  21. register int var5;
  22. /* allowed types */
  23. typedef void type6;
  24. typedef char type7; /* sint8_t or uint8_t */
  25. typedef signed char type8; /* sint8_t */
  26. typedef unsigned char type9; /* uint8_t */
  27. typedef short type10; /* sint16_t */
  28. typedef signed short type11; /* sint16_t */
  29. typedef short int type12; /* sint16_t */
  30. typedef signed short int type13; /* sint16_t */
  31. typedef unsigned short type14; /* uint16_t */
  32. typedef unsigned short int type15; /* uint16_t */
  33. typedef int type16; /* sint32_t */
  34. typedef signed type17; /* sint32_t */
  35. typedef signed int type18; /* sint32_t */
  36. typedef unsigned type19; /* uint32_t */
  37. typedef unsigned int type20; /* uint32_t */
  38. typedef long type21; /* sint32_t or sint64_t */
  39. typedef signed long type22; /* sint32_t or sint64_t */
  40. typedef long int type23; /* sint32_t or sint64_t */
  41. typedef signed long int type24; /* sint32_t or sint64_t */
  42. typedef unsigned long type25; /* uint32_t or uint64_t */
  43. typedef unsigned long int type25_2; /* uint32_t or uint64_t */
  44. typedef long long type26; /* sint64_t */
  45. typedef signed long long type27; /* sint64_t */
  46. typedef long long int type28; /* sint64_t */
  47. typedef signed long long int type29; /* sint64_t */
  48. typedef unsigned long long type30; /* uint64_t */
  49. typedef unsigned long long int type31; /* uint64_t */
  50. typedef float type32;
  51. typedef double type33;
  52. typedef long double type34;
  53. typedef _Bool type35;
  54. // typedef float _Complex type36;
  55. // typedef double _Complex type36_2;
  56. // typedef long double _Complex type36_3;
  57. /* struct and union */
  58. struct tag1;
  59. union tag2;
  60. typedef struct tag1 {int x; int y;} type37;
  61. typedef union tag2 {int x; int y;} type38;
  62. typedef struct {int x, y; int z;} type39;
  63. typedef struct {unsigned int x:8, y:8;} type40;
  64. typedef struct {unsigned int x:8, :8, y:8;} type41;
  65. /* enum */
  66. enum tag3;
  67. typedef enum tag3 {A,B,C} type42;
  68. typedef enum {D,E=10,F,} type43;
  69. /* type qualifiers */
  70. typedef void* type46;
  71. typedef const void* type47;
  72. typedef restrict void* type48;
  73. typedef volatile void* type49;
  74. typedef _Atomic void* type50;
  75. typedef const volatile void* type51;
  76. /* function specifiers */
  77. static void f1();
  78. static inline void f2();
  79. static _Noreturn void f3();
  80. /* align specifier */
  81. typedef double _Alignas(char) type52;
  82. typedef double _Alignas(1) type53;
  83. /* pointers */
  84. typedef void * type54;
  85. typedef void ** type55;
  86. typedef const void * const volatile * const type56;
  87. /* arrays */
  88. typedef char type57[];
  89. typedef char type58[const];
  90. typedef char type59[const volatile];
  91. typedef char type60[10];
  92. typedef char type61[const 10];
  93. typedef char type62[static 10];
  94. typedef char type63[static const volatile 10];
  95. typedef char type64[const volatile static 10];
  96. typedef char type65[];
  97. typedef char type66[const volatile];
  98. typedef char type67[10][10];
  99. /* functions */
  100. static void f4();
  101. static void f5(void);
  102. static void f6(int x);
  103. static void f7(int x, int y);
  104. static void f8(int x, int y, ...);
  105. static void f9(int, int);
  106. static void f9(int, int, ...);
  107. static void f10(...);
  108. static void f11(const char *name);
  109. static void f12(const char *);
  110. static void f13(const int a[5]);
  111. static void f14(const int[5]);
  112. /* nested */
  113. typedef int *type69[4];
  114. typedef int (*type70)[4];
  115. typedef int (*type71[3])(int *x, int *y);
  116. typedef int (*type72(int (*)(long), int))(int, ...);
  117. EOF
  118. );
  119. echo " ok\n";
  120. ?>
  121. --EXPECT--
  122. Empty declaration
  123. ok
  124. Various declarations
  125. ok