class CrShader::GdshaderincReader

Overview

Lightweight signature extractor for Godot .gdshaderinc header files. Scans struct, const, and function return signatures so .crshader files using #include "res://...gdshaderinc" or include "..." receive accurate return-type, struct-field, and constant-type inference without duplicating emissions.

Defined in:

crshader/parser/gdshaderinc_reader.cr

Constant Summary

CONST_REGEX = /\bconst\s+([A-Za-z_][A-Za-z0-9_]*)\s+([A-Za-z_][A-Za-z0-9_]*)(\s*\[[^\]]*\])?\s*=/
FIELD_REGEX = /\b([A-Za-z_][A-Za-z0-9_]*)\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*\[[^\]]*\])?\s*;/
FUNC_REGEX = /(?:^|\n)\s*([A-Za-z_][A-Za-z0-9_]*)\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(([^)]*)\)\s*\{/
RESERVED_RETURN_WORDS = Set {"if", "for", "while", "switch", "return", "struct", "uniform", "varying", "const", "layout"}
STRUCT_REGEX = /\bstruct\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([^}]*)\}\s*;/m
UNIFORM_REGEX = /\b(?:(?:instance|global)\s+)?uniform\s+(?:(?:lowp|mediump|highp)\s+)*([A-Za-z_][A-Za-z0-9_]*)\s+([A-Za-z_][A-Za-z0-9_]*)(\s*\[[^\]]*\])?/
VARYING_REGEX = /\b(?:(?:flat|smooth)\s+)?varying\s+(?:(?:flat|smooth|lowp|mediump|highp)\s+)*([A-Za-z_][A-Za-z0-9_]*)\s+([A-Za-z_][A-Za-z0-9_]*)(\s*\[[^\]]*\])?\s*;/

Class Method Summary

Class Method Detail

def self.import_signatures(inc_path : String, program : ShaderProgram, base_file : String | Nil = nil) : Bool #

def self.parse_into(raw_source : String, program : ShaderProgram, current_file : String | Nil = nil) : Void #

def self.resolve_path(inc_path : String, base_file : String | Nil = nil) : String | Nil #