1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // Multi-Phasic Applications: SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc
.squirreljme
.c
;
12 import java
.io
.IOException
;
13 import net
.multiphasicapps
.tac
.TestRunnable
;
16 * Tests function pointers.
20 public class TestFunctionPointer
31 CType type
= CFunctionType
.of(CIdentifier
.of("boop"),
32 CPrimitiveType
.SIGNED_INTEGER
,
33 CVariable
.of(CPrimitiveType
.UNSIGNED_CHAR
, "squeak"))
36 try (__Spool__ spool
= __Spool__
.__init(false))
38 // int (*cute)(unsigned char squeak);
39 spool
.declare(CVariable
.of(type
, "cute"));
41 this.secondary("intboopsqueak", spool
.tokens());
44 // Then pointer for different rule
45 try (__Spool__ spool
= __Spool__
.__init(false))
47 // int (*const cute)(unsigned char squeak);
48 spool
.declare(CVariable
.of(type
.constType(), "cute"));
50 this.secondary("const", spool
.tokens());
54 try (__Spool__ spool
= __Spool__
.__init(false))
56 // int (** cute)(unsigned char squeak);
57 spool
.declare(CVariable
.of(type
.pointerType(),
60 this.secondary("pointerpointer", spool
.tokens());
64 try (__Spool__ spool
= __Spool__
.__init(false))
66 // int (*const cute)(unsigned char squeak);
67 spool
.declare(CVariable
.of(type
68 .constType().pointerType().pointerType().constType(),
71 this.secondary("alt", spool
.tokens());
75 try (__Spool__ spool
= __Spool__
.__init(false))
77 // int (*const cute)(unsigned char squeak);
78 spool
.declare(CVariable
.of(type
.constType().arrayType(2),
81 this.secondary("array", spool
.tokens());
85 try (__Spool__ spool
= __Spool__
.__init(false))
87 // int (*const cute)(unsigned char squeak);
88 spool
.declare(CVariable
.of(type
.constType()
89 .arrayType(2).arrayType(3),
92 this.secondary("arrayarray", spool
.tokens());
95 // Return an array type
96 try (__Spool__ spool
= __Spool__
.__init(false))
98 spool
.declare(CVariable
.of(
99 CFunctionType
.of(CIdentifier
.of("boop"),
100 CPrimitiveType
.SIGNED_INTEGER
.arrayType(2),
101 CVariable
.of(CPrimitiveType
.UNSIGNED_CHAR
,
103 .pointerType(), "cute"));
105 this.secondary("returnarray", spool
.tokens());
108 // Return an array array type
109 try (__Spool__ spool
= __Spool__
.__init(false))
111 spool
.declare(CVariable
.of(
112 CFunctionType
.of(CIdentifier
.of("boop"),
113 CPrimitiveType
.SIGNED_INTEGER
.arrayType(2)
115 CVariable
.of(CPrimitiveType
.UNSIGNED_CHAR
,
117 .pointerType(), "cute"));
119 this.secondary("returnarraytwo", spool
.tokens());