#include extern char* parse(const char*); extern char* format_error(const char*, const char*); VALUE parse_internal(VALUE _instance, VALUE rb_code_string) { Check_Type(rb_code_string, T_STRING); char* code_string = StringValueCStr(rb_code_string); return rb_str_new2(parse(code_string)); } VALUE format_error_internal(VALUE _instance, VALUE rb_filename, VALUE rb_error) { Check_Type(rb_filename, T_STRING); Check_Type(rb_error, T_STRING); char* filename = StringValueCStr(rb_filename); char* error = StringValueCStr(rb_error); return rb_str_new2(format_error(filename, error)); } void Init_lit_parser(void) { VALUE root_module = rb_const_get(rb_cObject, rb_intern("LIT")); VALUE parser_module = rb_const_get(root_module, rb_intern("Parser")); rb_define_singleton_method(parser_module, "__parse_internal", parse_internal, 1); rb_define_singleton_method(parser_module, "__format_error_internal", format_error_internal, 2); }