Blank out c-source-writer tests as they need to be ported from the internal TAC to...
[SquirrelJME.git] / tools / c-source-writer / src / ____ / java / cc / squirreljme / c / TestFunctionPointer.java
blob6959c70534ff5108dd60290b578185b8b0e2373f
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;
15 /**
16 * Tests function pointers.
18 * @since 2023/06/05
20 public class TestFunctionPointer
21 extends TestRunnable
23 /**
24 * {@inheritDoc}
25 * @since 2023/06/05
27 @Override
28 public void test()
29 throws IOException
31 CType type = CFunctionType.of(CIdentifier.of("boop"),
32 CPrimitiveType.SIGNED_INTEGER,
33 CVariable.of(CPrimitiveType.UNSIGNED_CHAR, "squeak"))
34 .pointerType();
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());
53 // Pointer pointer
54 try (__Spool__ spool = __Spool__.__init(false))
56 // int (** cute)(unsigned char squeak);
57 spool.declare(CVariable.of(type.pointerType(),
58 "cute"));
60 this.secondary("pointerpointer", spool.tokens());
63 // Alternating
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(),
69 "cute"));
71 this.secondary("alt", spool.tokens());
74 // Array
75 try (__Spool__ spool = __Spool__.__init(false))
77 // int (*const cute)(unsigned char squeak);
78 spool.declare(CVariable.of(type.constType().arrayType(2),
79 "cute"));
81 this.secondary("array", spool.tokens());
84 // Array of array
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),
90 "cute"));
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,
102 "squeak"))
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)
114 .arrayType(3),
115 CVariable.of(CPrimitiveType.UNSIGNED_CHAR,
116 "squeak"))
117 .pointerType(), "cute"));
119 this.secondary("returnarraytwo", spool.tokens());