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