summaryrefslogtreecommitdiff
path: root/macros/scilab2c.sci
blob: 83cbde768383477054cb384628c8af4e9ef6e5cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2009-2009 - DIGITEO - Bruno JOFRET
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution.  The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
//
//

function scilab2c(varargin)
  [lhs, rhs] = argn();
  
  select rhs
    //
    // scilab2c()
    //
   case 0
    sci2c_gui();
    return
    //
    // scilab2c(UserScilabMainFile, CCodeOutputDir)
    //
   case 2
    for i = 1:2
      if typeof(varargin(i)) <> "string"
	error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"scilab2c",i));
	return
      end
    end
    UserScilabMainFile = varargin(1);
    CCodeOutputDir = varargin(2);
    UserSciFilesPaths = [];
    RunMode = 'All';
    //RunMode = 'GenLibraryStructure';
    //RunMode = 'Translate';
    //
    // scilab2c(UserScilabMainFile, CCodeOutputDir, UserSciFilesPaths)
    //
   case 3
    for i = 1:3
      if typeof(varargin(i)) <> "string"
	error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"scilab2c",i));
	return
      end
    end
    UserScilabMainFile = varargin(1);
    CCodeOutputDir = varargin(2);
    if varargin(3) == ""
      UserSciFilesPaths = [];
    else
      UserSciFilesPaths = varargin(3);
    end
    RunMode = "All";
    //
    // scilab2c(UserScilabMainFile, CCodeOutputDir, UserSciFilesPaths, RunMode)
    //
   case 4
    for i = 1:4
      if typeof(varargin(i)) <> "string"
	error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"scilab2c",i));
	return
      end
    end
    if varargin(4) <> "All" & varargin(4) <> "Translate" & varargin(4) <> "GenLibraryStructure"
      	error(msprintf(gettext("%s: argument #%d must be: ""All"", ""Translate"" or ""GenLibraryStructure"".\n"),"scilab2c",4));
	return
      return
    end
    UserScilabMainFile = varargin(1);
    CCodeOutputDir = varargin(2);
    if varargin(3) == ""
      UserSciFilesPaths = [];
    else
      UserSciFilesPaths = varargin(3);
    end
    RunMode = varargin(4);
  else
    error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"),"scilab2c",2));
  end


// --- LAUNCH USER SCI CODE TO TEST IT BEFORE TRANSLATING IT!!! ---
    runscicode(UserScilabMainFile, UserSciFilesPaths);
// --- ASK USER FOR CONTINUATION. ---

// -- FIXME : bypass this for now !!
    userchoice = messagebox("Exection Succesfull. Start translation ?", "modal", "info", ["Yes" "No"])
    if (userchoice == 1)
// --- LAUNCH SCI2C ---
      runsci2c(UserScilabMainFile, UserSciFilesPaths, CCodeOutputDir, RunMode);
    end

endfunction