Differences From Artifact [f0f5b8d756]:

To Artifact [c82b78366b]:


8
9
10
11
12
13
14





15
16
17
18
19
20
21
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26







+
+
+
+
+







# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.43  2002/04/30 23:27:00  geraint
## Replaced octave_map with columnvector in simpar.cc. Not quite as descriptive but
## standardises the interfaces somewhat and reduces the dependency on liboctinterp
## (and thus libreadline, libkpathsea, libncurses, etc).
##
## Revision 1.42  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.41  2002/04/23 17:46:05  gawthrop
## _sim.m now returns time as third argument
##
725
726
727
728
729
730
731
732

733
734
735
736
737
738
739
740
741
742
743
744
745
746

747
748
749
750
751
752
753
754
755
756

757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774

775
776
777
778
779
780
781
730
731
732
733
734
735
736

737
738
739
740
741
742
743
744
745
746
747
748
749
750

751
752
753
754
755
756
757
758
759
760

761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778

779
780
781
782
783
784
785
786







-
+













-
+









-
+

















-
+







    echo ${ans}
}


write_DLD_header()
{
    cat <<EOF
#ifndef STANDALONE
#if (CODEGENTARGET == OCTAVEDLD)
#include <octave/oct.h>
#include <octave/toplev.h>
#include <math.h>
#include "useful-functions.hh"
#include "${system}_cr.h"
#include "${system}_def.h"
#include "${system}_sympar.h"

DEFUN_DLD (${system}_${rep}, args, ,
"Usage: [$output] = ${system}_${rep}($args)\nOctave ${rep} representation of system ${system}\nGenerated by MTT on `date`")
{

  octave_value_list retval;
#endif // ! STANDALONE
#endif // (CODEGENTARGET == OCTAVEDLD)

EOF
}


map_DLD_inputs ()
{
    s=${1:-""}					# comma separated input list
    if [ -z ${s:-""} ];then return; fi
    printf "#ifndef STANDALONE\n"
    printf "#if (CODEGENTARGET == OCTAVEDLD)\n"
    c=`get_field ${s} 0`			# count of inputs
    i=0
    printf "  if (${c} != args.length ()) usage (\"${fun_name} expected ${c} argument(s): ${s}\");\n\n"
    while [ ${i} -lt ${c} ]; do
	j=${i}
	i=`expr ${i} + 1`
	w=`get_field ${s} ${i}`		# argument name
	get_arg_specific_stuff ${w}
	case ${arg_type} in
	    "const double")
		printf "  ${arg_type}\t${w}\t= args(${j}).double_value ();\n"
		;;
	    ColumnVector | Matrix | *)
		printf "  ${arg_type}\t${w}\t= args(${j}).%s ();\n" ${vector_value}
		;;
	esac
    done
    printf "#endif // ! STANDALONE\n\n"
    printf "#endif // (CODEGENTARGET == OCTAVEDLD)\n\n"
}	


declare_DLD_outputs ()
{
    s=${1:-""}					# comma separated output list
    c=`get_field ${s} 0`			# count of outputs
794
795
796
797
798
799
800
801

802
803
804
805
806
807
808
809
810
811
812

813
814
815
816
817
818
819
820

821







822
823
824
825
826
827
828
799
800
801
802
803
804
805

806
807
808
809
810
811
812
813
814
815
816

817
818
819
820
821
822
823
824
825
826

827
828
829
830
831
832
833
834
835
836
837
838
839
840







-
+










-
+








+
-
+
+
+
+
+
+
+







    s=${1:-""}					# comma separated output list
    c=`get_field ${s} 0`			# count of outputs
    i=0
    cat <<EOF

\/\/ END Code

#ifndef STANDALONE
#if (CODEGENTARGET == OCTAVEDLD)
EOF
    while [ ${i} -lt ${c} ]; do
	j=${i}
	i=`expr ${i} + 1`
	w=`get_field ${s} ${i}`
	printf "  retval (${j})\t= octave_value (${w});\n"
    done
    cat <<EOF
  return (retval);
}
#endif // ! STANDALONE
#endif // (CODEGENTARGET == OCTAVEDLD)
EOF
}

write_standalone_header ()
{
    get_arg_specific_stuff ${output}
    cat <<EOF

// Code generation directives
#ifdef STANDALONE
#define STANDALONE 0
#define OCTAVEDLD  1
#if (! defined (CODEGENTARGET))
#define CODEGENTARGET STANDALONE
#endif // (! defined (CODEGENTARGET))

#if (CODEGENTARGET == STANDALONE)
#include <octave/oct.h>
#include "useful-functions.hh"
#include "${system}_cr.h"
#include "${system}_def.h"
#include "${system}_sympar.h"

${arg_type} F${system}_${rep} (
843
844
845
846
847
848
849
850

851
852
853
854
855
856
857

858
859
860

861
862
863
864
865
866
867
855
856
857
858
859
860
861

862
863
864
865
866
867
868

869
870
871

872
873
874
875
876
877
878
879







-
+






-
+


-
+







	    get_arg_specific_stuff ${w}
	    printf "\t${arg_type}\t&${w}${comma}\n"
	done
    fi
    cat <<EOF
)
{
#endif // STANDALONE
#endif // (CODEGENTARGET == STANDALONE)
EOF
}

return_standalone_output ()
{
    cat <<EOF
#ifdef STANDALONE
#if (CODEGENTARGET == STANDALONE)
  return ${output};
}
#endif // STANDALONE
#endif // (CODEGENTARGET == STANDALONE)
EOF
}

# Header information
cat<<EOF
$modeline
$function $declaration

MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]