]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Table/TableFunction.py
ee677cf1079e445b209490b1c40a9ac8e66dd2ef
2 # This file is used to create/update/query/erase table for functions
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
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.
17 from __future__
import absolute_import
18 import Common
.EdkLogger
as EdkLogger
19 from Table
.Table
import Table
20 from Common
.StringUtils
import ConvertToSqlString
24 # This class defined a table used for function
26 # @param Table: Inherited from Table class
28 class TableFunction(Table
):
29 def __init__(self
, Cursor
):
30 Table
.__init
__(self
, Cursor
)
31 self
.Table
= 'Function'
35 # Create table Function
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
53 SqlCommand
= """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
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
68 Table
.Create(self
, SqlCommand
)
72 # Insert a record into table Function
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
89 def Insert(self
, Header
, Modifier
, Name
, ReturnStatement
, StartLine
, StartColumn
, EndLine
, EndColumn
, BodyStartLine
, BodyStartColumn
, BelongsToFile
, FunNameStartLine
, FunNameStartColumn
):
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
)