[Lldb-commits] [lldb] r364946 - [swig] Define attribute(ref) instead of accessing swig internals.

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 2 10:25:20 PDT 2019


Author: jdevlieghere
Date: Tue Jul  2 10:25:20 2019
New Revision: 364946

URL: http://llvm.org/viewvc/llvm-project?rev=364946&view=rev
Log:
[swig] Define attribute(ref) instead of accessing swig internals.

As of SWIG 4.0, __swig_getmethods__ and __swig_setmethods__ are no
longer defined. The solution is to stop using these internal swig
dictionaries and use %attribute and %attributeref instead. I plan on
doing this incrementally, with this differential serving as an example.

Differential revision: https://reviews.llvm.org/D63530

Modified:
    lldb/trunk/scripts/interface/SBAddress.i
    lldb/trunk/scripts/interface/SBBlock.i
    lldb/trunk/scripts/interface/SBBreakpoint.i
    lldb/trunk/scripts/interface/SBCompileUnit.i
    lldb/trunk/scripts/interface/SBData.i
    lldb/trunk/scripts/interface/SBDeclaration.i
    lldb/trunk/scripts/interface/SBError.i
    lldb/trunk/scripts/interface/SBExecutionContext.i
    lldb/trunk/scripts/interface/SBFileSpec.i
    lldb/trunk/scripts/interface/SBFrame.i

Modified: lldb/trunk/scripts/interface/SBAddress.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBAddress.i?rev=364946&r1=364945&r2=364946&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBAddress.i (original)
+++ lldb/trunk/scripts/interface/SBAddress.i Tue Jul  2 10:25:20 2019
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+%include <attribute.i>
+
 namespace lldb {
 
 %feature("docstring",
@@ -162,39 +164,20 @@ public:
             '''Convert the address to an hex string'''
             return '0x%x' % int(self)
 
-        __swig_getmethods__["module"] = GetModule
-        if _newclass: module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) that this address resides within.''')
-
-        __swig_getmethods__["compile_unit"] = GetCompileUnit
-        if _newclass: compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) that this address resides within.''')
-
-        __swig_getmethods__["line_entry"] = GetLineEntry
-        if _newclass: line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line entry (lldb.SBLineEntry) that this address resides within.''')
-
-        __swig_getmethods__["function"] = GetFunction
-        if _newclass: function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) that this address resides within.''')
-
-        __swig_getmethods__["block"] = GetBlock
-        if _newclass: block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) that this address resides within.''')
-
-        __swig_getmethods__["symbol"] = GetSymbol
-        if _newclass: symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) that this address resides within.''')
-
-        __swig_getmethods__["offset"] = GetOffset
-        if _newclass: offset = property(GetOffset, None, doc='''A read only property that returns the section offset in bytes as an integer.''')
-
-        __swig_getmethods__["section"] = GetSection
-        if _newclass: section = property(GetSection, None, doc='''A read only property that returns an lldb object that represents the section (lldb.SBSection) that this address resides within.''')
-
-        __swig_getmethods__["file_addr"] = GetFileAddress
-        if _newclass: file_addr = property(GetFileAddress, None, doc='''A read only property that returns file address for the section as an integer. This is the address that represents the address as it is found in the object file that defines it.''')
-
-        __swig_getmethods__["load_addr"] = __get_load_addr_property__
-        __swig_setmethods__["load_addr"] = __set_load_addr_property__
-        if _newclass: load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. The setter resolves SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command) and not in Python based commands, or breakpoint commands.''')
+        load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. The setter resolves SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command) and not in Python based commands, or breakpoint commands.''')
 
     %}
 
 };
 
+%attributeref(lldb::SBAddress, lldb::SBModule, module, GetModule);
+%attributeref(lldb::SBAddress, lldb::SBCompileUnit, compile_unit, GetCompileUnit);
+%attributeref(lldb::SBAddress, lldb::SBLineEntry, line_entry, GetLineEntry);
+%attributeref(lldb::SBAddress, lldb::SBFunction, function, GetFunction);
+%attributeref(lldb::SBAddress, lldb::SBBlock, block, GetBlock);
+%attributeref(lldb::SBAddress, lldb::SBSymbol, symbol, GetSymbol);
+%attributeref(lldb::SBAddress, lldb::SBSection, section, GetSection);
+%attribute(lldb::SBAddress, lldb::addr_t, symbol, GetOffset);
+%attribute(lldb::SBAddress, lldb::addr_t, file_addr, GetFileAddress);
+
 } // namespace lldb

