% Miscellany (opaque type mapping, macro ignores, inline_c, etc) {{{
slirp_define_opaque("TrivDatum",NULL,"triv_datum_destroy");
% Old symbol-ignore method 
ignored_macros = [ "TRIV_IGNORABLE_MACRO", ignored_macros ];
ignored_variables = [ "TRIV_IGNORABLE_INT2", ignored_variables];
#copy int FD_PROXY { int fd }

#inline_c
#define MAXSTR 99
#include "stdio.h"
#end
% }}}

#argmap (  in, 		which=2		 ,  usage="float_array  " ) (long nelems, float  array[]) (int i, short s) % {{{
   printf("Array input to %s is of dimension: %d\n",$funcname, $2_ndims);
   $1 = ($1_type) $2_dim1;		/* inmap1 */
   i = (int) $1;
   s = 100;
#end % }}}

% These rules transform triv_mult2() into the equivalent of triv_mult() {{{
% (the long* and short* copies will be no-ops, since they do won't match
% anything, and are included here so as to better test the parser)
#copy double *OUTPUT {long* huey,	double* result,   short*dewey}
#clear double*result
#copy double *OUTPUT {double *result}
% }}}

#argmap (	in	  ) char ** % {{{
   /* inmap2: demonstrate that inmap1 will take precedence, i.e.
      this fragment is not injected into the emitted code */
#end % }}}

% In map defined only so as to exercise subsequent #clear directive  {{{
#argmap		( in) double op2
#end
#clear double op2 % }}}

#copy(long nelems, float  array[]) {     (long nelems, char **)	}

#argmap (in) char **NULL_TERMINATED_STRING_ARRAY (int size) % {{{
   {
   char **copy = $1;
   size = 0;
   while (*copy++)
	size++;
   }
   printf("\nNull terminated string array size: %d elements\n",size);
#end % }}}

#argmap(in, omit) unsigned long int ul (char tmp[MAXSTR]) % {{{
   /* Accept zero args, and always pass this constant instead */
   $1 = 112233;
   strcpy(tmp, "JustTesting");
#end % }}}

#argmap(in, omit) (unsigned long int ul, double d) % {{{
   /* Accept zero args, and always pass these constants instead */
   $1 = 332211;
   $2 = 999.111;
#end % }}}

#argmap(in) TrivInt (int blah) % {{{
   blah = $1;
#end	% }}}

#argmap(final) TrivInt (int copy) % {{{
   copy = $argnum;
   printf("Finalizing arg %d of %s (with local copy)\n", copy, $funcname);
#end % }}}

#ignore % New (recommended) symbol-ignore method {{{
					TRIV_IGNORABLE_MACRO2
dummy1,		% There is no implementation for this,

	dummy2% ... or this

   dummy3, dummy4,		% ... or these

% comments within ignore directives should operate as they do w/in S-Lang proper
triv_ignorable_func		% this supports annotating the ignored func
% 			lists in a 
					% variety of ways
   TRIV_IGNORABLE_INT
#end % }}}

#argmap(in, which=[1,3]) (double	  *DA1  ,   long nelems	,	   double*DA2) (int tmp) % {{{
   tmp = $argnum;
   $2 = $1_dim1;
   if ($2 != (long) $3_length) {
	SLang_verror(SL_INTRINSIC_ERROR,"%s: array size mismatch",$funcname);
	return;
   }
#end % }}}

% Annotations for triv_copy_string {{{
#argmap(in, which=1) (char* src, char *dest, long len)
   $3 = strlen($1);
   $2 = SLmalloc($3 + 1);
#end

#argmap(out) char *dest
   if (SLang_push_malloced_string($1) == -1)
	SLfree($1);
#end

#typedef int Ignore

#retmap(omit) Ignore % {{{
      /* #retmap(omit) Ignore */
#end % }}}
% }}}

#argmap(final) TrivDatum* % {{{
   /* no-op, just to exercise parameter substitutions with opaque types */
   { TrivDatum **p = &$1; (void) p;}
#end % }}}

#argmap(out)  TrivDatum * * copy % {{{
   (void) SLang_push_opaque(TrivDatum_Type,  $1, 0);
#end % }}}

#prototype % {{{
   void  triv_print_array_nts(char **NULL_TERMINATED_STRING_ARRAY);
   % Exercise multi-return value handling
   FILE* triv_fopen (char *name, char *mode, unsigned long *OUTPUT,
						unsigned short *OUT);
   Ignore triv_copy_string (char *src, char *dest, long len);
#end % }}}
