infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
007_type_registry.c File Reference

Unit test for the named type registry system. More...

#include "common/double_tap.h"
#include "types.h"
#include <infix/infix.h>
#include <math.h>
Include dependency graph for 007_type_registry.c:

Macros

#define DBLTAP_IMPLEMENTATION
 

Functions

double get_point_x (Point p)
 
Point move_point_handler (Point p)
 
void execute_move_point_callback (Point(*func_ptr)(Point), Point p_in)
 
 subtest ("Basic Registry Lifecycle and Simple Definitions")
 
 subtest ("Using Named Types in Forward Calls")
 
 subtest ("Using Named Types in Reverse Calls")
 
 subtest ("Advanced Definitions (Recursive & Forward Declared)")
 
 subtest ("Error Handling")
 
 subtest ("Semantic Aliases for Non-Aggregate Types")
 

Variables

 TEST
 

Detailed Description

Unit test for the named type registry system.

This test file validates the complete functionality of the type registry, ensuring that named types can be defined, resolved, and used correctly in both forward and reverse FFI calls.

The test covers:

  • Lifecycle and Basic Definitions: Verifying that a registry can be created and destroyed, that simple types can be registered, and that attempting to redefine a type correctly produces an error.
  • Usage in FFI Calls: Demonstrates using a registered named type (e.g., @Point) in a signature string to create both forward and reverse trampolines, and verifies that the resulting FFI calls work correctly.
  • Advanced Definitions: Tests the registry's ability to handle complex scenarios like recursive type definitions (struct Node { struct Node* next; }) and mutually-recursive types using forward declarations. It uses introspection to verify that the resulting type graphs have the correct circular structure.
  • Error Handling: Ensures that the system fails gracefully with the correct error codes when using unregistered types, unresolved forward declarations, or when using the @Name syntax with a NULL registry.

Macro Definition Documentation

◆ DBLTAP_IMPLEMENTATION

#define DBLTAP_IMPLEMENTATION

Function Documentation

◆ execute_move_point_callback()

void execute_move_point_callback ( Point(*)(Point func_ptr,
Point  p_in 
)

◆ get_point_x()

double get_point_x ( Point  p)

◆ move_point_handler()

Point move_point_handler ( Point  p)

◆ subtest() [1/6]

subtest ( "Advanced Definitions (Recursive & Forward Declared)"  )

◆ subtest() [2/6]

subtest ( "Basic Registry Lifecycle and Simple Definitions"  )

◆ subtest() [3/6]

subtest ( "Error Handling"  )

◆ subtest() [4/6]

subtest ( "Semantic Aliases for Non-Aggregate Types"  )

◆ subtest() [5/6]

subtest ( "Using Named Types in Forward Calls"  )

◆ subtest() [6/6]

subtest ( "Using Named Types in Reverse Calls"  )

Variable Documentation

◆ TEST

TEST
Initial value:
{
plan(6)
#define plan(count)
Definition double_tap.h:163