Modified: lldb/trunk/scripts/interface/SBBlock.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBBlock.i?rev=364946&r1=364945&r2=364946&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBBlock.i (original)
+++ lldb/trunk/scripts/interface/SBBlock.i Tue Jul  2 10:25:20 2019
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+%include <attribute.i>
+
 namespace lldb {
 
 %feature("docstring",
@@ -143,34 +145,17 @@ public:
         def get_call_site(self):
             return declaration(self.GetInlinedCallSiteFile(), self.GetInlinedCallSiteLine(), self.GetInlinedCallSiteColumn())
 
-        __swig_getmethods__["parent"] = GetParent
-        if _newclass: parent = property(GetParent, None, doc='''A read only property that returns the same result as GetParent().''')
-
-        __swig_getmethods__["first_child"] = GetFirstChild
-        if _newclass: first_child = property(GetFirstChild, None, doc='''A read only property that returns the same result as GetFirstChild().''')
-
-        __swig_getmethods__["call_site"] = get_call_site
-        if _newclass: call_site = property(get_call_site, None, doc='''A read only property that returns a lldb.declaration object that contains the inlined call site file, line and column.''')
-
-        __swig_getmethods__["sibling"] = GetSibling
-        if _newclass: sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''')
-
-        __swig_getmethods__["name"] = GetInlinedName
-        if _newclass: name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''')
-
-        __swig_getmethods__["inlined_block"] = GetContainingInlinedBlock
-        if _newclass: inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''')
-
-        __swig_getmethods__["range"] = get_ranges_access_object
-        if _newclass: range = property(get_ranges_access_object, None, doc='''A read only property that allows item access to the address ranges for a block by integer (range = block.range[0]) and by lldb.SBAdddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''')
-
-        __swig_getmethods__["ranges"] = get_ranges_array
-        if _newclass: ranges = property(get_ranges_array, None, doc='''A read only property that returns a list() object that contains all of the address ranges for the block.''')
-
-        __swig_getmethods__["num_ranges"] = GetNumRanges
-        if _newclass: num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''')
+        call_site = property(get_call_site, None, doc='''A read only property that returns a lldb.declaration object that contains the inlined call site file, line and column.''')
+        range = property(get_ranges_access_object, None, doc='''A read only property that allows item access to the address ranges for a block by integer (range = block.range[0]) and by lldb.SBAdddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''')
+        ranges = property(get_ranges_array, None, doc='''A read only property that returns a list() object that contains all of the address ranges for the block.''')
     %}
-
 };
 
+%attributeref(lldb::SBBlock, lldb::SBBlock, parent, GetParent);
+%attributeref(lldb::SBBlock, lldb::SBBlock, first_child, GetFirstChild);
+%attributeref(lldb::SBBlock, lldb::SBBlock, sibling, GetSibling);
+%attributeref(lldb::SBBlock, lldb::SBBlock, inlined_block, GetContainingInlinedBlock);
+%attribute(lldb::SBBlock, const char*, name, GetInlinedName);
+%attribute(lldb::SBBlock, uint32_t, num_ranges, GetNumRanges);
+
 } // namespace lldb

