# This is free and unencumbered software released into the public domain. require_relative '../exporter' module FFIDB::Exporters ## # Code generator for the Common Lisp programming language (using CFFI). # # @see https://common-lisp.net/project/cffi/ class Lisp < FFIDB::Exporter TYPE_MAP = ::YAML.load(File.read(File.expand_path("../../../etc/mappings/lisp.yaml", __dir__))) .transform_values(&:to_sym) .freeze def finish puts self.render_template('lisp.erb') end protected ## # @param [FFIDB::Type] c_type # @return [#inspect] def struct_type(c_type) case when c_type.array? then [c_type.array_type.to_s.to_sym, :count, c_type.array_size] else [self.param_type(c_type)] end end ## # @param [FFIDB::Type] c_type # @return [#inspect] def param_type(c_type) case when c_type.enum? then :int else TYPE_MAP[c_type.to_s] || TYPE_MAP['void *'] end end end # Lisp end # FFIDB::Exporters