def dump(self, path=''): data = '''#ifndef %s #define %s %s #endif // %s ''' % (self.guard, self.guard, self.content, self.guard) filename = os.path.join(path, self.name + '.hpp') f = GenFile.gfopen(filename, 'w') f.write(data)
def make(name): f = GenFile.gfopen(os.path.join(headersDir, "SVGAnimated%s.hpp"%name),'w') f.write('''// generated by makeAnimated.py #ifndef __svg_Animated%s__ #define __svg_Animated%s__ #include <w3c/svg/Animated.hpp> '''%(name,name)) f.write('''#include <w3c/svg/SVG%s.hpp> namespace svg { typedef Animated<SVG%s> SVGAnimated%s; } #endif // __svg_Animated%s__ '''%(name,name,name, name))
def dump(self, path=""): data = """#ifndef %s #define %s %s #endif // %s """ % ( self.guard, self.guard, self.content, self.guard, ) filename = os.path.join(path, self.name + ".hpp") f = GenFile.gfopen(filename, "w") f.write(data)
def toto(name, cpptype): f=GenFile.gfopen(config.genDir+"/SVG%s.hpp"%name, 'w') content = '''// generated by makeBasicTypes.py #ifndef __svg_SVG%s__ #define __svg_SVG%s__ namespace svg { '''%(name,name) content = content + '\ttypedef %s SVG%s;'%(cpptype, name) content = content + ''' } #endif // __svg_SVG%s__ '''%(name) f.write(content)
def make(name): f = GenFile.gfopen(os.path.join(headersDir, "SVGAnimated%s.hpp" % name), 'w') f.write('''// generated by makeAnimated.py #ifndef __svg_Animated%s__ #define __svg_Animated%s__ #include <w3c/svg/Animated.hpp> ''' % (name, name)) f.write('''#include <w3c/svg/SVG%s.hpp> namespace svg { typedef Animated<SVG%s> SVGAnimated%s; } #endif // __svg_Animated%s__ ''' % (name, name, name, name))
def toto(name, cpptype): f = GenFile.gfopen(config.genDir + "/SVG%s.hpp" % name, 'w') content = '''// generated by makeBasicTypes.py #ifndef __svg_SVG%s__ #define __svg_SVG%s__ namespace svg { ''' % (name, name) content = content + '\ttypedef %s SVG%s;' % (cpptype, name) content = content + ''' } #endif // __svg_SVG%s__ ''' % (name) f.write(content)
def make(name, as_pointer=0): f = GenFile.gfopen(os.path.join(headersDir, "SVG%sList.hpp" % name), 'w') f.write('''// generated by makeList.py #ifndef __svg_%sList__ #define __svg_%sList__ #include <w3c/svg/SVGList.hpp> ''' % (name, name)) typename = name if as_pointer != 0: typename = typename + '*' f.write('''#include <w3c/svg/SVG%s.hpp> namespace svg { typedef SVGList<SVG%s> SVG%sList; } #endif // __svg_%sList__ ''' % (name, typename, name, name))
def make(name, as_pointer=0): f = GenFile.gfopen(os.path.join(headersDir, "SVG%sList.hpp"%name),'w') f.write('''// generated by makeList.py #ifndef __svg_%sList__ #define __svg_%sList__ #include <w3c/svg/SVGList.hpp> '''%(name,name)) typename = name if as_pointer!=0: typename=typename+'*' f.write('''#include <w3c/svg/SVG%s.hpp> namespace svg { typedef SVGList<SVG%s> SVG%sList; } #endif // __svg_%sList__ '''%(name, typename,name, name))
element_cpp_name = make_cpp_string_name(element_dtd_name) includes = includes + '#include <w3c/svg/SVG%sElement.hpp>\n'%(classname) output = output + ''' if (nodeName==svg::%s_element_string) { svg::SVG%sElement *elem = new svg::SVG%sElement; elem->parse(node, owner, viewport); return elem; } else '''%(element_cpp_name, classname, classname) strdef_output = strdef_output + 'STRDEF(%s,"%s")\n'%(classname, element_dtd_name) output = output +''' { std::cerr << "element " << nodeName.c_str() << " (type " << node.getNodeType() << ") unknown" << std::endl; return 0; } } ''' #f = open(config.genDir+"/getNextSVGElement.cpp", 'w') #f.write('// generated by genSvgElement.py\n\n' + includes +'\n'+output) f= GenFile.gfopen(config.genDir+"/strings_def.hpp", 'w') f.write('// generated by genSvgElement.py\n\n' + strdef_output) header = cppHeader.Header("svg", prefix='svg') header.add_content('// generated by genSvgElement.py\n\n' + includes) header.dump(path=config.genDir)
import re, string import config import GenFile colorstxt = open(config.svgl_home+'/share/colors.txt','r').read() color_re = re.compile("(\w+)\s+rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)") output='// generated by makeColors.py\n' beg=0 pos=0 while 1: m = color_re.search(colorstxt, beg) if m==None: break; beg = m.end() colorname = m.group(1) red=int(m.group(2)) green=int(m.group(3)) blue=int(m.group(4)) output = output +'COLORDEF(%s,%s,%s,%s)\n'%(colorname, red,green,blue) #f = open(config.genDir+"/colors_def.hpp",'w') f = GenFile.gfopen(config.genDir+"/colors_def.hpp") f.write(output)
# elif isinstance(entity_type, parse_attr.attr_named_entity_ref): # entity_name = cppName.make_cppname(entity_type.entity_name) # includes = includes + '#include <svg/%s.hpp>\n'%(entity_name) # fields = fields + '\t\t\t%s %s;\n'%(entity_name, cppName.make_cppname(entity_type.name)) # elif isinstance(entity_type, parse_attr.attr_named_enum): # entity_name = cppName.make_cppname(entity_type.name) includestr = "#include <w3c/svg/strings.hpp>\n" for i in includes: includestr = includestr + "#include <w3c/svg/%s.hpp>\n" % i # f = open(config.genDir+"/makeEnumType.cpp", "w") f = GenFile.gfopen(config.genDir + "/makeEnumType.cpp") f.write( """ // generated by genAttributeParser.py #include <w3c/svg/makeEnumType.hpp> #include <iostream> namespace svgl { using namespace svg; """ + output_cpp_read + """ """ + output_cpp_print + """
'''%(classname) #%(element_string) header.add_content('// generated by genFromIdl.py\n' + fwd_decl_str + '\n'+includestr+fwd_element_str+'\n' + output) header.dump(path=config.genDir) #header = cppHeader.Header("svg") #content='// generated by genFromIdl.py\n' #for h in all_headers: # content=content+'#include <svg/%s.hpp>\n'%(h) #header.add_content(content) #header.dump(path=config.genDir) if len(destructors): includestr='' f = GenFile.gfopen(config.genDir+'/destructors.cpp', 'w') output_cpp='' for i in destructors: output_cpp = output_cpp + ' %s::~%s() {}\n'%(i.name, i.name) includestr = includestr + '#include<w3c/svg/%s.hpp>\n'%(i.name) f.write('// generated by genFromIdl.py\n' + includestr+''' namespace svg { '''+output_cpp + ''' } ''') #includestr='''#include <svg/getNextSVGElement.hpp> ##include <dom/DOM.hpp> #'''
import re, string import config import GenFile colorstxt = open(config.svgl_home + '/share/colors.txt', 'r').read() color_re = re.compile("(\w+)\s+rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)") output = '// generated by makeColors.py\n' beg = 0 pos = 0 while 1: m = color_re.search(colorstxt, beg) if m == None: break beg = m.end() colorname = m.group(1) red = int(m.group(2)) green = int(m.group(3)) blue = int(m.group(4)) output = output + 'COLORDEF(%s,%s,%s,%s)\n' % (colorname, red, green, blue) #f = open(config.genDir+"/colors_def.hpp",'w') f = GenFile.gfopen(config.genDir + "/colors_def.hpp") f.write(output)
# includes = includes +'#include <svg/%s.hpp>\n'%(entity_name) #elif isinstance(entity_type, parse_attr.attr_named_entity_ref): # entity_name = cppName.make_cppname(entity_type.entity_name) # includes = includes + '#include <svg/%s.hpp>\n'%(entity_name) # fields = fields + '\t\t\t%s %s;\n'%(entity_name, cppName.make_cppname(entity_type.name)) #elif isinstance(entity_type, parse_attr.attr_named_enum): # entity_name = cppName.make_cppname(entity_type.name) includestr = '#include <w3c/svg/strings.hpp>\n' for i in includes: includestr = includestr + '#include <w3c/svg/%s.hpp>\n' % i #f = open(config.genDir+"/makeEnumType.cpp", "w") f = GenFile.gfopen(config.genDir + "/makeEnumType.cpp") f.write(''' // generated by genAttributeParser.py #include <w3c/svg/makeEnumType.hpp> #include <iostream> namespace svgl { using namespace svg; ''' + output_cpp_read + ''' ''' + output_cpp_print + ''' } ''') #f = open(config.genDir+"/makeEnumType.hpp", "w") f = GenFile.gfopen(config.genDir + "/makeEnumType.hpp")
includes = includes + '#include <w3c/svg/SVG%sElement.hpp>\n' % (classname) output = output + ''' if (nodeName==svg::%s_element_string) { svg::SVG%sElement *elem = new svg::SVG%sElement; elem->parse(node, owner, viewport); return elem; } else ''' % (element_cpp_name, classname, classname) strdef_output = strdef_output + 'STRDEF(%s,"%s")\n' % (classname, element_dtd_name) output = output + ''' { std::cerr << "element " << nodeName.c_str() << " (type " << node.getNodeType() << ") unknown" << std::endl; return 0; } } ''' #f = open(config.genDir+"/getNextSVGElement.cpp", 'w') #f.write('// generated by genSvgElement.py\n\n' + includes +'\n'+output) f = GenFile.gfopen(config.genDir + "/strings_def.hpp", 'w') f.write('// generated by genSvgElement.py\n\n' + strdef_output) header = cppHeader.Header("svg", prefix='svg') header.add_content('// generated by genSvgElement.py\n\n' + includes) header.dump(path=config.genDir)
if len(print_output_cpps): for key,out in print_output_cpps.items(): print_output_cpp=print_output_cpp+out includestr='' for i in includes: includestr = includestr+'#include <w3c/svg/%s.hpp>\n'%i parse_includestr='''//#include <w3c/svg/makeEnumType.hpp> #include <svgl/parseHelper.hpp> //#include <w3c/dom/DOM.hpp> #include <w3c/svg/String.hpp> ''' f = GenFile.gfopen(config.genDir+"/ElementParseAttributesMethods.cpp", 'w') f.write('// generated by makeParseAttribute.py\n\n' + parse_includestr + includestr + ''' namespace svg { '''+ output_cpp +''' } ''') parse_includestr='''#include <w3c/svg/makeEnumType.hpp> #include <svgl/parseHelper.hpp> //#include <dom/DOM.hpp> #include <w3c/svg/String.hpp> #include <svgl/AnimateAdapter.hpp> #include <svgl/AnimateAdapterDouble.hpp>