Module: dfmc-c-ffi Copyright: Original Code is Copyright (c) 1995-2004 Functional Objects, Inc. All rights reserved. License: Functional Objects Library Public License Version 1.0 Dual-license: GNU Lesser General Public License Warranty: Distributed WITHOUT WARRANTY OF ANY KIND define function c-ffi-default-inline-policy () => (policy) // #{ inline-only } #{ } end function; define function parse-boolean-fragment (fragment, #key default = #f) => (result) macro-case(fragment) { #f } => #f; { #t } => #t; { ?anything-else:* } => default; end macro-case; end function; define class () slot name, init-keyword: name:; slot designator-name, init-keyword: designator-name:; slot model-type; constant slot void? :: , init-keyword: void?:, init-value: #f; end; define class () slot name, init-keyword: name:; slot designator-name, init-keyword: designator-name:; slot model-type; constant slot call-discipline :: , // input output or in-out init-keyword: call-discipline:; // slot other-options :: = #(); end; /* define class () slot c-name, init-keyword: c-name:; slot argument-specs :: , init-keyword: argument-specs:; slot result-spec :: , init-keyword: result-spec:; slot dylan-function, init-keyword: dylan-function:; slot options :: , init-keyword: options:; end class ; define class () slot c-name, init-keyword: c-name:; slot argument-specs :: , init-keyword: argument-specs:; slot result-spec :: , init-keyword: result-spec:; slot generic-function-method :: , init-keyword: generic-function-method:, init-value: #f; slot options :: , init-keyword: options:; end class ; */ // // DEFINE C-FUNCTION // /* define option => c-name: :: expression end option; define option => c-modifiers: :: expression end option; define option => indirect: :: expression excludes end option; define option => generic-function-method: :: expression end option; define constant $c-function-options = list(, , , ); */ define ¯o C-function-definer { define ?mods:* C-function ?dylan-name:name ?spec:* end } => begin let (arg-specs, result-spec, c-name, options) = parse-c-function-spec(dylan-name, spec); let (arg-fragments, result-fragment, parameter-list-fragment, return-values-fragment, define-gf?) = parse-early-options(arg-specs, result-spec, options, dylan-name); let inline-policy = mods; let body = #{ c-function-body ?dylan-name (c-name ?c-name), (options ??options, ...), ?result-fragment, ??arg-fragments, ... end }; if (define-gf?) #{ define ?inline-policy method ?dylan-name ?parameter-list-fragment => ?return-values-fragment; ?body end } else #{ define ?inline-policy function ?dylan-name ?parameter-list-fragment => ?return-values-fragment; ?body end } end if; end mods: { } => c-ffi-default-inline-policy(); { ?other:* } => #{ ?other }; spec: { } => #(); { ?stuff:*; ... } => pair(stuff, ...); end ¯o; define method parse-early-options (arg-specs :: , result-spec :: , function-options :: , definition-name) => (arg-fragments :: , result-fragment ::