Modified: lldb/trunk/scripts/interface/SBBreakpoint.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBBreakpoint.i?rev=364946&r1=364945&r2=364946&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBBreakpoint.i (original)
+++ lldb/trunk/scripts/interface/SBBreakpoint.i Tue Jul  2 10:25:20 2019
@@ -7,6 +7,8 @@
 //===----------------------------------------------------------------------===//
 namespace lldb {
 
+%include <attribute.i>
+
 %feature("docstring",
 "Represents a logical breakpoint and its associated settings.
 
@@ -286,31 +288,18 @@ public:
             object.'''
             return self.GetNumLocations()
 
-        __swig_getmethods__["locations"] = get_breakpoint_location_list
-        if _newclass: locations = property(get_breakpoint_location_list, None, doc='''A read only property that returns a list() of lldb.SBBreakpointLocation objects for this breakpoint.''')
-
-        __swig_getmethods__["location"] = get_locations_access_object
-        if _newclass: location = property(get_locations_access_object, None, doc='''A read only property that returns an object that can access locations by index (not location ID) (location = bkpt.location[12]).''')
-
-        __swig_getmethods__["id"] = GetID
-        if _newclass: id = property(GetID, None, doc='''A read only property that returns the ID of this breakpoint.''')
-
-        __swig_getmethods__["enabled"] = IsEnabled
-        __swig_setmethods__["enabled"] = SetEnabled
-        if _newclass: enabled = property(IsEnabled, SetEnabled, doc='''A read/write property that configures whether this breakpoint is enabled or not.''')
-
-        __swig_getmethods__["one_shot"] = IsOneShot
-        __swig_setmethods__["one_shot"] = SetOneShot
-        if _newclass: one_shot = property(IsOneShot, SetOneShot, doc='''A read/write property that configures whether this breakpoint is one-shot (deleted when hit) or not.''')
-
-        __swig_getmethods__["num_locations"] = GetNumLocations
-        if _newclass: num_locations = property(GetNumLocations, None, doc='''A read only property that returns the count of locations of this breakpoint.''')
-
+        locations = property(get_breakpoint_location_list)
+        location = property(get_locations_access_object)
     %}
 
 
 };
 
+%attribute(lldb::SBBreakpoint, lldb::break_id_t, id, GetID);
+%attribute(lldb::SBBreakpoint, bool, enabled, IsEnabled, SetEnabled);
+%attribute(lldb::SBBreakpoint, bool, one_shot, IsOneShot, SetOneShot);
+%attribute(lldb::SBBreakpoint, size_t, num_locations, GetNumLocations);
+
 class SBBreakpointListImpl;
 
 class LLDB_API SBBreakpointList

Modified: lldb/trunk/scripts/interface/SBCompileUnit.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBCompileUnit.i?rev=364946&r1=364945&r2=364946&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBCompileUnit.i (original)
+++ lldb/trunk/scripts/interface/SBCompileUnit.i Tue Jul  2 10:25:20 2019
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+%include <attribute.i>
+
 namespace lldb {
 
 %feature("docstring",
@@ -125,13 +127,10 @@ public:
             '''Return the number of line entries in a lldb.SBCompileUnit
             object.'''
             return self.GetNumLineEntries()
-
-        __swig_getmethods__["file"] = GetFileSpec
-        if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns the same result an lldb object that represents the source file (lldb.SBFileSpec) for the compile unit.''')
-
-        __swig_getmethods__["num_line_entries"] = GetNumLineEntries
-        if _newclass: num_line_entries = property(GetNumLineEntries, None, doc='''A read only property that returns the number of line entries in a compile unit as an integer.''')
     %}
 };
 
+%attributeref(lldb::SBCompileUnit, lldb::SBFileSpec, file, GetFileSpec);
+%attribute(lldb::SBCompileUnit, uint32_t, num_line_entries, GetNumLineEntries);
+
 } // namespace lldb

