[Lldb-commits] [PATCH] Fix swig files to allow non-Python languages

Joe Ranieri joe at alacatialabs.com
Mon Feb 17 21:46:16 PST 2014


On Thu, Oct 31, 2013 at 7:53 PM, Joe Ranieri <joe at alacatialabs.com> wrote:
> The attached patch puts all the Python-specific includes and
> %pythoncode directives behind #ifs in order to allow wrapper
> generation for other languages.
>
> -- Joe Ranieri

Ping?

-- Joe Ranieri
-------------- next part --------------
Index: scripts/Python/interface/SBAddress.i
===================================================================
--- scripts/Python/interface/SBAddress.i	(revision 201542)
+++ scripts/Python/interface/SBAddress.i	(working copy)
@@ -139,6 +139,7 @@
     lldb::SBLineEntry
     GetLineEntry ();
     
+#ifdef SWIGPYTHON
     %pythoncode %{
         def __get_load_addr_property__ (self):
             '''Get the load address for a lldb.SBAddress using the current target.'''
@@ -195,6 +196,7 @@
         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.''')
 
     %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBBlock.i
===================================================================
--- scripts/Python/interface/SBBlock.i	(revision 201542)
+++ scripts/Python/interface/SBBlock.i	(working copy)
@@ -103,6 +103,7 @@
                    bool locals,
                    bool statics);
 
+#ifdef SWIGPYTHON
     %pythoncode %{
         def get_range_at_index(self, idx):
             if idx < self.GetNumRanges():
@@ -173,6 +174,7 @@
         __swig_getmethods__["num_ranges"] = GetNumRanges
         if _newclass: num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''')
     %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBBreakpoint.i
===================================================================
--- scripts/Python/interface/SBBreakpoint.i	(revision 201542)
+++ scripts/Python/interface/SBBreakpoint.i	(working copy)
@@ -210,6 +210,7 @@
     static uint32_t
     GetNumBreakpointLocationsFromEvent (const lldb::SBEvent &event_sp);
     
+#ifdef SWIGPYTHON
     %pythoncode %{
         
         __swig_getmethods__["id"] = GetID
@@ -227,6 +228,7 @@
         if _newclass: num_locations = property(GetNumLocations, None, doc='''A read only property that returns the count of locations of this breakpoint.''')
 
     %}
+#endif
 
     
 };
Index: scripts/Python/interface/SBCompileUnit.i
===================================================================
--- scripts/Python/interface/SBCompileUnit.i	(revision 201542)
+++ scripts/Python/interface/SBCompileUnit.i	(working copy)
@@ -115,6 +115,7 @@
     bool
     operator != (const lldb::SBCompileUnit &rhs) const;
     
+#ifdef SWIGPYTHON
     %pythoncode %{
         __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.''')
@@ -122,6 +123,7 @@
         __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.''')
     %}
+#endif
 };
 
 } // namespace lldb
Index: scripts/Python/interface/SBData.i
===================================================================
--- scripts/Python/interface/SBData.i	(revision 201542)
+++ scripts/Python/interface/SBData.i	(working copy)
@@ -133,6 +133,7 @@
     bool
     SetDataFromDoubleArray (double* array, size_t array_len);
 
+#ifdef SWIGPYTHON
     %pythoncode %{
         
         class read_data_helper:
@@ -334,6 +335,7 @@
         if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns the size the same result as GetByteSize().''')
         
     %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBDeclaration.i
===================================================================
--- scripts/Python/interface/SBDeclaration.i	(revision 201542)
+++ scripts/Python/interface/SBDeclaration.i	(working copy)
@@ -52,6 +52,7 @@
         bool
         operator != (const lldb::SBDeclaration &rhs) const;
         
+#ifdef SWIGPYTHON
         %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.''')
