Peano
Loading...
Searching...
No Matches
DaStGenToLegacyTool.py
Go to the documentation of this file.
1# This file is part of the Peano project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3import os
5
6
7
8class DaStGenToLegacyTool(object):
9
10 """
11 Full qualified filename of jar file.
12 """
13 DaStGenJarFile = "~/git/DaStGen/DaStGen.jar"
14 __DaStGenArguments = "--plugin PeanoSnippetGenerator --naming Peano4NameTranslator "
15
16
17 """
18 This converter requires my good old DaStGen Java tool, writes a spec file for
19 DaStGen and finally invokes the tool.
20 """
21 def __init__(self,data):
22 self.data = data
23
24
26 return "peano4::stacks::STDVectorStack< " + self.data.get_full_qualified_type() + " >";
27
28
30 return "#include \"peano4/stacks/STDVectorStack.h\" \n \
31 #include \"" + self.data.namespace[-1] + "/" + self.data.name + ".h\""
32
33 __Template_Prologue = """
34#include "peano4/utils/Globals.h"
35
36// have to know whether we are using MPI
37#include "config.h"
38
39Constant: Dimensions;
40Packed-Type: short int;
41"""
42
43 def __get_file_name(self):
44 return self.data.name + ".def"
45
47 return self.data.subdirectory + self.data.namespace[-1] + "/" + self.__get_file_name()
48
49
50 __Template_DebugFlags = """
51 #ifdef PeanoDebug
52 persistent parallelise expose double debugX[Dimensions];
53 persistent parallelise expose double debugH[Dimensions];
54 #endif
55
56
57"""
58
59
61 directory = self.data.subdirectory + self.data.namespace[-1]
62 if not os.path.exists( directory ):
63 os.mkdir(directory)
64 print( "created directory " + directory + " for DaStGen legacy file" )
65
66 file = open( self.__get_full_qualified_file_name(), "w" )
68 file.write( "class " )
69 for i in self.data.namespace:
70 file.write( i )
71 file.write( "::" )
72 file.write( self.data.name )
73 file.write( " {\n" )
74
76
77 for i in self.data.attributes_double:
78 file.write( " persistent parallelise double " )
79 file.write( i )
80 file.write( ";\n" )
81
82 for i in self.data.attributes_integer:
83 file.write( " persistent parallelise int " )
84 file.write( i )
85 file.write( ";\n" )
86
87 for i in self.data.attributes_enum:
88 file.write( " enum " + i[0] + " {\n" )
89 file.write( " " )
90 for j in i[1]:
91 file.write( j )
92 if j!=i[1][-1]:
93 file.write( ", " )
94 else:
95 file.write( "\n" )
96 file.write( " };\n" )
97 file.write( " persistent packed parallelise " + i[0] + " " + i[0] + ";\n" )
98
99 file.write( "};\n\n\n" )
100
101
102 def construct_output(self,output):
103 """
104 Pass in a version of output. It is important that external tools are used
105 first before we start any compile or so. So I add them first.
106 """
108 output.makefile.add_cpp_file( self.data.subdirectory + self.data.namespace[-1] + "/" + self.data.name + ".cpp", generated=True )
109 output.add( peano4.output.InvokeExternalTool( "java -jar " + self.DaStGenJarFile + " " + self.__DaStGenArguments + " " + self.__get_file_name() + " .", self.data.subdirectory + self.data.namespace[-1] ), False )
110
construct_output(self, output)
Pass in a version of output.