{43C5BAB1-1DCA-4743-A183-77E0D42FE7D0} = {43C5BAB1-1DCA-4743-A183-77E0D42FE7D0}
{8CCDD3C2-B025-4A12-A986-1AA28D7C0C33} = {8CCDD3C2-B025-4A12-A986-1AA28D7C0C33}
{A5911CD7-F8E8-440C-A23E-4843A0636F3A} = {A5911CD7-F8E8-440C-A23E-4843A0636F3A}
+ {7CA60AEF-9AFA-4D06-AF28-613C0AA27640} = {7CA60AEF-9AFA-4D06-AF28-613C0AA27640}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BuildChm", "modules\helptools\src\BuildChm\BuildChm.vcproj", "{D319F719-F429-4842-A6F9-B1227FE2A54D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "abstractSyntaxTree", "modules\abstractSyntaxTree\abstractSyntaxTree.vcproj", "{0D3FA25B-8116-44EC-A45E-260789DAA3D9}"
ProjectSection(ProjectDependencies) = postProject
+ {ECFFEB0C-1EDA-45EE-9A10-B18143852E17} = {ECFFEB0C-1EDA-45EE-9A10-B18143852E17}
{2C60033B-0DBD-4CA4-80D3-176C9BE9CE2F} = {2C60033B-0DBD-4CA4-80D3-176C9BE9CE2F}
{E1284D3E-4B3F-446B-B541-F661A8A166A7} = {E1284D3E-4B3F-446B-B541-F661A8A166A7}
{3170E4C2-1173-4264-A222-7EE8CCB3DDF7} = {3170E4C2-1173-4264-A222-7EE8CCB3DDF7}
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "functions_manager", "modules\functions_manager\functions_manager.vcproj", "{8EAC9381-C059-43EA-B5D7-FD5D6997B0BD}"
ProjectSection(ProjectDependencies) = postProject
{764FAC09-369D-4C11-A0FF-CE097D9A4FAF} = {764FAC09-369D-4C11-A0FF-CE097D9A4FAF}
+ {ECFFEB0C-1EDA-45EE-9A10-B18143852E17} = {ECFFEB0C-1EDA-45EE-9A10-B18143852E17}
{45CA5B12-7601-4968-AE16-16069FD1A152} = {45CA5B12-7601-4968-AE16-16069FD1A152}
{C6E2BC17-34D8-46E4-85F3-6293CB21ADCD} = {C6E2BC17-34D8-46E4-85F3-6293CB21ADCD}
{28305722-6486-481D-BD0F-B4398D8A09C5} = {28305722-6486-481D-BD0F-B4398D8A09C5}
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "parse", "modules\parse\parse.vcproj", "{74D43792-DBFC-47F0-ADBC-4D7A20CDADA2}"
ProjectSection(ProjectDependencies) = postProject
+ {ECFFEB0C-1EDA-45EE-9A10-B18143852E17} = {ECFFEB0C-1EDA-45EE-9A10-B18143852E17}
{2C60033B-0DBD-4CA4-80D3-176C9BE9CE2F} = {2C60033B-0DBD-4CA4-80D3-176C9BE9CE2F}
{0D3FA25B-8116-44EC-A45E-260789DAA3D9} = {0D3FA25B-8116-44EC-A45E-260789DAA3D9}
+ {6A84AD8C-BA18-4A3F-9C72-EC3DF0939E9E} = {6A84AD8C-BA18-4A3F-9C72-EC3DF0939E9E}
{3170E4C2-1173-4264-A222-7EE8CCB3DDF7} = {3170E4C2-1173-4264-A222-7EE8CCB3DDF7}
EndProjectSection
EndProject
{2C60033B-0DBD-4CA4-80D3-176C9BE9CE2F} = {2C60033B-0DBD-4CA4-80D3-176C9BE9CE2F}
{80C0F142-184B-4E08-A8EE-5E71437CF904} = {80C0F142-184B-4E08-A8EE-5E71437CF904}
{4FC72D4A-80EE-4B1A-8724-0201C1A35621} = {4FC72D4A-80EE-4B1A-8724-0201C1A35621}
+ {8028F371-6A94-4A26-8804-6E7F05F1D1AA} = {8028F371-6A94-4A26-8804-6E7F05F1D1AA}
{6A84AD8C-BA18-4A3F-9C72-EC3DF0939E9E} = {6A84AD8C-BA18-4A3F-9C72-EC3DF0939E9E}
{3170E4C2-1173-4264-A222-7EE8CCB3DDF7} = {3170E4C2-1173-4264-A222-7EE8CCB3DDF7}
{64E090DA-DCB5-4F4D-93D7-E88DDEC9C2EF} = {64E090DA-DCB5-4F4D-93D7-E88DDEC9C2EF}
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core_gw", "modules\core\src\cpp\core_gw.vcproj", "{3E933EB6-D427-4828-9B30-B6B9987491F6}"
ProjectSection(ProjectDependencies) = postProject
+ {ECFFEB0C-1EDA-45EE-9A10-B18143852E17} = {ECFFEB0C-1EDA-45EE-9A10-B18143852E17}
{C6E2BC17-34D8-46E4-85F3-6293CB21ADCD} = {C6E2BC17-34D8-46E4-85F3-6293CB21ADCD}
{2C60033B-0DBD-4CA4-80D3-176C9BE9CE2F} = {2C60033B-0DBD-4CA4-80D3-176C9BE9CE2F}
{64BC155E-292F-484F-9404-76EE6AE67A43} = {64BC155E-292F-484F-9404-76EE6AE67A43}
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "io_gw", "modules\io\src\cpp\io_gw.vcproj", "{719EC179-3AD3-4C6B-BBD8-B44C96B1A204}"
ProjectSection(ProjectDependencies) = postProject
+ {ECFFEB0C-1EDA-45EE-9A10-B18143852E17} = {ECFFEB0C-1EDA-45EE-9A10-B18143852E17}
{C6E2BC17-34D8-46E4-85F3-6293CB21ADCD} = {C6E2BC17-34D8-46E4-85F3-6293CB21ADCD}
{2C60033B-0DBD-4CA4-80D3-176C9BE9CE2F} = {2C60033B-0DBD-4CA4-80D3-176C9BE9CE2F}
{80C0F142-184B-4E08-A8EE-5E71437CF904} = {80C0F142-184B-4E08-A8EE-5E71437CF904}
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "output_stream_gw", "modules\output_stream\sci_gateway\cpp\output_stream_gw\output_stream_gw.vcproj", "{C000FDF7-4D32-4630-9595-560D9CC66D11}"
ProjectSection(ProjectDependencies) = postProject
+ {ECFFEB0C-1EDA-45EE-9A10-B18143852E17} = {ECFFEB0C-1EDA-45EE-9A10-B18143852E17}
{2C60033B-0DBD-4CA4-80D3-176C9BE9CE2F} = {2C60033B-0DBD-4CA4-80D3-176C9BE9CE2F}
{A5911CD7-F8E8-440C-A23E-4843A0636F3A} = {A5911CD7-F8E8-440C-A23E-4843A0636F3A}
{64E090DA-DCB5-4F4D-93D7-E88DDEC9C2EF} = {64E090DA-DCB5-4F4D-93D7-E88DDEC9C2EF}
{
public:
CommentExp (const Location& location,
- std::string* comment) :
+ std::wstring* comment) :
ConstExp (location),
_comment (comment)
{
** \{ */
public:
/** \brief Return the comment (read only). */
- std::string &comment_get () const
+ std::wstring &comment_get () const
{
return *_comment;
}
/** \} */
protected:
- std::string* _comment;
+ std::wstring* _comment;
};
} // namespace ast
#include "exp.hxx"
#include "arraylistvar.hxx"
+using namespace std;
+
namespace ast
{
- /*
- ** \brief Abstract a Function Declaration node.
- **
- ** \b Example: function foo(s : string) : int = (print(s); 2097)
- */
- class FunctionDec : public Dec
- {
- // \name Ctor & dtor.
- public:
/*
- ** \brief Construct a Function Declaration node.
- ** \param location scanner position informations
- ** \param name of function
- ** \param list of params
- ** \param list of returns
- ** \param body
+ ** \brief Abstract a Function Declaration node.
+ **
+ ** \b Example: function foo(s : string) : int = (print(s); 2097)
*/
- FunctionDec (const Location& location,
- const std::string name,
- ArrayListVar& args,
- ArrayListVar& returns,
- Exp& body) :
- Dec (location),
- _name (name),
- _args (&args),
- _returns (&returns),
- _body (&body)
- {
- }
-
- virtual ~FunctionDec ()
- {
- delete _body;
- delete _args;
- delete _returns;
- }
-
-
- // \name Visitors entry point.
- public:
- // \brief Accept a const visitor
- virtual void accept (Visitor& v)
- {
- v.visit (*this);
- }
- // \brief Accept a non-const visitor
- virtual void accept (ConstVisitor& v) const
- {
- v.visit (*this);
- }
-
-
- // \name Accessors.
- public:
- const std::string& name_get (void) const
- {
- return _name;
- }
-
- const Exp& body_get (void) const
- {
- return *_body;
- }
- Exp& body_get (void)
- {
- return *_body;
- }
-
- const ArrayListVar& args_get () const
- {
- return *_args;
- }
- ArrayListVar& args_get ()
- {
- return *_args;
- }
-
- const ArrayListVar& returns_get () const
- {
- return *_returns;
- }
- ArrayListVar& returns_get ()
- {
- return *_returns;
- }
-
- void body_set(Exp *body)
+ class FunctionDec : public Dec
{
- _body = body;
- }
-
- protected:
- std::string _name;
- ArrayListVar* _args;
- ArrayListVar* _returns;
- Exp* _body;
- };
+ // \name Ctor & dtor.
+ public:
+ /*
+ ** \brief Construct a Function Declaration node.
+ ** \param location scanner position informations
+ ** \param name of function
+ ** \param list of params
+ ** \param list of returns
+ ** \param body
+ */
+ FunctionDec (const Location& location,
+ const std::wstring name,
+ ArrayListVar& args,
+ ArrayListVar& returns,
+ Exp& body) :
+ Dec (location),
+ _name (name),
+ _args (&args),
+ _returns (&returns),
+ _body (&body)
+ {
+ }
+
+ virtual ~FunctionDec ()
+ {
+ delete _body;
+ delete _args;
+ delete _returns;
+ }
+
+
+ // \name Visitors entry point.
+ public:
+ // \brief Accept a const visitor
+ virtual void accept (Visitor& v)
+ {
+ v.visit (*this);
+ }
+ // \brief Accept a non-const visitor
+ virtual void accept (ConstVisitor& v) const
+ {
+ v.visit (*this);
+ }
+
+
+ // \name Accessors.
+ public:
+ const wstring& name_get (void) const
+ {
+ return _name;
+ }
+
+ const Exp& body_get (void) const
+ {
+ return *_body;
+ }
+
+ Exp& body_get (void)
+ {
+ return *_body;
+ }
+
+ const ArrayListVar& args_get () const
+ {
+ return *_args;
+ }
+
+ ArrayListVar& args_get ()
+ {
+ return *_args;
+ }
+
+ const ArrayListVar& returns_get () const
+ {
+ return *_returns;
+ }
+
+ ArrayListVar& returns_get ()
+ {
+ return *_returns;
+ }
+
+ void body_set(Exp *body)
+ {
+ _body = body;
+ }
+
+ protected:
+ std::wstring _name;
+ ArrayListVar* _args;
+ ArrayListVar* _returns;
+ Exp* _body;
+ };
} // namespace ast
ControlExp (location),
_test (&test),
_then (&t),
- _else (new ast::CommentExp(location, new std::string("No else !!"))),
+ _else (new ast::CommentExp(location, new std::wstring(L"No else !!"))),
// For first display in order to see what appends
_has_else (false)
{
}
/** \} */
- std::string location_string_get() const
+ std::wstring location_string_get() const
{
- std::ostringstream os;
- os << " (" << first_line << "," << first_column << ")";
- return std::string(os.str());
+ std::wostringstream os;
+ os << L" (" << first_line << L"," << first_column << L")";
+ return os.str();
}
public:
namespace ast
{
- class EXTERN_AST PrintVisitor : public GenVisitor<const_kind>
- {
- public:
- PrintVisitor(std::ostream& my_ostr) :
- ostr (&my_ostr)
+ class EXTERN_AST PrintVisitor : public GenVisitor<const_kind>
{
- indent = 0;
- force_parenthesis = true;
- }
-
- PrintVisitor(std::ostream& my_ostr, bool parenthesis_display) :
- ostr (&my_ostr),
- force_parenthesis (parenthesis_display)
- {
- indent = 0;
- }
-
- /** \name Visit Matrix Expressions nodes.
- ** \{ */
- public :
- virtual void visit (const MatrixExp &e);
- virtual void visit (const MatrixLineExp &e);
- /** \} */
-
- /** \name Visit Cell Expressions nodes.
- ** \{ */
- public :
- virtual void visit (const CellExp &e);
- /** \} */
-
- /** \name Visit Constant Expressions nodes.
- ** \{ */
- public :
- virtual void visit (const StringExp &e);
- virtual void visit (const CommentExp &e);
- virtual void visit (const IntExp &e);
- virtual void visit (const FloatExp &e);
- virtual void visit (const DoubleExp &e);
- virtual void visit (const BoolExp &e);
- virtual void visit (const NilExp &e);
- /** \} */
-
- /** \name Visit Variable related nodes.
- ** \{ */
- virtual void visit (const SimpleVar &e);
- virtual void visit (const ColonVar &e);
- virtual void visit (const DollarVar &e);
- virtual void visit (const ArrayListVar &e);
- /** \} */
-
- /** \name Visit Control Expressions or Instructions nodes.
- ** \{ */
- virtual void visit (const FieldExp &e);
- virtual void visit (const OpExp &e);
- virtual void visit (const LogicalOpExp &e);
- virtual void visit (const AssignExp &e);
- virtual void visit (const CellCallExp &e);
- virtual void visit (const CallExp &e);
- virtual void visit (const IfExp &e);
- virtual void visit (const TryCatchExp &e);
- virtual void visit (const WhileExp &e);
- virtual void visit (const ForExp &e);
- virtual void visit (const BreakExp &e);
- virtual void visit (const ReturnExp &e);
- virtual void visit (const SelectExp &e);
- virtual void visit (const CaseExp &e);
- virtual void visit (const SeqExp &e);
- virtual void visit (const ArrayListExp &e);
- virtual void visit (const AssignListExp &e);
- /** \} */
-
- /** \name Visit Single Operation nodes.
- ** \{ */
- virtual void visit (const NotExp &e);
- virtual void visit (const TransposeExp &e);
- /** \} */
-
- /** \name Visit Declaration nodes.
- ** \{ */
- /** \brief Visit Var declarations. */
- virtual void visit (const VarDec &e);
- virtual void visit (const FunctionDec &e);
- /** \} */
-
- /** \name Visit Type dedicated Expressions related node.
- ** \{ */
- public:
- virtual void visit(const ListExp &e);
- /** \} */
+ public:
+ PrintVisitor(std::wostream& my_ostr) :
+ ostr (&my_ostr)
+ {
+ indent = 0;
+ force_parenthesis = true;
+ }
+
+ PrintVisitor(std::wostream& my_ostr, bool parenthesis_display) :
+ ostr (&my_ostr),
+ force_parenthesis (parenthesis_display)
+ {
+ indent = 0;
+ }
+
+ /** \name Visit Matrix Expressions nodes.
+ ** \{ */
+ public :
+ virtual void visit (const MatrixExp &e);
+ virtual void visit (const MatrixLineExp &e);
+ /** \} */
+
+ /** \name Visit Cell Expressions nodes.
+ ** \{ */
+ public :
+ virtual void visit (const CellExp &e);
+ /** \} */
+
+ /** \name Visit Constant Expressions nodes.
+ ** \{ */
+ public :
+ virtual void visit (const StringExp &e);
+ virtual void visit (const CommentExp &e);
+ virtual void visit (const IntExp &e);
+ virtual void visit (const FloatExp &e);
+ virtual void visit (const DoubleExp &e);
+ virtual void visit (const BoolExp &e);
+ virtual void visit (const NilExp &e);
+ /** \} */
+
+ /** \name Visit Variable related nodes.
+ ** \{ */
+ virtual void visit (const SimpleVar &e);
+ virtual void visit (const ColonVar &e);
+ virtual void visit (const DollarVar &e);
+ virtual void visit (const ArrayListVar &e);
+ /** \} */
+
+ /** \name Visit Control Expressions or Instructions nodes.
+ ** \{ */
+ virtual void visit (const FieldExp &e);
+ virtual void visit (const OpExp &e);
+ virtual void visit (const LogicalOpExp &e);
+ virtual void visit (const AssignExp &e);
+ virtual void visit (const CellCallExp &e);
+ virtual void visit (const CallExp &e);
+ virtual void visit (const IfExp &e);
+ virtual void visit (const TryCatchExp &e);
+ virtual void visit (const WhileExp &e);
+ virtual void visit (const ForExp &e);
+ virtual void visit (const BreakExp &e);
+ virtual void visit (const ReturnExp &e);
+ virtual void visit (const SelectExp &e);
+ virtual void visit (const CaseExp &e);
+ virtual void visit (const SeqExp &e);
+ virtual void visit (const ArrayListExp &e);
+ virtual void visit (const AssignListExp &e);
+ /** \} */
+
+ /** \name Visit Single Operation nodes.
+ ** \{ */
+ virtual void visit (const NotExp &e);
+ virtual void visit (const TransposeExp &e);
+ /** \} */
+
+ /** \name Visit Declaration nodes.
+ ** \{ */
+ /** \brief Visit Var declarations. */
+ virtual void visit (const VarDec &e);
+ virtual void visit (const FunctionDec &e);
+ /** \} */
+
+ /** \name Visit Type dedicated Expressions related node.
+ ** \{ */
+ public:
+ virtual void visit(const ListExp &e);
+ /** \} */
/*-------------.
- | Attributes. |
- `-------------*/
- protected:
- std::ostream *ostr;
- int indent;
- bool force_parenthesis;
-
- void apply_indent(void);
- void enable_force_parenthesis(void);
- void set_force_parenthesis(bool new_state);
- };
+ | Attributes. |
+ `-------------*/
+ protected:
+ std::wostream *ostr;
+ int indent;
+ bool force_parenthesis;
+
+ void apply_indent(void);
+ void enable_force_parenthesis(void);
+ void set_force_parenthesis(bool new_state);
+ };
}
#endif // !AST_PRINTVISITOR_HXX
}
else
{//never append ?
- std::ostringstream os;
- os << _("Unable to extract left part expression.\n");
+ std::wostringstream os;
+ os << _W("Unable to extract left part expression.\n");
os << ((Location)e.left_exp_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
if(piIndexSeq[i] < 1)
{
//manage error
- std::ostringstream os;
- os << _("Indexes must be positive .\n");
+ std::wostringstream os;
+ os << _W("Indexes must be positive .\n");
os << ((Location)e.left_exp_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
if(e.is_verbose())
{
- std::ostringstream ostr;
+ std::wostringstream ostr;
if(pVar)
{
- ostr << pVar->name_get() << " = " << std::endl;
+ ostr << pVar->name_get() << L" = " << std::endl;
}
else
{
- ostr << "???" << " = " << std::endl;
+ ostr << L"???" << L" = " << std::endl;
}
ostr << std::endl;
ostr << pOut->toString(ConfigVariable::getFormat(), ConfigVariable::getConsoleWidth()) << std::endl;
- YaspWrite((char *)ostr.str().c_str());
+ YaspWriteW(ostr.str().c_str());
}
}
else
{
//manage error
- std::ostringstream os;
- os << _("Submatrix incorrectly defined.\n");
+ std::wostringstream os;
+ os << _W("Submatrix incorrectly defined.\n");
os << ((Location)e.right_exp_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
}
else
{//never append ?
- std::ostringstream os;
- os << _("Unable to extract left part expression.\n");
+ std::wostringstream os;
+ os << _W("Unable to extract left part expression.\n");
os << ((Location)e.left_exp_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
if(piIndexSeq[i] < 1)
{
//manage error
- std::ostringstream os;
- os << _("Indexes must be positive .\n");
+ std::wostringstream os;
+ os << _W("Indexes must be positive .\n");
os << ((Location)e.left_exp_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
if(e.is_verbose())
{
- std::ostringstream ostr;
+ std::wostringstream ostr;
if(pVar)
{
- ostr << pVar->name_get() << " = " << std::endl;
+ ostr << pVar->name_get() << L" = " << std::endl;
}
else
{
- ostr << "???" << " = " << std::endl;
+ ostr << L"???" << L" = " << std::endl;
}
ostr << std::endl;
ostr << pOut->toString(ConfigVariable::getFormat(), ConfigVariable::getConsoleWidth()) << std::endl;
- YaspWrite((char *)ostr.str().c_str());
+ YaspWriteW(ostr.str().c_str());
}
}
else
{
//manage error
- std::ostringstream os;
- os << _("Submatrix incorrectly defined.\n");
+ std::wostringstream os;
+ os << _W("Submatrix incorrectly defined.\n");
os << ((Location)e.right_exp_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
if(execMeR.result_size_get() != 1)
{
- std::ostringstream os;
- os << "Lhs != Rhs";
+ std::wostringstream os;
+ os << L"Lhs != Rhs";
os << ((Location)e.right_exp_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
if(e.is_verbose())
{
- std::ostringstream ostr;
- ostr << pVar->name_get() << " = " << std::endl;
- ostr << std::endl;
+ std::wostringstream ostr;
+ ostr << pVar->name_get() << L" = " << std::endl << std::endl;
ostr << pIT->toString(ConfigVariable::getFormat(), ConfigVariable::getConsoleWidth()) << std::endl;
- YaspWrite((char *)ostr.str().c_str());
+ YaspWriteW(ostr.str().c_str());
}
}
else if(pList)
if(execMeR.result_size_get() != execMeR.expected_size_get())
{
- std::ostringstream os;
- os << "Lhs != Rhs";
+ std::wostringstream os;
+ os << L"Lhs != Rhs";
throw os.str();
}
symbol::Context::getInstance()->put(pListVar->name_get(), *((GenericType*)execMeR.result_get(i)));
if(e.is_verbose())
{
- std::ostringstream ostr;
- ostr << pListVar->name_get() << " = " << std::endl;
+ std::wostringstream ostr;
+ ostr << pListVar->name_get() << L" = " << std::endl;
ostr << std::endl;
ostr << execMeR.result_get(i)->toString(ConfigVariable::getFormat(), ConfigVariable::getConsoleWidth()) << std::endl;
- YaspWrite((char *)ostr.str().c_str());
+ YaspWriteW(ostr.str().c_str());
}
i--;
}
if(pStr->isRef(1) == true)
{
pStr = pStr->clone();
- const string *pstName = getStructNameFromExp(pField);
+ const wstring *pstName = getStructNameFromExp(pField);
symbol::Context::getInstance()->put(*pstName, *pStr);
}
//we can assign only one value
if(execMeR.result_size_get() != 1)
{
- std::ostringstream os;
- os << "Lhs != Rhs";
+ std::wostringstream os;
+ os << L"Lhs != Rhs";
os << ((Location)e.right_exp_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
pStr->add(pTail->name_get(), pIT);
if(e.is_verbose())
{
- const string *pstName = getStructNameFromExp(pField);
+ const wstring *pstName = getStructNameFromExp(pField);
- std::ostringstream ostr;
- ostr << *pstName << " = " << std::endl;
- ostr << std::endl;
+ std::wostringstream ostr;
+ ostr << *pstName << L" = " << std::endl << std::endl;
ostr << symbol::Context::getInstance()->get(*pstName)->toString(ConfigVariable::getFormat(), ConfigVariable::getConsoleWidth()) << std::endl;
- YaspWrite((char *)ostr.str().c_str());
+ YaspWriteW(ostr.str().c_str());
}
}
else
{//Houston ...
- std::ostringstream os;
- os << "unknow script form";
+ std::wostringstream os;
+ os << L"unknow script form";
os << ((Location)e.right_exp_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
}
- catch(string sz)
+ catch(wstring sz)
{
throw sz;
}
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2010-2010 - 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
- *
+ *
*/
// This code is separated in run_CallExp.hxx
execVar[j].result_set(pIL->extract_matrix());
delete pIL;
}
-
+
if(execVar[j].is_single_result())
{
in.push_back(execVar[j].result_get());
}
}
}
-
+
int iRetCount = Max(1, expected_size_get());
T execCall;
Function::ReturnValue Ret = pCall->call(in, iRetCount, out, &execCall);
-
+
if(Ret == Callable::OK)
{
if(expected_size_get() == 1 && out.size() == 0) //to manage ans
{
if(static_cast<int>(out.size()) < expected_size_get())
{
- std::ostringstream os;
- os << "bad lhs, expected : " << expected_size_get() << " returned : " << out.size() << std::endl;
+ std::wostringstream os;
+ os << L"bad lhs, expected : " << expected_size_get() << L" returned : " << out.size() << std::endl;
throw os.str();
}
}
out[0]->IncreaseRef();
result_set(out[0]);
}
- else
+ else
{
for(int i = 0 ; i < static_cast<int>(out.size()) ; i++)
{//protect output values
}
else if(Ret == Callable::Error)
{
- std::ostringstream os;
- char szError[bsiz];
+ std::wostringstream os;
+ wchar_t szError[bsiz];
#ifdef _MSC_VER
- sprintf_s(szError, bsiz, _("Function \"%s\" failed\n"), pCall->getName().c_str());
+ swprintf_s(szError, bsiz, _W("Function \"%s\" failed\n"), pCall->getName().c_str());
#else
- sprintf(szError, _("Function \"%s\" failed\n"), pCall->getName().c_str());
+ swprintf(szError, bsiz, _W("Function \"%S\" failed\n"), pCall->getName().c_str());
#endif
- throw string(szError);
+ throw wstring(szError);
}
-
+
for (unsigned int k = 0; k < e.args_get().size(); k++)
{
execVar[k].result_get()->DecreaseRef();
}
-
+
//std::cout << "before delete[]" << std::endl;
delete[] execVar;
//std::cout << "after delete[]" << std::endl;
{//unprotect output values
out[0]->DecreaseRef();
}
- else
+ else
{
for(int i = 0 ; i < static_cast<int>(out.size()) ; i++)
{//unprotect output values
if(pIT->isStruct())
{
- list<string> stFields;
+ list<wstring> stFields;
list<Exp*>::const_iterator it1;
for(it1 = e.args_get().begin() ; it1 != e.args_get().end() ; it1++)
{
String *pString = execArg.result_get()->getAsString();
for(int i = 0 ; i < pString->size_get() ; i++)
{
- stFields.push_back(string(pString->string_get(i)));
+ stFields.push_back(pString->string_get(i));
}
}
else
}
else if(pIT->isTList())
{
- list<string> stFields;
+ list<wstring> stFields;
list<Exp*>::const_iterator it1;
InternalType::RealType rtIndex = InternalType::RealInternal;
(*it1)->accept(execArg);
if(bTypeSet == true && execArg.result_get()->getType() != rtIndex)
- {//error
- YaspWrite("merdouille");
+ {//TODO: error
+ YaspWriteW(L"merdouille");
}
if(execArg.result_get()->isString())
String *pString = execArg.result_get()->getAsString();
for(int i = 0 ; i < pString->size_get() ; i++)
{
- stFields.push_back(string(pString->string_get(i)));
+ stFields.push_back(pString->string_get(i));
}
}
else if(execArg.result_get()->isDouble())
if(piIndexSeq[i] < 1)
{
//manage error
- std::ostringstream os;
- os << _("Indexes must be positive .\n");
+ std::wostringstream os;
+ os << _W("Indexes must be positive .\n");
os << ((Location)e.name_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
if(piIndexSeq[i] < 1)
{
//manage error
- std::ostringstream os;
- os << _("Indexes must be positive .\n");
+ std::wostringstream os;
+ os << _W("Indexes must be positive .\n");
os << ((Location)e.name_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
case InternalType::RealDouble :
pOut = pIT->getAsDouble()->extract(iTotalCombi, piIndexSeq, piMaxDim, piDimSize, bSeeAsVector);
break;
- case InternalType::RealBool :
+ case InternalType::RealBool :
pOut = pIT->getAsBool()->extract(iTotalCombi, piIndexSeq, piMaxDim, piDimSize, bSeeAsVector);
break;
case InternalType::RealInt :
{
if(pOut == NULL)
{
- std::ostringstream os;
- os << "inconsistent row/column dimensions";
+ std::wostringstream os;
+ os << L"inconsistent row/column dimensions";
os << ((*e.args_get().begin())->location_get()).location_string_get() << std::endl;
throw os.str();
}
result_set(pOut);
}
- else
+ else
{
if(ResultList.size() == 0)
{
- std::ostringstream os;
- os << "inconsistent row/column dimensions";
+ std::wostringstream os;
+ os << L"inconsistent row/column dimensions";
os << ((*e.args_get().begin())->location_get()).location_string_get() << std::endl;
throw os.str();
}
}
else if(iCurRow != ((GenericType*)execMe->result_get())->rows_get() && ((GenericType*)execMe->result_get())->rows_get() != 0)
{
- std::ostringstream os;
- os << "inconsistent row/column dimensions";
+ std::wostringstream os;
+ os << L"inconsistent row/column dimensions";
os << ((Location)(*row)->location_get()).location_string_get() << std::endl;
throw os.str();
}
}
else if(iCols != 0 && iCols != iCurCol)
{
- std::ostringstream os;
- os << "inconsistent row/column dimensions";
+ std::wostringstream os;
+ os << L"inconsistent row/column dimensions";
os << ((Location)(*row)->location_get()).location_string_get() << std::endl;
throw os.str();
}
result_set(poResult);
}
- catch(string sz)
+ catch(wstring sz)
{
throw sz;
}
int iResult = AddDoubleToDouble(pL, pR, (Double**)&pResult);
if(iResult != 0)
{
- std::ostringstream os;
- os << "inconsistent row/column dimensions";
+ std::wostringstream os;
+ os << L"inconsistent row/column dimensions";
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
if(iResult != 0)
{
- std::ostringstream os;
- os << "inconsistent row/column dimensions";
+ std::wostringstream os;
+ os << L"inconsistent row/column dimensions";
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
int iResult = AddDoubleToPoly(pR, pL, (MatrixPoly**)&pResult);
if(iResult != 0)
{
- std::ostringstream os;
- os << "inconsistent row/column dimensions";
+ std::wostringstream os;
+ os << L"inconsistent row/column dimensions";
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
int iResult = AddDoubleToPoly(pL, pR, (MatrixPoly**)&pResult);
if(iResult != 0)
{
- std::ostringstream os;
- os << "inconsistent row/column dimensions";
+ std::wostringstream os;
+ os << L"inconsistent row/column dimensions";
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
{
if(iResult == 1)
{
- std::ostringstream os;
- os << "inconsistent row/column dimensions";
+ std::wostringstream os;
+ os << L"inconsistent row/column dimensions";
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
else if(iResult == 2)
{
- std::ostringstream os;
- os << "variables don't have the same formal variable";
+ std::wostringstream os;
+ os << L"variables don't have the same formal variable";
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
int iResult = SubstractDoubleToDouble(pL, pR, (Double**)&pResult);
if(iResult != 0)
{
- std::ostringstream os;
- os << _("Inconsistent row/column dimensions.\n");
+ std::wostringstream os;
+ os << _W("Inconsistent row/column dimensions.\n");
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
int iResult = SubstractPolyToDouble(pL, pR, (MatrixPoly**)&pResult);
if(iResult != 0)
{
- std::ostringstream os;
- os << _("Inconsistent row/column dimensions.\n");
+ std::wostringstream os;
+ os << _W("Inconsistent row/column dimensions.\n");
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
int iResult = SubstractDoubleToPoly(pL, pR, (MatrixPoly**)&pResult);
if(iResult != 0)
{
- std::ostringstream os;
- os << _("Inconsistent row/column dimensions.\n");
+ std::wostringstream os;
+ os << _W("Inconsistent row/column dimensions.\n");
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
int iResult = SubstractPolyToPoly(pL, pR, (MatrixPoly**)&pResult);
if(iResult != 0)
{
- std::ostringstream os;
- os << _("Inconsistent row/column dimensions.\n");
+ std::wostringstream os;
+ os << _W("Inconsistent row/column dimensions.\n");
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
int iResult = MultiplyDoubleByDouble(pL, pR, (Double**)&pResult);
if(iResult)
{
- std::ostringstream os;
- os << _("Inconsistent row/column dimensions.\n");
+ std::wostringstream os;
+ os << _W("Inconsistent row/column dimensions.\n");
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
if(iResult)
{
- std::ostringstream os;
- os << _("Inconsistent row/column dimensions.\n");
+ std::wostringstream os;
+ os << _W("Inconsistent row/column dimensions.\n");
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
if(iResult)
{
- std::ostringstream os;
- os << _("Inconsistent row/column dimensions.\n");
+ std::wostringstream os;
+ os << _W("Inconsistent row/column dimensions.\n");
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
if(iResult)
{
- std::ostringstream os;
- os << _("Inconsistent row/column dimensions.\n");
+ std::wostringstream os;
+ os << _W("Inconsistent row/column dimensions.\n");
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
int iResult = DivideDoubleByDouble(pL, pR, (Double**)&pResult);
if(iResult)
{//manage errors
- std::ostringstream os;
- os << _("Inconsistent row/column dimensions.\n");
+ std::wostringstream os;
+ os << _W("Inconsistent row/column dimensions.\n");
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
int iResult = DividePolyByDouble(pL, pR, (MatrixPoly**)&pResult);
if(iResult)
{//manage errors
- std::ostringstream os;
- os << _("Inconsistent row/column dimensions.\n");
+ std::wostringstream os;
+ os << _W("Inconsistent row/column dimensions.\n");
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
int iResult = DivideDoubleByPoly(pL, pR, (MatrixPoly**)&pResult);
if(iResult)
{//manage errors
- std::ostringstream os;
- os << _("Inconsistent row/column dimensions.\n");
+ std::wostringstream os;
+ os << _W("Inconsistent row/column dimensions.\n");
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
int iResult = DotMultiplyDoubleByDouble(pL, pR, (Double**)&pResult);
if(iResult)
{
- std::ostringstream os;
- os << _("Inconsistent row/column dimensions.\n");
+ std::wostringstream os;
+ os << _W("Inconsistent row/column dimensions.\n");
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
{
pResult = new Bool(pR->rows_get(), pR->cols_get());
- char* pstL = pL->string_get()[0];
+ wchar_t* pstL = pL->string_get()[0];
for(int i = 0 ; i < pR->rows_get() ; i++)
{
for(int j = 0 ; j < pR->cols_get() ; j++)
{
- char* pstR = pR->string_get(i,j);
- if(strcmp(pstL, pstR) == 0)
+ wchar_t* pstR = pR->string_get(i,j);
+ if(wcscmp(pstL, pstR) == 0)
{
pResult->getAsBool()->bool_set(i,j,true);
}
{
pResult = new Bool(pL->rows_get(), pL->cols_get());
- char* pstR = pR->string_get()[0];
+ wchar_t* pstR = pR->string_get()[0];
for(int i = 0 ; i < pL->rows_get() ; i++)
{
for(int j = 0 ; j < pL->cols_get() ; j++)
{
- char* pstL = pL->string_get(i,j);
- if(strcmp(pstL, pstR) == 0)
+ wchar_t* pstL = pL->string_get(i,j);
+ if(wcscmp(pstL, pstR) == 0)
{
pResult->getAsBool()->bool_set(i,j,true);
}
{
for(int j = 0 ; j < pL->cols_get() ; j++)
{
- char* pstR = pR->string_get(i,j);
- char* pstL = pL->string_get(i,j);
- if(strcmp(pstL, pstR) == 0)
+ wchar_t* pstR = pR->string_get(i,j);
+ wchar_t* pstL = pL->string_get(i,j);
+ if(wcscmp(pstL, pstR) == 0)
{
pResult->getAsBool()->bool_set(i,j,true);
}
{
pResult = new Bool(pR->rows_get(), pR->cols_get());
- char* pstL = pL->string_get()[0];
+ wchar_t* pstL = pL->string_get()[0];
for(int i = 0 ; i < pR->rows_get() ; i++)
{
for(int j = 0 ; j < pR->cols_get() ; j++)
{
- char* pstR = pR->string_get(i,j);
- if(strcmp(pstL, pstR) == 0)
+ wchar_t* pstR = pR->string_get(i,j);
+ if(wcscmp(pstL, pstR) == 0)
{
pResult->getAsBool()->bool_set(i,j,false);
}
{
pResult = new Bool(pL->rows_get(), pL->cols_get());
- char* pstR = pR->string_get()[0];
+ wchar_t* pstR = pR->string_get()[0];
for(int i = 0 ; i < pL->rows_get() ; i++)
{
for(int j = 0 ; j < pL->cols_get() ; j++)
{
- char* pstL = pL->string_get(i,j);
- if(strcmp(pstL, pstR) == 0)
+ wchar_t* pstL = pL->string_get(i,j);
+ if(wcscmp(pstL, pstR) == 0)
{
pResult->getAsBool()->bool_set(i,j,false);
}
{
for(int j = 0 ; j < pL->cols_get() ; j++)
{
- char* pstR = pR->string_get(i,j);
- char* pstL = pL->string_get(i,j);
- if(strcmp(pstL, pstR) == 0)
+ wchar_t* pstR = pR->string_get(i,j);
+ wchar_t* pstL = pL->string_get(i,j);
+ if(wcscmp(pstL, pstR) == 0)
{
pResult->getAsBool()->bool_set(i,j,false);
}
int iResult = PowerDoubleByDouble(pL, pR, (Double**)&pResult);
if(iResult != 0)
{
- std::ostringstream os;
- os << _("Inconsistent row/column dimensions.\n");
+ std::wostringstream os;
+ os << _W("Inconsistent row/column dimensions.\n");
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
int iResult = PowerPolyByDouble(pL, pR, (MatrixPoly**)&pResult);
if(iResult != 0)
{
- std::ostringstream os;
- os << _("Inconsistent row/column dimensions.\n");
+ std::wostringstream os;
+ os << _W("Inconsistent row/column dimensions.\n");
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
}
else
{
- std::ostringstream os;
- os << _("Inconsistent row/column dimensions.\n");
+ std::wostringstream os;
+ os << _W("Inconsistent row/column dimensions.\n");
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
}
else
{
- std::ostringstream os;
- os << _("Inconsistent row/column dimensions.\n");
+ std::wostringstream os;
+ os << _W("Inconsistent row/column dimensions.\n");
os << ((Location)e.right_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
if(iColMax != static_cast<int>((*row)->columns_get().size()))
{
- std::ostringstream os;
- os << "inconsistent row/column dimensions";
+ std::wostringstream os;
+ os << L"inconsistent row/column dimensions";
os << ((Location)(*row)->location_get()).location_string_get() << std::endl;
throw os.str();
}
result_set(pI);
if(pI != NULL && pI->getAsCallable() == false && e.is_verbose())
{
- std::ostringstream ostr;
- ostr << e.name_get() << " = " << "(" << pI->getRef() << ")"<< std::endl;
+ std::wostringstream ostr;
+ ostr << e.name_get() << L" = " << L"(" << pI->getRef() << L")"<< std::endl;
ostr << std::endl;
ostr << pI->toString(ConfigVariable::getFormat(), ConfigVariable::getConsoleWidth()) << std::endl;
- YaspWrite(const_cast<char *>(ostr.str().c_str()));
+ YaspWriteW(ostr.str().c_str());
}
}
else
{
- char szError[bsiz];
+ wchar_t szError[bsiz];
#ifdef _MSC_VER
- sprintf_s(szError, bsiz, _("Undefined variable: %s\n"), e.name_get().c_str());
+ swprintf_s(szError, bsiz, _W("Undefined variable: %s\n"), e.name_get().c_str());
#else
- sprintf(szError, _("Undefined variable: %s\n"), e.name_get().c_str());
+ swprintf(szError, bsiz, _W("Undefined variable: %S\n"), e.name_get().c_str());
#endif
- throw string(szError);
+ throw wstring(szError);
//Err, SimpleVar doesn't exist in Scilab scopes.
}
}
dblCoef.val_set(0, 0, 0);
dblCoef.val_set(0, 1, 1);
- MatrixPoly *pVar = new MatrixPoly("$", 1, 1, pRank);
- Poly *poPoly = pVar->poly_get(0,0);
+ MatrixPoly *pVar = new MatrixPoly(L"$", 1, 1, pRank);
+ Poly *poPoly = pVar->poly_get(0,0);
poPoly->coef_set(&dblCoef);
ImplicitList *pIL = new ImplicitList();
dblCoef.val_set(0, 0, 0);
dblCoef.val_set(0, 1, 1);
- MatrixPoly *pVar = new MatrixPoly("$", 1, 1, pRank);
- Poly *poPoly = pVar->poly_get(0,0);
+ MatrixPoly *pVar = new MatrixPoly(L"$", 1, 1, pRank);
+ Poly *poPoly = pVar->poly_get(0,0);
poPoly->coef_set(&dblCoef);
result_set(pVar);
}
{
e.head_get()->accept(execHead);
}
- catch(string sz)
+ catch(wstring sz)
{
throw sz;
}
}
else
{
- char szError[bsiz];
+ wchar_t szError[bsiz];
#ifdef _MSC_VER
- sprintf_s(szError, bsiz, _("Unknown field : %s.\n"), psvRightMember->name_get().c_str());
+ swprintf_s(szError, bsiz, _W("Unknown field : %s.\n"), psvRightMember->name_get().c_str());
#else
- sprintf(szError, _("Unknown field : %s.\n"), psvRightMember->name_get().c_str());
+ swprintf(szError, bsiz, _W("Unknown field : %S.\n"), psvRightMember->name_get().c_str());
#endif
- throw string(szError);
+ throw wstring(szError);
}
}
else
{
- char szError[bsiz];
+ wchar_t szError[bsiz];
#ifdef _MSC_VER
- sprintf_s(szError, bsiz, _("/!\\ Unmanaged FieldExp.\n"));
+ swprintf_s(szError, bsiz, _W("/!\\ Unmanaged FieldExp.\n"));
#else
- sprintf(szError, _("/!\\ Unmanaged FieldExp.\n"));
-#endif
- throw string(szError);
+ swprintf(szError, bsiz, _W("/!\\ Unmanaged FieldExp.\n"));
+#endif
+ throw wstring(szError);
}
}
else if(execHead.result_get() != NULL && execHead.result_get()->isTList())
}
else
{
- char szError[bsiz];
+ wchar_t szError[bsiz];
#ifdef _MSC_VER
- sprintf_s(szError, bsiz, _("Unknown field : %s.\n"), psvRightMember->name_get().c_str());
+ swprintf_s(szError, bsiz, _W("Unknown field : %s.\n"), psvRightMember->name_get().c_str());
#else
- sprintf(szError, _("Unknown field : %s.\n"), psvRightMember->name_get().c_str());
+ swprintf(szError, bsiz, _W("Unknown field : %S.\n"), psvRightMember->name_get().c_str());
#endif
- throw string(szError);
+ throw wstring(szError);
}
}
else
{
- char szError[bsiz];
+ wchar_t szError[bsiz];
#ifdef _MSC_VER
- sprintf_s(szError, bsiz, _("/!\\ Unmanaged FieldExp.\n"));
+ swprintf_s(szError, bsiz, _W("/!\\ Unmanaged FieldExp.\n"));
#else
- sprintf(szError, _("/!\\ Unmanaged FieldExp.\n"));
-#endif
- throw string(szError);
+ swprintf(szError, bsiz, _W("/!\\ Unmanaged FieldExp.\n"));
+#endif
+ throw wstring(szError);
}
}
else
{
- char szError[bsiz];
+ wchar_t szError[bsiz];
#ifdef _MSC_VER
- sprintf_s(szError, bsiz, _("Attempt to reference field of non-structure array.\n"));
+ swprintf_s(szError, bsiz, _W("Attempt to reference field of non-structure array.\n"));
#else
- sprintf(szError, _("Attempt to reference field of non-structure array.\n"));
+ swprintf(szError, bsiz, _W("Attempt to reference field of non-structure array.\n"));
#endif
- throw string(szError);
+ throw wstring(szError);
}
}
if(piIndexSeq[i] < 1)
{
//manage error
- std::ostringstream os;
- os << _("Indexes must be positive .\n");
+ std::wostringstream os;
+ os << _W("Indexes must be positive .\n");
os << ((Location)e.name_get().location_get()).location_string_get() << std::endl;
throw os.str();
}
if(ResultList.size() == 0)
{
- std::ostringstream os;
- os << "inconsistent row/column dimensions";
+ std::wostringstream os;
+ os << L"inconsistent row/column dimensions";
os << ((*e.args_get().begin())->location_get()).location_string_get() << std::endl;
throw os.str();
}
InternalType *pIT = NULL;
pIT = pVar->extract_value(0);
- string varName = e.vardec_get().name_get();
+ wstring varName = e.vardec_get().name_get();
symbol::Context::getInstance()->put(varName, *pIT);
for(int i = 0 ; i < pVar->size_get() ; i++)
{
if(static_cast<int>(out.size()) < expected_size_get())
{
- std::ostringstream os;
- os << "bad lhs, expected : " << expected_size_get() << " returned : " << out.size() << std::endl;
+ std::wostringstream os;
+ os << L"bad lhs, expected : " << expected_size_get() << L" returned : " << out.size() << std::endl;
throw os.str();
}
}
}
else if(Ret == Callable::Error)
{
- std::ostringstream os;
- char szError[bsiz];
+ std::wostringstream os;
+ wchar_t szError[bsiz];
#ifdef _MSC_VER
- sprintf_s(szError, bsiz, _("Function \"%s\" failed\n"), pCall->getName().c_str());
+ swprintf_s(szError, bsiz, _W("Function \"%s\" failed\n"), pCall->getName().c_str());
#else
- sprintf(szError, _("Function \"%s\" failed\n"), pCall->getName().c_str());
+ swprintf(szError, bsiz, _W("Function \"%S\" failed\n"), pCall->getName().c_str());
#endif
- throw string(szError);
+ throw wstring(szError);
}
}
//don't output Silplevar and empty result
if(execMe.result_get() != NULL && (pVar == NULL || bImplicitCall))
{
- symbol::Context::getInstance()->put("ans", *execMe.result_get());
+ symbol::Context::getInstance()->put(L"ans", *execMe.result_get());
if((*itExp)->is_verbose())
{
//TODO manage multiple returns
- std::ostringstream ostr;
- ostr << "ans = " << std::endl;
- ostr << std::endl;
+ std::wostringstream ostr;
+ ostr << L"ans = " << std::endl << std::endl;
ostr << execMe.result_get()->toString(ConfigVariable::getFormat(), ConfigVariable::getConsoleWidth()) << std::endl;
- YaspWrite(const_cast<char *>(ostr.str().c_str()));
+ YaspWriteW(ostr.str().c_str());
}
}
result_set(execMe.result_get());
result_get()->IncreaseRef();
}
- catch(string sz)
+ catch(wstring sz)
{
throw sz;
}
std::list<ast::Var *>::const_iterator i;
//get input parameters list
- std::list<string> *pVarList = new std::list<string>();
+ std::list<wstring> *pVarList = new std::list<wstring>();
const ArrayListVar *pListVar = &e.args_get();
for(i = pListVar->vars_get().begin() ; i != pListVar->vars_get().end() ; i++)
{
}
//get output parameters list
- std::list<string> *pRetList = new std::list<string>();
+ std::list<wstring> *pRetList = new std::list<wstring>();
const ArrayListVar *pListRet = &e.returns_get();
for(i = pListRet->vars_get().begin() ; i != pListRet->vars_get().end() ; i++)
{
//types::Macro macro(VarList, RetList, (SeqExp&)e.body_get());
types::Macro *pMacro = new types::Macro(e.name_get(), *pVarList, *pRetList,
- static_cast<SeqExp&>(const_cast<Exp&>(e.body_get())), "script");
+ static_cast<SeqExp&>(const_cast<Exp&>(e.body_get())), L"script");
symbol::Context::getInstance()->AddMacro(pMacro);
}
/** \} */
#endif
throw string(st);
}
- catch(string sz)
+ catch(wstring sz)
{
//TODO YaSp : Overloading
throw sz;
** \param name the name of the variable
*/
SimpleVar (const Location& location,
- const std::string name):
+ const std::wstring name):
Var (location),
_name (name)
{
** \{ */
public:
/** \brief Return the Variable's name. */
- const std::string& name_get () const
+ const std::wstring& name_get () const
{
return _name;
}
protected:
/** \brief Variable's name */
- std::string _name;
+ std::wstring _name;
};
} // namespace ast
{
public:
StringExp (const Location& location,
- std::string value) :
+ std::wstring value) :
ConstExp (location),
_value (value)
{
** \{ */
public:
/** \brief Return the name of the type name (read only). */
- const std::string value_get () const
+ const std::wstring value_get () const
{
return _value;
}
/** \} */
protected:
- const std::string _value;
+ const std::wstring _value;
};
} // namespace ast
/** Scilab tokens and key words
** \{ */
-#define SCI_DOT "."
-
-#define SCI_TRUE "%T"
-#define SCI_FALSE "%F"
-
-#define SCI_INT8 "int8"
-#define SCI_INT16 "int16"
-#define SCI_INT32 "int32"
-#define SCI_INT64 "int64"
-#define SCI_LPAREN "("
-#define SCI_RPAREN ")"
-#define SCI_LBRACE "{"
-#define SCI_RBRACE "}"
-#define SCI_LBRACK "["
-#define SCI_RBRACK "]"
-
-#define SCI_PLUS "+"
-#define SCI_MINUS "-"
-#define SCI_TIMES "*"
-#define SCI_DIVIDE "/"
-#define SCI_RDIVIDE "\\"
-#define SCI_POWER "^"
-
-#define SCI_DOTTIMES ".*"
-#define SCI_DOTDIVIDE "./"
-#define SCI_DOTRDIVIDE ".\\"
-#define SCI_DOTPOWER ".^"
-
-#define SCI_KRONTIMES ".*."
-#define SCI_KRONDIVIDE "./."
-#define SCI_KRONRDIVIDE ".\\."
-
-#define SCI_CONTROLTIMES "*."
-#define SCI_CONTROLDIVIDE "/."
-#define SCI_CONTROLRDIVIDE "\\."
-
-#define SCI_EQ "=="
-#define SCI_NE "<>"
-#define SCI_GE ">="
-#define SCI_GT ">"
-#define SCI_LE "<="
-#define SCI_LT "<"
-
-#define SCI_AND "&"
-#define SCI_OR "|"
-#define SCI_ANDAND "&&"
-#define SCI_OROR "||"
-#define SCI_NOT "~"
-
-#define SCI_CONJUGATE_TRANSPOSE "'"
-#define SCI_TRANSPOSE ".'"
-
-#define SCI_QUOTE "\'"
-#define SCI_DQUOTE "\""
-#define SCI_COMMA ","
-#define SCI_SEMICOLON ";"
-#define SCI_COLON ":"
-
-#define SCI_DOLLAR "$"
-
-#define SCI_ASSIGN "="
-#define SCI_OPEN_COMMENT "//"
+#define SCI_DOT L"."
+
+#define SCI_TRUE L"%T"
+#define SCI_FALSE L"%F"
+
+#define SCI_INT8 L"int8"
+#define SCI_INT16 L"int16"
+#define SCI_INT32 L"int32"
+#define SCI_INT64 L"int64"
+#define SCI_LPAREN L"("
+#define SCI_RPAREN L")"
+#define SCI_LBRACE L"{"
+#define SCI_RBRACE L"}"
+#define SCI_LBRACK L"["
+#define SCI_RBRACK L"]"
+
+#define SCI_PLUS L"+"
+#define SCI_MINUS L"-"
+#define SCI_TIMES L"*"
+#define SCI_DIVIDE L"/"
+#define SCI_RDIVIDE L"\\"
+#define SCI_POWER L"^"
+
+#define SCI_DOTTIMES L".*"
+#define SCI_DOTDIVIDE L"./"
+#define SCI_DOTRDIVIDE L".\\"
+#define SCI_DOTPOWER L".^"
+
+#define SCI_KRONTIMES L".*."
+#define SCI_KRONDIVIDE L"./."
+#define SCI_KRONRDIVIDE L".\\."
+
+#define SCI_CONTROLTIMES L"*."
+#define SCI_CONTROLDIVIDE L"/."
+#define SCI_CONTROLRDIVIDE L"\\."
+
+#define SCI_EQ L"=="
+#define SCI_NE L"<>"
+#define SCI_GE L">="
+#define SCI_GT L">"
+#define SCI_LE L"<="
+#define SCI_LT L"<"
+
+#define SCI_AND L"&"
+#define SCI_OR L"|"
+#define SCI_ANDAND L"&&"
+#define SCI_OROR L"||"
+#define SCI_NOT L"~"
+
+#define SCI_CONJUGATE_TRANSPOSE L"'"
+#define SCI_TRANSPOSE L".'"
+
+#define SCI_QUOTE L"\'"
+#define SCI_DQUOTE L"\""
+#define SCI_COMMA L","
+#define SCI_SEMICOLON L";"
+#define SCI_COLON L":"
+
+#define SCI_DOLLAR L"$"
+
+#define SCI_ASSIGN L"="
+#define SCI_OPEN_COMMENT L"//"
// Syntax to acces field 'bar' in variable 'foo'
// foo.var
#define SCI_ARGS_SEPARATOR SCI_COMMA
// Syntax to have if control structure
-#define SCI_IF "if"
-#define SCI_THEN "then"
-#define SCI_ELSE "else"
-#define SCI_ENDIF "end"
+#define SCI_IF L"if"
+#define SCI_THEN L"then"
+#define SCI_ELSE L"else"
+#define SCI_ENDIF L"end"
#define SCI_OPEN_TEST SCI_LPAREN
#define SCI_CLOSE_TEST SCI_RPAREN
// Syntax to have while control structure
-#define SCI_WHILE "while"
-#define SCI_DO "do"
-#define SCI_ENDWHILE "end"
+#define SCI_WHILE L"while"
+#define SCI_DO L"do"
+#define SCI_ENDWHILE L"end"
// Syntax to have for control structure
-#define SCI_FOR "for"
-#define SCI_ENDFOR "end"
-#define SCI_BREAK "break"
+#define SCI_FOR L"for"
+#define SCI_ENDFOR L"end"
+#define SCI_BREAK L"break"
// Syntax to have try/catch control structure
-#define SCI_TRY "try"
-#define SCI_CATCH "catch"
-#define SCI_ENDTRY "end"
+#define SCI_TRY L"try"
+#define SCI_CATCH L"catch"
+#define SCI_ENDTRY L"end"
// Syntax to have function declaration
-#define SCI_FUNCTION "function"
+#define SCI_FUNCTION L"function"
#define SCI_OPEN_RETURNS SCI_LBRACK
#define SCI_CLOSE_RETURNS SCI_RBRACK
#define SCI_OPEN_ARGS SCI_LPAREN
#define SCI_CLOSE_ARGS SCI_RPAREN
-#define SCI_ENDFUNCTION "endfunction"
+#define SCI_ENDFUNCTION L"endfunction"
// Syntax to have select control structure
-#define SCI_SELECT "select"
-#define SCI_CASE "case"
-#define SCI_DEFAULT_CASE "else"
-#define SCI_ENDSELECT "end"
+#define SCI_SELECT L"select"
+#define SCI_CASE L"case"
+#define SCI_DEFAULT_CASE L"else"
+#define SCI_ENDSELECT L"end"
// Syntax to have return control structure
-#define SCI_RETURN "return"
+#define SCI_RETURN L"return"
// Syntax to describe implicit list
#define SCI_IMPLICIT_LIST SCI_COLON
** \li "2097" is the initial value of the variable
*/
VarDec (const Location& location,
- std::string name, Exp& init) :
+ std::wstring name, Exp& init) :
Dec (location),
_name (name),
_init (&init),
** \{ */
public:
/** \brief Return the variable name (read only). */
- const std::string& name_get (void) const
+ const std::wstring& name_get (void) const
{
return _name;
}
protected:
/** \brief Name of the declared variable. */
- std::string _name;
+ std::wstring _name;
/** \brief The initial value (expression) assigned to the variable. */
Exp* _init;
int _iRows, int _iCols, int *_piRows);
-EXTERN_AST const std::string* getStructNameFromExp(const ast::Exp* _pExp);
+EXTERN_AST const std::wstring* getStructNameFromExp(const ast::Exp* _pExp);
EXTERN_AST types::Struct* getStructFromExp(const ast::Exp* _pExp);
namespace ast
{
- static int level = -1;
-
- static void DEBUG_START_NODE()
- {
- ++level;
- }
-
- static void DEBUG_END_NODE(void)
- {
- --level;
- }
-
- static void DEBUG(std::string str)
- {
- for(int i = 0 ; i < level; ++i)
- {
- std::cerr << " ";
- }
- if (level > 0)
- {
- std::cerr << " ";
- }
- std::cerr << str << std::endl;
- }
-
- static void DEBUG(std::string str, const Exp &e)
- {
- for(int i = 0 ; i < level; ++i)
- {
- std::cerr << " ";
- }
- if (level > 0)
- {
- std::cerr << "|_./ ";
- }
- std::cerr << str;
-
- Location loc = e.location_get();
- std::cerr << " @(" << loc.first_line << "." << loc.first_column << " -> ";
- std::cerr << loc.last_line << "." << loc.last_column << ")" << std::endl;
- }
-
-
- void DebugVisitor::visit (const MatrixExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec MatrixExp", e);
- std::list<MatrixLineExp *>::const_iterator i;
- for (i = e.lines_get().begin() ; i != e.lines_get().end() ; ++i )
- {
- (*i)->accept (*this);
- }
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const MatrixLineExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec MatrixLineExp", e);
- std::list<Exp *>::const_iterator i;
- for (i = e.columns_get().begin() ; i != e.columns_get().end() ; ++i)
- {
- (*i)->accept (*this);
- }
- DEBUG_END_NODE();
- }
- /** \} */
-
- void DebugVisitor::visit (const CellExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec CellExp", e);
- std::list<MatrixLineExp *>::const_iterator i;
- for (i = e.lines_get().begin() ; i != e.lines_get().end() ; ++i )
- {
- (*i)->accept (*this);
- }
- DEBUG_END_NODE();
- }
-
- /** \} */
-
- /** \name Visit Constant Expressions nodes.
- ** \{ */
- void DebugVisitor::visit (const StringExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec StringExp : "+e.value_get(), e);
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const CommentExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec CommentExp : "+e.comment_get(), e);
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const IntExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec IntExp : "+e.value_get(), e);
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const FloatExp &e)
- {
- DEBUG_START_NODE();
- std::ostringstream stream;
- stream << e.value_get();
- DEBUG("Exec FloatExp : "+stream.str(), e);
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const DoubleExp &e)
- {
- DEBUG_START_NODE();
- std::ostringstream stream;
- stream << e.value_get();
- DEBUG("Exec DoubleExp : "+stream.str(), e);
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const BoolExp &e)
- {
- DEBUG_START_NODE();
- std::ostringstream stream;
- stream << e.value_get();
- DEBUG("Exec BoolExp : "+stream.str(), e);
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const NilExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec NilExp", e);
- DEBUG_END_NODE();
- }
- /** \} */
-
- /** \name Visit Variable related nodes.
- ** \{ */
- void DebugVisitor::visit (const SimpleVar &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec SimpleVar : "+e.name_get(), e);
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const ColonVar &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec ColonVar", e);
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const DollarVar &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec DollarVar", e);
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const ArrayListVar &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec ArrayListVar", e);
- std::list<Var *>::const_iterator i;
- for (i = e.vars_get().begin() ; i != e.vars_get().end() ; ++i)
- {
- (*i)->accept (*this);
- }
- DEBUG_END_NODE();
- }
- /** \} */
-
- /** \name Visit Control Expressions or Instructions nodes.
- ** \{ */
-
- void DebugVisitor::visit (const FieldExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec FieldExp", e);
- // FIXME
- {
- e.head_get()->accept(*this);
- e.tail_get()->accept(*this);
- }
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit(const OpExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec OpExp", e);
- // FIXME
- {
- e.left_get().accept(*this);
- //e.oper_get();
- e.right_get().accept(*this);
- }
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit(const LogicalOpExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec LogicalOpExp", e);
- // FIXME
- {
- e.left_get().accept(*this);
- //e.oper_get();
- e.right_get().accept(*this);
- }
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const AssignExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec AssignExp", e);
- //FIXME
- {
- e.left_exp_get().accept (*this);
- e.right_exp_get().accept (*this);
- }
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit(const CellCallExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec CellCallExp", e);
- e.name_get().accept (*this);
- // FIXME
- {
- std::list<Exp *>::const_iterator i;
-
- for (i = e.args_get().begin (); i != e.args_get().end (); ++i)
- {
- (*i)->accept (*this);
- }
- }
- DEBUG_END_NODE();
- }
+ static int level = -1;
+
+ static void DEBUG_START_NODE()
+ {
+ ++level;
+ }
+
+ static void DEBUG_END_NODE(void)
+ {
+ --level;
+ }
+
+ static void DEBUG(wstring str)
+ {
+ for(int i = 0 ; i < level; ++i)
+ {
+ wcerr << L" ";
+ }
+ if (level > 0)
+ {
+ wcerr << L" ";
+ }
+ wcerr << str << endl;
+ }
+
+ static void DEBUG(wstring str, const Exp &e)
+ {
+ for(int i = 0 ; i < level; ++i)
+ {
+ wcerr << L" ";
+ }
+ if (level > 0)
+ {
+ wcerr << L"|_./ ";
+ }
+ wcerr << str;
+
+ Location loc = e.location_get();
+ wcerr << L" @(" << loc.first_line << L"." << loc.first_column << L" -> ";
+ wcerr << loc.last_line << L"." << loc.last_column << L")" << endl;
+ }
+
+
+ void DebugVisitor::visit (const MatrixExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec MatrixExp", e);
+ list<MatrixLineExp *>::const_iterator i;
+ for (i = e.lines_get().begin() ; i != e.lines_get().end() ; ++i )
+ {
+ (*i)->accept (*this);
+ }
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const MatrixLineExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec MatrixLineExp", e);
+ list<Exp *>::const_iterator i;
+ for (i = e.columns_get().begin() ; i != e.columns_get().end() ; ++i)
+ {
+ (*i)->accept (*this);
+ }
+ DEBUG_END_NODE();
+ }
+ /** \} */
+
+ void DebugVisitor::visit (const CellExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec CellExp", e);
+ list<MatrixLineExp *>::const_iterator i;
+ for (i = e.lines_get().begin() ; i != e.lines_get().end() ; ++i )
+ {
+ (*i)->accept (*this);
+ }
+ DEBUG_END_NODE();
+ }
+
+ /** \} */
+
+ /** \name Visit Constant Expressions nodes.
+ ** \{ */
+ void DebugVisitor::visit (const StringExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec StringExp : "+e.value_get(), e);
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const CommentExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec CommentExp : "+e.comment_get(), e);
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const IntExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec IntExp : "+e.value_get(), e);
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const FloatExp &e)
+ {
+ DEBUG_START_NODE();
+ wostringstream stream;
+ stream << e.value_get();
+ DEBUG(L"Exec FloatExp : "+stream.str(), e);
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const DoubleExp &e)
+ {
+ DEBUG_START_NODE();
+ wostringstream stream;
+ stream << e.value_get();
+ DEBUG(L"Exec DoubleExp : "+stream.str(), e);
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const BoolExp &e)
+ {
+ DEBUG_START_NODE();
+ wostringstream stream;
+ stream << e.value_get();
+ DEBUG(L"Exec BoolExp : "+stream.str(), e);
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const NilExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec NilExp", e);
+ DEBUG_END_NODE();
+ }
+ /** \} */
+
+ /** \name Visit Variable related nodes.
+ ** \{ */
+ void DebugVisitor::visit (const SimpleVar &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec SimpleVar : "+e.name_get(), e);
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const ColonVar &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec ColonVar", e);
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const DollarVar &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec DollarVar", e);
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const ArrayListVar &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec ArrayListVar", e);
+ list<Var *>::const_iterator i;
+ for (i = e.vars_get().begin() ; i != e.vars_get().end() ; ++i)
+ {
+ (*i)->accept (*this);
+ }
+ DEBUG_END_NODE();
+ }
+ /** \} */
+
+ /** \name Visit Control Expressions or Instructions nodes.
+ ** \{ */
+
+ void DebugVisitor::visit (const FieldExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec FieldExp", e);
+ // FIXME
+ {
+ e.head_get()->accept(*this);
+ e.tail_get()->accept(*this);
+ }
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit(const OpExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec OpExp", e);
+ // FIXME
+ {
+ e.left_get().accept(*this);
+ //e.oper_get();
+ e.right_get().accept(*this);
+ }
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit(const LogicalOpExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec LogicalOpExp", e);
+ // FIXME
+ {
+ e.left_get().accept(*this);
+ //e.oper_get();
+ e.right_get().accept(*this);
+ }
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const AssignExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec AssignExp", e);
+ //FIXME
+ {
+ e.left_exp_get().accept (*this);
+ e.right_exp_get().accept (*this);
+ }
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit(const CellCallExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec CellCallExp", e);
+ e.name_get().accept (*this);
+ // FIXME
+ {
+ list<Exp *>::const_iterator i;
+
+ for (i = e.args_get().begin (); i != e.args_get().end (); ++i)
+ {
+ (*i)->accept (*this);
+ }
+ }
+ DEBUG_END_NODE();
+ }
void DebugVisitor::visit(const CallExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec CallExp", e);
- e.name_get().accept (*this);
- // FIXME
- {
- std::list<Exp *>::const_iterator i;
-
- for (i = e.args_get().begin (); i != e.args_get().end (); ++i)
- {
- (*i)->accept (*this);
- }
- }
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const IfExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec IfExp", e);
- // FIXME
- {
- e.test_get ().accept(*this);
- e.then_get ().accept(*this);
- if (e.has_else())
- {
- e.else_get ().accept(*this);
- }
- }
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const TryCatchExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec TryCatchExp", e);
- // FIXME
- {
- e.try_get ().accept(*this);
- e.catch_get ().accept(*this);
- }
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const WhileExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec WhileExp", e);
- // FIMXE
- e.test_get().accept (*this);
- e.body_get().accept (*this);
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const ForExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec ForExp", e);
- e.vardec_get().accept(*this);
- e.body_get().accept (*this);
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const BreakExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec BreakExp", e);
- // FIXME
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const ReturnExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec ReturnExp", e);
- if (!e.is_global())
- {
- e.exp_get().accept(*this);
- }
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const SelectExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec SelectExp", e);
- e.select_get()->accept(*this);
- ast::cases_t::iterator it;
- for (it = e.cases_get()->begin() ; it != e.cases_get()->end() ; ++it)
- {
- (*it)->accept(*this);
- }
- if (e.default_case_get() != NULL)
- {
- e.default_case_get()->accept(*this);
- }
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const CaseExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec CaseExp", e);
- e.test_get()->accept(*this);
- e.body_get()->accept(*this);
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const SeqExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec SeqExp", e);
- std::list<Exp *>::const_iterator i;
- for (i = e.exps_get().begin (); i != e.exps_get().end (); ++i)
- {
- if(!(*i)->is_verbose())
- {
- DEBUG("__MUTE__");
- }
- (*i)->accept (*this);
- }
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const ArrayListExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec ArrayListExp", e);
- std::list<Exp *>::const_iterator i;
- for (i = e.exps_get().begin (); i != e.exps_get().end (); ++i)
- {
- (*i)->accept (*this);
- }
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const AssignListExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec AssignListExp", e);
- std::list<Exp *>::const_iterator i;
- for (i = e.exps_get().begin (); i != e.exps_get().end (); ++i)
- {
- (*i)->accept (*this);
- }
- DEBUG_END_NODE();
- }
- /** \} */
-
- /** \name Visit Single Operation nodes.
- ** \{ */
- void DebugVisitor::visit (const NotExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec NotExp", e);
- e.exp_get().accept (*this);
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const TransposeExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec TransposeExp", e);
- e.exp_get().accept (*this);
- DEBUG_END_NODE();
- }
- /** \} */
-
- /** \name Visit Declaration nodes.
- ** \{ */
- /** \brief Visit Var declarations. */
- void DebugVisitor::visit (const VarDec &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec VarDec", e);
- {
- DEBUG_START_NODE();
- DEBUG("Exec Symbol : " + e.name_get(), e);
- DEBUG_END_NODE();
- }
- e.init_get().accept(*this);
- DEBUG_END_NODE();
- }
-
- void DebugVisitor::visit (const FunctionDec &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec FunctionDec", e);
- // FIXME
-
- // First ask if there are some return values.
- //visit(e.returns_get());
-
- // Then get the function name
- //visit(e.name_get());
-
- // Then get function args
- //visit(e.args_get());
-
- // Now debug function body
- e.body_get().accept(*this);
-
- DEBUG_END_NODE();
- }
- /** \} */
-
- /** \name Visit Type dedicated Expressions related node.
- ** \{ */
- void DebugVisitor::visit(const ListExp &e)
- {
- DEBUG_START_NODE();
- DEBUG("Exec ListExp", e);
- e.start_get().accept(*this);
- e.step_get().accept(*this);
- e.end_get().accept(*this);
- DEBUG_END_NODE();
- }
- /** \} */
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec CallExp", e);
+ e.name_get().accept (*this);
+ // FIXME
+ {
+ list<Exp *>::const_iterator i;
+
+ for (i = e.args_get().begin (); i != e.args_get().end (); ++i)
+ {
+ (*i)->accept (*this);
+ }
+ }
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const IfExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec IfExp", e);
+ // FIXME
+ {
+ e.test_get ().accept(*this);
+ e.then_get ().accept(*this);
+ if (e.has_else())
+ {
+ e.else_get ().accept(*this);
+ }
+ }
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const TryCatchExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec TryCatchExp", e);
+ // FIXME
+ {
+ e.try_get ().accept(*this);
+ e.catch_get ().accept(*this);
+ }
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const WhileExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec WhileExp", e);
+ // FIMXE
+ e.test_get().accept (*this);
+ e.body_get().accept (*this);
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const ForExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec ForExp", e);
+ e.vardec_get().accept(*this);
+ e.body_get().accept (*this);
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const BreakExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec BreakExp", e);
+ // FIXME
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const ReturnExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec ReturnExp", e);
+ if (!e.is_global())
+ {
+ e.exp_get().accept(*this);
+ }
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const SelectExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec SelectExp", e);
+ e.select_get()->accept(*this);
+ ast::cases_t::iterator it;
+ for (it = e.cases_get()->begin() ; it != e.cases_get()->end() ; ++it)
+ {
+ (*it)->accept(*this);
+ }
+ if (e.default_case_get() != NULL)
+ {
+ e.default_case_get()->accept(*this);
+ }
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const CaseExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec CaseExp", e);
+ e.test_get()->accept(*this);
+ e.body_get()->accept(*this);
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const SeqExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec SeqExp", e);
+ list<Exp *>::const_iterator i;
+ for (i = e.exps_get().begin (); i != e.exps_get().end (); ++i)
+ {
+ if(!(*i)->is_verbose())
+ {
+ DEBUG(L"__MUTE__");
+ }
+ (*i)->accept (*this);
+ }
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const ArrayListExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec ArrayListExp", e);
+ list<Exp *>::const_iterator i;
+ for (i = e.exps_get().begin (); i != e.exps_get().end (); ++i)
+ {
+ (*i)->accept (*this);
+ }
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const AssignListExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec AssignListExp", e);
+ list<Exp *>::const_iterator i;
+ for (i = e.exps_get().begin (); i != e.exps_get().end (); ++i)
+ {
+ (*i)->accept (*this);
+ }
+ DEBUG_END_NODE();
+ }
+ /** \} */
+
+ /** \name Visit Single Operation nodes.
+ ** \{ */
+ void DebugVisitor::visit (const NotExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec NotExp", e);
+ e.exp_get().accept (*this);
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const TransposeExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec TransposeExp", e);
+ e.exp_get().accept (*this);
+ DEBUG_END_NODE();
+ }
+ /** \} */
+
+ /** \name Visit Declaration nodes.
+ ** \{ */
+ /** \brief Visit Var declarations. */
+ void DebugVisitor::visit (const VarDec &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec VarDec", e);
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec Symbol : " + e.name_get(), e);
+ DEBUG_END_NODE();
+ }
+ e.init_get().accept(*this);
+ DEBUG_END_NODE();
+ }
+
+ void DebugVisitor::visit (const FunctionDec &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec FunctionDec", e);
+ // FIXME
+
+ // First ask if there are some return values.
+ //visit(e.returns_get());
+
+ // Then get the function name
+ //visit(e.name_get());
+
+ // Then get function args
+ //visit(e.args_get());
+
+ // Now debug function body
+ e.body_get().accept(*this);
+
+ DEBUG_END_NODE();
+ }
+ /** \} */
+
+ /** \name Visit Type dedicated Expressions related node.
+ ** \{ */
+ void DebugVisitor::visit(const ListExp &e)
+ {
+ DEBUG_START_NODE();
+ DEBUG(L"Exec ListExp", e);
+ e.start_get().accept(*this);
+ e.step_get().accept(*this);
+ e.end_get().accept(*this);
+ DEBUG_END_NODE();
+ }
+ /** \} */
}
// Print the TREE on OSTR.
// This refers to the syntax only.
- void print(const Exp &tree, std::ostream &ostr)
+ void print(const Exp &tree, std::wostream &ostr)
{
PrintVisitor visitor = PrintVisitor(ostr);
tree.accept (visitor);
/** \brief Print an abstract syntax tree.
** \param tree abstract syntax tree's root node
** \param ostr output stream */
- void print (const Exp &tree, std::ostream &ostr);
+ void print (const Exp &tree, std::wostream &ostr);
/** \brief Intercept output stream redirection. */
- inline std::ostream& operator<< (std::ostream& ostr, const Exp &tree)
+ inline std::wostream& operator<< (std::wostream& ostr, const Exp &tree)
{
print (tree, ostr);
return ostr;
** \{ */
void PrintVisitor::visit (const StringExp &e)
{
- std::string::const_iterator it;
+ std::wstring::const_iterator it;
*ostr << SCI_OPEN_STRING;
- std::string value = e.value_get();
+ std::wstring value = e.value_get();
for (it = value.begin() ; it != value.end() ; ++it)
{
return NULL;
}
-const std::string* getStructNameFromExp(const Exp* _pExp)
+const std::wstring* getStructNameFromExp(const Exp* _pExp)
{
const FieldExp* pField = dynamic_cast<const FieldExp*>(_pExp);
const SimpleVar* pVar = dynamic_cast<const SimpleVar*>(_pExp);
typed_list in = *pStr->m_pIn;
InternalType** out = pStr->m_pOut;
int* piRetCount = pStr->m_piRetCount;
- char* pstName = pStr->m_pstName;
+ wchar_t* pstName = pStr->m_pstName;
Bool *pBool = new Bool(_iRows, _iCols);
if(pBool == NULL)
GatewayStruct* pStr = (GatewayStruct*)_pvCtx;
typed_list in = *pStr->m_pIn;
int* piRetCount = pStr->m_piRetCount;
- char* pstName = pStr->m_pstName;
+ wchar_t* pstName = pStr->m_pstName;
int iAddr = 0;
typed_list in = *pStr->m_pIn;
InternalType** out = pStr->m_pOut;
int* piRetCount = pStr->m_piRetCount;
- char* pstName = pStr->m_pstName;
+ wchar_t* pstName = pStr->m_pstName;
Double* pDbl = new Double(_iRows, _iCols, _iComplex == 1);
if(pDbl == NULL)
#include "api_oldstack.h"
#include "localization.h"
#include "MALLOC.h"
+#include "charEncoding.h"
#include "context.hxx"
+
using namespace std;
using namespace types;
SciErr getPolyVariableName(void* _pvCtx, int* _piAddress, char* _pstVarName, int* _piVarNameLen)
{
- SciErr sciErr; sciErr.iErr = 0; sciErr.iMsgCount = 0;
- char *pstVarName = NULL;
+ SciErr sciErr; sciErr.iErr = 0; sciErr.iMsgCount = 0;
+ char *pstVarName = NULL;
- if(_piAddress == NULL)
- {
- addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getPolyVariableName");
- return sciErr;
- }
+ if(_piAddress == NULL)
+ {
+ addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getPolyVariableName");
+ return sciErr;
+ }
- if(!((InternalType*)_piAddress)->isPoly())
- {
- addErrorMessage(&sciErr, API_ERROR_INVALID_TYPE, _("%s: Invalid argument type, %s excepted"), "getPolyVariableName", _("polynomial matrix"));
- return sciErr;
- }
+ if(!((InternalType*)_piAddress)->isPoly())
+ {
+ addErrorMessage(&sciErr, API_ERROR_INVALID_TYPE, _("%s: Invalid argument type, %s excepted"), "getPolyVariableName", _("polynomial matrix"));
+ return sciErr;
+ }
- if(_pstVarName == NULL || *_piVarNameLen == 0)
- {
- *_piVarNameLen = (int)((InternalType*)_piAddress)->getAsPoly()->var_get().size();
- return sciErr; //No error
- }
+ if(_pstVarName == NULL || *_piVarNameLen == 0)
+ {
+ *_piVarNameLen = (int)((InternalType*)_piAddress)->getAsPoly()->var_get().size();
+ return sciErr; //No error
+ }
- strcpy(_pstVarName, ((InternalType*)_piAddress)->getAsPoly()->var_get().c_str());
- return sciErr;
+ const char* pstTemp = wide_string_to_UTF8(((InternalType*)_piAddress)->getAsPoly()->var_get().c_str());
+ strcpy(_pstVarName, pstTemp);
+ FREE(pstTemp);
+ return sciErr;
}
SciErr getMatrixOfPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal)
{
- return getCommonMatrixOfPoly(_pvCtx, _piAddress, 0, _piRows, _piCols, _piNbCoef, _pdblReal, NULL);
+ return getCommonMatrixOfPoly(_pvCtx, _piAddress, 0, _piRows, _piCols, _piNbCoef, _pdblReal, NULL);
}
SciErr getComplexMatrixOfPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
{
- return getCommonMatrixOfPoly(_pvCtx, _piAddress, 1, _piRows, _piCols, _piNbCoef, _pdblReal, _pdblImg);
+ return getCommonMatrixOfPoly(_pvCtx, _piAddress, 1, _piRows, _piCols, _piNbCoef, _pdblReal, _pdblImg);
}
SciErr getCommonMatrixOfPoly(void* _pvCtx, int* _piAddress, int _iComplex, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
{
- SciErr sciErr; sciErr.iErr = 0; sciErr.iMsgCount = 0;
- int iType = 0;
- int iSize = 0;
- int *piOffset = NULL;
- double *pdblReal = NULL;
- double *pdblImg = NULL;
-
- if(_piAddress == NULL)
- {
- addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), _iComplex ? "getComplexMatrixOfPoly" : "getMatrixOfPoly");
- return sciErr;
- }
-
- sciErr = getVarType(_pvCtx, _piAddress, &iType);
- if(sciErr.iErr)
- {
- addErrorMessage(&sciErr, API_ERROR_GET_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getComplexMatrixOfPoly" : "getMatrixOfPoly", getRhsFromAddress(_pvCtx, _piAddress));
- return sciErr;
- }
-
- if(iType != sci_poly)
- {
- addErrorMessage(&sciErr, API_ERROR_INVALID_TYPE, _("%s: Invalid argument type, %s excepted"), _iComplex ? "getComplexMatrixOfPoly" : "getMatrixOfPoly", _("polynomial matrix"));
- return sciErr;
- }
-
- if(isVarComplex(_pvCtx, _piAddress) != _iComplex)
- {
- addErrorMessage(&sciErr, API_ERROR_INVALID_COMPLEXITY, _("%s: Bad call to get a non complex matrix"), _iComplex ? "getComplexMatrixOfPoly" : "getMatrixOfPoly");
- return sciErr;
- }
-
- sciErr = getVarDimension(_pvCtx, _piAddress, _piRows, _piCols);
- if(sciErr.iErr)
- {
- addErrorMessage(&sciErr, API_ERROR_GET_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getComplexMatrixOfPoly" : "getMatrixOfPoly", getRhsFromAddress(_pvCtx, _piAddress));
- return sciErr;
- }
-
- iSize = *_piRows * *_piCols;
-
- if(_piNbCoef == NULL)
- {
- return sciErr;
- }
-
- MatrixPoly *pMP = ((InternalType*)_piAddress)->getAsPoly();
- pMP->rank_get(_piNbCoef);
-
- if(_pdblReal == NULL)
- {
- return sciErr;
- }
-
- for(int i = 0 ; i < iSize ; i++)
- {
- memcpy(_pdblReal[i], pMP->poly_get(i)->coef_real_get(), sizeof(double) * pMP->poly_get(i)->rank_get());
- }
-
- if(_iComplex == 1)
- {
- for(int i = 0 ; i < iSize ; i++)
- {
- memcpy(_pdblImg[i], pMP->poly_get(i)->coef_img_get(), sizeof(double) * _piNbCoef[i]);
- }
- }
- return sciErr;
+ SciErr sciErr; sciErr.iErr = 0; sciErr.iMsgCount = 0;
+ int iType = 0;
+ int iSize = 0;
+ int *piOffset = NULL;
+ double *pdblReal = NULL;
+ double *pdblImg = NULL;
+
+ if(_piAddress == NULL)
+ {
+ addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), _iComplex ? "getComplexMatrixOfPoly" : "getMatrixOfPoly");
+ return sciErr;
+ }
+
+ sciErr = getVarType(_pvCtx, _piAddress, &iType);
+ if(sciErr.iErr)
+ {
+ addErrorMessage(&sciErr, API_ERROR_GET_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getComplexMatrixOfPoly" : "getMatrixOfPoly", getRhsFromAddress(_pvCtx, _piAddress));
+ return sciErr;
+ }
+
+ if(iType != sci_poly)
+ {
+ addErrorMessage(&sciErr, API_ERROR_INVALID_TYPE, _("%s: Invalid argument type, %s excepted"), _iComplex ? "getComplexMatrixOfPoly" : "getMatrixOfPoly", _("polynomial matrix"));
+ return sciErr;
+ }
+
+ if(isVarComplex(_pvCtx, _piAddress) != _iComplex)
+ {
+ addErrorMessage(&sciErr, API_ERROR_INVALID_COMPLEXITY, _("%s: Bad call to get a non complex matrix"), _iComplex ? "getComplexMatrixOfPoly" : "getMatrixOfPoly");
+ return sciErr;
+ }
+
+ sciErr = getVarDimension(_pvCtx, _piAddress, _piRows, _piCols);
+ if(sciErr.iErr)
+ {
+ addErrorMessage(&sciErr, API_ERROR_GET_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getComplexMatrixOfPoly" : "getMatrixOfPoly", getRhsFromAddress(_pvCtx, _piAddress));
+ return sciErr;
+ }
+
+ iSize = *_piRows * *_piCols;
+
+ if(_piNbCoef == NULL)
+ {
+ return sciErr;
+ }
+
+ MatrixPoly *pMP = ((InternalType*)_piAddress)->getAsPoly();
+ pMP->rank_get(_piNbCoef);
+
+ if(_pdblReal == NULL)
+ {
+ return sciErr;
+ }
+
+ for(int i = 0 ; i < iSize ; i++)
+ {
+ memcpy(_pdblReal[i], pMP->poly_get(i)->coef_real_get(), sizeof(double) * pMP->poly_get(i)->rank_get());
+ }
+
+ if(_iComplex == 1)
+ {
+ for(int i = 0 ; i < iSize ; i++)
+ {
+ memcpy(_pdblImg[i], pMP->poly_get(i)->coef_img_get(), sizeof(double) * _piNbCoef[i]);
+ }
+ }
+ return sciErr;
}
SciErr createMatrixOfPoly(void* _pvCtx, int _iVar, char* _pstVarName, int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal)
{
- return createCommonMatrixOfPoly(_pvCtx, _iVar, 0, _pstVarName, _iRows, _iCols, _piNbCoef, _pdblReal, NULL);
+ return createCommonMatrixOfPoly(_pvCtx, _iVar, 0, _pstVarName, _iRows, _iCols, _piNbCoef, _pdblReal, NULL);
}
SciErr createComplexMatrixOfPoly(void* _pvCtx, int _iVar, char* _pstVarName, int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
{
- return createCommonMatrixOfPoly(_pvCtx, _iVar, 1, _pstVarName, _iRows, _iCols, _piNbCoef, _pdblReal, _pdblImg);
+ return createCommonMatrixOfPoly(_pvCtx, _iVar, 1, _pstVarName, _iRows, _iCols, _piNbCoef, _pdblReal, _pdblImg);
}
SciErr createCommonMatrixOfPoly(void* _pvCtx, int _iVar, int _iComplex, char* _pstVarName, int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
{
- SciErr sciErr; sciErr.iErr = 0; sciErr.iMsgCount = 0;
- if(_pvCtx == NULL)
- {
- addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), _iComplex ? "createComplexMatrixOfPoly" : "createMatrixOfPoly");
- return sciErr;
- }
-
- GatewayStruct* pStr = (GatewayStruct*)_pvCtx;
- InternalType** out = pStr->m_pOut;
-
- MatrixPoly* pP = new MatrixPoly(_pstVarName, _iRows, _iCols, _piNbCoef);
- if(pP == NULL)
- {
- addErrorMessage(&sciErr, API_ERROR_NO_MORE_MEMORY, _("%s: No more memory to allocated variable"), _iComplex ? "createComplexMatrixOfPoly" : "createMatrixOfPoly");
- return sciErr;
- }
-
- if(_iComplex)
- {
- pP->complex_set(true);
- }
-
- int rhs = _iVar - api_Rhs((int*)_pvCtx);
- out[rhs - 1] = pP;
-
- for(int i = 0 ; i < pP->size_get() ; i++)
- {
- Double* pD = new Double(_piNbCoef[i], 1, _iComplex == 1);
- pD->real_set(_pdblReal[i]);
- if(_iComplex)
- {
- pD->img_set(_pdblImg[i]);
- }
- pP->poly_set(i, pD);
- }
-
- return sciErr;
+ SciErr sciErr; sciErr.iErr = 0; sciErr.iMsgCount = 0;
+ if(_pvCtx == NULL)
+ {
+ addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), _iComplex ? "createComplexMatrixOfPoly" : "createMatrixOfPoly");
+ return sciErr;
+ }
+
+ GatewayStruct* pStr = (GatewayStruct*)_pvCtx;
+ InternalType** out = pStr->m_pOut;
+
+ const wchar_t* pstTemp = to_wide_string(_pstVarName);
+ MatrixPoly* pP = new MatrixPoly(pstTemp, _iRows, _iCols, _piNbCoef);
+ FREE(pstTemp);
+ if(pP == NULL)
+ {
+ addErrorMessage(&sciErr, API_ERROR_NO_MORE_MEMORY, _("%s: No more memory to allocated variable"), _iComplex ? "createComplexMatrixOfPoly" : "createMatrixOfPoly");
+ return sciErr;
+ }
+
+ if(_iComplex)
+ {
+ pP->complex_set(true);
+ }
+
+ int rhs = _iVar - api_Rhs((int*)_pvCtx);
+ out[rhs - 1] = pP;
+
+ for(int i = 0 ; i < pP->size_get() ; i++)
+ {
+ Double* pD = new Double(_piNbCoef[i], 1, _iComplex == 1);
+ pD->real_set(_pdblReal[i]);
+ if(_iComplex)
+ {
+ pD->img_set(_pdblImg[i]);
+ }
+ pP->poly_set(i, pD);
+ }
+
+ return sciErr;
}
SciErr fillCommonMatrixOfPoly(void* _pvCtx, int* _piAddress, char* _pstVarName, int _iComplex, int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg, int* _piTotalLen)
{
- SciErr sciErr; sciErr.iErr = 0; sciErr.iMsgCount = 0;
- int* piOffset = NULL;
- int *piVarName = NULL;
- int iSize = _iRows * _iCols;
-
- double *pdblReal = NULL;
- double *pdblImg = NULL;
-
- //header
- _piAddress[0] = sci_poly;
- _piAddress[1] = _iRows;
- _piAddress[2] = _iCols;
- _piAddress[3] = _iComplex;
-
-
- //4 for header
- piVarName = _piAddress + 4;//4 for header
- if(strlen(_pstVarName) > 4)//4 characters max
- {
- addErrorMessage(&sciErr, API_ERROR_TOO_LONG_VAR, _("%s: Formal variable name of polynomial can't exceed 4 characters"));
- return sciErr;
- }
-
- //fill variable name with space ( 40 sergescii )
- piVarName[0] = 40;
- piVarName[1] = 40;
- piVarName[2] = 40;
- piVarName[3] = 40;
- //str2code(piVarName, &_pstVarName);
-
- piOffset = _piAddress + 8; //4 for header and 4 for variable name
- piOffset[0] = 1;
- for(int i = 0 ; i < iSize ; i++)
- {
- piOffset[i + 1] = piOffset[i] + _piNbCoef[i];
- }
-
- pdblReal = (double*)(piOffset + iSize + 1 + ((iSize + 1) % 2 == 0 ? 0 : 1 ));
-
- for(int i = 0 ; i < iSize ; i++)
- {
- memcpy(pdblReal + piOffset[i] - 1, _pdblReal[i], _piNbCoef[i] * sizeof(double));
- }
-
- if(_iComplex == 1)
- {
- pdblImg = pdblReal + piOffset[iSize] - 1;
- for(int i = 0 ; i < iSize ; i++)
- {
- memcpy(pdblImg + piOffset[i] - 1, _pdblImg[i], _piNbCoef[i] * sizeof(double));
- }
- }
-
- *_piTotalLen = (piOffset[iSize] - 1) * (_iComplex + 1) * 2;
- return sciErr;
+ SciErr sciErr; sciErr.iErr = 0; sciErr.iMsgCount = 0;
+ int* piOffset = NULL;
+ int *piVarName = NULL;
+ int iSize = _iRows * _iCols;
+
+ double *pdblReal = NULL;
+ double *pdblImg = NULL;
+
+ //header
+ _piAddress[0] = sci_poly;
+ _piAddress[1] = _iRows;
+ _piAddress[2] = _iCols;
+ _piAddress[3] = _iComplex;
+
+
+ //4 for header
+ piVarName = _piAddress + 4;//4 for header
+ if(strlen(_pstVarName) > 4)//4 characters max
+ {
+ addErrorMessage(&sciErr, API_ERROR_TOO_LONG_VAR, _("%s: Formal variable name of polynomial can't exceed 4 characters"));
+ return sciErr;
+ }
+
+ //fill variable name with space ( 40 sergescii )
+ piVarName[0] = 40;
+ piVarName[1] = 40;
+ piVarName[2] = 40;
+ piVarName[3] = 40;
+ //str2code(piVarName, &_pstVarName);
+
+ piOffset = _piAddress + 8; //4 for header and 4 for variable name
+ piOffset[0] = 1;
+ for(int i = 0 ; i < iSize ; i++)
+ {
+ piOffset[i + 1] = piOffset[i] + _piNbCoef[i];
+ }
+
+ pdblReal = (double*)(piOffset + iSize + 1 + ((iSize + 1) % 2 == 0 ? 0 : 1 ));
+
+ for(int i = 0 ; i < iSize ; i++)
+ {
+ memcpy(pdblReal + piOffset[i] - 1, _pdblReal[i], _piNbCoef[i] * sizeof(double));
+ }
+
+ if(_iComplex == 1)
+ {
+ pdblImg = pdblReal + piOffset[iSize] - 1;
+ for(int i = 0 ; i < iSize ; i++)
+ {
+ memcpy(pdblImg + piOffset[i] - 1, _pdblImg[i], _piNbCoef[i] * sizeof(double));
+ }
+ }
+
+ *_piTotalLen = (piOffset[iSize] - 1) * (_iComplex + 1) * 2;
+ return sciErr;
}
SciErr createNamedMatrixOfPoly(void* _pvCtx, char* _pstName, char* _pstVarName, int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal)
{
- return createCommonNamedMatrixOfPoly(_pvCtx, _pstName, _pstVarName, 0, _iRows, _iCols, _piNbCoef, _pdblReal, NULL);
+ return createCommonNamedMatrixOfPoly(_pvCtx, _pstName, _pstVarName, 0, _iRows, _iCols, _piNbCoef, _pdblReal, NULL);
}
SciErr createNamedComplexMatrixOfPoly(void* _pvCtx, char* _pstName, char* _pstVarName, int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
{
- return createCommonNamedMatrixOfPoly(_pvCtx, _pstName, _pstVarName, 1, _iRows, _iCols, _piNbCoef, _pdblReal, _pdblImg);
+ return createCommonNamedMatrixOfPoly(_pvCtx, _pstName, _pstVarName, 1, _iRows, _iCols, _piNbCoef, _pdblReal, _pdblImg);
}
SciErr createCommonNamedMatrixOfPoly(void* _pvCtx, char* _pstName, char* _pstVarName, int _iComplex, int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
{
- SciErr sciErr; sciErr.iErr = 0; sciErr.iMsgCount = 0;
- int iVarID[nsiz];
- int iSaveRhs = api_Rhs((int*)_pvCtx);
- int iSaveTop = api_Top((int*)_pvCtx);
- int *piAddr = NULL;
- int iTotalLen = 0;
+ SciErr sciErr; sciErr.iErr = 0; sciErr.iMsgCount = 0;
+ int iVarID[nsiz];
+ int iSaveRhs = api_Rhs((int*)_pvCtx);
+ int iSaveTop = api_Top((int*)_pvCtx);
+ int *piAddr = NULL;
+ int iTotalLen = 0;
- C2F(str2name)(_pstName, iVarID, (unsigned long)strlen(_pstName));
- Top = Top + Nbvars + 1;
+ C2F(str2name)(_pstName, iVarID, (unsigned long)strlen(_pstName));
+ Top = Top + Nbvars + 1;
- getNewVarAddressFromPosition(_pvCtx, Top, &piAddr);
+ getNewVarAddressFromPosition(_pvCtx, Top, &piAddr);
- //write matrix information
- sciErr = fillCommonMatrixOfPoly(_pvCtx, piAddr, _pstVarName, _iComplex, _iRows, _iCols, _piNbCoef, _pdblReal, _pdblImg, &iTotalLen);
- if(sciErr.iErr)
- {
- addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_POLY, _("%s: Unable to create %s named \"%s\""), _iComplex ? "createNamedComplexMatrixOfPoly" : "createNamedMatrixOfPoly", _("matrix of double"), _pstName);
- return sciErr;
- }
+ //write matrix information
+ sciErr = fillCommonMatrixOfPoly(_pvCtx, piAddr, _pstVarName, _iComplex, _iRows, _iCols, _piNbCoef, _pdblReal, _pdblImg, &iTotalLen);
+ if(sciErr.iErr)
+ {
+ addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_POLY, _("%s: Unable to create %s named \"%s\""), _iComplex ? "createNamedComplexMatrixOfPoly" : "createNamedMatrixOfPoly", _("matrix of double"), _pstName);
+ return sciErr;
+ }
- //update "variable index"
- updateLstk(Top, *Lstk(Top) + 4, iTotalLen);
+ //update "variable index"
+ updateLstk(Top, *Lstk(Top) + 4, iTotalLen);
- //Rhs = 0;
- //Add name in stack reference list
- createNamedVariable(iVarID);
+ //Rhs = 0;
+ //Add name in stack reference list
+ createNamedVariable(iVarID);
- //Top = iSaveTop;
- //Rhs = iSaveRhs;
+ //Top = iSaveTop;
+ //Rhs = iSaveRhs;
- return sciErr;
+ return sciErr;
}
SciErr readNamedMatrixOfPoly(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal)
{
- return readCommonNamedMatrixOfPoly(_pvCtx, _pstName, 0, _piRows, _piCols, _piNbCoef, _pdblReal, NULL);
+ return readCommonNamedMatrixOfPoly(_pvCtx, _pstName, 0, _piRows, _piCols, _piNbCoef, _pdblReal, NULL);
}
SciErr readNamedComplexMatrixOfPoly(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
{
- return readCommonNamedMatrixOfPoly(_pvCtx, _pstName, 1, _piRows, _piCols, _piNbCoef, _pdblReal, _pdblImg);
+ return readCommonNamedMatrixOfPoly(_pvCtx, _pstName, 1, _piRows, _piCols, _piNbCoef, _pdblReal, _pdblImg);
}
SciErr readCommonNamedMatrixOfPoly(void* _pvCtx, char* _pstName, int _iComplex, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
{
- SciErr sciErr; sciErr.iErr = 0; sciErr.iMsgCount = 0;
- int* piAddr = NULL;
-
- sciErr = getVarAddressFromName(_pvCtx, _pstName, &piAddr);
- if(sciErr.iErr)
- {
- addErrorMessage(&sciErr, API_ERROR_READ_NAMED_POLY, _("%s: Unable to get variable \"%s\""), _iComplex ? "readNamedComplexMatrixOfPoly" :"readNamedMatrixOfPoly", _pstName);
- return sciErr;
- }
-
- if(_iComplex == 1)
- {
- sciErr = getComplexMatrixOfPoly(_pvCtx, piAddr, _piRows, _piCols, _piNbCoef, _pdblReal, _pdblImg);
- }
- else
- {
- sciErr = getMatrixOfPoly(_pvCtx, piAddr, _piRows, _piCols, _piNbCoef, _pdblReal);
- }
-
- if(sciErr.iErr)
- {
- addErrorMessage(&sciErr, API_ERROR_READ_NAMED_POLY, _("%s: Unable to get variable \"%s\""), _iComplex ? "readNamedComplexMatrixOfPoly" :"readNamedMatrixOfPoly", _pstName);
- return sciErr;
- }
-
- return sciErr;
+ SciErr sciErr; sciErr.iErr = 0; sciErr.iMsgCount = 0;
+ int* piAddr = NULL;
+
+ sciErr = getVarAddressFromName(_pvCtx, _pstName, &piAddr);
+ if(sciErr.iErr)
+ {
+ addErrorMessage(&sciErr, API_ERROR_READ_NAMED_POLY, _("%s: Unable to get variable \"%s\""), _iComplex ? "readNamedComplexMatrixOfPoly" :"readNamedMatrixOfPoly", _pstName);
+ return sciErr;
+ }
+
+ if(_iComplex == 1)
+ {
+ sciErr = getComplexMatrixOfPoly(_pvCtx, piAddr, _piRows, _piCols, _piNbCoef, _pdblReal, _pdblImg);
+ }
+ else
+ {
+ sciErr = getMatrixOfPoly(_pvCtx, piAddr, _piRows, _piCols, _piNbCoef, _pdblReal);
+ }
+
+ if(sciErr.iErr)
+ {
+ addErrorMessage(&sciErr, API_ERROR_READ_NAMED_POLY, _("%s: Unable to get variable \"%s\""), _iComplex ? "readNamedComplexMatrixOfPoly" :"readNamedMatrixOfPoly", _pstName);
+ return sciErr;
+ }
+
+ return sciErr;
}
/*shortcut functions */
/*--------------------------------------------------------------------------*/
int isPolyType(void* _pvCtx, int* _piAddress)
{
- return checkVarType(_pvCtx, _piAddress, sci_poly);
+ return checkVarType(_pvCtx, _piAddress, sci_poly);
}
/*--------------------------------------------------------------------------*/
int isNamedPolyType(void* _pvCtx, char* _pstName)
{
- return checkNamedVarType(_pvCtx, _pstName, sci_poly);
+ return checkNamedVarType(_pvCtx, _pstName, sci_poly);
}
/*--------------------------------------------------------------------------*/
int getAllocatedSinglePoly(void* _pvCtx, int* _piAddress, int* _piNbCoef, double** _pdblReal)
{
- return getCommonAllocatedSinglePoly(_pvCtx, _piAddress, 0, _piNbCoef, _pdblReal, NULL);
+ return getCommonAllocatedSinglePoly(_pvCtx, _piAddress, 0, _piNbCoef, _pdblReal, NULL);
}
/*--------------------------------------------------------------------------*/
int getAllocatedSingleComplexPoly(void* _pvCtx, int* _piAddress, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
{
- return getCommonAllocatedSinglePoly(_pvCtx, _piAddress, 1, _piNbCoef, _pdblReal, _pdblImg);
+ return getCommonAllocatedSinglePoly(_pvCtx, _piAddress, 1, _piNbCoef, _pdblReal, _pdblImg);
}
/*--------------------------------------------------------------------------*/
static int getCommonAllocatedSinglePoly(void* _pvCtx, int* _piAddress, int _iComplex, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
{
- SciErr sciErr;
- int iRows = 0;
- int iCols = 0;
-
- double* pdblReal = NULL;
- double* pdblImg = NULL;
-
- if(isScalar(_pvCtx, _piAddress) == 0)
- {
- addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_POLY, _("%s: Wrong type for input argument #%d: A scalar expected.\n"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress));
- printError(&sciErr, 0);
- return sciErr.iErr;
- }
-
- sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, &iRows, &iCols, _piNbCoef, NULL, NULL);
- if(sciErr.iErr)
- {
- addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress));
- printError(&sciErr, 0);
- return sciErr.iErr;
- }
-
- *_pdblReal = (double*)MALLOC(sizeof(double) * *_piNbCoef);
-
- if(_iComplex)
- {
- *_pdblImg = (double*)MALLOC(sizeof(double) * *_piNbCoef);
- }
-
- sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, &iRows, &iCols, _piNbCoef, _pdblReal, _pdblImg);
- if(sciErr.iErr)
- {
- addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress));
- printError(&sciErr, 0);
- return sciErr.iErr;
- }
-
- return 0;
+ SciErr sciErr;
+ int iRows = 0;
+ int iCols = 0;
+
+ double* pdblReal = NULL;
+ double* pdblImg = NULL;
+
+ if(isScalar(_pvCtx, _piAddress) == 0)
+ {
+ addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_POLY, _("%s: Wrong type for input argument #%d: A scalar expected.\n"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress));
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, &iRows, &iCols, _piNbCoef, NULL, NULL);
+ if(sciErr.iErr)
+ {
+ addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress));
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ *_pdblReal = (double*)MALLOC(sizeof(double) * *_piNbCoef);
+
+ if(_iComplex)
+ {
+ *_pdblImg = (double*)MALLOC(sizeof(double) * *_piNbCoef);
+ }
+
+ sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, &iRows, &iCols, _piNbCoef, _pdblReal, _pdblImg);
+ if(sciErr.iErr)
+ {
+ addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress));
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ return 0;
}
/*--------------------------------------------------------------------------*/
int getAllocatedNamedSinglePoly(void* _pvCtx, char* _pstName, int* _piNbCoef, double** _pdblReal)
{
- return getCommonAllocatedNamedSinglePoly(_pvCtx, _pstName, 0, _piNbCoef, _pdblReal, NULL);
+ return getCommonAllocatedNamedSinglePoly(_pvCtx, _pstName, 0, _piNbCoef, _pdblReal, NULL);
}
/*--------------------------------------------------------------------------*/
int getAllocatedNamedSingleComplexPoly(void* _pvCtx, char* _pstName, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
{
- return getCommonAllocatedNamedSinglePoly(_pvCtx, _pstName, 1, _piNbCoef, _pdblReal, _pdblImg);
+ return getCommonAllocatedNamedSinglePoly(_pvCtx, _pstName, 1, _piNbCoef, _pdblReal, _pdblImg);
}
/*--------------------------------------------------------------------------*/
static int getCommonAllocatedNamedSinglePoly(void* _pvCtx, char* _pstName, int _iComplex, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
{
- SciErr sciErr;
- int iRows = 0;
- int iCols = 0;
-
- double* pdblReal = NULL;
- double* pdblImg = NULL;
-
- if(isNamedScalar(_pvCtx, _pstName) == 0)
- {
- addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_SINGLE_POLY, _("%s: Wrong type for input argument \"%s\": A scalar expected.\n"), _iComplex ? "getAllocatedNamedSingleComplexPoly" : "getAllocatedNamedSinglePoly", _pstName);
- printError(&sciErr, 0);
- return sciErr.iErr;
- }
-
- sciErr = readCommonNamedMatrixOfPoly(_pvCtx, _pstName, _iComplex, &iRows, &iCols, _piNbCoef, &pdblReal, &pdblImg);
- if(sciErr.iErr)
- {
- addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_SINGLE_POLY, _("%s: Unable to get argument \"%s\""), _iComplex ? "getAllocatedNamedSingleComplexPoly" : "getAllocatedNamedSinglePoly", _pstName);
- printError(&sciErr, 0);
- return sciErr.iErr;
- }
-
- *_pdblReal = (double*)MALLOC(sizeof(double) * *_piNbCoef);
- memcpy(*_pdblReal, pdblReal, sizeof(double) * *_piNbCoef);
-
- if(_iComplex)
- {
- *_pdblImg = (double*)MALLOC(sizeof(double) * *_piNbCoef);
- memcpy(*_pdblImg, pdblImg, sizeof(double) * *_piNbCoef);
- }
- return 0;
+ SciErr sciErr;
+ int iRows = 0;
+ int iCols = 0;
+
+ double* pdblReal = NULL;
+ double* pdblImg = NULL;
+
+ if(isNamedScalar(_pvCtx, _pstName) == 0)
+ {
+ addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_SINGLE_POLY, _("%s: Wrong type for input argument \"%s\": A scalar expected.\n"), _iComplex ? "getAllocatedNamedSingleComplexPoly" : "getAllocatedNamedSinglePoly", _pstName);
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ sciErr = readCommonNamedMatrixOfPoly(_pvCtx, _pstName, _iComplex, &iRows, &iCols, _piNbCoef, &pdblReal, &pdblImg);
+ if(sciErr.iErr)
+ {
+ addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_SINGLE_POLY, _("%s: Unable to get argument \"%s\""), _iComplex ? "getAllocatedNamedSingleComplexPoly" : "getAllocatedNamedSinglePoly", _pstName);
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ *_pdblReal = (double*)MALLOC(sizeof(double) * *_piNbCoef);
+ memcpy(*_pdblReal, pdblReal, sizeof(double) * *_piNbCoef);
+
+ if(_iComplex)
+ {
+ *_pdblImg = (double*)MALLOC(sizeof(double) * *_piNbCoef);
+ memcpy(*_pdblImg, pdblImg, sizeof(double) * *_piNbCoef);
+ }
+ return 0;
}
/*--------------------------------------------------------------------------*/
int getAllocatedMatrixOfPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal)
{
- return getCommonAllocatedMatrixOfPoly(_pvCtx, _piAddress, 0, _piRows, _piCols, _piNbCoef, _pdblReal, NULL);
+ return getCommonAllocatedMatrixOfPoly(_pvCtx, _piAddress, 0, _piRows, _piCols, _piNbCoef, _pdblReal, NULL);
}
/*--------------------------------------------------------------------------*/
int getAllocatedMatrixOfComplexPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg)
{
- return getCommonAllocatedMatrixOfPoly(_pvCtx, _piAddress, 1, _piRows, _piCols, _piNbCoef, _pdblReal, _pdblImg);
+ return getCommonAllocatedMatrixOfPoly(_pvCtx, _piAddress, 1, _piRows, _piCols, _piNbCoef, _pdblReal, _pdblImg);
}
/*--------------------------------------------------------------------------*/
static int getCommonAllocatedMatrixOfPoly(void* _pvCtx, int* _piAddress, int _iComplex, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg)
{
- SciErr sciErr;
-
- double* pdblReal = NULL;
- double* pdblImg = NULL;
-
- sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, _piRows, _piCols, NULL, NULL, NULL);
- if(sciErr.iErr)
- {
- addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_MATRIX_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedMatrixOfComplexPoly" : "getAllocatedMatrixOfPoly", getRhsFromAddress(_pvCtx, _piAddress));
- printError(&sciErr, 0);
- return sciErr.iErr;
- }
-
- *_piNbCoef = (int*)MALLOC(sizeof(int) * *_piRows * *_piCols);
-
- sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, _piRows, _piCols, *_piNbCoef, NULL, NULL);
- if(sciErr.iErr)
- {
- addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_MATRIX_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedMatrixOfComplexPoly" : "getAllocatedMatrixOfPoly", getRhsFromAddress(_pvCtx, _piAddress));
- printError(&sciErr, 0);
- return sciErr.iErr;
- }
-
- *_pdblReal = (double**)MALLOC(sizeof(double*) * *_piRows * *_piCols);
- for(int i = 0 ; i < *_piRows * *_piCols ; i++)
- {
- (*_pdblReal)[i] = (double*)MALLOC(sizeof(double) * (*_piNbCoef)[i]);
- }
-
- if(_iComplex)
- {
- *_pdblImg = (double**)MALLOC(sizeof(double*) * *_piRows * *_piCols);
- for(int i = 0 ; i < *_piRows * *_piCols ; i++)
- {
- (*_pdblImg)[i] = (double*)MALLOC(sizeof(double) * (*_piNbCoef)[i]);
- }
- }
-
- sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, _piRows, _piCols, *_piNbCoef, *_pdblReal, _pdblImg == NULL ? NULL : *_pdblImg);
- if(sciErr.iErr)
- {
- addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_MATRIX_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress));
- printError(&sciErr, 0);
- return sciErr.iErr;
- }
-
- return 0;
+ SciErr sciErr;
+
+ double* pdblReal = NULL;
+ double* pdblImg = NULL;
+
+ sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, _piRows, _piCols, NULL, NULL, NULL);
+ if(sciErr.iErr)
+ {
+ addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_MATRIX_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedMatrixOfComplexPoly" : "getAllocatedMatrixOfPoly", getRhsFromAddress(_pvCtx, _piAddress));
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ *_piNbCoef = (int*)MALLOC(sizeof(int) * *_piRows * *_piCols);
+
+ sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, _piRows, _piCols, *_piNbCoef, NULL, NULL);
+ if(sciErr.iErr)
+ {
+ addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_MATRIX_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedMatrixOfComplexPoly" : "getAllocatedMatrixOfPoly", getRhsFromAddress(_pvCtx, _piAddress));
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ *_pdblReal = (double**)MALLOC(sizeof(double*) * *_piRows * *_piCols);
+ for(int i = 0 ; i < *_piRows * *_piCols ; i++)
+ {
+ (*_pdblReal)[i] = (double*)MALLOC(sizeof(double) * (*_piNbCoef)[i]);
+ }
+
+ if(_iComplex)
+ {
+ *_pdblImg = (double**)MALLOC(sizeof(double*) * *_piRows * *_piCols);
+ for(int i = 0 ; i < *_piRows * *_piCols ; i++)
+ {
+ (*_pdblImg)[i] = (double*)MALLOC(sizeof(double) * (*_piNbCoef)[i]);
+ }
+ }
+
+ sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, _piRows, _piCols, *_piNbCoef, *_pdblReal, _pdblImg == NULL ? NULL : *_pdblImg);
+ if(sciErr.iErr)
+ {
+ addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_MATRIX_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress));
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ return 0;
}
/*--------------------------------------------------------------------------*/
int getAllocatedNamedMatrixOfPoly(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal)
{
- return getCommonAllocatedNamedMatrixOfPoly(_pvCtx, _pstName, 0, _piRows, _piCols, _piNbCoef, _pdblReal, NULL);
+ return getCommonAllocatedNamedMatrixOfPoly(_pvCtx, _pstName, 0, _piRows, _piCols, _piNbCoef, _pdblReal, NULL);
}
/*--------------------------------------------------------------------------*/
int getAllocatedNamedMatrixOfComplexPoly(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg)
{
- return getCommonAllocatedNamedMatrixOfPoly(_pvCtx, _pstName, 1, _piRows, _piCols, _piNbCoef, _pdblReal, _pdblImg);
+ return getCommonAllocatedNamedMatrixOfPoly(_pvCtx, _pstName, 1, _piRows, _piCols, _piNbCoef, _pdblReal, _pdblImg);
}
/*--------------------------------------------------------------------------*/
static int getCommonAllocatedNamedMatrixOfPoly(void* _pvCtx, char* _pstName, int _iComplex, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg)
{
- SciErr sciErr;
- int iRows = 0;
- int iCols = 0;
-
- double* pdblReal = NULL;
- double* pdblImg = NULL;
-
-
- sciErr = readCommonNamedMatrixOfPoly(_pvCtx, _pstName, _iComplex, _piRows, _piCols, NULL, NULL, NULL);
- if(sciErr.iErr)
- {
- addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_MATRIX_POLY, _("%s: Unable to get argument \"%s\""), _iComplex ? "getAllocatedNamedMatrixOfComplexPoly" : "getAllocatedNamedMatrixOfPoly", _pstName);
- printError(&sciErr, 0);
- return sciErr.iErr;
- }
-
- *_piNbCoef = (int*)MALLOC(sizeof(int) * *_piRows * *_piCols);
-
- sciErr = readCommonNamedMatrixOfPoly(_pvCtx, _pstName, _iComplex, _piRows, _piCols, *_piNbCoef, NULL, NULL);
- if(sciErr.iErr)
- {
- addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_MATRIX_POLY, _("%s: Unable to get argument \"%s\""), _iComplex ? "getAllocatedNamedMatrixOfComplexPoly" : "getAllocatedNamedMatrixOfPoly", _pstName);
- printError(&sciErr, 0);
- return sciErr.iErr;
- }
-
- *_pdblReal = (double**)MALLOC(sizeof(double*) * *_piRows * *_piCols);
- for(int i = 0 ; i < *_piRows * *_piCols ; i++)
- {
- (*_pdblReal)[i] = (double*)MALLOC(sizeof(double) * (*_piNbCoef)[i]);
- }
-
- if(_iComplex)
- {
- *_pdblImg = (double**)MALLOC(sizeof(double*) * *_piRows * *_piCols);
- for(int i = 0 ; i < *_piRows * *_piCols ; i++)
- {
- (*_pdblImg)[i] = (double*)MALLOC(sizeof(double) * (*_piNbCoef)[i]);
- }
- }
-
- sciErr = readCommonNamedMatrixOfPoly(_pvCtx, _pstName, _iComplex, _piRows, _piCols, *_piNbCoef, *_pdblReal, _pdblImg == NULL ? NULL : *_pdblImg);
- if(sciErr.iErr)
- {
- addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_MATRIX_POLY, _("%s: Unable to get argument \"%s\""), _iComplex ? "getAllocatedNamedMatrixOfComplexPoly" : "getAllocatedNamedMatrixOfPoly", _pstName);
- printError(&sciErr, 0);
- return sciErr.iErr;
- }
-
- return 0;
+ SciErr sciErr;
+ int iRows = 0;
+ int iCols = 0;
+
+ double* pdblReal = NULL;
+ double* pdblImg = NULL;
+
+
+ sciErr = readCommonNamedMatrixOfPoly(_pvCtx, _pstName, _iComplex, _piRows, _piCols, NULL, NULL, NULL);
+ if(sciErr.iErr)
+ {
+ addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_MATRIX_POLY, _("%s: Unable to get argument \"%s\""), _iComplex ? "getAllocatedNamedMatrixOfComplexPoly" : "getAllocatedNamedMatrixOfPoly", _pstName);
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ *_piNbCoef = (int*)MALLOC(sizeof(int) * *_piRows * *_piCols);
+
+ sciErr = readCommonNamedMatrixOfPoly(_pvCtx, _pstName, _iComplex, _piRows, _piCols, *_piNbCoef, NULL, NULL);
+ if(sciErr.iErr)
+ {
+ addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_MATRIX_POLY, _("%s: Unable to get argument \"%s\""), _iComplex ? "getAllocatedNamedMatrixOfComplexPoly" : "getAllocatedNamedMatrixOfPoly", _pstName);
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ *_pdblReal = (double**)MALLOC(sizeof(double*) * *_piRows * *_piCols);
+ for(int i = 0 ; i < *_piRows * *_piCols ; i++)
+ {
+ (*_pdblReal)[i] = (double*)MALLOC(sizeof(double) * (*_piNbCoef)[i]);
+ }
+
+ if(_iComplex)
+ {
+ *_pdblImg = (double**)MALLOC(sizeof(double*) * *_piRows * *_piCols);
+ for(int i = 0 ; i < *_piRows * *_piCols ; i++)
+ {
+ (*_pdblImg)[i] = (double*)MALLOC(sizeof(double) * (*_piNbCoef)[i]);
+ }
+ }
+
+ sciErr = readCommonNamedMatrixOfPoly(_pvCtx, _pstName, _iComplex, _piRows, _piCols, *_piNbCoef, *_pdblReal, _pdblImg == NULL ? NULL : *_pdblImg);
+ if(sciErr.iErr)
+ {
+ addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_MATRIX_POLY, _("%s: Unable to get argument \"%s\""), _iComplex ? "getAllocatedNamedMatrixOfComplexPoly" : "getAllocatedNamedMatrixOfPoly", _pstName);
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ return 0;
}
/*--------------------------------------------------------------------------*/
void freeAllocatedSinglePoly(double* _pdblReal)
{
- FREE(_pdblReal);
+ FREE(_pdblReal);
}
/*--------------------------------------------------------------------------*/
void freeAllocatedSingleComplexPoly(double* _pdblReal, double* _pdblImg)
{
- freeAllocatedSinglePoly(_pdblReal);
- FREE(_pdblImg);
+ freeAllocatedSinglePoly(_pdblReal);
+ FREE(_pdblImg);
}
/*--------------------------------------------------------------------------*/
void freeAllocatedMatrixOfPoly(int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal)
{
- FREE(_piNbCoef);
+ FREE(_piNbCoef);
- for(int i = 0 ; i < _iRows * _iCols ; i++)
- {
- FREE(_pdblReal[i]);
- }
- FREE(_pdblReal);
+ for(int i = 0 ; i < _iRows * _iCols ; i++)
+ {
+ FREE(_pdblReal[i]);
+ }
+ FREE(_pdblReal);
}
/*--------------------------------------------------------------------------*/
void freeAllocatedMatrixOfComplexPoly(int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
{
- freeAllocatedMatrixOfPoly(_iRows, _iCols, _piNbCoef, _pdblReal);
+ freeAllocatedMatrixOfPoly(_iRows, _iCols, _piNbCoef, _pdblReal);
- for(int i = 0 ; i < _iRows * _iCols ; i++)
- {
- FREE(_pdblImg[i]);
- }
- FREE(_pdblImg);
+ for(int i = 0 ; i < _iRows * _iCols ; i++)
+ {
+ FREE(_pdblImg[i]);
+ }
+ FREE(_pdblImg);
}
//non cummulative length
for(int i = 0 ; i < *_piRows * *_piCols ; i++)
{
- _piLength[i] = (int)strlen(pS->string_get(i));
+ _piLength[i] = (int)wcslen(pS->string_get(i));
}
if(_pstStrings == NULL || *_pstStrings == NULL)
return sciErr;
}
- strcpy(_pstStrings[i], pS->string_get(i));
+ char* pstTemp = wide_string_to_UTF8(pS->string_get(i));
+ strcpy(_pstStrings[i], pstTemp);
+ FREE(pstTemp);
}
return sciErr;
}
for(int i = 0 ; i < pS->size_get() ; i++)
{
- pS->string_set(i, _pstStrings[i]);
+ wchar_t* pstTemp = to_wide_string(_pstStrings[i]);
+ pS->string_set(i, pstTemp);
+ FREE(pstTemp);
}
int rhs = _iVar - api_Rhs((int*)_pvCtx);
#include "boolean_gw.hxx"
+#define MODULE_NAME L"boolean"
extern "C"
{
#include "gw_boolean.h"
bool BooleanModule::Load()
{
- symbol::Context::getInstance()->AddFunction(Function::createFunction("or", &sci_or, "boolean"));
- symbol::Context::getInstance()->AddFunction(Function::createFunction("and", &sci_and, "boolean"));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"or", &sci_or, MODULE_NAME));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"and", &sci_and, MODULE_NAME));
return true;
}
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="../../includes;../../../functions_manager/includes;../../../types/includes;../../../symbol/includes;../../../abstractSyntaxTree/includes;../../../elementary_functions/includes;../../../core/includes;../../../operations/includes;../../../api_scilab/includes"
+ AdditionalIncludeDirectories="../../includes;../../../functions_manager/includes;../../../types/includes;../../../symbol/includes;../../../abstractSyntaxTree/includes;../../../elementary_functions/includes;../../../core/includes;../../../operations/includes;../../../api_scilab/includes;../../../localization/includes"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;BOOLEAN_GW_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
/>
</Configuration>
<Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
+ Name="Debug|x64"
+ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
- WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCMIDLTool"
+ TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="../../includes;../../../functions_manager/includes;../../../types/includes;../../../symbol/includes;../../../abstractSyntaxTree/includes;../../../elementary_functions/includes;../../../core/includes;../../../operations/includes;../../../api_scilab/includes"
- PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;BOOLEAN_GW_EXPORTS"
- RuntimeLibrary="2"
- EnableFunctionLevelLinking="true"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../includes;../../../functions_manager/includes;../../../types/includes;../../../symbol/includes;../../../abstractSyntaxTree/includes;../../../elementary_functions/includes;../../../core/includes;../../../operations/includes;../../../api_scilab/includes;../../../localization/includes"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;BOOLEAN_GW_EXPORTS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
<Tool
Name="VCLinkerTool"
OutputFile=""$(SolutionDir)bin\$(ProjectName).dll""
- LinkIncremental="1"
+ LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
+ TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
</Configuration>
<Configuration
- Name="Debug|x64"
- OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
- IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
+ WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCMIDLTool"
- TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="../../includes;../../../functions_manager/includes;../../../types/includes;../../../symbol/includes;../../../abstractSyntaxTree/includes;../../../elementary_functions/includes;../../../core/includes;../../../operations/includes;../../../api_scilab/includes"
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;BOOLEAN_GW_EXPORTS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="../../includes;../../../functions_manager/includes;../../../types/includes;../../../symbol/includes;../../../abstractSyntaxTree/includes;../../../elementary_functions/includes;../../../core/includes;../../../operations/includes;../../../api_scilab/includes;../../../localization/includes"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;BOOLEAN_GW_EXPORTS"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
<Tool
Name="VCLinkerTool"
OutputFile=""$(SolutionDir)bin\$(ProjectName).dll""
- LinkIncremental="2"
+ LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
- TargetMachine="17"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="../../includes;../../../functions_manager/includes;../../../types/includes;../../../symbol/includes;../../../abstractSyntaxTree/includes;../../../elementary_functions/includes;../../../core/includes;../../../operations/includes;../../../api_scilab/includes"
+ AdditionalIncludeDirectories="../../includes;../../../functions_manager/includes;../../../types/includes;../../../symbol/includes;../../../abstractSyntaxTree/includes;../../../elementary_functions/includes;../../../core/includes;../../../operations/includes;../../../api_scilab/includes;../../../localization/includes"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;BOOLEAN_GW_EXPORTS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
** depending on input parameters
** and maybe on number of result expected <further implementation>
*/
- static std::string buildOverloadName(std::string _stFunctionName, types::typed_list &in, int _iRetCount);
+ static std::wstring buildOverloadName(std::wstring _stFunctionName, types::typed_list &in, int _iRetCount);
/**
*/
- static types::Function::ReturnValue generateNameAndCall(std::string _stFunctionName, types::typed_list &in, int _iRetCount,
+ static types::Function::ReturnValue generateNameAndCall(std::wstring _stFunctionName, types::typed_list &in, int _iRetCount,
types::typed_list &out, ast::ConstVisitor *_execMe);
/**
*/
- static types::Function::ReturnValue call(std::string _stFunctionName, types::typed_list &in, int _iRetCount,
+ static types::Function::ReturnValue call(std::wstring _stFunctionName, types::typed_list &in, int _iRetCount,
types::typed_list &out, ast::ConstVisitor *_execMe);
- static std::string getNameFromOper(ast::OpExp::Oper);
+ static std::wstring getNameFromOper(ast::OpExp::Oper);
};
#ifndef __STORECOMMAND_H__
#define __STORECOMMAND_H__
+#include <wchar.h>
#include "machine.h"
/*
* @param command the command
* @return <ReturnValue>
*/
-int StoreCommand (char *command);
+int StoreCommand (wchar_t *command);
/**
* try to execute a command or add it to the end of command queue
* @param flag a internal execution flag for sequential execution
* @return <ReturnValue>
*/
-int StoreCommandWithFlag (char *command, int flag);
+int StoreCommandWithFlag (wchar_t *command, int flag);
/**
* @TODO add comment
* flag = 0 : the command is not shown in scilab window
* flag = 1 : the command is shown in scilab window (if at prompt) and executed sequentially
*/
-int StorePrioritaryCommandWithFlag (char *command,int flag);
+int StorePrioritaryCommandWithFlag (wchar_t *command,int flag);
/**
*
**
** Parse the given file and create the AST.
*/
-void parseFileTask(Parser *parser, bool timed, const char* file_name, const char* prog_name);
+void parseFileTask(Parser *parser, bool timed, const wchar_t* file_name, const wchar_t* prog_name);
/*
** Parse
**
** Parse the given command and create the AST.
*/
-void parseCommandTask(Parser *parser, bool timed, char *command);
+void parseCommandTask(Parser *parser, bool timed, wchar_t *command);
/*
** Dump AST
#define SCI_VERSION_MAJOR 6
#define SCI_VERSION_MINOR 0
#define SCI_VERSION_MAINTENANCE 0
-#define SCI_VERSION_STRING "scilab-branch-YaSp"
+#define SCI_VERSION_STRING L"scilab-branch-YaSp"
/* SCI_VERSION_REVISION --> hash key commit */
#define SCI_VERSION_REVISION 0
#define SCI_VERSION_TIMESTAMP 0
/* for compatibility */
/* Deprecated */
#define SCI_VERSION SCI_VERSION_STRING
-#define DEFAULT_SCI_VERSION_MESSAGE "scilab-YaSp-GIT (INRIA,ENPC)"
+#define DEFAULT_SCI_VERSION_MESSAGE L"scilab-YaSp-GIT (INRIA,ENPC)"
#endif
}
symbol::Context* pContext = symbol::Context::getInstance();
- InternalType *pOut = pContext->get("nargout");
- InternalType *pIn = pContext->get("nargin");
+ InternalType *pOut = pContext->get(L"nargout");
+ InternalType *pIn = pContext->get(L"nargin");
if(pIn == NULL || pOut == NULL)
{
#include "function.hxx"
#include "callable.hxx"
#include "context.hxx"
+
+extern "C"
+{
#include "Scierror.h"
#include "localization.h"
+#include "charEncoding.h"
+}
Function::ReturnValue sci_clear(types::typed_list &in, int _iRetCount, types::typed_list &out)
{
#include "context.hxx"
#include "Scierror.h"
#include "localization.h"
+#include "charEncoding.h"
Function::ReturnValue sci_clearglobal(types::typed_list &in, int _iRetCount, types::typed_list &out)
{
FunctionFailed
};
-static ScopeRange getScopeFromOption(const char *_psScope)
+static ScopeRange getScopeFromOption(const wchar_t *_psScope)
{
- if (strcmp(_psScope, "all") == 0 || strcmp(_psScope, "a") == 0)
+ if (wcscmp(_psScope, L"all") == 0 || wcscmp(_psScope, L"a") == 0)
{
return All;
}
- if (strcmp(_psScope, "local") == 0 || strcmp(_psScope, "l") == 0)
+ if (wcscmp(_psScope, L"local") == 0 || wcscmp(_psScope, L"l") == 0)
{
return Local;
}
- if (strcmp(_psScope, "nolocal") == 0 || strcmp(_psScope, "n") == 0)
+ if (wcscmp(_psScope, L"nolocal") == 0 || wcscmp(_psScope, L"n") == 0)
{
return NoLocal;
}
return FunctionFailed;
}
- const char *psScope = NULL;
+ const wchar_t *psScope = NULL;
if (in.size() == 2)
{
psScope = in[1]->getAsString()->string_get(0,0);
else
{
// Default option is "all"
- psScope = "all";
+ psScope = L"all";
}
return Function::Error;
}
- out.push_back(symbol::Context::getInstance()->get("modules_list"));
+ out.push_back(symbol::Context::getInstance()->get(L"modules_list"));
return Function::OK;
}
/*--------------------------------------------------------------------------*/
for(int i = 0 ; i < in.size() ; i++)
{
- char* pstVar = in[i]->getAsString()->string_get(0);
+ wchar_t* pstVar = in[i]->getAsString()->string_get(0);
//does it visible in current global scope
if(pCtx->isGlobalVisible(pstVar) == false)
#include <math.h>
#include "version.h"
#include "localization.h"
+#include "charEncoding.h"
}
void banner(void)
{
- int i;
- char *line = " ___________________________________________ ";
- int startVersion = (int)(floor((double)(strlen(line)/2)) - floor((double)(strlen(SCI_VERSION_STRING)/2)));
-
- YaspWrite(line);
- YaspWrite("\n");
-
-/* To center the version name */
- for( i=0 ; i<startVersion ; i++ )
+ int i;
+ wchar_t *line = L" ___________________________________________ ";
+ int startVersion = (int)(floor((double)(wcslen(line)/2)) - floor((double)(wcslen(SCI_VERSION_STRING)/2)));
+
+ YaspWriteW(line);
+ YaspWriteW(L"\n");
+
+ /* To center the version name */
+ for(i = 0 ; i < startVersion ; i++ )
{
- YaspWrite(" ");
+ YaspWriteW(L" ");
}
- YaspWrite(SCI_VERSION_STRING);
- YaspWrite("\n\n");
+ YaspWriteW(SCI_VERSION_STRING);
+ YaspWriteW(L"\n\n");
- YaspWrite(_(" Consortium Scilab (DIGITEO)\n"));
+ YaspWriteW(_W(" Consortium Scilab (DIGITEO)\n"));
- YaspWrite(_(" Copyright (c) 1989-2009 (INRIA)\n"));
- YaspWrite(_(" Copyright (c) 1989-2007 (ENPC)\n"));
- YaspWrite(line);
- YaspWrite("\n");
- YaspWrite("\n");
- YaspWrite(" -*- THIS IS SCILAB 6.0 aka YaSp -*-\n");
- YaspWrite("\n");
- YaspWrite(line);
- YaspWrite("\n");
+ YaspWriteW(_W(" Copyright (c) 1989-2009 (INRIA)\n"));
+ YaspWriteW(_W(" Copyright (c) 1989-2007 (ENPC)\n"));
+ YaspWriteW(line);
+ YaspWriteW(L"\n");
+ YaspWriteW(L"\n");
+ YaspWriteW(L" -*- THIS IS SCILAB 6.0 aka YaSp -*-\n");
+ YaspWriteW(L"\n");
+ YaspWriteW(line);
+ YaspWriteW(L"\n");
#if ( defined(_MSC_VER) && ( (_MSC_VER >= 1200) && (_MSC_VER < 1300) ) )
- YaspWrite("\n\n");
- YaspWrite(_("Warning: the operational team of the Scilab Consortium\ndoesn't provide and doesn't support this version of Scilab built with\n"));
- YaspWrite(" ");
+ YaspWriteW(L"\n\n");
+ YaspWriteW(_W("Warning: the operational team of the Scilab Consortium\ndoesn't provide and doesn't support this version of Scilab built with\n"));
+ YaspWriteW(L" ");
#endif
}
#include "core_gw.hxx"
#include "context.hxx"
+#define MODULE_NAME L"core"
extern "C"
{
#include "gw_core.h"
bool CoreModule::Load()
{
- symbol::Context::getInstance()->AddFunction(Function::createFunction("type", &sci_type, "core"));
- symbol::Context::getInstance()->AddFunction(Function::createFunction("getmodules", &sci_getmodules, "core"));
- symbol::Context::getInstance()->AddFunction(Function::createFunction("getdebuginfo", &sci_getdebuginfo, "core"));
- symbol::Context::getInstance()->AddFunction(Function::createFunction("getversion", &sci_getversion, "core"));
- symbol::Context::getInstance()->AddFunction(Function::createFunction("clear", &sci_clear, "core"));
- symbol::Context::getInstance()->AddFunction(Function::createFunction("banner", &sci_banner, "core"));
- symbol::Context::getInstance()->AddFunction(Function::createFunction("quit", &sci_quit, "core"));
- symbol::Context::getInstance()->AddFunction(Function::createFunction("exit", &sci_exit, "core"));
- symbol::Context::getInstance()->AddFunction(Function::createFunction("exists", &sci_exists, "core"));
- symbol::Context::getInstance()->AddFunction(Function::createFunction("isdef", &sci_isdef, "core"));
- symbol::Context::getInstance()->AddFunction(Function::createFunction("argn", &sci_argn, "core"));
- symbol::Context::getInstance()->AddFunction(Function::createFunction("global", &sci_global, "core"));
- symbol::Context::getInstance()->AddFunction(Function::createFunction("clearglobal", &sci_clearglobal, "core"));
- symbol::Context::getInstance()->AddFunction(Function::createFunction("isglobal", &sci_isglobal, "core"));
- symbol::Context::getInstance()->AddFunction(Function::createFunction("getscilabmode", &sci_getscilabmode, "core"));
- symbol::Context::getInstance()->AddFunction(Function::createFunction("getos", &sci_getos, "core"));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"type", &sci_type, MODULE_NAME));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"getmodules", &sci_getmodules, MODULE_NAME));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"getdebuginfo", &sci_getdebuginfo, MODULE_NAME));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"getversion", &sci_getversion, MODULE_NAME));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"clear", &sci_clear, MODULE_NAME));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"banner", &sci_banner, MODULE_NAME));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"quit", &sci_quit, MODULE_NAME));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"exit", &sci_exit, MODULE_NAME));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"exists", &sci_exists, MODULE_NAME));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"isdef", &sci_isdef, MODULE_NAME));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"argn", &sci_argn, MODULE_NAME));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"global", &sci_global, MODULE_NAME));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"clearglobal", &sci_clearglobal, MODULE_NAME));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"isglobal", &sci_isglobal, MODULE_NAME));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"getos", &sci_getos, MODULE_NAME));
+ symbol::Context::getInstance()->AddFunction(Function::createFunction(L"getscilabmode", &sci_getscilabmode, MODULE_NAME));
return true;
}
>
</File>
<File
+ RelativePath="..\..\sci_gateway\cpp\sci_getos.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\sci_gateway\cpp\sci_getscilabmode.cpp"
>
</File>
#include "overload.hxx"
#include "context.hxx"
-std::string Overload::buildOverloadName(std::string _stFunctionName, types::typed_list &in, int _iRetCount)
+std::wstring Overload::buildOverloadName(std::wstring _stFunctionName, types::typed_list &in, int _iRetCount)
{
switch(in.size())
{
case 0 :
- return "%_" + _stFunctionName;
+ return L"%_" + _stFunctionName;
case 1:
- return "%" + in[0]->getShortTypeStr() + "_" + _stFunctionName;
+ return L"%" + in[0]->getShortTypeStr() + L"_" + _stFunctionName;
case 2:
- return "%" + in[0]->getShortTypeStr() + "_" + _stFunctionName + "_" + in[1]->getShortTypeStr();
+ return L"%" + in[0]->getShortTypeStr() + L"_" + _stFunctionName + L"_" + in[1]->getShortTypeStr();
default :
- throw "Don't know how to overload " + _stFunctionName;
+ throw L"Don't know how to overload " + _stFunctionName;
}
return _stFunctionName;
}
-types::Function::ReturnValue Overload::generateNameAndCall(std::string _stFunctionName, types::typed_list &in, int _iRetCount, types::typed_list &out, ast::ConstVisitor *_execMe)
+types::Function::ReturnValue Overload::generateNameAndCall(std::wstring _stFunctionName, types::typed_list &in, int _iRetCount, types::typed_list &out, ast::ConstVisitor *_execMe)
{
return call(buildOverloadName(_stFunctionName, in, _iRetCount), in, _iRetCount, out, _execMe);
}
-types::Function::ReturnValue Overload::call(std::string _stOverloadingFunctionName, types::typed_list &in, int _iRetCount, types::typed_list &out, ast::ConstVisitor *_execMe)
+types::Function::ReturnValue Overload::call(std::wstring _stOverloadingFunctionName, types::typed_list &in, int _iRetCount, types::typed_list &out, ast::ConstVisitor *_execMe)
{
types::InternalType *pIT = symbol::Context::getInstance()->get(_stOverloadingFunctionName);
if(pIT == NULL || pIT->isCallable() == false)
{
- throw _("check or define function ") + _stOverloadingFunctionName + _(" for overloading.");
+ throw _W("check or define function ") + _stOverloadingFunctionName + _W(" for overloading.");
}
return pIT->getAsCallable()->call(in, _iRetCount, out, _execMe);
}
-std::string Overload::getNameFromOper(ast::OpExp::Oper _oper)
+std::wstring Overload::getNameFromOper(ast::OpExp::Oper _oper)
{
switch (_oper)
{
/* standard operators */
case OpExp::plus :
- return std::string("a");
+ return std::wstring(L"a");
case OpExp::minus :
- return std::string("s");
+ return std::wstring(L"s");
case OpExp::times :
- return std::string("m");
+ return std::wstring(L"m");
case OpExp::divide :
- return std::string("r");
+ return std::wstring(L"r");
case OpExp::rdivide :
- return std::string("l");
+ return std::wstring(L"l");
case OpExp::power :
- return std::string("p");
+ return std::wstring(L"p");
/* dot operators */
case OpExp::dottimes :
- return std::string("x");
+ return std::wstring(L"x");
case OpExp::dotdivide :
- return std::string("d");
+ return std::wstring(L"d");
case OpExp::dotrdivide :
- return std::string("q");
+ return std::wstring(L"q");
case OpExp::dotpower :
- return std::string("j");
+ return std::wstring(L"j");
/* Kron operators */
case OpExp::krontimes :
- return std::string("k");
+ return std::wstring(L"k");
case OpExp::krondivide :
- return std::string("y");
+ return std::wstring(L"y");
case OpExp::kronrdivide :
- return std::string("z");
+ return std::wstring(L"z");
/* Control Operators ??? */
case OpExp::controltimes :
- return std::string("u");
+ return std::wstring(L"u");
case OpExp::controldivide :
- return std::string("v");
+ return std::wstring(L"v");
case OpExp::controlrdivide :
- return std::string("w");
+ return std::wstring(L"w");
case OpExp::eq :
- return std::string("o");
+ return std::wstring(L"o");
case OpExp::ne :
- return std::string("n");
+ return std::wstring(L"n");
case OpExp::lt :
- return std::string("1");
+ return std::wstring(L"1");
case OpExp::le :
- return std::string("3");
+ return std::wstring(L"3");
case OpExp::gt :
- return std::string("2");
+ return std::wstring(L"2");
case OpExp::ge :
- return std::string("4");
+ return std::wstring(L"4");
case OpExp::logicalAnd :
- return std::string("h");
+ return std::wstring(L"h");
case OpExp::logicalOr :
- return std::string("g");
+ return std::wstring(L"g");
case OpExp::logicalShortCutAnd :
- return std::string("h");
+ return std::wstring(L"h");
case OpExp::logicalShortCutOr :
- return std::string("g");
+ return std::wstring(L"g");
default :
- return std::string("???");
+ return std::wstring(L"???");
}
}
#define INTERACTIVE -1
-const char* prog_name;
-const char* file_name;
+const wchar_t* prog_name;
+const wchar_t* file_name;
bool parseTrace = false;
bool printAst = false;
void Add_WITH_DEMOS(void); //temporary variable
void Add_All_Variables(void);
-void Add_Double_Constant(string _szName, double _dblReal, double _dblImg, bool _bComplex);
-void Add_Poly_Constant(string _szName, string _szPolyVar, int _iRank, Double *_pdblReal);
-void Add_Boolean_Constant(string _szName, bool _bBool);
-void Add_String_Constant(string _szName, const char* _pstString);
+void Add_Double_Constant(wstring _szName, double _dblReal, double _dblImg, bool _bComplex);
+void Add_Poly_Constant(wstring _szName, wstring _szPolyVar, int _iRank, Double *_pdblReal);
+void Add_Boolean_Constant(wstring _szName, bool _bBool);
+void Add_String_Constant(wstring _szName, const char* _pstString);
int InitializeEnvironnement(void);
bool execScilabStart(void);
if (parser->getExitStatus() != Parser::Succeded)
{
- YaspWrite(parser->getErrorMessage());
+ YaspWriteW(parser->getErrorMessage());
return PARSE_ERROR;
}
if (strcmp(command, "") != 0)
{
+ wchar_t* pstCommand = to_wide_string(command);
/*
** -*- PARSING -*-
*/
- parseCommandTask(parser, timed, command);
+ parseCommandTask(parser, timed, pstCommand);
/*
** -*- DUMPING TREE -*-
}
else if(parser->getExitStatus() == Parser::Failed && parser->getControlStatus() == Parser::AllControlClosed)
{
- YaspWrite(parser->getErrorMessage());
- //std::cerr << "Parser control : " << parser->getControlStatus() << std::endl;
+ YaspWriteW(parser->getErrorMessage());
}
parser->freeTree();
+ FREE(pstCommand);
}
}
#ifdef DEBUG
int iFileIndex = INTERACTIVE;
int iLangIndex = 0;
- prog_name = argv[0];
+ prog_name = to_wide_string(argv[0]);
setScilabMode(SCILAB_STD);
get_option(argc, argv, &iFileIndex, &iLangIndex);
if (iFileIndex == INTERACTIVE)
{
- file_name = "prompt";
+ file_name = L"prompt";
iMainRet = interactiveMain();
}
else
{
- file_name = argv[iFileIndex];
+ file_name = to_wide_string(argv[iFileIndex]);
iMainRet = batchMain();
}
void Add_WITH_DEMOS(void)
{
- Add_Boolean_Constant("WITH_DEMOS", false);
+ Add_Boolean_Constant(L"WITH_DEMOS", false);
}
void Add_false(void)
{
- Add_Boolean_Constant("%f", false);
+ Add_Boolean_Constant(L"%f", false);
}
void Add_true(void)
{
- Add_Boolean_Constant("%t", true);
+ Add_Boolean_Constant(L"%t", true);
}
void Add_pi(void)
{
- Add_Double_Constant("%pi", 3.1415926535897931159980, 0, false);
+ Add_Double_Constant(L"%pi", 3.1415926535897931159980, 0, false);
}
void Add_i(void)
{
- Add_Double_Constant("%i", 0, 1, true);
+ Add_Double_Constant(L"%i", 0, 1, true);
}
void Add_s(void)
dblCoef.val_set(0, 0, 0);
dblCoef.val_set(0, 1, 1);
- Add_Poly_Constant("%s","s", 2, &dblCoef);
+ Add_Poly_Constant(L"%s",L"s", 2, &dblCoef);
}
void Add_z(void)
dblCoef.val_set(0, 0, 0);
dblCoef.val_set(0, 1, 1);
- Add_Poly_Constant("%z","z", 2, &dblCoef);
+ Add_Poly_Constant(L"%z",L"z", 2, &dblCoef);
}
-void Add_Poly_Constant(string _szName, string _szPolyVar, int _iRank, Double *_pdbl)
+void Add_Poly_Constant(wstring _szName, wstring _szPolyVar, int _iRank, Double *_pdbl)
{
types::MatrixPoly *pVar = new types::MatrixPoly(_szPolyVar, 1, 1, &_iRank);
Poly *poPoly = pVar->poly_get(0,0);
Context::getInstance()->put(_szName, *pVar);
}
-void Add_Double_Constant(string _szName, double _dblReal, double _dblImg, bool _bComplex)
+void Add_Double_Constant(wstring _szName, double _dblReal, double _dblImg, bool _bComplex)
{
types::Double* pVal = new types::Double(1,1,_bComplex);
pVal->val_set(0,0,_dblReal,_dblImg);
symbol::Context::getInstance()->put(_szName, *pVal);
}
-void Add_Boolean_Constant(string _szName, bool _bBool)
+void Add_Boolean_Constant(wstring _szName, bool _bBool)
{
types::Bool* pVal = new types::Bool(_bBool);
symbol::Context::getInstance()->put(_szName, *pVal);
}
-void Add_String_Constant(string _szName, const char* _pstString)
+void Add_String_Constant(wstring _szName, const char* _pstString)
{
types::String* ps = new types::String(_pstString);
symbol::Context::getInstance()->put(_szName, *ps);
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2010-2010 - 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
- *
+ *
*/
/*--------------------------------------------------------------------------*/
extern "C"
static CommandRec *commandQueue = NULL;
static __threadLock commandQueueSingleAccess = __StaticInitLock;
/*--------------------------------------------------------------------------*/
-int StoreCommand (char *command)
+int StoreCommand (wchar_t *command)
{
return (StoreCommandWithFlag (command, 0));
}
* flag = 0 : the command is not shown in scilab window
* flag = 1 : the command is shown in scilab window (if at prompt) and executed sequentially
*/
-int StoreCommandWithFlag (char *command,int flag)
+int StoreCommandWithFlag (wchar_t *command,int flag)
{
Parser parser;
try
ast::ExecVisitor exec;
parser.getTree()->accept(exec);
}
- catch (std::string error)
+ catch (std::wstring error)
{
- YaspWrite("\n");
- YaspWrite("\n");
- YaspWrite(command);
- YaspWrite("\n");
- YaspWrite(const_cast<char *>(error.c_str()));
- YaspWrite("\n");
- YaspWrite(_("while executing a callback"));
+ YaspWriteW(L"\n");
+ YaspWriteW(L"\n");
+ YaspWriteW(command);
+ YaspWriteW(L"\n");
+ YaspWriteW(error.c_str());
+ YaspWriteW(L"\n");
+ YaspWriteW(_W("while executing a callback"));
}
parser.freeTree();
* flag = 0 : the command is not shown in scilab window
* flag = 1 : the command is shown in scilab window (if at prompt) and executed sequentially
*/
-int StorePrioritaryCommandWithFlag (char *command,int flag)
+int StorePrioritaryCommandWithFlag (wchar_t *command,int flag)
{
Parser parser;
ast::ExecVisitor exec;
parser.getTree()->accept(exec);
}
- catch (std::string error)
+ catch (std::wstring error)
{
- YaspWrite("\n");
- YaspWrite("\n");
- YaspWrite(command);
- YaspWrite("\n");
- YaspWrite(const_cast<char *>(error.c_str()));
- YaspWrite("\n");
- YaspWrite(_("while executing a callback"));
+ YaspWriteW(L"\n");
+ YaspWriteW(L"\n");
+ YaspWriteW(command);
+ YaspWriteW(L"\n");
+ YaspWriteW(error.c_str());
+ YaspWriteW(L"\n");
+ YaspWriteW(_W("while executing a callback"));
}
-
+
parser.freeTree();
return (0);
}
/*--------------------------------------------------------------------------*/
int isEmptyCommandQueue(void)
{
-#pragma warning("isEmptyCommandQueue is deprecated. It will be removed _BEFORE_ Scilab 6.0.")
+#pragma message("WARNING : isEmptyCommandQueue is deprecated. It will be removed _BEFORE_ Scilab 6.0.")
// FIXME : Do not forget to remove me.
return 0;
}
*/
int GetCommand ( char *str)
{
-#pragma warning("GetCommand is deprecated. It will be removed _BEFORE_ Scilab 6.0.")
+#pragma message("WARNING : GetCommand is deprecated. It will be removed _BEFORE_ Scilab 6.0.")
// FIXME : Do not forget to remove me.
return 0;
}
/*--------------------------------------------------------------------------*/
int ismenu(void)
{
-#pragma warning("ismenu is deprecated. It will be removed _BEFORE_ Scilab 6.0.")
+#pragma message("WARNING : ismenu is deprecated. It will be removed _BEFORE_ Scilab 6.0.")
// FIXME : Do not forget to remove me.
return 0;
}
/* menu/button info for Scilab */
int C2F(getmen)(char * btn_cmd,int * lb, int * entry)
{
-#pragma warning("C2F(getmen) is deprecated. It will be removed _BEFORE_ Scilab 6.0.")
+#pragma message("WARNING : C2F(getmen) is deprecated. It will be removed _BEFORE_ Scilab 6.0.")
// FIXME : Do not forget to remove me.
return 0;
}
#include "yaspio.hxx"
-#define SCILAB_START "/etc/scilab.start"
+#define SCILAB_START L"/etc/scilab.start"
Timer _timer;
**
** Parse the given file and create the AST.
*/
-void parseFileTask(Parser *parser, bool timed, const char* file_name, const char* prog_name)
+void parseFileTask(Parser *parser, bool timed, const wchar_t* file_name, const wchar_t* prog_name)
{
#ifdef DEBUG
std::cerr << "*** Processing " << file_name << " file..." << std::endl;
**
** Parse the given command and create the AST.
*/
-void parseCommandTask(Parser *parser, bool timed, char *command)
+void parseCommandTask(Parser *parser, bool timed, wchar_t *command)
{
#ifdef DEBUG
std::cerr << "*** Processing [" << command << "]..." << std::endl;
if (tree)
{
- ast::PrintVisitor printMe = *new ast::PrintVisitor(std::cout);
+ ast::PrintVisitor printMe = *new ast::PrintVisitor(std::wcout);
tree->accept(printMe);
}
{
tree->accept(*exec);
}
- catch(string sz)
+ catch(wstring sz)
{
- YaspWrite((char *) sz.c_str());
- YaspWrite("\n");
+ YaspWriteW(sz.c_str());
+ YaspWriteW(L"\n");
}
delete exec;
{
return;
Parser parse;
- string stSCI = ConfigVariable::getSCIPath();
+ wstring stSCI = ConfigVariable::getSCIPath();
stSCI += SCILAB_START;
- parse.parseFile(stSCI, "");
+ parse.parseFile(stSCI, L"");
if(parse.getExitStatus() != Parser::Succeded)
{
- YaspWrite(parse.getErrorMessage());
- YaspWrite("Failed to parse scilab.start");
+ YaspWriteW(parse.getErrorMessage());
+ YaspWriteW(L"Failed to parse scilab.start");
return;
}
function test_run(varargin)
-
+
lhs = argn(1);
rhs = argn(2);
-
+
// test type
type_filter = "all_tests"; // By default, lauch nonreg tests AND unitary tests
skip_mat = []; // The list of test to skip
-
+
// =========================================================================
// Print test_run help
// =========================================================================
-
+
if (rhs >= 3) & (~ isempty(grep(varargin(3),"help"))) then
example = test_examples();
printf("%s\n",example);
return;
end
-
+
// =======================================================
// Gestion des types de tests à lancer
// =======================================================
-
+
global MACOSX;
global LINUX;
-
+
if getos() <> 'Windows' then
OSNAME = unix_g('uname');
MACOSX = (strcmpi(OSNAME,"darwin") == 0);
MACOSX = %F;
LINUX = %F;
end
-
+
global testsuite;
testsuite = testsuite_new();
-
+
if rhs >= 3 then
-
+
option_mat = varargin(3);
-
+
if (or(option_mat == "unit_tests") & or(option_mat == "nonreg_tests")) | (or(option_mat == "all_tests") ) then
type_filter = "all_tests";
-
+
elseif or(option_mat == "unit_tests") then
type_filter = "unit_tests";
-
+
elseif or(option_mat == "nonreg_tests") then
type_filter = "nonreg_tests";
end
-
+
if or(option_mat == "skip_tests") then
skip_mat = varargin(2);
end
-
+
end
-
+
// =======================================================
// Stacksize management
// =======================================================
-
+
gstacksize(10000000);
stacksize(10000000);
-
+
// =======================================================
// Gestion des tests à lancer
// =======================================================
-
+
if (rhs == 0) ..
- | ((rhs == 1) & (varargin(1)==[])) ..
- | (((rhs == 2)|(rhs == 3)) & (varargin(1)==[]) & (varargin(2)==[])) then
-
+ | ((rhs == 1) & (varargin(1)==[])) ..
+ | (((rhs == 2)|(rhs == 3)) & (varargin(1)==[]) & (varargin(2)==[])) then
+
// No input argument
// test_run()
// test_run([])
// => Launch each test of each module
-
+
module_list = getmodules();
module_list = gsort(module_list,"lr","i");
-
+
for i=1:size(module_list,"*")
module = module_new();
module = module_set_name(module,module_list(i))
tests = get_tests_from_module(module,type_filter,skip_mat);
testsuite = testsuite_add_tests( testsuite, tests );
end
-
+
elseif (rhs == 1) ..
- | ((rhs == 2) & (varargin(2)==[])) ..
- | ((rhs == 3) & (varargin(2)==[])) ..
- | ( ~ isempty(skip_mat)) then
-
+ | ((rhs == 2) & (varargin(2)==[])) ..
+ | ((rhs == 3) & (varargin(2)==[])) ..
+ | ( ~ isempty(skip_mat)) then
+
// One input argument
// test_run(<module_name>)
// test_run([<module_name_1>,<module_name_2>])
-
+
// varargin(1) = [<module_name_1>,<module_name_2>]
-
+
module_mat = varargin(1);
-
+
// test_run([<module_name_1>,<module_name_2>])
-
+
for i=1:size(module_mat,"*")
-
+
module = module_new();
module = module_set_name(module,module_mat(i))
-
- // It's a scilab internal module
+
+ // It's a scilab internal module
if with_module(module.items(1)) then
module = module_set_path(module,pathconvert(SCI+"/modules/"+module.items(1),%F));
-
- // It's an external module
+
+ // It's an external module
elseif isdir(module.items(1)) then
module = module_set_path(module,pathconvert(module.items(1),%F));
-
- // It's an error
+
+ // It's an error
else
error(sprintf(gettext("%s is not an installed module or toolbox"),module_mat(i)));
end
-
+
tests = get_tests_from_module(module,type_filter,skip_mat);
-
+
testsuite = testsuite_add_tests( testsuite , tests);
-
+
end
-
+
elseif (rhs == 2) | (rhs == 3) then
-
+
// Two input arguments
// test_run(<module_name>,<test_name>)
// test_run(<module_name>,[<test_name_1>,<test_name_2>] )
-
+
// varargin(1) = <module_name> ==> string 1x1
// varargin(2) = <test_name_1> ==> mat nl x nc
-
+
module_in = varargin(1);
test_mat = varargin(2);
-
+
if ((or(size(module_in) <> [1,1])) & (test_mat <> [])) then
-
+
example = test_examples();
err = ["" ; msprintf(gettext("%s: Wrong size for input argument."),"test_run") ; "" ; example ];
printf("%s\n",err);
return;
end
-
+
module = module_new();
module = module_set_name(module,module_in)
-
+
// It's a scilab internal module
if with_module(module.items(1)) then
module = module_set_path(module,pathconvert(SCI+"/modules/"+module.items(1),%F));
-
- // It's an external module
+
+ // It's an external module
elseif isdir(module.items(1)) then
module = module_set_path(module,pathconvert(module.items(1),%F));
-
- // It's an error
+
+ // It's an error
else
error(sprintf(gettext("%s is not an installed module or toolbox"),module.items(1)));
end
-
+
for i=1:size(test_mat,"*")
-
+
types = ["unit_tests";"nonreg_tests"]
my_tests = list();
-
+
for j=1:size(types,"*")
-
+
if (type_filter<>"all_tests") & (type_filter<>types(j)) then
continue;
end
-
+
// Get the list of directories where search
-
+
test_directory_path = module.path + "/tests/" + types(j);
for k=2:size(module.items,"*")
test_directory_path = test_directory_path + "/" + module.items(k);
end
-
+
// The main directory doesn't exist, continue the loop
-
+
if ~ isdir(test_directory_path) then
continue;
end
-
+
test_main_directory = directory_new();
test_main_directory = directory_set_type(test_main_directory,types(j));
test_main_directory = directory_set_module(test_main_directory,module);
test_main_directory = directory_set_path(test_main_directory,test_directory_path);
-
+
test_directories = get_directories(test_main_directory);
-
+
for k=1:size(test_directories)
-
+
this_directory = test_directories(k);
-
+
test = st_new();
test = st_set_name( test , test_mat(i) );
test = st_set_module( test , this_directory.module );
test = st_set_type( test , types(j) );
test = st_set_path( test , pathconvert( this_directory.path + "/" + test.name + ".tst" , %F ) );
-
+
if ~ isempty( fileinfo(test.path) ) then
test = st_analyse(test);
my_tests($+1) = test;
end
-
+
end
-
+
end
-
+
if size(my_tests) == 0 then
error(sprintf(gettext("The test ""%s"" is not available from the ""%s"" module"),test_mat(i),module.name));
end
-
+
testsuite = testsuite_add_tests(testsuite,my_tests);
-
+
end
-
+
else
error(msprintf(gettext('%s: Wrong number of input arguments.'),"test_run"));
end
-
+
// =========================================================================
// Gestion des options
// =========================================================================
-
+
if rhs >= 3 then
-
+
// Mode
-
+
if grep(option_mat,"mode_nw") <> [] then
testsuite = testsuite_set_WM(testsuite,"NW");
end
-
+
if grep(option_mat,"mode_nwni") <> [] then
testsuite = testsuite_set_WM(testsuite,"NWNI");
end
-
+
// Reference
-
+
if grep(option_mat,"no_check_ref") <> [] then
testsuite = testsuite_set_reference(testsuite,"skip")
end
-
+
if grep(option_mat,"create_ref") <> [] then
testsuite = testsuite_set_reference(testsuite,"create")
end
-
+
// Error Output
-
+
if grep(option_mat,"no_check_error_output") <> [] then
testsuite = testsuite_set_EO(testsuite,"skip")
end
-
+
// Enable long-time tests
-
+
if grep(option_mat,"disable_lt") <> [] then
testsuite = testsuite_set_LT(testsuite,"skip")
end
-
+
if grep(option_mat,"enable_lt") <> [] then
testsuite = testsuite_set_LT(testsuite,"enable")
end
-
+
end
-
+
// =========================================================================
// List test
// =========================================================================
-
+
if (rhs >= 3) & (~ isempty(grep(option_mat,"list"))) then
testsuite_list(testsuite);
clearglobal testsuite;
return;
-
- // =========================================================================
- // Test launch
- // =========================================================================
-
+
+ // =========================================================================
+ // Test launch
+ // =========================================================================
+
else
testsuite_run(testsuite);
clearglobal testsuite;
return;
end
-
+
endfunction
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function my_tests = get_tests_from_module(module,type_filter,skip_mat)
-
+
my_types = ["unit_tests","nonreg_tests"];
-
+
// 1st action : build the list of directories to explore
// test_type : {"all_tests"|"unit_tests"|"nonreg_tests"}
-
+
// Example of a directory :
// path: "/home/robert/scilab/modules/time/tests/unit_tests/date"
// type: "unit_tests"
// module: "time|date"
-
+
my_directories = list();
-
+
for i=1:size(my_types,"*")
-
+
if (type_filter == "all_tests") | (type_filter == my_types(i)) then
-
+
directory = directory_new();
directory = directory_set_type(directory,my_types(i));
directory = directory_set_module(directory,module);
-
+
directory_path = module.path+"/tests/"+my_types(i);
module_items = module.items;
-
+
for j=2:size(module_items,"*")
directory_path = directory_path + "/" + module_items(j);
end
-
+
directory = directory_set_path(directory,directory_path);
-
+
if isdir(directory.path) then
my_directories = lstcat( my_directories , get_directories(directory) );
end
end
end
-
+
// 2nd action : Build the list of tests
// Example of a test :
// name: "bug_793"
// path: "/home/robert/scilab/modules/time/tests/nonreg_tests/bug_793.tst"
// type: "nonreg_tests"
// module: "time"
-
+
my_tests = list();
-
+
for i=1:length(my_directories)
-
+
directory = my_directories(i);
tests_in = get_tests_from_directory(directory.path);
tests_out = list();
-
+
for j=1:length(tests_in)
test = tests_in(j);
if or(test.name==skip_mat) then
test = st_analyse(test);
tests_out($+1) = test;
end
-
+
my_tests = lstcat( my_tests , tests_out );
-
+
end
-
+
endfunction
//-----------------------------------------------------------------------------
function tests = get_tests_from_directory(directory)
-
+
tests = list();
-
+
if isdir(directory) then
test_mat = gsort(basename(listfiles(directory+"/*.tst")),"lr","i");
for i=1:size(test_mat,"*")
tests($+1) = this_test;
end
end
-
+
endfunction
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function directories = get_directories(directory)
-
+
this_directory_type = directory.type;
-
+
directories = list();
directories($+1) = directory;
-
+
items = gsort(listfiles(directory.path),"lr","i");
-
+
for i=1:size(items,"*")
if isdir(pathconvert(directory.path) + items(i)) then
-
+
new_module = module_new();
new_module = module_set_name( new_module , directory.module.name + "|" + items(i) );
new_module = module_set_path( new_module , pathconvert(directory.path) + items(i) );
-
+
new_dir = directory_new();
new_dir = directory_set_path(new_dir,pathconvert(directory.path) + items(i));
new_dir = directory_set_module(new_dir,new_module);
new_dir = directory_set_type(new_dir,directory.type)
-
+
directories = lstcat( directories , get_directories(new_dir) );
end
end
-
+
endfunction
//-----------------------------------------------------------------------------
function dia_out = remove_headers(dia_in)
-
+
dia_out = dia_in;
-
+
body_start = grep(dia_out,"// <-- HEADER END -->");
-
+
if body_start<>[] then
dia_out(1:body_start(1)) = [];
end
-
+
body_end = grep(dia_out,"// <-- FOOTER START -->");
-
+
if body_end<>[] then
[dia_nl,dia_nc] = size(dia);
dia_out(body_end(1):dia_nl) = [];
end
-
+
return;
-
+
endfunction
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function example = test_examples()
-
+
example = [ sprintf("Examples :\n\n") ];
-
+
example = [ example ; sprintf("// Launch all tests\n") ];
example = [ example ; sprintf("test_run();\n") ];
example = [ example ; sprintf("test_run([]);\n") ];
example = [ example ; sprintf("test_run([],[],''help'');\n") ];
example = [ example ; sprintf("test_run([],[],[''no_check_ref'',''mode_nw'']);\n") ];
example = [ example ; "" ];
-
+
endfunction
// =============================================================================
// -----------------------------------------------------------------------------
function st = st_new()
-
+
st = tlist([ "T_SINGLETEST" ..
- "name" ..
- "type" ..
- "path" ..
- "module" ..
- "skip" ..
- "content" ..
- "interactive" ..
- "notyetfixed" ..
- "longtime" .. // needs long-time duration
- "reopened" ..
- "platform" ..
- "language" ..
- "jvm_mandatory" ..
- "graphic" ..
- "mode" .. // NW, NWNI, GUI
- "reference" .. // check, create, skip
- "error_output" .. // check, skip
- "try_catch" ..
- "path_dia" .. // diary file
- "path_dia_ref" .. // reference file
- "tmp_tst" .. // diary file
- "tmp_dia" .. // reference file
- "tmp_res" .. // diary file
- "tmp_err" .. // reference file
- "status" .. // status
- "xcos" .. // xcos test ?
- "cmd" .. // command to launch
- ] );
-
+ "name" ..
+ "type" ..
+ "path" ..
+ "module" ..
+ "skip" ..
+ "content" ..
+ "interactive" ..
+ "notyetfixed" ..
+ "longtime" .. // needs long-time duration
+ "reopened" ..
+ "platform" ..
+ "language" ..
+ "jvm_mandatory" ..
+ "graphic" ..
+ "mode" .. // NW, NWNI, GUI
+ "reference" .. // check, create, skip
+ "error_output" .. // check, skip
+ "try_catch" ..
+ "path_dia" .. // diary file
+ "path_dia_ref" .. // reference file
+ "tmp_tst" .. // diary file
+ "tmp_dia" .. // reference file
+ "tmp_res" .. // diary file
+ "tmp_err" .. // reference file
+ "status" .. // status
+ "xcos" .. // xcos test ?
+ "cmd" .. // command to launch
+ ] );
+
// Default values
st.skip = %F;
st.interactive = %F;
st.try_catch = %T;
st.error_output = "check";
st.reference = "check";
-
+
st.path_dia = "";
st.path_dia_ref = "";
st.tmp_dia = "";
st.tmp_res = "";
st.tmp_err = "";
-
+
st.cmd = "";
-
+
st.content = "";
-
+
st.status = status_new();
st.xcos = %F;
-
+
endfunction
// setters
// -----------------------------------------------------------------------------
function st = st_set_name(st,name)
-
+
st.name = name;
-
+
st.tmp_tst = pathconvert( TMPDIR + "/" + name + ".tst" , %F);
st.tmp_dia = pathconvert( TMPDIR + "/" + name + ".dia.tmp" , %F);
st.tmp_res = pathconvert( TMPDIR + "/" + name + ".res" , %F);
endfunction
function st = st_set_path(st,path)
-
+
st.path = path;
basepath = strsubst(path,"/\.tst$/","","r");
st.path_dia_ref = basepath + ".dia.ref";
-
+
// Reference file management OS by OS
if getos() == 'Windows' then
altreffile = [ basepath+".win.dia.ref" ];
else
altreffile = [ basepath+".unix.dia.ref" ];
end
-
+
for i=1:size(altreffile,"*")
if ~ isempty(fileinfo(altreffile(i))) then
st.path_dia_ref = altreffile(i);
end
end
-
+
endfunction
function st = st_set_module(st,module)
// -----------------------------------------------------------------------------
function st_show(st)
-
+
if st.skip then st_skip = "Yes"; else st_skip = "No"; end
if st.interactive then st_interactive = "Yes"; else st_interactive = "No"; end
if st.notyetfixed then st_notyetfixed = "Yes"; else st_notyetfixed = "No"; end
mprintf(" type = %s\n" ,st.type);
mprintf(" module = %s\n" ,st.module.name);
mprintf("\n");
-
+
mprintf("Test paths :\n");
mprintf(" path = %s\n" ,st.path);
mprintf(" path_dia = %s\n" ,st.path_dia);
mprintf(" tmp_res = %s\n" ,st.tmp_res);
mprintf(" tmp_err = %s\n" ,st.tmp_err);
mprintf("\n");
-
+
mprintf("Test features :\n");
mprintf(" skip = %s\n" ,st_skip);
mprintf(" interactive = %s\n" ,st_interactive);
mprintf(" try_catch = %s\n" ,st_try_catch);
mprintf(" xcos = %s\n" ,st_xcos);
mprintf("\n");
-
+
mprintf("Test scilab cmd :\n");
mprintf(" cmd = %s\n" ,st.cmd);
mprintf("\n");
-
+
module_show(test.module);
status_show(test.status);
-
+
endfunction
// Analyse
// -----------------------------------------------------------------------------
function st = st_analyse(st)
-
+
if typeof(st) <> "T_SINGLETEST" then
error(msprintf(gettext("%s: Wrong type for input argument #%d: %s expected.\n"),"st_analyse","T_SINGLETEST",1));
end
-
+
if isempty( fileinfo(st.path) ) then
error(msprintf(gettext("%s: The test ''%s'' doesn''t exist or is not read available.\n"),"st_analyse",st.path));
end
-
+
// Get the test content
st = st_set_content(st,mgetl(st.path));
-
+
// Test status
// =========================================================================
-
+
if ~ isempty( grep(st.content,"<-- NOT FIXED -->") ) then
st = st_set_notyetfixed(st,%T);
end
-
+
if ~ isempty( grep(st.content,"<-- REOPENED -->") ) then
st = st_set_reopened(st,%T);
end
-
+
// platform
// =========================================================================
-
+
if ~ isempty( grep(st.content,"<-- WINDOWS ONLY -->") ) then
st = st_set_platform(st,"windows");
end
-
+
if ~ isempty( grep(st.content,"<-- LINUX ONLY -->") ) then
st = st_set_platform(st,"linux");
end
-
+
if ~ isempty( grep(st.content,"<-- MACOSX ONLY -->") ) then
st = st_set_platform(st,"macosx");
end
-
+
if ~ isempty( grep(st.content,"<-- MACOSX ONLY -->") ) then
st = st_set_platform(st,"macosx");
end
-
+
// Test execution
// =========================================================================
-
+
if ~ isempty( grep(st.content,"<-- INTERACTIVE TEST -->") ) then
st = st_set_interactive(st,%T);
end
-
+
if ~ isempty( grep(st.content,"<-- LONG TIME EXECUTION -->") ) then
st = st_set_longtime(st,%T);
end
-
+
if ~ isempty( grep(st.content,"<-- TEST WITH GRAPHIC -->") ) then
st = st_set_graphic(st,%T);
st = st_set_jvm_mandatory(st,%T);
st = st_set_mode(st,"NW");
end
-
+
if ~ isempty( grep(st.content,"<-- JVM NOT MANDATORY -->") ) then
st = st_set_jvm_mandatory(st,%F);
st = st_set_mode(st,"NWNI");
end
-
+
if ~ isempty( grep(st.content,"<-- XCOS TEST -->") ) then
st = st_set_xcos(st,%T);
st = st_set_jvm_mandatory(st,%T);
end
// Language
// =========================================================================
-
+
if ~ isempty( grep(st.content,"<-- FRENCH IMPOSED -->") ) then
st = st_set_language(st,"fr_FR");
end
-
+
if ~ isempty( grep(st.content,"<-- ENGLISH IMPOSED -->") ) then
st = st_set_language(st,"en_US");
end
-
+
// Test building
// =========================================================================
-
+
if ~ isempty( grep(st.content,"<-- NO TRY CATCH -->") ) then
st = st_set_try_catch(st,%F);
end
-
+
// Test result
// =========================================================================
-
+
if ~ isempty( grep(st.content,"<-- NO CHECK ERROR OUTPUT -->") ) then
st = st_set_error_output(st,"skip");
end
-
+
if ~ isempty( grep(st.content,"<-- NO CHECK REF -->") ) then
st = st_set_reference(st,"skip");
end
-
+
endfunction
//-----------------------------------------------------------------------------
function st = st_run(st)
-
+
//Reset standard globals
rand("seed",0);
rand("uniform");
-
+
st.status = status_new();
-
+
// Case where the test is skipped
// =========================================================================
-
+
// The test is interactive
-
+
if st.interactive then
st.status = status_set_id(st.status,10);
st.status = status_set_message(st.status,"skipped : interactive test");
return;
end
-
+
// The test needs long-time duration
-
+
if st.longtime & (testsuite.longtime == "skip") then
st.status = status_set_id(st.status,10);
st.status = status_set_message(st.status,"skipped : Long time duration");
return;
end
-
+
// The bug is not yet fixed
-
+
if st.notyetfixed then
st.status = status_set_id(st.status,10);
st.status = status_set_message(st.status,"skipped : not yet fixed");
return;
end
-
+
// The bug is reopenned
-
+
if st.reopened then
st.status = status_set_id(st.status,10);
st.status = status_set_message(st.status,"skipped : Bug reopened");
return;
end
-
+
// The test cannot be launched on this platform
-
+
if (st.platform=="windows") & (getos() <> 'Windows') then
st.status = status_set_id(st.status,10);
st.status = status_set_message(st.status,"skipped : Windows only");
return;
end
-
+
if (st.platform=="unix") & getos() == 'Windows' then
st.status = status_set_id(st.status,10);
st.status = status_set_message(st.status,"skipped : Unix only");
return;
end
-
+
if (st.platform=="linux") & (~LINUX) then
st.status = status_set_id(status,10);
st.status = status_set_message(status,"skipped : Linux only");
return;
end
-
+
if (st.platform=="macosx") & (~MACOSX) then
st.status = status_set_id(st.status,10);
st.status = status_set_message(st.status,"skipped : MacOSX only");
return;
end
-
+
// The test launches some graphic windows
-
+
if st.graphic & (testsuite.wanted_mode == "NWNI") then
st.status = status_set_id(st.status,10);
st.status = status_set_message(st.status,"skipped : Test with graphic");
return;
end
-
+
// Build the test
// =========================================================================
-
+
txt = st.content;
-
+
// Do some modification in tst file
txt = strsubst(txt,"pause,end" ,"bugmes();quit;end");
txt = strsubst(txt,"pause, end","bugmes();quit;end");
txt = strsubst(txt,"pause; end","bugmes();quit;end");
txt = strsubst(txt,"-->","@#>"); //to avoid suppression of input --> with prompts
txt = strsubst(txt,"halt();","");
-
+
// Test header
-
+
head = [ ...
- "// <-- HEADER START -->"; ...
- "mode(3);" ; ...
- "lines(28,72);"; ...
- "lines(0);" ; ...
- "function %onprompt" ; ...
- "quit;" ; ...
- "endfunction" ; ...
- "deff(''[]=bugmes()'',''write(%io(2),''''error on test'''')'');" ; ...
- "predef(''all'');" ; ...
- "tmpdirToPrint = msprintf(''TMPDIR1=''''%s''''\n'',TMPDIR);" ...
+ "// <-- HEADER START -->"; ...
+ "mode(3);" ; ...
+ "lines(28,72);"; ...
+ "lines(0);" ; ...
+ "function %onprompt" ; ...
+ "quit;" ; ...
+ "endfunction" ; ...
+ "deff(''[]=bugmes()'',''write(%io(2),''''error on test'''')'');" ; ...
+ "predef(''all'');" ; ...
+ "tmpdirToPrint = msprintf(''TMPDIR1=''''%s''''\n'',TMPDIR);" ...
]
-
+
if st.xcos then
head = [ head ; "loadScicosLibs();"];
end
-
+
if st.try_catch then
head = [ head ; "try" ];
end
-
- head = [ ...
- head ; ...
- "diary(''"+st.tmp_dia+"'');"; ...
- "write(%io(2),tmpdirToPrint);"; ...
- "// <-- HEADER END -->" ...
- ];
-
+
+ head = [head ; "diary(''"+st.tmp_dia+"'');" ; "write(%io(2),tmpdirToPrint);" ; "// <-- HEADER END -->"];
+
// Test footer
-
+
tail = [ "// <-- FOOTER START -->" ];
-
+
if st.try_catch then
- tail = [ tail; ...
- "catch"; ...
- " errmsg = ""<--""+""Error on the test script file""+""-->"";"; ...
- " printf(""%s\n"",errmsg);"; ...
- " lasterror()"; ...
- "end"; ...
- ];
- end
-
+ tail = [ tail ; "catch" ; " errmsg = ""<--""+""Error on the test script file""+""-->"";" ; " printf(""%s\n"",errmsg);" ; " lasterror()" ; "end"];
+ end
+
tail = [ tail; "diary(0);" ];
-
+
if st.graphic then
tail = [ tail; "xdel(winsid());sleep(1000);" ];
end
-
+
tail = [ tail; "exit;" ; "// <-- FOOTER END -->" ];
-
+
// Assembly
-
+
txt = [head;
- txt;
- tail];
-
+ txt;
+ tail];
+
// Build the command
// =========================================================================
-
+
// Gestion de l'emplacement de bin/scilab
// -------------------------------------------------------------------------
-
+
if (getos() <> 'Windows') & (fileinfo(SCI+"/bin/scilab")==[]) then
SCI_BIN = strsubst(SCI,'share/scilab','');
else
SCI_BIN = SCI;
end
-
+
// Mode Argument (NW, NWNI, GUI)
// -------------------------------------------------------------------------
-
+
if testsuite.wanted_mode == "NW" then
mode_arg = "-nw";
-
+
elseif testsuite.wanted_mode == "NWNI" then
mode_arg = "-nwni";
-
+
else
if st.mode == "NWNI" then
mode_arg = "-nwni";
mode_arg = "-nw";
end
end
-
+
// Language Argument (en_US, fr_FR, ... )
// -------------------------------------------------------------------------
-
+
if st.language == "any" then
language_arg = "";
elseif getos() == 'Windows' then
else
language_arg = "LANG=" + st.language + " ; ";
end
-
+
// Assembly
// -------------------------------------------------------------------------
-
+
if getos() == 'Windows' then
test_cmd = "( """+SCI_BIN+"\bin\scilex.exe"+""""+" "+mode_arg+" "+language_arg+" -nb -f """+st.tmp_tst+""" > """+st.tmp_res+""" ) 2> """+st.tmp_err+"""";
else
test_cmd = "( "+language_arg+" "+SCI_BIN+"/bin/scilab "+mode_arg+" -nb -f "+st.tmp_tst+" > "+st.tmp_res+" ) 2> "+st.tmp_err;
end
-
+
st= st_set_cmd(st,test_cmd);
-
+
// Remove the previous tmp files
// =========================================================================
-
+
if ~ isempty(fileinfo(st.tmp_tst)) then
deletefile(st.tmp_tst);
end
-
+
if ~ isempty(fileinfo(st.tmp_dia)) then
deletefile(st.tmp_dia);
end
-
+
if ~ isempty(fileinfo(st.tmp_res)) then
deletefile(st.tmp_res);
end
-
+
if ~ isempty(fileinfo(st.tmp_err)) then
deletefile(st.tmp_err);
end
-
-
+
+
// Write the tmp test file
// =========================================================================
mputl(txt,st.tmp_tst);
-
-
+
+
// Launch the test exec
// =========================================================================
host(st.cmd);
-
-
-
+
+
+
// First Check : error output
// =========================================================================
-
+
if (st.error_output == "check") & (testsuite.error_output == "check") then
-
+
tmp_errfile_info = fileinfo(st.tmp_err);
-
+
if ( (tmp_errfile_info <> []) & (tmp_errfile_info(1)<>0) ) then
st.status = status_set_id(st.status,5);
st.status = status_set_message(st.status,"failed : error_output not empty");
return;
end
end
-
+
// Get the dia file
dia = mgetl(st.tmp_dia);
-
+
// To get TMPDIR value
tmpdir1_line = grep(dia,"TMPDIR1");
execstr(dia(tmpdir1_line));
-
+
//Check for execution errors
if st.try_catch & grep(dia,"<--Error on the test script file-->")<>[] then
details = [ sprintf(" Check the following file : \n - %s",st.tmp_dia); ..
- sprintf(" Or launch the following command : \n - exec %s;",st.path) ];
+ sprintf(" Or launch the following command : \n - exec %s;",st.path) ];
st.status = status_set_id(st.status,3);
st.status = status_set_message(st.status,"failed : premature end of the test script");
st.status = status_set_details(st.status,details);
return;
end
-
+
// Remove Header and Footer
dia = remove_headers(dia);
-
+
//Check for execution errors
dia_tmp = dia;
dia_tmp(grep(dia_tmp,"//")) = []; // remove commented lines
-
+
if st.try_catch & grep(dia_tmp,"!--error")<>[] then
details = [ sprintf(" Check the following file : \n - %s",st.tmp_dia); ..
- sprintf(" Or launch the following command : \n - exec %s;",st.path) ];
+ sprintf(" Or launch the following command : \n - exec %s;",st.path) ];
st.status = status_set_id(st.status,1);
st.status = status_set_message(st.status,"failed : the string (!--error) has been detected");
st.status = status_set_details(st.status,details);
return;
end
-
-
+
+
if grep(dia_tmp,"error on test")<>[] then
details = [ sprintf(" Check the following file : \n - %s",st.tmp_dia); ..
- sprintf(" Or launch the following command : \n - exec %s;",st.path) ];
+ sprintf(" Or launch the following command : \n - exec %s;",st.path) ];
st.status = status_set_id(st.status,2);
st.status = status_set_message(st.status, "failed : one or several tests failed");
st.status = status_set_details(st.status,details);
return;
end
-
-
+
+
if tmpdir1_line == [] then
st.status = status_set_id(st.status,6);
st.status = status_set_message(st.status, "failed : the dia file is not correct");
st.status = status_set_details(st.status,sprintf(" Check the following file : \n - %s",st.tmp_dia));
return;
end
-
-
-
+
+
+
// Check the reference file only if check_ref (i.e. for the whole
// test sequence) is true and this_check_ref (i.e. for the specific current .tst)
// is true.
-
+
if (st.reference=="check") & (testsuite.reference=="check") then
if isempty(fileinfo(st.path_dia_ref)) then
st.status = status_set_id(st.status,5);
return;
end
end
-
+
// Comparaison ref <--> dia
-
+
if ( (st.reference=="check") & (testsuite.reference=="check") ) | (testsuite.reference=="create") then
-
+
// Do some modification in dia file
dia(grep(dia,"write(%io(2),tmpdirToPrint"))= [];
dia(grep(dia,"TMPDIR1")) = [];
dia(grep(dia,"diary(0)")) = [];
-
+
dia = strsubst(dia,TMPDIR ,"TMPDIR");
dia = strsubst(dia,TMPDIR1,"TMPDIR");
-
+
if getos() == 'Windows' then
dia = strsubst(dia,strsubst(TMPDIR ,"\","/"),"TMPDIR");
dia = strsubst(dia,strsubst(TMPDIR1,"\","/"),"TMPDIR");
dia = strsubst(dia,getshortpathname(TMPDIR) ,"TMPDIR");
dia = strsubst(dia,getshortpathname(TMPDIR1),"TMPDIR");
end
-
+
dia = strsubst(dia,SCI,"SCI");
-
+
if getos() == 'Windows' then
dia = strsubst(dia,strsubst(SCI ,"\","/"),"SCI");
dia = strsubst(dia,strsubst(SCI ,"/","\"),"SCI");
dia = strsubst(dia,strsubst(getshortpathname(SCI) ,"\","/"),"SCI");
dia = strsubst(dia,getshortpathname(SCI) ,"SCI");
end
-
+
//suppress the prompts
dia = strsubst(dia,"-->" ,"");
dia = strsubst(dia,"@#>" ,"-->");
dia = strsubst(dia,"-1->","");
-
+
//standardise number display
-
+
// strsubst(dia," .","0.");
// strsubst(dia,"-.","-0.")
// strsubst(dia,"E+","D+");
// strsubst(dia,"E-","D-");
-
+
//not to change the ref files
dia = strsubst(dia,"bugmes();return","bugmes();quit");
-
+
if testsuite.reference=="create" then
-
+
// Delete previous .dia.ref file
if fileinfo(st.path_dia_ref) <> [] then
deletefile(st.path_dia_ref)
end
-
+
mputl(dia,st.path_dia_ref);
-
+
st.status = status_set_id(st.status,20);
st.status = status_set_message(st.status,"passed : ref created");
return;
-
+
else
-
+
// write down the resulting dia file
mputl(dia,st.path_dia);
-
+
//Check for diff with the .ref file
-
+
[u,ierr] = mopen(st.path_dia_ref,"r");
if ierr== 0 then //ref file exists
-
+
ref=mgetl(u);
mclose(u)
-
+
// suppress blank (diff -nw)
-
+
dia = strsubst(dia,' ','')
ref = strsubst(ref,' ','')
-
+
dia(find(dia=='')) = [];
ref(find(ref=='')) = [];
-
+
dia(find(dia=='')) = [];
ref(find(ref=='')) = [];
-
+
dia( find(part(dia,(1:2))=="//") ) = [];
ref( find(part(ref,(1:2))=="//") ) = [];
-
+
if or(ref<>dia) then
st.status = status_set_id(st.status,4);
st.status = status_set_message(st.status,"failed : dia and ref are not equal");
st.status = status_set_details(st.status,sprintf(" Compare the following files : \n - %s\n - %s",st.path_dia,st.path_dia_ref));
return;
end
-
+
else
error(sprintf(gettext("The ref file (%s) doesn''t exist"),st.path_dia_ref));
end
end
-
+
end
-
+
st.status = status_set_id(st.status,0);
st.status = status_set_message(st.status,"passed");
-
+
return;
-
+
endfunction
// -----------------------------------------------------------------------------
function md = module_new()
-
- md = tlist([ "T_MODULE" ..
- "name" ..
- "path" ..
- "items" ] );
-
+ md = tlist([ "T_MODULE" "name" "path" "items" ] );
endfunction
// setters
// -----------------------------------------------------------------------------
function module_show(module)
- mprintf("Module :\n");
- mprintf(" name = %s\n" ,module.name);
- mprintf(" path = %s\n" ,module.path);
- mprintf(" items = %s\n" ,module.items);
- mprintf("\n");
+ mprintf("Module :\n");
+ mprintf(" name = %s\n" ,module.name);
+ mprintf(" path = %s\n" ,module.path);
+ mprintf(" items = %s\n" ,module.items);
+ mprintf("\n");
endfunction
// -----------------------------------------------------------------------------
function directory = directory_new()
-
- directory = tlist([ "T_DIRECTORY" ..
- "path" ..
- "module" ..
- "type" ..
- ]);
-
+ directory = tlist([ "T_DIRECTORY" "path" "module" "type"]);
endfunction
// setters
// -----------------------------------------------------------------------------
function testsuite = testsuite_new()
-
- testsuite = tlist([ "T_TESTSUITE" ..
- "items" ..
- "current_mode" .. // NW, NWNI, GUI
- "wanted_mode" .. // NW, NWNI, GUI
- "reference" .. // check, create, skip
- "error_output" .. // check, skip
- "longtime" .. // enable, skip
- ]);
-
+
+ testsuite = tlist([ "T_TESTSUITE" "items" "current_mode" "wanted_mode" "reference" "error_output" "longtime"]);
+
testsuite.items = list();
-
+
// Default values
-
+
if and(getscilabmode() <> ["NW";"STD"]) then
testsuite.current_mode = "NWNI";
else
testsuite.current_mode = "NW";
end
-
+
testsuite.wanted_mode = "";
testsuite.reference = "check";
testsuite.error_output = "check";
testsuite.longtime = "skip";
-
+
endfunction