@@ -62,6 +63,7 @@
             __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.''')
             %}
+#endif
         
     };
     
Index: scripts/Python/interface/SBError.i
===================================================================
--- scripts/Python/interface/SBError.i	(revision 201542)
+++ scripts/Python/interface/SBError.i	(working copy)
@@ -103,6 +103,7 @@
     bool
     GetDescription (lldb::SBStream &description);
     
+#ifdef SWIGPYTHON
     %pythoncode %{
         __swig_getmethods__["value"] = GetError
         if _newclass: value = property(GetError, None, doc='''A read only property that returns the same result as GetError().''')
@@ -120,6 +121,7 @@
         if _newclass: type = property(GetType, None, doc='''A read only property that returns the same result as GetType().''')
         
     %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBFileSpec.i
===================================================================
--- scripts/Python/interface/SBFileSpec.i	(revision 201542)
+++ scripts/Python/interface/SBFileSpec.i	(working copy)
@@ -73,6 +73,7 @@
     bool
     GetDescription (lldb::SBStream &description) const;
     
+#ifdef SWIGPYTHON
     %pythoncode %{
         def __get_fullpath__(self):
             spec_dir = self.GetDirectory()
@@ -97,6 +98,7 @@
         __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.''')
     %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBFrame.i
===================================================================
--- scripts/Python/interface/SBFrame.i	(revision 201542)
+++ scripts/Python/interface/SBFrame.i	(working copy)
@@ -258,6 +258,7 @@
     bool
     GetDescription (lldb::SBStream &description);
     
+#ifdef SWIGPYTHON
     %pythoncode %{
         def get_all_variables(self):
             return self.GetVariables(True,True,True,True)
@@ -347,6 +348,7 @@
         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.''')
 
     %}
+#endif
 };
 
 } // namespace lldb
Index: scripts/Python/interface/SBFunction.i
===================================================================
--- scripts/Python/interface/SBFunction.i	(revision 201542)
+++ scripts/Python/interface/SBFunction.i	(working copy)
@@ -92,6 +92,7 @@
     bool
     operator != (const lldb::SBFunction &rhs) const;
     
+#ifdef SWIGPYTHON
     %pythoncode %{
         def get_instructions_from_current_target (self):
             return self.GetInstructions (target)
@@ -120,6 +121,7 @@
         __swig_getmethods__["type"] = GetType
         if _newclass: type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the return type (lldb.SBType) for this function.''')
     %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBInstruction.i
===================================================================
--- scripts/Python/interface/SBInstruction.i	(revision 201542)
+++ scripts/Python/interface/SBInstruction.i	(working copy)
@@ -66,6 +66,7 @@
     bool
     TestEmulation (lldb::SBStream &output_stream, const char *test_file);
     
+#ifdef SWIGPYTHON
     %pythoncode %{
         def __mnemonic_property__ (self):
             return self.GetMnemonic (target)
@@ -96,6 +97,7 @@
         __swig_getmethods__["is_branch"] = DoesBranch
         if _newclass: is_branch = property(DoesBranch, None, doc='''A read only property that returns a boolean value that indicates if this instruction is a branch instruction.''')
     %}
+#endif
     
 
 };
Index: scripts/Python/interface/SBInstructionList.i
===================================================================
--- scripts/Python/interface/SBInstructionList.i	(revision 201542)
+++ scripts/Python/interface/SBInstructionList.i	(working copy)
@@ -59,6 +59,7 @@
     bool
     DumpEmulationForAllInstructions (const char *triple);
 
+#ifdef SWIGPYTHON
     %pythoncode %{
         def __len__(self):
             '''Access len of the instruction list.'''
@@ -85,6 +86,7 @@
                         closest_inst = inst
             return None        
     %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBLineEntry.i
===================================================================
--- scripts/Python/interface/SBLineEntry.i	(revision 201542)
+++ scripts/Python/interface/SBLineEntry.i	(working copy)
@@ -83,6 +83,7 @@
     bool
     operator != (const lldb::SBLineEntry &rhs) const;
     
+#ifdef SWIGPYTHON
     %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.''')
@@ -100,6 +101,7 @@
         if _newclass: end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this line entry.''')
         
     %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBModule.i
===================================================================
--- scripts/Python/interface/SBModule.i	(revision 201542)
+++ scripts/Python/interface/SBModule.i	(working copy)
@@ -315,6 +315,7 @@
     bool
     operator != (const lldb::SBModule &rhs) const;
              
