Synopsis - Cross-Reference
File: Synopsis/Parsers/IDL/__init__.py1# 2# Copyright (C) 2003 Stefan Seefeld 3# All rights reserved. 4# Licensed to the public under the terms of the GNU LGPL (>= 2), 5# see the file COPYING for details. 6# 7 8"""Parser for IDL using omniidl for low-level parsing.""" 9 10from Synopsis.Processor import * 11import omni 12import os, os.path, tempfile 13 14class Parser(Processor): 15 16 preprocess = Parameter(True, 'whether or not to preprocess the input') 17 cppflags = Parameter([], 'list of preprocessor flags such as -I or -D') 18 primary_file_only = Parameter(True, 'should only primary file be processed') 19 base_path = Parameter('', 'path prefix to strip off of the file names') 20 21 def process(self, ir, **kwds): 22 23 self.set_parameters(kwds) 24 if not self.input: raise MissingArgument('input') 25 self.ir = ir 26 27 if self.preprocess: 28 29 from Synopsis.Parsers import Cpp 30 cpp = Cpp.Parser(base_path = self.base_path, 31 language = 'IDL', 32 flags = self.cppflags, 33 emulate_compiler = None) 34 35 for file in self.input: 36 37 i_file = file 38 if self.preprocess: 39 40 if self.output: 41 i_file = os.path.splitext(self.output)[0] + '.i' 42 else: 43 i_file = os.path.join(tempfile.gettempdir(), 44 'synopsis-%s.i'%os.getpid()) 45 self.ir = cpp.process(self.ir, 46 cpp_output = i_file, 47 input = [file], 48 primary_file_only = self.primary_file_only, 49 verbose = self.verbose, 50 debug = self.debug) 51 52 53 self.ir = omni.parse(self.ir, i_file, 54 os.path.abspath(file), 55 self.primary_file_only, 56 os.path.abspath(self.base_path) + os.sep, 57 self.verbose, 58 self.debug) 59 60 if self.preprocess: os.remove(i_file) 61 62 return self.output_and_return_ir() 63 64
Generated on Tue May 13 02:39:33 2008 by
synopsis (version 0.10)
synopsis (version 0.10)