1 /*!
2 * \file bindings/python/mfront/AbstractDSL.cxx
3 * \brief
4 * \author Thomas Helfer
5 * \date 04 mai 2016
6 * \copyright Copyright (C) 2006-2018 CEA/DEN, EDF R&D. All rights
7 * reserved.
8 * This project is publicly released under either the GNU GPL Licence
9 * or the CECILL-A licence. A copy of thoses licences are delivered
10 * with the sources of TFEL. CEA or EDF may also distribute this
11 * project under specific licensing conditions.
12 */
13
14 #include<set>
15 #include<memory>
16 #include"TFEL/Python/SharedPtr.hxx"
17 #include<boost/python.hpp>
18
19 #include"MFront/FileDescription.hxx"
20 #include"MFront/TargetsDescription.hxx"
21 #include"MFront/AbstractDSL.hxx"
22
setInterfaces(mfront::AbstractDSL & dsl,const std::vector<std::string> & i)23 static void setInterfaces(mfront::AbstractDSL& dsl,
24 const std::vector<std::string>& i)
25 {
26 std::set<std::string> inames(i.begin(),i.end());
27 dsl.setInterfaces(inames);
28 }
29
30 static std::vector<std::string>
getKeywordsList(mfront::AbstractDSL & dsl)31 getKeywordsList(mfront::AbstractDSL& dsl)
32 {
33 std::vector<std::string> keys;
34 dsl.getKeywordsList(keys);
35 return keys;
36 }
37
38 static void
analyseFile1(mfront::AbstractDSL & dsl,const std::string & f)39 analyseFile1(mfront::AbstractDSL& dsl,
40 const std::string& f)
41 {
42 dsl.analyseFile(f,{},{});
43 }
44
45 static void
analyseFile2(mfront::AbstractDSL & dsl,const std::string & f,const std::vector<std::string> & args)46 analyseFile2(mfront::AbstractDSL& dsl,
47 const std::string& f,
48 const std::vector<std::string>& args)
49 {
50 dsl.analyseFile(f,args,{});
51 }
52
53 static void
analyseFile3(mfront::AbstractDSL & dsl,const std::string & f,const std::vector<std::string> & args,const std::map<std::string,std::string> & s)54 analyseFile3(mfront::AbstractDSL& dsl,
55 const std::string& f,
56 const std::vector<std::string>& args,
57 const std::map<std::string,std::string>& s)
58 {
59 dsl.analyseFile(f,args,s);
60 }
61
declareAbstractDSL()62 void declareAbstractDSL(){
63 using namespace boost::python;
64 using namespace mfront;
65 enum_<AbstractDSL::DSLTarget>("DSLTarget")
66 .value("MATERIALPROPERTYDSL",AbstractDSL::MATERIALPROPERTYDSL)
67 .value("BEHAVIOURDSL",AbstractDSL::BEHAVIOURDSL)
68 .value("MODELDSL",AbstractDSL::MODELDSL)
69 ;
70 class_<AbstractDSL,std::shared_ptr<AbstractDSL>,
71 boost::noncopyable>("AbstractDSL",no_init)
72 .def("getTargetType",&AbstractDSL::getTargetType)
73 .def("getFileDescription",&AbstractDSL::getFileDescription,
74 return_internal_reference<>())
75 .def("analyseFile",analyseFile1)
76 .def("analyseFile",analyseFile2)
77 .def("analyseFile",analyseFile3)
78 .def("analyseString",&AbstractDSL::analyseString)
79 .def("getTargetsDescription",&AbstractDSL::getTargetsDescription,
80 return_internal_reference<>())
81 .def("generateOutputFiles",&AbstractDSL::generateOutputFiles)
82 .def("setInterfaces",&setInterfaces)
83 .def("getKeywordsList",&getKeywordsList)
84 ;
85 }
86