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

Implements the high-level signature string parser. More...

#include "common/infix_internals.h"
#include <ctype.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for signature.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  parser_state
 
struct  printer_state
 

Macros

#define MAX_RECURSION_DEPTH   32
 

Functions

static infix_typeparse_type (parser_state *)
 
static infix_status parse_function_signature_details (parser_state *, infix_type **, infix_function_argument **, size_t *, size_t *)
 
static infix_typeparse_aggregate (parser_state *, char, char)
 
static infix_typeparse_vector_type (parser_state *)
 
static infix_typeparse_function_type (parser_state *)
 
static infix_typeparse_packed_struct (parser_state *)
 
static infix_typeparse_primitive (parser_state *)
 
static void set_parser_error (parser_state *state, infix_error_code_t code)
 
static void skip_whitespace (parser_state *state)
 
static bool parse_size_t (parser_state *state, size_t *out_val)
 
static const char * parse_identifier (parser_state *state)
 
static bool consume_keyword (parser_state *state, const char *keyword)
 
static const char * parse_optional_name_prefix (parser_state *state)
 
static bool is_function_signature_ahead (const parser_state *state)
 
static infix_struct_memberparse_aggregate_members (parser_state *state, char end_char, size_t *out_num_members)
 
c23_nodiscard infix_status _infix_parse_type_internal (infix_type **out_type, infix_arena_t **out_arena, const char *signature, infix_registry_t *registry)
 The core, non-resolving entry point for the signature parser.
 
c23_nodiscard infix_status infix_type_from_signature (infix_type **out_type, infix_arena_t **out_arena, const char *signature, infix_registry_t *registry)
 Implementation of the public infix_type_from_signature API function.
 
c23_nodiscard infix_status infix_signature_parse (const char *signature, infix_arena_t **out_arena, infix_type **out_ret_type, infix_function_argument **out_args, size_t *out_num_args, size_t *out_num_fixed_args, infix_registry_t *registry)
 Implementation of the public infix_signature_parse API function.
 
static void _print (printer_state *state, const char *fmt,...)
 
static void _infix_type_print_signature_recursive (printer_state *state, const infix_type *type)
 
infix_status infix_type_print (char *buffer, size_t buffer_size, const infix_type *type, infix_print_dialect_t dialect)
 Implementation of the public infix_type_print API function.
 
infix_status infix_function_print (char *buffer, size_t buffer_size, const char *function_name, const infix_type *ret_type, const infix_function_argument *args, size_t num_args, size_t num_fixed_args, infix_print_dialect_t dialect)
 Implementation of the public infix_function_print API function.
 

Detailed Description

Implements the high-level signature string parser.

Copyright (c) 2025 Sanko Robinson

This source code is dual-licensed under the Artistic License 2.0 or the MIT License. You may choose to use this code under the terms of either license.

SPDX-License-Identifier: (Artistic-2.0 OR MIT)

The documentation blocks within this file are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).

SPDX-License-Identifier: CC-BY-4.0

Macro Definition Documentation

◆ MAX_RECURSION_DEPTH

#define MAX_RECURSION_DEPTH   32

Function Documentation

◆ _infix_parse_type_internal()

c23_nodiscard infix_status _infix_parse_type_internal ( infix_type **  out_type,
infix_arena_t **  out_arena,
const char *  signature,
infix_registry_t registry 
)

The core, non-resolving entry point for the signature parser.

◆ _infix_type_print_signature_recursive()

static void _infix_type_print_signature_recursive ( printer_state state,
const infix_type type 
)
static

◆ _print()

static void _print ( printer_state state,
const char *  fmt,
  ... 
)
static

◆ consume_keyword()

static bool consume_keyword ( parser_state state,
const char *  keyword 
)
static

◆ is_function_signature_ahead()

static bool is_function_signature_ahead ( const parser_state state)
static

◆ parse_aggregate()

static infix_type * parse_aggregate ( parser_state state,
char  start_char,
char  end_char 
)
static

◆ parse_aggregate_members()

static infix_struct_member * parse_aggregate_members ( parser_state state,
char  end_char,
size_t *  out_num_members 
)
static

◆ parse_function_signature_details()

static infix_status parse_function_signature_details ( parser_state state,
infix_type **  out_ret_type,
infix_function_argument **  out_args,
size_t *  out_num_args,
size_t *  out_num_fixed_args 
)
static

◆ parse_function_type()

static infix_type * parse_function_type ( parser_state state)
static

◆ parse_identifier()

static const char * parse_identifier ( parser_state state)
static

◆ parse_optional_name_prefix()

static const char * parse_optional_name_prefix ( parser_state state)
static

◆ parse_packed_struct()

static infix_type * parse_packed_struct ( parser_state state)
static

◆ parse_primitive()

static infix_type * parse_primitive ( parser_state state)
static

◆ parse_size_t()

static bool parse_size_t ( parser_state state,
size_t *  out_val 
)
static

◆ parse_type()

static infix_type * parse_type ( parser_state state)
static

◆ parse_vector_type()

static infix_type * parse_vector_type ( parser_state state)
static

◆ set_parser_error()

static void set_parser_error ( parser_state state,
infix_error_code_t  code 
)
static

◆ skip_whitespace()

static void skip_whitespace ( parser_state state)
static