Modified: lldb/trunk/scripts/interface/SBData.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBData.i?rev=364946&r1=364945&r2=364946&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBData.i (original)
+++ lldb/trunk/scripts/interface/SBData.i Tue Jul  2 10:25:20 2019
@@ -6,6 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+%include <attribute.i>
 
 namespace lldb {
 
@@ -264,78 +265,31 @@ public:
         def _read_all_double(self):
             return self._make_helper_double().all()
 
-        __swig_getmethods__["uint8"] = _make_helper_uint8
-        if _newclass: uint8 = property(_make_helper_uint8, None, doc='''A read only property that returns an array-like object out of which you can read uint8 values.''')
-
-        __swig_getmethods__["uint16"] = _make_helper_uint16
-        if _newclass: uint16 = property(_make_helper_uint16, None, doc='''A read only property that returns an array-like object out of which you can read uint16 values.''')
-
-        __swig_getmethods__["uint32"] = _make_helper_uint32
-        if _newclass: uint32 = property(_make_helper_uint32, None, doc='''A read only property that returns an array-like object out of which you can read uint32 values.''')
-
-        __swig_getmethods__["uint64"] = _make_helper_uint64
-        if _newclass: uint64 = property(_make_helper_uint64, None, doc='''A read only property that returns an array-like object out of which you can read uint64 values.''')
-
-        __swig_getmethods__["sint8"] = _make_helper_sint8
-        if _newclass: sint8 = property(_make_helper_sint8, None, doc='''A read only property that returns an array-like object out of which you can read sint8 values.''')
-
-        __swig_getmethods__["sint16"] = _make_helper_sint16
-        if _newclass: sint16 = property(_make_helper_sint16, None, doc='''A read only property that returns an array-like object out of which you can read sint16 values.''')
-
-        __swig_getmethods__["sint32"] = _make_helper_sint32
-        if _newclass: sint32 = property(_make_helper_sint32, None, doc='''A read only property that returns an array-like object out of which you can read sint32 values.''')
-
-        __swig_getmethods__["sint64"] = _make_helper_sint64
-        if _newclass: sint64 = property(_make_helper_sint64, None, doc='''A read only property that returns an array-like object out of which you can read sint64 values.''')
-
-        __swig_getmethods__["float"] = _make_helper_float
-        if _newclass: float = property(_make_helper_float, None, doc='''A read only property that returns an array-like object out of which you can read float values.''')
-
-        __swig_getmethods__["double"] = _make_helper_double
-        if _newclass: double = property(_make_helper_double, None, doc='''A read only property that returns an array-like object out of which you can read double values.''')
-
-        __swig_getmethods__["uint8s"] = _read_all_uint8
-        if _newclass: uint8s = property(_read_all_uint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint8 values.''')
-
-        __swig_getmethods__["uint16s"] = _read_all_uint16
-        if _newclass: uint16s = property(_read_all_uint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint16 values.''')
-
-        __swig_getmethods__["uint32s"] = _read_all_uint32
-        if _newclass: uint32s = property(_read_all_uint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint32 values.''')
-
-        __swig_getmethods__["uint64s"] = _read_all_uint64
-        if _newclass: uint64s = property(_read_all_uint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint64 values.''')
-
-        __swig_getmethods__["sint8s"] = _read_all_sint8
-        if _newclass: sint8s = property(_read_all_sint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint8 values.''')
-
-        __swig_getmethods__["sint16s"] = _read_all_sint16
-        if _newclass: sint16s = property(_read_all_sint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint16 values.''')
-
-        __swig_getmethods__["sint32s"] = _read_all_sint32
-        if _newclass: sint32s = property(_read_all_sint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint32 values.''')
-
-        __swig_getmethods__["sint64s"] = _read_all_sint64
-        if _newclass: sint64s = property(_read_all_sint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint64 values.''')
-
-        __swig_getmethods__["floats"] = _read_all_float
-        if _newclass: floats = property(_read_all_float, None, doc='''A read only property that returns an array with all the contents of this SBData represented as float values.''')
-
-        __swig_getmethods__["doubles"] = _read_all_double
-        if _newclass: doubles = property(_read_all_double, None, doc='''A read only property that returns an array with all the contents of this SBData represented as double values.''')
+        uint8 = property(_make_helper_uint8, None, doc='''A read only property that returns an array-like object out of which you can read uint8 values.''')
+        uint16 = property(_make_helper_uint16, None, doc='''A read only property that returns an array-like object out of which you can read uint16 values.''')
+        uint32 = property(_make_helper_uint32, None, doc='''A read only property that returns an array-like object out of which you can read uint32 values.''')
+        uint64 = property(_make_helper_uint64, None, doc='''A read only property that returns an array-like object out of which you can read uint64 values.''')
+        sint8 = property(_make_helper_sint8, None, doc='''A read only property that returns an array-like object out of which you can read sint8 values.''')
+        sint16 = property(_make_helper_sint16, None, doc='''A read only property that returns an array-like object out of which you can read sint16 values.''')
+        sint32 = property(_make_helper_sint32, None, doc='''A read only property that returns an array-like object out of which you can read sint32 values.''')
+        sint64 = property(_make_helper_sint64, None, doc='''A read only property that returns an array-like object out of which you can read sint64 values.''')
+        float = property(_make_helper_float, None, doc='''A read only property that returns an array-like object out of which you can read float values.''')
+        double = property(_make_helper_double, None, doc='''A read only property that returns an array-like object out of which you can read double values.''')
+        uint8s = property(_read_all_uint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint8 values.''')
+        uint16s = property(_read_all_uint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint16 values.''')
+        uint32s = property(_read_all_uint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint32 values.''')
+        uint64s = property(_read_all_uint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint64 values.''')
+        sint8s = property(_read_all_sint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint8 values.''')
+        sint16s = property(_read_all_sint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint16 values.''')
+        sint32s = property(_read_all_sint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint32 values.''')
+        sint64s = property(_read_all_sint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint64 values.''')
+        floats = property(_read_all_float, None, doc='''A read only property that returns an array with all the contents of this SBData represented as float values.''')
+        doubles = property(_read_all_double, None, doc='''A read only property that returns an array with all the contents of this SBData represented as double values.''')
 
     %}
