public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Jaben Carsey <jaben.carsey@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>, Yonghong Zhu <yonghong.zhu@intel.com>
Subject: [PATCH v1 8/9] BaseTools: FdfParser - refactor functions to make static
Date: Fri, 13 Apr 2018 13:51:35 -0700	[thread overview]
Message-ID: <88f706cc2b907abdebee4396c4d6868bbc333d6b.1523652584.git.jaben.carsey@intel.com> (raw)
In-Reply-To: <cover.1523652583.git.jaben.carsey@intel.com>
In-Reply-To: <cover.1523652583.git.jaben.carsey@intel.com>

From: Jaben <jaben.carsey@intel.com>

make functions that doesn't use self into @staticmethod

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
 BaseTools/Source/Python/GenFds/FdfParser.py       | 11 ++++++-----
 BaseTools/Source/Python/GenFds/FfsInfStatement.py | 10 +++++-----
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 662c232c86e4..dce41701a510 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1131,7 +1131,8 @@ class FdfParser:
             self.__UndoToken()
             return False
 
-    def __Verify(self, Name, Value, Scope):
+    @staticmethod
+    def __Verify(Name, Value, Scope):
         if Scope in ['UINT64', 'UINT8']:
             ValueNumber = 0
             try:
@@ -3200,16 +3201,16 @@ class FdfParser:
                     raise Warning("expected value of %s" % Name, self.FileName, self.CurrentLineNumber)
                 Value = self.__Token
                 if Name == 'IMAGE_HEADER_INIT_VERSION':
-                    if self.__Verify(Name, Value, 'UINT8'):
+                    if FdfParser.__Verify(Name, Value, 'UINT8'):
                         FmpData.Version = Value
                 elif Name == 'IMAGE_INDEX':
-                    if self.__Verify(Name, Value, 'UINT8'):
+                    if FdfParser.__Verify(Name, Value, 'UINT8'):
                         FmpData.ImageIndex = Value
                 elif Name == 'HARDWARE_INSTANCE':
-                    if self.__Verify(Name, Value, 'UINT8'):
+                    if FdfParser.__Verify(Name, Value, 'UINT8'):
                         FmpData.HardwareInstance = Value
                 elif Name == 'MONOTONIC_COUNT':
-                    if self.__Verify(Name, Value, 'UINT64'):
+                    if FdfParser.__Verify(Name, Value, 'UINT64'):
                         FmpData.MonotonicCount = Value
                         if FmpData.MonotonicCount.upper().startswith('0X'):
                             FmpData.MonotonicCount = (long)(FmpData.MonotonicCount, 16)
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index 5364569b96d7..4f9936a97342 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -1011,7 +1011,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
                         if VfrUniOffsetList:
                             UniVfrOffsetFileName = os.path.join(self.OutputPath, self.BaseName + '.offset')
                             UniVfrOffsetFileSection = os.path.join(self.OutputPath, self.BaseName + 'Offset' + '.raw')
-                            self.__GenUniVfrOffsetFile (VfrUniOffsetList, UniVfrOffsetFileName)
+                            FfsInfStatement.__GenUniVfrOffsetFile (VfrUniOffsetList, UniVfrOffsetFileName)
                             UniVfrOffsetFileNameList = []
                             UniVfrOffsetFileNameList.append(UniVfrOffsetFileName)
                             """Call GenSection"""
@@ -1069,11 +1069,11 @@ class FfsInfStatement(FfsInfStatementClassObject):
     #
     #   Create parameter string for GenFfs
     #
-    #   @param  self        The object pointer
     #   @param  Rule        The rule object used to generate section
     #   @retval tuple       (FileType, Fixed, CheckSum, Alignment)
     #
-    def __GetGenFfsCmdParameter__(self, Rule):
+    @staticmethod
+    def __GetGenFfsCmdParameter__(Rule):
         result = tuple()
         result += ('-t', Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType])
         if Rule.Fixed != False:
@@ -1103,11 +1103,11 @@ class FfsInfStatement(FfsInfStatementClassObject):
     #
     #   Generate the offset file for the module which contain VFR or UNI file.
     #
-    #   @param  self                    The object pointer
     #   @param  VfrUniOffsetList        A list contain the VFR/UNI offsets in the EFI image file.
     #   @param  UniVfrOffsetFileName    The output offset file name.
     #
-    def __GenUniVfrOffsetFile(self, VfrUniOffsetList, UniVfrOffsetFileName):
+    @staticmethod
+    def __GenUniVfrOffsetFile(VfrUniOffsetList, UniVfrOffsetFileName):
 
         # Use a instance of StringIO to cache data
         fStringIO = StringIO.StringIO('')  
-- 
2.16.2.windows.1



  parent reply	other threads:[~2018-04-13 20:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-13 20:51 [PATCH v1 0/9] BaseTools: refactoring Jaben Carsey
2018-04-13 20:51 ` [PATCH v1 1/9] BaseTools: remove unused local variable Jaben Carsey
2018-04-13 20:51 ` [PATCH v1 2/9] BaseTools: change DscBuildData functions without need for self to staticmethod Jaben Carsey
2018-04-13 20:51 ` [PATCH v1 3/9] BaseTools: Remove unused functions from DscBuildData Jaben Carsey
2018-04-13 20:51 ` [PATCH v1 4/9] BaseTools: move RegEx compile out of loops Jaben Carsey
2018-04-13 20:51 ` [PATCH v1 5/9] BaseTools: use dictionary.get() when we have value if not found Jaben Carsey
2018-04-13 20:51 ` [PATCH v1 6/9] BaseTools: refactor DepexSection.GenSection Jaben Carsey
2018-04-13 20:51 ` [PATCH v1 7/9] BaseTools: FdfParser refactor to remove a dictionary Jaben Carsey
2018-04-13 20:51 ` Jaben Carsey [this message]
2018-04-13 20:51 ` [PATCH v1 9/9] BaseTools: FfsInfStatement - remove unused function Jaben Carsey
2018-04-17 13:18 ` [PATCH v1 0/9] BaseTools: refactoring Zhu, Yonghong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=88f706cc2b907abdebee4396c4d6868bbc333d6b.1523652584.git.jaben.carsey@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox