1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2013 - INRIA - Serge STEER
3 // Copyright (C) 2014 - Scilab Enterprises - Clément DAVID
5 // This file must be used under the terms of the CeCILL.
6 // This source file is licensed as described in the file COPYING, which
7 // you should have received as part of this distribution. The terms
8 // are also available at
9 // http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
11 function tbx_build_pal_loader(palettename,interfacefunctions,module_path,script_path)
13 error(msprintf(gettext("%s: Wrong number of input arguments: At least %d expected.\n"),"tbx_build_blocks",3));
15 // checking palettename argument
16 if type(palettename) <> 10 then
17 error(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"),"tbx_build_blocks",1));
19 if size(palettename,"*") <> 1 then
20 error(msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"),"tbx_build_blocks",1));
23 // checking module_path argument
24 if type(module_path) <> 10 then
25 error(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"),"tbx_build_blocks",3));
27 if size(module_path,"*") <> 1 then
28 error(msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"),"tbx_build_blocks",3));
30 if ~isdir(module_path) then
31 error(msprintf(gettext("%s: The directory ''%s'' doesn''t exist or is not read accessible.\n"),"tbx_build_blocks",module_path));
34 // checking interfacefunctions argument
35 if type(interfacefunctions) <> 10 then
36 error(msprintf(gettext("%s: Wrong type for input argument #%d: A string array expected.\n"),"tbx_build_blocks",2));
39 // checking optional script_path argument
41 if type(script_path) <> 10 then
42 error(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"),"tbx_build_blocks",4));
44 if size(script_path,"*") <> 1 then
45 error(msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"),"tbx_build_blocks",4));
48 script_path=module_path + "/macros"
50 if ~isdir(script_path) then
51 error(msprintf(gettext("%s: The directory ''%s'' doesn''t exist or is not read accessible.\n"),"tbx_build_blocks",script_path));
55 t=["// This file is released under the 3-clause BSD license. See COPYING-BSD."
56 "// Generated by tbx_build_pal_loader: Please, do not edit this file"
58 "function loaderpal()"
59 " xpal = xcosPal("""+palettename+""");"
60 " images_path = get_absolute_file_path(""loader_pal.sce"")+""/../images/"";"
61 " interfacefunctions ="+sci2exp(interfacefunctions);
62 " for i=1:size(interfacefunctions,""*"")"
63 " h5_instances = ls(images_path + ""h5/"" + interfacefunctions(i) + "".sod"");"
64 " if h5_instances==[] then"
65 " error(msprintf(_(""%s: block %s has not been built.\n""),""loader_pal.sce"",interfacefunctions(i)))"
67 " pal_icons = ls(images_path + ""gif/"" + interfacefunctions(i) + ""."" + [""png"" ""jpg"" ""gif""]);"
68 " if pal_icons==[] then"
69 " error(msprintf(_(""%s: block %s has no palette icon.\n""),""loader_pal.sce"",interfacefunctions(i)))"
71 " graph_icons = ls(images_path + ""svg/"" + interfacefunctions(i) + ""."" + [""svg"" ""png"" ""jpg"" ""gif""]);"
72 " if graph_icons==[] then"
73 " error(msprintf(_(""%s: block %s has no editor icon.\n""),""loader_pal.sce"",interfacefunctions(i)))"
75 " xpal = xcosPalAddBlock(xpal, interfacefunctions(i), pal_icons(1) , graph_icons(1));"
79 "loaderpal(),clear loaderpal"]
80 mputl(t,script_path+"loader_pal.sce")