-
-    %pythoncode %{
-        __swig_getmethods__["byte_order"] = GetByteOrder
-        __swig_setmethods__["byte_order"] = SetByteOrder
-        if _newclass: byte_order = property(GetByteOrder, SetByteOrder, doc='''A read/write property getting and setting the endianness of this SBData (data.byte_order = lldb.eByteOrderLittle).''')
-
-        __swig_getmethods__["size"] = GetByteSize
-        if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns the size the same result as GetByteSize().''')
-
-    %}
-
 };
 
+%attribute(lldb::SBData, lldb::ByteOrder, byte_order, GetByteOrder, SetByteOrder);
+%attribute(lldb::SBData, size_t, byte_order, GetByteSize);
+
 } // namespace lldb

Modified: lldb/trunk/scripts/interface/SBDeclaration.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBDeclaration.i?rev=364946&r1=364945&r2=364946&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBDeclaration.i (original)
+++ lldb/trunk/scripts/interface/SBDeclaration.i Tue Jul  2 10:25:20 2019
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+%include <attribute.i>
+
 namespace lldb {
 
     %feature("docstring",
@@ -52,18 +54,10 @@ namespace lldb {
 
         bool
         operator != (const lldb::SBDeclaration &rhs) const;
-
-        %pythoncode %{
-            __swig_getmethods__["file"] = GetFileSpec
-            if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''')
-
-            __swig_getmethods__["line"] = GetLine
-            if _newclass: line = property(GetLine, None, doc='''A read only property that returns the 1 based line number for this line entry, a return value of zero indicates that no line information is available.''')
-
-            __swig_getmethods__["column"] = GetColumn
-            if _newclass: column = property(GetColumn, None, doc='''A read only property that returns the 1 based column number for this line entry, a return value of zero indicates that no column information is available.''')
-            %}
-
     };
 
+%attributeref(lldb::SBDeclaration, lldb::SBFileSpec, file, GetFileSpec);
+%attribute(lldb::SBDeclaration, uint32_t, line, GetLine);
+%attribute(lldb::SBDeclaration, uint32_t, column, GetColumn);
+
 } // namespace lldb

Modified: lldb/trunk/scripts/interface/SBError.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBError.i?rev=364946&r1=364945&r2=364946&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBError.i (original)
+++ lldb/trunk/scripts/interface/SBError.i Tue Jul  2 10:25:20 2019
@@ -104,25 +104,12 @@ public:
 
     bool
     GetDescription (lldb::SBStream &description);
-
-    %pythoncode %{
-        __swig_getmethods__["value"] = GetError
-        if _newclass: value = property(GetError, None, doc='''A read only property that returns the same result as GetError().''')
-
-        __swig_getmethods__["fail"] = Fail
-        if _newclass: fail = property(Fail, None, doc='''A read only property that returns the same result as Fail().''')
-
-        __swig_getmethods__["success"] = Success
-        if _newclass: success = property(Success, None, doc='''A read only property that returns the same result as Success().''')
-
-        __swig_getmethods__["description"] = GetCString
-        if _newclass: description = property(GetCString, None, doc='''A read only property that returns the same result as GetCString().''')
-
-        __swig_getmethods__["type"] = GetType
-        if _newclass: type = property(GetType, None, doc='''A read only property that returns the same result as GetType().''')
-
-    %}
-
 };
 
+%attribute(lldb::SBError, uint32_t, value, GetError);
+%attribute(lldb::SBError, bool, fail, Fail);
+%attribute(lldb::SBError, bool, success, Success);
+%attribute(lldb::SBError, const char*, description, GetCString);
+%attribute(lldb::SBError, lldb::ErrorType, type, GetType);
+
 } // namespace lldb

