1 //===-- SWIGPythonBridge.cpp ----------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/Host/Config.h"
10 #include "lldb/lldb-enumerations.h"
11 
12 #if LLDB_ENABLE_PYTHON
13 
14 // LLDB Python header must be included first
15 #include "lldb-python.h"
16 
17 #include "SWIGPythonBridge.h"
18 
19 using namespace lldb;
20 
21 namespace lldb_private {
22 
23 template <typename T> const char *GetPythonValueFormatString(T t);
GetPythonValueFormatString(char *)24 template <> const char *GetPythonValueFormatString(char *) { return "s"; }
GetPythonValueFormatString(char)25 template <> const char *GetPythonValueFormatString(char) { return "b"; }
GetPythonValueFormatString(unsigned char)26 template <> const char *GetPythonValueFormatString(unsigned char) {
27   return "B";
28 }
GetPythonValueFormatString(short)29 template <> const char *GetPythonValueFormatString(short) { return "h"; }
GetPythonValueFormatString(unsigned short)30 template <> const char *GetPythonValueFormatString(unsigned short) {
31   return "H";
32 }
GetPythonValueFormatString(int)33 template <> const char *GetPythonValueFormatString(int) { return "i"; }
GetPythonValueFormatString(unsigned int)34 template <> const char *GetPythonValueFormatString(unsigned int) { return "I"; }
GetPythonValueFormatString(long)35 template <> const char *GetPythonValueFormatString(long) { return "l"; }
GetPythonValueFormatString(unsigned long)36 template <> const char *GetPythonValueFormatString(unsigned long) {
37   return "k";
38 }
GetPythonValueFormatString(long long)39 template <> const char *GetPythonValueFormatString(long long) { return "L"; }
GetPythonValueFormatString(unsigned long long)40 template <> const char *GetPythonValueFormatString(unsigned long long) {
41   return "K";
42 }
GetPythonValueFormatString(float)43 template <> const char *GetPythonValueFormatString(float) { return "f"; }
GetPythonValueFormatString(double)44 template <> const char *GetPythonValueFormatString(double) { return "d"; }
45 
46 } // namespace lldb_private
47 
48 #endif // LLDB_ENABLE_PYTHON
49