---input--- module: nanomsg synopsis: generated bindings for the nanomsg library author: Bruce Mitchener, Jr. copyright: See LICENSE file in this distribution. define simple-C-mapped-subtype () export-map , export-function: identity; end; define interface #include { "sp/sp.h", "sp/fanin.h", "sp/inproc.h", "sp/pair.h", "sp/reqrep.h", "sp/survey.h", "sp/fanout.h", "sp/ipc.h", "sp/pubsub.h", "sp/tcp.h" }, exclude: { "SP_HAUSNUMERO", "SP_PAIR_ID", "SP_PUBSUB_ID", "SP_REQREP_ID", "SP_FANIN_ID", "SP_FANOUT_ID", "SP_SURVEY_ID" }, equate: {"char *" => }, rename: { "sp_recv" => %sp-recv, "sp_send" => %sp-send, "sp_setsockopt" => %sp-setsockopt }; function "sp_version", output-argument: 1, output-argument: 2, output-argument: 3; function "sp_send", map-argument: { 2 => }; function "sp_recv", map-argument: { 2 => }; end interface; // Function for adding the base address of the repeated slots of a // to an offset and returning the result as a . This is // necessary for passing contents across the FFI. define function buffer-offset (the-buffer :: , data-offset :: ) => (result-offset :: ) u%+(data-offset, primitive-wrap-machine-word (primitive-repeated-slot-as-raw (the-buffer, primitive-repeated-slot-offset(the-buffer)))) end function; define inline function sp-send (socket :: , data :: , flags :: ) => (res :: ) %sp-send(socket, buffer-offset(data, 0), data.size, flags) end; define inline function sp-recv (socket :: , data :: , flags :: ) => (res :: ) %sp-recv(socket, buffer-offset(data, 0), data.size, flags); end; define inline method sp-setsockopt (socket :: , level :: , option :: , value :: ) with-stack-structure (int :: ) pointer-value(int) := value; let setsockopt-result = %sp-setsockopt(socket, level, option, int, size-of()); if (setsockopt-result < 0) // Check error! end; setsockopt-result end; end; define inline method sp-setsockopt (socket :: , level :: , option :: , data :: ) let setsockopt-result = %sp-setsockopt(socket, level, option, as(, data), data.size); if (setsockopt-result < 0) // Check error! end; setsockopt-result end; ---tokens--- 'module' Name.Attribute ':' Operator ' ' Text 'nanomsg' Literal.String '\n' Text 'synopsis' Name.Attribute ':' Operator ' ' Text 'generated bindings for the nanomsg library' Literal.String '\n' Text 'author' Name.Attribute ':' Operator ' ' Text 'Bruce Mitchener, Jr.' Literal.String '\n' Text 'copyright' Name.Attribute ':' Operator ' ' Text 'See LICENSE file in this distribution.' Literal.String '\n\n' Text 'define' Keyword ' ' Text 'simple-C-mapped-subtype' Name ' ' Text '' Name.Class ' ' Text '(' Punctuation '' Name.Class ')' Punctuation '\n ' Text 'export-map' Name ' ' Text '' Name.Class ',' Punctuation ' ' Text 'export-function:' Keyword ' ' Text 'identity' Name.Builtin ';' Punctuation '\n' Text 'end' Keyword ';' Punctuation '\n\n' Text 'define' Keyword ' ' Text 'interface' Name.Builtin '\n ' Text '#include' Keyword ' ' Text '{' Punctuation '\n ' Text '"' Literal.String 'sp/sp.h' Literal.String '"' Literal.String ',' Punctuation '\n ' Text '"' Literal.String 'sp/fanin.h' Literal.String '"' Literal.String ',' Punctuation '\n ' Text '"' Literal.String 'sp/inproc.h' Literal.String '"' Literal.String ',' Punctuation '\n ' Text '"' Literal.String 'sp/pair.h' Literal.String '"' Literal.String ',' Punctuation '\n ' Text '"' Literal.String 'sp/reqrep.h' Literal.String '"' Literal.String ',' Punctuation '\n ' Text '"' Literal.String 'sp/survey.h' Literal.String '"' Literal.String ',' Punctuation '\n ' Text '"' Literal.String 'sp/fanout.h' Literal.String '"' Literal.String ',' Punctuation '\n ' Text '"' Literal.String 'sp/ipc.h' Literal.String '"' Literal.String ',' Punctuation '\n ' Text '"' Literal.String 'sp/pubsub.h' Literal.String '"' Literal.String ',' Punctuation '\n ' Text '"' Literal.String 'sp/tcp.h' Literal.String '"' Literal.String '\n ' Text '}' Punctuation ',' Punctuation '\n\n ' Text 'exclude:' Keyword ' ' Text '{' Punctuation '\n ' Text '"' Literal.String 'SP_HAUSNUMERO' Literal.String '"' Literal.String ',' Punctuation '\n ' Text '"' Literal.String 'SP_PAIR_ID' Literal.String '"' Literal.String ',' Punctuation '\n ' Text '"' Literal.String 'SP_PUBSUB_ID' Literal.String '"' Literal.String ',' Punctuation '\n ' Text '"' Literal.String 'SP_REQREP_ID' Literal.String '"' Literal.String ',' Punctuation '\n ' Text '"' Literal.String 'SP_FANIN_ID' Literal.String '"' Literal.String ',' Punctuation '\n ' Text '"' Literal.String 'SP_FANOUT_ID' Literal.String '"' Literal.String ',' Punctuation '\n ' Text '"' Literal.String 'SP_SURVEY_ID' Literal.String '"' Literal.String '\n ' Text '}' Punctuation ',' Punctuation '\n\n ' Text 'equate:' Keyword ' ' Text '{' Punctuation '"' Literal.String 'char *' Literal.String '"' Literal.String ' ' Text '=>' Punctuation ' ' Text '' Name.Class '}' Punctuation ',' Punctuation '\n\n ' Text 'rename:' Keyword ' ' Text '{' Punctuation '\n ' Text '"' Literal.String 'sp_recv' Literal.String '"' Literal.String ' ' Text '=>' Punctuation ' ' Text '%sp-recv' Name ',' Punctuation '\n ' Text '"' Literal.String 'sp_send' Literal.String '"' Literal.String ' ' Text '=>' Punctuation ' ' Text '%sp-send' Name ',' Punctuation '\n ' Text '"' Literal.String 'sp_setsockopt' Literal.String '"' Literal.String ' ' Text '=>' Punctuation ' ' Text '%sp-setsockopt' Name '\n ' Text '}' Punctuation ';' Punctuation '\n\n ' Text 'function' Name.Builtin ' ' Text '"' Literal.String 'sp_version' Literal.String '"' Literal.String ',' Punctuation '\n ' Text 'output-argument:' Keyword ' ' Text '1' Literal.Number.Integer ',' Punctuation '\n ' Text 'output-argument:' Keyword ' ' Text '2' Literal.Number.Integer ',' Punctuation '\n ' Text 'output-argument:' Keyword ' ' Text '3' Literal.Number.Integer ';' Punctuation '\n\n ' Text 'function' Name.Builtin ' ' Text '"' Literal.String 'sp_send' Literal.String '"' Literal.String ',' Punctuation '\n ' Text 'map-argument:' Keyword ' ' Text '{' Punctuation ' ' Text '2' Literal.Number.Integer ' ' Text '=>' Punctuation ' ' Text '' Name.Class ' ' Text '}' Punctuation ';' Punctuation '\n\n ' Text 'function' Name.Builtin ' ' Text '"' Literal.String 'sp_recv' Literal.String '"' Literal.String ',' Punctuation '\n ' Text 'map-argument:' Keyword ' ' Text '{' Punctuation ' ' Text '2' Literal.Number.Integer ' ' Text '=>' Punctuation ' ' Text '' Name.Class ' ' Text '}' Punctuation ';' Punctuation '\n\n' Text 'end' Keyword ' ' Text 'interface' Name.Builtin ';' Punctuation '\n\n' Text '// Function for adding the base address of the repeated slots of a \n' Comment.Single '// to an offset and returning the result as a . This is\n' Comment.Single '// necessary for passing contents across the FFI.\n' Comment.Single '\n' Text 'define' Keyword ' ' Text 'function' Name.Builtin ' ' Text 'buffer-offset' Name '\n ' Text '(' Punctuation 'the-buffer' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ',' Punctuation ' ' Text 'data-offset' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ')' Punctuation '\n ' Text '=>' Punctuation ' ' Text '(' Punctuation 'result-offset' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ')' Punctuation '\n ' Text 'u%+' Name '(' Punctuation 'data-offset' Name ',' Punctuation '\n ' Text 'primitive-wrap-machine-word' Name '\n ' Text '(' Punctuation 'primitive-repeated-slot-as-raw' Name '\n ' Text '(' Punctuation 'the-buffer' Name ',' Punctuation ' ' Text 'primitive-repeated-slot-offset' Name '(' Punctuation 'the-buffer' Name ')' Punctuation ')' Punctuation ')' Punctuation ')' Punctuation '\n' Text 'end' Keyword ' ' Text 'function' Name.Builtin ';' Punctuation '\n\n' Text 'define' Keyword ' ' Text 'inline' Name.Builtin ' ' Text 'function' Name.Builtin ' ' Text 'sp-send' Name ' ' Text '(' Punctuation 'socket' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ',' Punctuation ' ' Text 'data' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ',' Punctuation ' ' Text 'flags' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ')' Punctuation ' ' Text '=>' Punctuation ' ' Text '(' Punctuation 'res' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ')' Punctuation '\n ' Text '%sp-send' Name '(' Punctuation 'socket' Name ',' Punctuation ' ' Text 'buffer-offset' Name '(' Punctuation 'data' Name ',' Punctuation ' ' Text '0' Literal.Number.Integer ')' Punctuation ',' Punctuation ' ' Text 'data' Name '.' Punctuation 'size' Name.Builtin ',' Punctuation ' ' Text 'flags' Name ')' Punctuation '\n' Text 'end' Keyword ';' Punctuation '\n\n' Text 'define' Keyword ' ' Text 'inline' Name.Builtin ' ' Text 'function' Name.Builtin ' ' Text 'sp-recv' Name ' ' Text '(' Punctuation 'socket' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ',' Punctuation ' ' Text 'data' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ',' Punctuation ' ' Text 'flags' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ')' Punctuation ' ' Text '=>' Punctuation ' ' Text '(' Punctuation 'res' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ')' Punctuation '\n ' Text '%sp-recv' Name '(' Punctuation 'socket' Name ',' Punctuation ' ' Text 'buffer-offset' Name '(' Punctuation 'data' Name ',' Punctuation ' ' Text '0' Literal.Number.Integer ')' Punctuation ',' Punctuation ' ' Text 'data' Name '.' Punctuation 'size' Name.Builtin ',' Punctuation ' ' Text 'flags' Name ')' Punctuation ';' Punctuation '\n' Text 'end' Keyword ';' Punctuation '\n\n' Text 'define' Keyword ' ' Text 'inline' Name.Builtin ' ' Text 'method' Name.Builtin ' ' Text 'sp-setsockopt' Name ' ' Text '(' Punctuation 'socket' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ',' Punctuation ' ' Text 'level' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ',' Punctuation ' ' Text 'option' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ',' Punctuation ' ' Text 'value' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ')' Punctuation '\n ' Text 'with-stack-structure' Name ' ' Text '(' Punctuation 'int' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ')' Punctuation '\n ' Text 'pointer-value' Name '(' Punctuation 'int' Name ')' Punctuation ' ' Text ':=' Operator ' ' Text 'value' Name ';' Punctuation '\n ' Text 'let' Keyword ' ' Text 'setsockopt-result' Name ' ' Text '=' Operator '\n ' Text '%sp-setsockopt' Name '(' Punctuation 'socket' Name ',' Punctuation ' ' Text 'level' Name ',' Punctuation ' ' Text 'option' Name ',' Punctuation ' ' Text 'int' Name ',' Punctuation ' ' Text 'size-of' Name '(' Punctuation '' Name.Class ')' Punctuation ')' Punctuation ';' Punctuation '\n ' Text 'if' Keyword ' ' Text '(' Punctuation 'setsockopt-result' Name ' ' Text '<' Operator ' ' Text '0' Literal.Number.Integer ')' Punctuation '\n ' Text '// Check error!\n' Comment.Single ' ' Text 'end' Keyword ';' Punctuation '\n ' Text 'setsockopt-result' Name '\n ' Text 'end' Keyword ';' Punctuation '\n' Text 'end' Keyword ';' Punctuation '\n\n' Text 'define' Keyword ' ' Text 'inline' Name.Builtin ' ' Text 'method' Name.Builtin ' ' Text 'sp-setsockopt' Name ' ' Text '(' Punctuation 'socket' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ',' Punctuation ' ' Text 'level' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ',' Punctuation ' ' Text 'option' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ',' Punctuation ' ' Text 'data' Name ' ' Text '::' Punctuation ' ' Text '' Name.Class ')' Punctuation '\n ' Text 'let' Keyword ' ' Text 'setsockopt-result' Name ' ' Text '=' Operator '\n ' Text '%sp-setsockopt' Name '(' Punctuation 'socket' Name ',' Punctuation ' ' Text 'level' Name ',' Punctuation ' ' Text 'option' Name ',' Punctuation ' ' Text 'as' Name.Builtin '(' Punctuation '' Name.Class ',' Punctuation ' ' Text 'data' Name ')' Punctuation ',' Punctuation ' ' Text 'data' Name '.' Punctuation 'size' Name.Builtin ')' Punctuation ';' Punctuation '\n ' Text 'if' Keyword ' ' Text '(' Punctuation 'setsockopt-result' Name ' ' Text '<' Operator ' ' Text '0' Literal.Number.Integer ')' Punctuation '\n ' Text '// Check error!\n' Comment.Single ' ' Text 'end' Keyword ';' Punctuation '\n ' Text 'setsockopt-result' Name '\n' Text 'end' Keyword ';' Punctuation '\n' Text