+#ifdef SWIGPYTHON
     %pythoncode %{
         class symbols_access(object):
             re_compile_type = type(re.compile('.'))
@@ -518,6 +519,7 @@
         if _newclass: num_sections = property(GetNumSections, None, doc='''A read only property that returns number of sections in the module as an integer.''')
         
     %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBProcess.i
===================================================================
--- scripts/Python/interface/SBProcess.i	(revision 201542)
+++ scripts/Python/interface/SBProcess.i	(working copy)
@@ -383,6 +383,7 @@
     const char *
     GetExtendedBacktraceTypeAtIndex (uint32_t idx);
 
+#ifdef SWIGPYTHON
     %pythoncode %{
         def __get_is_alive__(self):
             '''Returns "True" if the process is currently alive, "False" otherwise'''
@@ -478,6 +479,7 @@
         __swig_getmethods__["broadcaster"] = GetBroadcaster
         if _newclass: broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this process.''')
     %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBSection.i
===================================================================
--- scripts/Python/interface/SBSection.i	(revision 201542)
+++ scripts/Python/interface/SBSection.i	(working copy)
@@ -99,6 +99,7 @@
     bool
     operator != (const lldb::SBSection &rhs);
      
+#ifdef SWIGPYTHON
     %pythoncode %{
         def get_addr(self):
             return SBAddress(self, 0)
@@ -128,6 +129,7 @@
         if _newclass: type = property(GetSectionType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eSectionType") that represents the type of this section (code, data, etc.).''')
 
     %}
+#endif
 
 private:
 
Index: scripts/Python/interface/SBSymbol.i
===================================================================
--- scripts/Python/interface/SBSymbol.i	(revision 201542)
+++ scripts/Python/interface/SBSymbol.i	(working copy)
@@ -68,6 +68,7 @@
     bool
     operator != (const lldb::SBSymbol &rhs) const;
     
+#ifdef SWIGPYTHON
     %pythoncode %{
         def get_instructions_from_current_target (self):
             return self.GetInstructions (target)
@@ -101,6 +102,7 @@
 
         
     %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBSymbolContext.i
===================================================================
--- scripts/Python/interface/SBSymbolContext.i	(revision 201542)
+++ scripts/Python/interface/SBSymbolContext.i	(working copy)
@@ -81,6 +81,7 @@
     GetDescription (lldb::SBStream &description);
     
     
+#ifdef SWIGPYTHON
     %pythoncode %{
         __swig_getmethods__["module"] = GetModule
         __swig_setmethods__["module"] = SetModule
@@ -106,6 +107,7 @@
         __swig_setmethods__["line_entry"] = SetLineEntry
         if _newclass: line_entry = property(GetLineEntry, SetLineEntry, doc='''A read/write property that allows the getting/setting of the line entry (lldb.SBLineEntry) in this symbol context.''')
     %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBSymbolContextList.i
===================================================================
--- scripts/Python/interface/SBSymbolContextList.i	(revision 201542)
+++ scripts/Python/interface/SBSymbolContextList.i	(working copy)
@@ -60,6 +60,7 @@
     void
     Clear();
     
+#ifdef SWIGPYTHON
     %pythoncode %{
         def __len__(self):
             return int(self.GetSize())
@@ -134,6 +135,7 @@
         __swig_getmethods__["symbols"] = get_symbol_array
         if _newclass: symbols = property(get_symbol_array, None, doc='''Returns a list() of lldb.SBSymbol objects, one for each symbol in each SBSymbolContext object in this list.''')
     %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBTarget.i
===================================================================
--- scripts/Python/interface/SBTarget.i	(revision 201542)
+++ scripts/Python/interface/SBTarget.i	(working copy)
@@ -778,6 +778,8 @@
 
     lldb::SBValue
     EvaluateExpression (const char *expr, const lldb::SBExpressionOptions &options);
+
+#ifdef SWIGPYTHON
     %pythoncode %{
         class modules_access(object):
             '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.'''
@@ -876,6 +878,7 @@
         __swig_getmethods__["triple"] = GetTriple
         if _newclass: triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this target as a string.''')
     %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBThread.i
===================================================================
--- scripts/Python/interface/SBThread.i	(revision 201542)
+++ scripts/Python/interface/SBThread.i	(working copy)
@@ -284,6 +284,7 @@
     uint32_t
     GetExtendedBacktraceOriginatingIndexID();
 
+#ifdef SWIGPYTHON
     %pythoncode %{
         class frames_access(object):
             '''A helper object that will lazily hand out frames for a thread when supplied an index.'''
@@ -350,6 +351,7 @@
         __swig_getmethods__["is_stopped"] = IsStopped
         if _newclass: is_stopped = property(IsStopped, None, doc='''A read only property that returns a boolean value that indicates if this thread is stopped but not exited.''')
     %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBType.i
===================================================================
--- scripts/Python/interface/SBType.i	(revision 201542)
+++ scripts/Python/interface/SBType.i	(working copy)
@@ -43,6 +43,7 @@
     uint32_t
     GetBitfieldSizeInBits();
 
+#ifdef SWIGPYTHON
     %pythoncode %{
         __swig_getmethods__["name"] = GetName
         if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this member as a string.''')
@@ -63,6 +64,7 @@
         if _newclass: bitfield_bit_size = property(GetBitfieldSizeInBits, None, doc='''A read only property that returns the bitfield size in bits for this member as an integer, or zero if this member is not a bitfield.''')
 
     %}
+#endif
 
 protected:
     std::unique_ptr<lldb_private::TypeMemberImpl> m_opaque_ap;
@@ -237,6 +239,7 @@
     bool
     IsTypeComplete ();
 
+#ifdef SWIGPYTHON
     %pythoncode %{
         def template_arg_array(self):
             num_args = self.num_template_args
@@ -355,6 +358,7 @@
         if _newclass: members = property(get_members_array, None, doc='''A read only property that returns a list() of all lldb.SBTypeMember objects that represent all of the base classes, virtual base classes and fields for this type in ascending bit offset order.''')
 
         %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBTypeCategory.i
===================================================================
--- scripts/Python/interface/SBTypeCategory.i	(revision 201542)
+++ scripts/Python/interface/SBTypeCategory.i	(working copy)
@@ -115,6 +115,7 @@
         bool
         DeleteTypeSynthetic (lldb::SBTypeNameSpecifier);
         
+#ifdef SWIGPYTHON
         %pythoncode %{
             
             class formatters_access_class(object):
@@ -229,6 +230,7 @@
             __swig_setmethods__["enabled"] = SetEnabled
             if _newclass: enabled = property(GetEnabled, SetEnabled)
         %}
+#endif
 
     };
 
Index: scripts/Python/interface/SBTypeFilter.i
===================================================================
--- scripts/Python/interface/SBTypeFilter.i	(revision 201542)
+++ scripts/Python/interface/SBTypeFilter.i	(working copy)
@@ -61,6 +61,7 @@
         bool
         operator != (lldb::SBTypeFilter &rhs);
         
+#ifdef SWIGPYTHON
         %pythoncode %{
             __swig_getmethods__["options"] = GetOptions
             __swig_setmethods__["options"] = SetOptions
@@ -69,6 +70,7 @@
             __swig_getmethods__["count"] = GetNumberOfExpressionPaths
             if _newclass: count = property(GetNumberOfExpressionPaths, None)
         %}
+#endif
                 
     };
 
Index: scripts/Python/interface/SBTypeFormat.i
===================================================================
--- scripts/Python/interface/SBTypeFormat.i	(revision 201542)
+++ scripts/Python/interface/SBTypeFormat.i	(working copy)
@@ -61,6 +61,7 @@
         bool
         operator != (lldb::SBTypeFormat &rhs);
         
+#ifdef SWIGPYTHON
         %pythoncode %{
             __swig_getmethods__["format"] = GetFormat
             __swig_setmethods__["format"] = SetFormat
@@ -70,6 +71,7 @@
             __swig_setmethods__["options"] = SetOptions
             if _newclass: options = property(GetOptions, SetOptions)            
         %}
+#endif
 
     };
     
Index: scripts/Python/interface/SBTypeNameSpecifier.i
===================================================================
--- scripts/Python/interface/SBTypeNameSpecifier.i	(revision 201542)
+++ scripts/Python/interface/SBTypeNameSpecifier.i	(working copy)
@@ -53,6 +53,7 @@
         bool
         operator != (lldb::SBTypeNameSpecifier &rhs);
         
+#ifdef SWIGPYTHON
         %pythoncode %{
             __swig_getmethods__["name"] = GetName
             if _newclass: name = property(GetName, None)
@@ -60,6 +61,7 @@
             __swig_getmethods__["is_regex"] = IsRegex
             if _newclass: is_regex = property(IsRegex, None)
         %}
+#endif
 
         
     };
Index: scripts/Python/interface/SBTypeSummary.i
===================================================================
--- scripts/Python/interface/SBTypeSummary.i	(revision 201542)
+++ scripts/Python/interface/SBTypeSummary.i	(working copy)
@@ -75,6 +75,7 @@
         bool
         operator != (lldb::SBTypeSummary &rhs);
         
+#ifdef SWIGPYTHON
         %pythoncode %{
             __swig_getmethods__["options"] = GetOptions
             __swig_setmethods__["options"] = SetOptions
@@ -92,6 +93,7 @@
             __swig_getmethods__["summary_data"] = GetData
             if _newclass: summary_data = property(GetData, None)
         %}
+#endif
         
     };
 
Index: scripts/Python/interface/SBTypeSynthetic.i
===================================================================
--- scripts/Python/interface/SBTypeSynthetic.i	(revision 201542)
+++ scripts/Python/interface/SBTypeSynthetic.i	(working copy)
@@ -63,6 +63,7 @@
         bool
         operator != (lldb::SBTypeSynthetic &rhs);
         
+#ifdef SWIGPYTHON
         %pythoncode %{
             __swig_getmethods__["options"] = GetOptions
             __swig_setmethods__["options"] = SetOptions
@@ -74,6 +75,7 @@
             __swig_getmethods__["synthetic_data"] = GetData
             if _newclass: synthetic_data = property(GetData, None)
         %}
+#endif
         
     };
     
Index: scripts/Python/interface/SBValue.i
===================================================================
--- scripts/Python/interface/SBValue.i	(revision 201542)
+++ scripts/Python/interface/SBValue.i	(working copy)
@@ -408,6 +408,7 @@
     bool
     GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes);
     
+#ifdef SWIGPYTHON
     %pythoncode %{
         def __get_dynamic__ (self):
             '''Helper function for the "SBValue.dynamic" property.'''
@@ -498,6 +499,7 @@
         __swig_getmethods__["path"] = get_expr_path
         if _newclass: path = property(get_expr_path, None, doc='''A read only property that returns the expression path that one can use to reach this value in an expression.''')
     %}
+#endif
 
 };
 
Index: scripts/Python/interface/SBValueList.i
===================================================================
--- scripts/Python/interface/SBValueList.i	(revision 201542)
+++ scripts/Python/interface/SBValueList.i	(working copy)
@@ -96,6 +96,8 @@
 
     lldb::SBValue
     FindValueObjectByUID (lldb::user_id_t uid);
+
+#ifdef SWIGPYTHON
     %pythoncode %{
         def __len__(self):
             return int(self.GetSize())
@@ -131,6 +133,7 @@
                 return matches
 
     %}
+#endif
 
 
 };
Index: scripts/lldb.swig
===================================================================
--- scripts/lldb.swig	(revision 201542)
+++ scripts/lldb.swig	(working copy)
@@ -37,12 +37,14 @@
 // Parameter types will be used in the autodoc string.
 %feature("autodoc", "1");
 
+#ifdef SWIGPYTHON
 %pythoncode%{
 import uuid
 import re
 import os
 %}
 %include "./Python/python-typemaps.swig"
+#endif
 
 /* C++ headers to be included. */
 %{
@@ -102,7 +104,9 @@
 #include "lldb/API/SBValueList.h"
 #include "lldb/API/SBWatchpoint.h"
 
+#ifdef SWIGPYTHON
 #include "../scripts/Python/python-swigsafecast.swig"
+#endif
 
 %}
 
@@ -168,6 +172,8 @@
 %include "./Python/interface/SBValueList.i"
 %include "./Python/interface/SBWatchpoint.i"
 
+#ifdef SWIGPYTHON
 %include "./Python/python-extensions.swig"
 
 %include "./Python/python-wrapper.swig"
+#endif


More information about the lldb-commits mailing list