Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:50

0001 //===-- OptionGroupPythonClassWithDict.h ------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_INTERPRETER_OPTIONGROUPPYTHONCLASSWITHDICT_H
0010 #define LLDB_INTERPRETER_OPTIONGROUPPYTHONCLASSWITHDICT_H
0011 
0012 #include "lldb/Interpreter/Options.h"
0013 #include "lldb/Utility/Flags.h"
0014 #include "lldb/Utility/StructuredData.h"
0015 #include "lldb/lldb-types.h"
0016 
0017 namespace lldb_private {
0018 
0019 // Use this Option group if you have a python class that implements some
0020 // Python extension point, and you pass a SBStructuredData to the class 
0021 // __init__ method.  
0022 // class_option specifies the class name
0023 // the key and value options are read in in pairs, and a 
0024 // StructuredData::Dictionary is constructed with those pairs.
0025 class OptionGroupPythonClassWithDict : public OptionGroup {
0026 public:
0027   enum OptionKind {
0028     eScriptClass    = 1 << 0,
0029     eDictKey        = 1 << 1,
0030     eDictValue      = 1 << 2,
0031     ePythonFunction = 1 << 3,
0032     eAllOptions     = (eScriptClass | eDictKey | eDictValue | ePythonFunction)
0033   };
0034 
0035   OptionGroupPythonClassWithDict(const char *class_use, bool is_class = true,
0036                                  int class_option = 'C', int key_option = 'k',
0037                                  int value_option = 'v',
0038                                  uint16_t required_options = eScriptClass |
0039                                                              ePythonFunction);
0040 
0041   ~OptionGroupPythonClassWithDict() override = default;
0042 
0043   llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
0044     return llvm::ArrayRef<OptionDefinition>(m_option_definition);
0045   }
0046 
0047   Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
0048                         ExecutionContext *execution_context) override;
0049 
0050   void OptionParsingStarting(ExecutionContext *execution_context) override;
0051   Status OptionParsingFinished(ExecutionContext *execution_context) override;
0052   
0053   const StructuredData::DictionarySP GetStructuredData() {
0054     return m_dict_sp;
0055   }
0056   const std::string &GetName() {
0057     return m_name;
0058   }
0059 
0060 protected:
0061   std::string m_name;
0062   std::string m_current_key;
0063   StructuredData::DictionarySP m_dict_sp;
0064   std::string m_class_usage_text, m_key_usage_text, m_value_usage_text;
0065   bool m_is_class;
0066   OptionDefinition m_option_definition[4];
0067   Flags m_required_options;
0068 };
0069 
0070 } // namespace lldb_private
0071 
0072 #endif // LLDB_INTERPRETER_OPTIONGROUPPYTHONCLASSWITHDICT_H