Modified: lldb/trunk/scripts/interface/SBExecutionContext.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBExecutionContext.i?rev=364946&r1=364945&r2=364946&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBExecutionContext.i (original)
+++ lldb/trunk/scripts/interface/SBExecutionContext.i Tue Jul  2 10:25:20 2019
@@ -36,21 +36,11 @@ public:
 
     SBFrame
     GetFrame () const;
-
-    %pythoncode %{
-        __swig_getmethods__["target"] = GetTarget
-        if _newclass: target = property(GetTarget, None, doc='''A read only property that returns the same result as GetTarget().''')
-
-        __swig_getmethods__["process"] = GetProcess
-        if _newclass: process = property(GetProcess, None, doc='''A read only property that returns the same result as GetProcess().''')
-
-        __swig_getmethods__["thread"] = GetThread
-        if _newclass: thread = property(GetThread, None, doc='''A read only property that returns the same result as GetThread().''')
-
-        __swig_getmethods__["frame"] = GetFrame
-        if _newclass: frame = property(GetFrame, None, doc='''A read only property that returns the same result as GetFrame().''')
-    %}
-
 };
 
+%attributeref(lldb::SBExecutionContext, lldb::SBTarget, target, GetTarget);
+%attributeref(lldb::SBExecutionContext, lldb::SBProcess, process, GetProcess);
+%attributeref(lldb::SBExecutionContext, lldb::SBThread, process, GetThread);
+%attributeref(lldb::SBExecutionContext, lldb::SBFrame, process, GetFrame);
+
 } // namespace lldb

Modified: lldb/trunk/scripts/interface/SBFileSpec.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBFileSpec.i?rev=364946&r1=364945&r2=364946&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBFileSpec.i (original)
+++ lldb/trunk/scripts/interface/SBFileSpec.i Tue Jul  2 10:25:20 2019
@@ -92,19 +92,13 @@ public:
                 return spec_file
             return None
 
-        __swig_getmethods__["fullpath"] = __get_fullpath__
-        if _newclass: fullpath = property(__get_fullpath__, None, doc='''A read only property that returns the fullpath as a python string.''')
-
-        __swig_getmethods__["basename"] = GetFilename
-        if _newclass: basename = property(GetFilename, None, doc='''A read only property that returns the path basename as a python string.''')
-
-        __swig_getmethods__["dirname"] = GetDirectory
-        if _newclass: dirname = property(GetDirectory, None, doc='''A read only property that returns the path directory name as a python string.''')
-
-        __swig_getmethods__["exists"] = Exists
-        if _newclass: exists = property(Exists, None, doc='''A read only property that returns a boolean value that indicates if the file exists.''')
+        fullpath = property(__get_fullpath__, None, doc='''A read only property that returns the fullpath as a python string.''')
     %}
 
 };
 
+%attribute(lldb::SBFileSpec, const char*, basename, GetFilename);
+%attribute(lldb::SBFileSpec, const char*, dirname, GetDirectory);
+%attribute(lldb::SBFileSpec, bool, exists, Exists);
+
 } // namespace lldb

