]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/Table/TableFunction.py
Revert BaseTools: PYTHON3 migration
[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
f7496d71 4# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
40d841f6 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
1ccc4d89 17from __future__ import absolute_import\r
30fdf114 18import Common.EdkLogger as EdkLogger\r
855698fb 19from Table.Table import Table\r
5a57246e 20from Common.StringUtils import ConvertToSqlString\r
30fdf114
LG
21\r
22## TableFunction\r
23#\r
24# This class defined a table used for function\r
f7496d71 25#\r
30fdf114
LG
26# @param Table: Inherited from Table class\r
27#\r
28class TableFunction(Table):\r
29 def __init__(self, Cursor):\r
30 Table.__init__(self, Cursor)\r
31 self.Table = 'Function'\r
f7496d71 32\r
30fdf114
LG
33 ## Create table\r
34 #\r
35 # Create table Function\r
36 #\r
37 # @param ID: ID of a Function\r
38 # @param Header: Header of a Function\r
f7496d71 39 # @param Modifier: Modifier of a Function\r
30fdf114
LG
40 # @param Name: Name of a Function\r
41 # @param ReturnStatement: ReturnStatement of a Funciont\r
42 # @param StartLine: StartLine of a Function\r
43 # @param StartColumn: StartColumn of a Function\r
44 # @param EndLine: EndLine of a Function\r
45 # @param EndColumn: EndColumn of a Function\r
46 # @param BodyStartLine: StartLine of a Function body\r
47 # @param BodyStartColumn: StartColumn of a Function body\r
48 # @param BelongsToFile: The Function belongs to which file\r
49 # @param FunNameStartLine: StartLine of a Function name\r
50 # @param FunNameStartColumn: StartColumn of a Function name\r
51 #\r
52 def Create(self):\r
53 SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,\r
54 Header TEXT,\r
55 Modifier VARCHAR,\r
56 Name VARCHAR NOT NULL,\r
57 ReturnStatement VARCHAR,\r
58 StartLine INTEGER NOT NULL,\r
59 StartColumn INTEGER NOT NULL,\r
60 EndLine INTEGER NOT NULL,\r
61 EndColumn INTEGER NOT NULL,\r
62 BodyStartLine INTEGER NOT NULL,\r
63 BodyStartColumn INTEGER NOT NULL,\r
64 BelongsToFile SINGLE NOT NULL,\r
65 FunNameStartLine INTEGER NOT NULL,\r
66 FunNameStartColumn INTEGER NOT NULL\r
67 )""" % self.Table\r
68 Table.Create(self, SqlCommand)\r
69\r
70 ## Insert table\r
71 #\r
72 # Insert a record into table Function\r
73 #\r
74 # @param ID: ID of a Function\r
75 # @param Header: Header of a Function\r
f7496d71 76 # @param Modifier: Modifier of a Function\r
30fdf114
LG
77 # @param Name: Name of a Function\r
78 # @param ReturnStatement: ReturnStatement of a Funciont\r
79 # @param StartLine: StartLine of a Function\r
80 # @param StartColumn: StartColumn of a Function\r
81 # @param EndLine: EndLine of a Function\r
82 # @param EndColumn: EndColumn of a Function\r
83 # @param BodyStartLine: StartLine of a Function body\r
84 # @param BodyStartColumn: StartColumn of a Function body\r
85 # @param BelongsToFile: The Function belongs to which file\r
86 # @param FunNameStartLine: StartLine of a Function name\r
87 # @param FunNameStartColumn: StartColumn of a Function name\r
88 #\r
89 def Insert(self, Header, Modifier, Name, ReturnStatement, StartLine, StartColumn, EndLine, EndColumn, BodyStartLine, BodyStartColumn, BelongsToFile, FunNameStartLine, FunNameStartColumn):\r
90 self.ID = self.ID + 1\r
91 (Header, Modifier, Name, ReturnStatement) = ConvertToSqlString((Header, Modifier, Name, ReturnStatement))\r
92 SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s, %s, %s)""" \\r
93 % (self.Table, self.ID, Header, Modifier, Name, ReturnStatement, StartLine, StartColumn, EndLine, EndColumn, BodyStartLine, BodyStartColumn, BelongsToFile, FunNameStartLine, FunNameStartColumn)\r
94 Table.Insert(self, SqlCommand)\r
95\r
96 return self.ID\r