]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/Table/TableFunction.py
BaseTools: Replace StandardError with Expression
[mirror_edk2.git] / BaseTools / Source / Python / Table / TableFunction.py
CommitLineData
30fdf114
LG
1## @file\r
2# This file is used to create/update/query/erase table for functions\r
3#\r
40d841f6
LG
4# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>\r
5# This program and the accompanying materials\r
30fdf114
LG
6# are licensed and made available under the terms and conditions of the BSD License\r
7# which accompanies this distribution. The full text of the license may be found at\r
8# http://opensource.org/licenses/bsd-license.php\r
9#\r
10# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12#\r
13\r
14##\r
15# Import Modules\r
16#\r
17import Common.EdkLogger as EdkLogger\r
18from Table import Table\r
5a57246e 19from Common.StringUtils import ConvertToSqlString\r
30fdf114
LG
20\r
21## TableFunction\r
22#\r
23# This class defined a table used for function\r
24# \r
25# @param Table: Inherited from Table class\r
26#\r
27class TableFunction(Table):\r
28 def __init__(self, Cursor):\r
29 Table.__init__(self, Cursor)\r
30 self.Table = 'Function'\r
31 \r
32 ## Create table\r
33 #\r
34 # Create table Function\r
35 #\r
36 # @param ID: ID of a Function\r
37 # @param Header: Header of a Function\r
38 # @param Modifier: Modifier of a Function \r
39 # @param Name: Name of a Function\r
40 # @param ReturnStatement: ReturnStatement of a Funciont\r
41 # @param StartLine: StartLine of a Function\r
42 # @param StartColumn: StartColumn of a Function\r
43 # @param EndLine: EndLine of a Function\r
44 # @param EndColumn: EndColumn of a Function\r
45 # @param BodyStartLine: StartLine of a Function body\r
46 # @param BodyStartColumn: StartColumn of a Function body\r
47 # @param BelongsToFile: The Function belongs to which file\r
48 # @param FunNameStartLine: StartLine of a Function name\r
49 # @param FunNameStartColumn: StartColumn of a Function name\r
50 #\r
51 def Create(self):\r
52 SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,\r
53 Header TEXT,\r
54 Modifier VARCHAR,\r
55 Name VARCHAR NOT NULL,\r
56 ReturnStatement VARCHAR,\r
57 StartLine INTEGER NOT NULL,\r
58 StartColumn INTEGER NOT NULL,\r
59 EndLine INTEGER NOT NULL,\r
60 EndColumn INTEGER NOT NULL,\r
61 BodyStartLine INTEGER NOT NULL,\r
62 BodyStartColumn INTEGER NOT NULL,\r
63 BelongsToFile SINGLE NOT NULL,\r
64 FunNameStartLine INTEGER NOT NULL,\r
65 FunNameStartColumn INTEGER NOT NULL\r
66 )""" % self.Table\r
67 Table.Create(self, SqlCommand)\r
68\r
69 ## Insert table\r
70 #\r
71 # Insert a record into table Function\r
72 #\r
73 # @param ID: ID of a Function\r
74 # @param Header: Header of a Function\r
75 # @param Modifier: Modifier of a Function \r
76 # @param Name: Name of a Function\r
77 # @param ReturnStatement: ReturnStatement of a Funciont\r
78 # @param StartLine: StartLine of a Function\r
79 # @param StartColumn: StartColumn of a Function\r
80 # @param EndLine: EndLine of a Function\r
81 # @param EndColumn: EndColumn of a Function\r
82 # @param BodyStartLine: StartLine of a Function body\r
83 # @param BodyStartColumn: StartColumn of a Function body\r
84 # @param BelongsToFile: The Function belongs to which file\r
85 # @param FunNameStartLine: StartLine of a Function name\r
86 # @param FunNameStartColumn: StartColumn of a Function name\r
87 #\r
88 def Insert(self, Header, Modifier, Name, ReturnStatement, StartLine, StartColumn, EndLine, EndColumn, BodyStartLine, BodyStartColumn, BelongsToFile, FunNameStartLine, FunNameStartColumn):\r
89 self.ID = self.ID + 1\r
90 (Header, Modifier, Name, ReturnStatement) = ConvertToSqlString((Header, Modifier, Name, ReturnStatement))\r
91 SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s, %s, %s)""" \\r
92 % (self.Table, self.ID, Header, Modifier, Name, ReturnStatement, StartLine, StartColumn, EndLine, EndColumn, BodyStartLine, BodyStartColumn, BelongsToFile, FunNameStartLine, FunNameStartColumn)\r
93 Table.Insert(self, SqlCommand)\r
94\r
95 return self.ID\r