Modified: lldb/trunk/scripts/interface/SBFrame.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBFrame.i?rev=364946&r1=364945&r2=364946&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBFrame.i (original)
+++ lldb/trunk/scripts/interface/SBFrame.i Tue Jul  2 10:25:20 2019
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+%include <attribute.i>
+
 namespace lldb {
 
 %feature("docstring",
@@ -328,86 +330,34 @@ public:
 
             return registers_access(self.registers)
 
-        __swig_getmethods__["pc"] = GetPC
-        __swig_setmethods__["pc"] = SetPC
-        if _newclass: pc = property(GetPC, SetPC)
-
-        __swig_getmethods__["addr"] = GetPCAddress
-        if _newclass: addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''')
-
-        __swig_getmethods__["fp"] = GetFP
-        if _newclass: fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''')
-
-        __swig_getmethods__["sp"] = GetSP
-        if _newclass: sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''')
-
-        __swig_getmethods__["module"] = GetModule
-        if _newclass: module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) for this stack frame.''')
-
-        __swig_getmethods__["compile_unit"] = GetCompileUnit
-        if _newclass: compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) for this stack frame.''')
-
-        __swig_getmethods__["function"] = GetFunction
-        if _newclass: function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) for this stack frame.''')
-
-        __swig_getmethods__["symbol"] = GetSymbol
-        if _newclass: symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) for this stack frame.''')
-
-        __swig_getmethods__["block"] = GetBlock
-        if _newclass: block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) for this stack frame.''')
-
-        __swig_getmethods__["is_inlined"] = IsInlined
-        if _newclass: is_inlined = property(IsInlined, None, doc='''A read only property that returns an boolean that indicates if the block frame is an inlined function.''')
-
-        __swig_getmethods__["name"] = GetFunctionName
-        if _newclass: name = property(GetFunctionName, None, doc='''A read only property that retuns the name for the function that this frame represents. Inlined stack frame might have a concrete function that differs from the name of the inlined function (a named lldb.SBBlock).''')
-
-        __swig_getmethods__["line_entry"] = GetLineEntry
-        if _newclass: line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line table entry (lldb.SBLineEntry) for this stack frame.''')
-
-        __swig_getmethods__["thread"] = GetThread
-        if _newclass: thread = property(GetThread, None, doc='''A read only property that returns an lldb object that represents the thread (lldb.SBThread) for this stack frame.''')
-
-        __swig_getmethods__["disassembly"] = Disassemble
-        if _newclass: disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''')
-
-        __swig_getmethods__["idx"] = GetFrameID
-        if _newclass: idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''')
-
-        __swig_getmethods__["variables"] = get_all_variables
-        if _newclass: variables = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''')
-
-        __swig_getmethods__["vars"] = get_all_variables
-        if _newclass: vars = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''')
-
-        __swig_getmethods__["locals"] = get_locals
-        if _newclass: locals = property(get_locals, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the local variables in this stack frame.''')
-
-        __swig_getmethods__["args"] = get_arguments
-        if _newclass: args = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''')
-
-        __swig_getmethods__["arguments"] = get_arguments
-        if _newclass: arguments = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''')
-
-        __swig_getmethods__["statics"] = get_statics
-        if _newclass: statics = property(get_statics, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the static variables in this stack frame.''')
-
-        __swig_getmethods__["registers"] = GetRegisters
-        if _newclass: registers = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''')
-
-        __swig_getmethods__["regs"] = GetRegisters
-        if _newclass: regs = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''')
-
-        __swig_getmethods__["register"] = get_registers_access
-        if _newclass: register = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame.''')
-
-        __swig_getmethods__["reg"] = get_registers_access
-        if _newclass: reg = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame''')
-
-        __swig_getmethods__["parent"] = get_parent_frame
-        if _newclass: parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''')
-
+        parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''')
+        variables = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''')
+        vars = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''')
+        locals = property(get_locals, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the local variables in this stack frame.''')
+        args = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''')
+        arguments = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''')
+        statics = property(get_statics, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the static variables in this stack frame.''')
+        register = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame.''')
+        reg = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame''')
     %}
 };
 
+%attributeref(lldb::SBFrame, lldb::SBAddress, addr, GetPCAddress);
+%attributeref(lldb::SBFrame, lldb::SBModule, module, GetModule);
+%attributeref(lldb::SBFrame, lldb::SBCompileUnit, compile_unit, GetCompileUnit);
+%attributeref(lldb::SBFrame, lldb::SBFunction, function, GetFunction);
+%attributeref(lldb::SBFrame, lldb::SBBlock, block, GetBlock);
+%attributeref(lldb::SBFrame, lldb::SBSymbol, symbol, GetSymbol);
+%attributeref(lldb::SBFrame, lldb::SBLineEntry, line_entry, GetLineEntry);
+%attributeref(lldb::SBFrame, lldb::SBThread, thread, GetThread);
+%attributeref(lldb::SBFrame, lldb::SBValueList, registers, GetRegisters);
+%attributeref(lldb::SBFrame, lldb::SBValueList, regs, GetRegisters);
+%attribute(lldb::SBFrame, lldb::addr_t, pc, GetPC, SetPC);
+%attribute(lldb::SBFrame, lldb::addr_t, fp, GetFP);
+%attribute(lldb::SBFrame, lldb::addr_t, sp, GetSP);
+%attribute(lldb::SBFrame, bool, is_inlined, IsInlined);
+%attribute(lldb::SBFrame, const char*, name, GetFunctionName);
+%attribute(lldb::SBFrame, const char*, disassembly, Disassemble);
+%attribute(lldb::SBFrame, uint32_t, idx, GetFrameID);
+
 } // namespace lldb




More information about the lldb-commits mailing list