]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Table/TableFunction.py
Check In tool source code based on Build tool project revision r1655.
[mirror_edk2.git] / BaseTools / Source / Python / Table / TableFunction.py
diff --git a/BaseTools/Source/Python/Table/TableFunction.py b/BaseTools/Source/Python/Table/TableFunction.py
new file mode 100644 (file)
index 0000000..c013d0d
--- /dev/null
@@ -0,0 +1,95 @@
+## @file\r
+# This file is used to create/update/query/erase table for functions\r
+#\r
+# Copyright (c) 2008, Intel Corporation\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+\r
+##\r
+# Import Modules\r
+#\r
+import Common.EdkLogger as EdkLogger\r
+from Table import Table\r
+from Common.String import ConvertToSqlString\r
+\r
+## TableFunction\r
+#\r
+# This class defined a table used for function\r
+# \r
+# @param Table:       Inherited from Table class\r
+#\r
+class TableFunction(Table):\r
+    def __init__(self, Cursor):\r
+        Table.__init__(self, Cursor)\r
+        self.Table = 'Function'\r
+    \r
+    ## Create table\r
+    #\r
+    # Create table Function\r
+    #\r
+    # @param ID:                  ID of a Function\r
+    # @param Header:              Header of a Function\r
+    # @param Modifier:            Modifier of a Function \r
+    # @param Name:                Name of a Function\r
+    # @param ReturnStatement:     ReturnStatement of a Funciont\r
+    # @param StartLine:           StartLine of a Function\r
+    # @param StartColumn:         StartColumn of a Function\r
+    # @param EndLine:             EndLine of a Function\r
+    # @param EndColumn:           EndColumn of a Function\r
+    # @param BodyStartLine:       StartLine of a Function body\r
+    # @param BodyStartColumn:     StartColumn of a Function body\r
+    # @param BelongsToFile:       The Function belongs to which file\r
+    # @param FunNameStartLine:    StartLine of a Function name\r
+    # @param FunNameStartColumn:  StartColumn of a Function name\r
+    #\r
+    def Create(self):\r
+        SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,\r
+                                                       Header TEXT,\r
+                                                       Modifier VARCHAR,\r
+                                                       Name VARCHAR NOT NULL,\r
+                                                       ReturnStatement VARCHAR,\r
+                                                       StartLine INTEGER NOT NULL,\r
+                                                       StartColumn INTEGER NOT NULL,\r
+                                                       EndLine INTEGER NOT NULL,\r
+                                                       EndColumn INTEGER NOT NULL,\r
+                                                       BodyStartLine INTEGER NOT NULL,\r
+                                                       BodyStartColumn INTEGER NOT NULL,\r
+                                                       BelongsToFile SINGLE NOT NULL,\r
+                                                       FunNameStartLine INTEGER NOT NULL,\r
+                                                       FunNameStartColumn INTEGER NOT NULL\r
+                                                      )""" % self.Table\r
+        Table.Create(self, SqlCommand)\r
+\r
+    ## Insert table\r
+    #\r
+    # Insert a record into table Function\r
+    #\r
+    # @param ID:                  ID of a Function\r
+    # @param Header:              Header of a Function\r
+    # @param Modifier:            Modifier of a Function \r
+    # @param Name:                Name of a Function\r
+    # @param ReturnStatement:     ReturnStatement of a Funciont\r
+    # @param StartLine:           StartLine of a Function\r
+    # @param StartColumn:         StartColumn of a Function\r
+    # @param EndLine:             EndLine of a Function\r
+    # @param EndColumn:           EndColumn of a Function\r
+    # @param BodyStartLine:       StartLine of a Function body\r
+    # @param BodyStartColumn:     StartColumn of a Function body\r
+    # @param BelongsToFile:       The Function belongs to which file\r
+    # @param FunNameStartLine:    StartLine of a Function name\r
+    # @param FunNameStartColumn:  StartColumn of a Function name\r
+    #\r
+    def Insert(self, Header, Modifier, Name, ReturnStatement, StartLine, StartColumn, EndLine, EndColumn, BodyStartLine, BodyStartColumn, BelongsToFile, FunNameStartLine, FunNameStartColumn):\r
+        self.ID = self.ID + 1\r
+        (Header, Modifier, Name, ReturnStatement) = ConvertToSqlString((Header, Modifier, Name, ReturnStatement))\r
+        SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s, %s, %s)""" \\r
+                                    % (self.Table, self.ID, Header, Modifier, Name, ReturnStatement, StartLine, StartColumn, EndLine, EndColumn, BodyStartLine, BodyStartColumn, BelongsToFile, FunNameStartLine, FunNameStartColumn)\r
+        Table.Insert(self, SqlCommand)\r
+\r
+        return self.ID\r