Defining a helper value class for library in a VAPI file

Hey all - is it possible to define utility classes inside a VAPI file that don’t exist in the library being wrapped?

I’ve been trying to do this but ran into problems at compile time where the class I’ve added doesn’t end up getting a struct definition generated in any of the C code.

Here’s a snippet of what I put together. (As some background context, I’m trying to wrap the PCRE2 library more directly in Vala to get my hands on more of the functionality than is available through the default GLib regex type. I found this existing VAPI as a starter: https://github.com/rrthomas/rpl/raw/refs/heads/main/pcre2.vapi)

[CCode (cprefix = "PCRE2_", lower_case_cprefix = "pcre2_", cheader_filename = "pcre2.h")]
namespace Pcre2 {
	
	// ---snip---

	[Compact]
	[CCode (cprefix = "pcre2_", cname = "pcre2_code", free_function = "pcre2_code_free")]
	public class Regex {
		// ---snip---

		[CCode (cname = "pcre2_pattern_info")]
		private int _pcre2_pattern_info(PatternInfo what, void *where);

		[Compact]
		[CCode (cname = "_vala_pcre2_nametable", type="_vala_pcre2_nametable")]
		public class NameTable {
			public void * nametable;
			public uint32 name_count;
			public uint32 name_entry_size;

			public static NameTable (void * nametable, uint32 name_count, uint32 name_entry_size) {
				this(nametable, name_count, name_entry_size);
				this.nametable = nametable;
				this.name_count = name_count;
				this.name_entry_size = name_entry_size;
			}
		}

		[CCode (cname = "_vala_get_pcre2_nametable")]
		public NameTable get_nametable () {
			uint32 count = 0;
			_pcre2_pattern_info (PatternInfo.NAMECOUNT, &count);
			uint32 entrysize = 0;
			_pcre2_pattern_info (PatternInfo.NAMEENTRYSIZE, &entrysize);
			void * tableptr = null;
			_pcre2_pattern_info (PatternInfo.NAMETABLE, &tableptr);
			return new NameTable (tableptr, count, entrysize);
		}
	]
}

Trying to use this, I get all sorts of errors like this in the final compile:

/home/stewart/Projects/mystery_app/rutil.c: At top level:
/home/stewart/Projects/mystery_app/rutil.c:1440:8: error: unknown type name ‘_vala_pcre2_nametable’
 1440 | static _vala_pcre2_nametable*
      |        ^~~~~~~~~~~~~~~~~~~~~
/home/stewart/Projects/mystery_app/rutil.c: In function ‘pcre2_name_table_construct’:
/home/stewart/Projects/mystery_app/rutil.c:1446:9: error: unknown type name ‘_vala_pcre2_nametable’
 1446 |         _vala_pcre2_nametable* self = NULL;
      |         ^~~~~~~~~~~~~~~~~~~~~
/home/stewart/Projects/mystery_app/rutil.c:1447:17: error: ‘_vala_pcre2_nametable’ undeclared (first use in this function)
 1447 |         self = (_vala_pcre2_nametable*) pcre2_name_table_construct (object_type, nametable, name_count, name_entry_size);
      |                 ^~~~~~~~~~~~~~~~~~~~~

As a workaround, I’ve put the NameTable class in a separate .vala file that’s also in the same Pcre2 namespace, but this seems unideal - I need to remember to include that .vala file in the compile list every time I use the .vapi (unless there is some other file inclusion trick I don’t know about that can mitigate this)