]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Table/TableFunction.py
ebaddc5fff159e8c55d19085e5293ec06d23afd4
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 import Common
.EdkLogger
as EdkLogger
18 from Table
.Table
import Table
19 from Common
.StringUtils
import ConvertToSqlString
23 # This class defined a table used for function
25 # @param Table: Inherited from Table class
27 class TableFunction(Table
):
28 def __init__(self
, Cursor
):
29 Table
.__init
__(self
, Cursor
)
30 self
.Table
= 'Function'
34 # Create table Function
36 # @param ID: ID of a Function
37 # @param Header: Header of a Function
38 # @param Modifier: Modifier of a Function
39 # @param Name: Name of a Function
40 # @param ReturnStatement: ReturnStatement of a Funciont
41 # @param StartLine: StartLine of a Function
42 # @param StartColumn: StartColumn of a Function
43 # @param EndLine: EndLine of a Function
44 # @param EndColumn: EndColumn of a Function
45 # @param BodyStartLine: StartLine of a Function body
46 # @param BodyStartColumn: StartColumn of a Function body
47 # @param BelongsToFile: The Function belongs to which file
48 # @param FunNameStartLine: StartLine of a Function name
49 # @param FunNameStartColumn: StartColumn of a Function name
52 SqlCommand
= """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
55 Name VARCHAR NOT NULL,
56 ReturnStatement VARCHAR,
57 StartLine INTEGER NOT NULL,
58 StartColumn INTEGER NOT NULL,
59 EndLine INTEGER NOT NULL,
60 EndColumn INTEGER NOT NULL,
61 BodyStartLine INTEGER NOT NULL,
62 BodyStartColumn INTEGER NOT NULL,
63 BelongsToFile SINGLE NOT NULL,
64 FunNameStartLine INTEGER NOT NULL,
65 FunNameStartColumn INTEGER NOT NULL
67 Table
.Create(self
, SqlCommand
)
71 # Insert a record into table Function
73 # @param ID: ID of a Function
74 # @param Header: Header of a Function
75 # @param Modifier: Modifier of a Function
76 # @param Name: Name of a Function
77 # @param ReturnStatement: ReturnStatement of a Funciont
78 # @param StartLine: StartLine of a Function
79 # @param StartColumn: StartColumn of a Function
80 # @param EndLine: EndLine of a Function
81 # @param EndColumn: EndColumn of a Function
82 # @param BodyStartLine: StartLine of a Function body
83 # @param BodyStartColumn: StartColumn of a Function body
84 # @param BelongsToFile: The Function belongs to which file
85 # @param FunNameStartLine: StartLine of a Function name
86 # @param FunNameStartColumn: StartColumn of a Function name
88 def Insert(self
, Header
, Modifier
, Name
, ReturnStatement
, StartLine
, StartColumn
, EndLine
, EndColumn
, BodyStartLine
, BodyStartColumn
, BelongsToFile
, FunNameStartLine
, FunNameStartColumn
):
90 (Header
, Modifier
, Name
, ReturnStatement
) = ConvertToSqlString((Header
, Modifier
, Name
, ReturnStatement
))
91 SqlCommand
= """insert into %s values(%s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s, %s, %s)""" \
92 % (self
.Table
, self
.ID
, Header
, Modifier
, Name
, ReturnStatement
, StartLine
, StartColumn
, EndLine
, EndColumn
, BodyStartLine
, BodyStartColumn
, BelongsToFile
, FunNameStartLine
, FunNameStartColumn
)
93 Table
.Insert(self
, SqlCommand
)