Commit 490730da authored by ussrhero's avatar ussrhero
Browse files

added : getSymbolEnumeratorFromSource routine (create symbol enumerator for source code)

parent 85028a9a
Subproject commit 58bd65641b0a351204b60f0697d4868241eae198 Subproject commit 60f7380b1dcfe762f5fec6f33df40e93315874dc
...@@ -106,6 +106,7 @@ BOOST_PYTHON_FUNCTION_OVERLOADS( TypeInfo_ptrTo, TypeInfoAdapter::ptrTo, 1, 2 ); ...@@ -106,6 +106,7 @@ BOOST_PYTHON_FUNCTION_OVERLOADS( TypeInfo_ptrTo, TypeInfoAdapter::ptrTo, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( getTypeFromSource_, pykd::getTypeFromSource, 2, 3 ); BOOST_PYTHON_FUNCTION_OVERLOADS( getTypeFromSource_, pykd::getTypeFromSource, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( getTypeInfoProviderFromPdb_, pykd::getTypeInfoProviderFromPdb, 1, 2 ); BOOST_PYTHON_FUNCTION_OVERLOADS( getTypeInfoProviderFromPdb_, pykd::getTypeInfoProviderFromPdb, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( getTypeInfoProviderFromSource_, pykd::getTypeInfoProviderFromSource, 1, 2); BOOST_PYTHON_FUNCTION_OVERLOADS( getTypeInfoProviderFromSource_, pykd::getTypeInfoProviderFromSource, 1, 2);
BOOST_PYTHON_FUNCTION_OVERLOADS( getSymbolEnumeratorFromSource_, pykd::getSymbolEnumeratorFromSource, 1, 2);
BOOST_PYTHON_FUNCTION_OVERLOADS(evalExpr_, pykd::evalExpr, 1, 3); BOOST_PYTHON_FUNCTION_OVERLOADS(evalExpr_, pykd::evalExpr, 1, 3);
BOOST_PYTHON_FUNCTION_OVERLOADS( addSyntheticModule_, pykd::addSyntheticModule, 3, 4 ); BOOST_PYTHON_FUNCTION_OVERLOADS( addSyntheticModule_, pykd::addSyntheticModule, 3, 4 );
...@@ -444,6 +445,8 @@ void pykd_init() ...@@ -444,6 +445,8 @@ void pykd_init()
"Create typeInfo provider from C/C++ source code") ); "Create typeInfo provider from C/C++ source code") );
python::def( "getTypeInfoProviderFromPdb", &pykd::getTypeInfoProviderFromPdb, getTypeInfoProviderFromPdb_( python::args("filePath", "baseOffset"), python::def( "getTypeInfoProviderFromPdb", &pykd::getTypeInfoProviderFromPdb, getTypeInfoProviderFromPdb_( python::args("filePath", "baseOffset"),
"Create typeInfo provider from pdb file") ); "Create typeInfo provider from pdb file") );
python::def("getSymbolEnumeratorFromSource", &pykd::getSymbolEnumeratorFromSource, getSymbolEnumeratorFromSource_(python::args("sourceCode", "compileOptions"),
"Create symbol enumerator for source code"));
python::def("evalExpr", &pykd::evalExpr, evalExpr_(python::args("expression", "scope", "typeProvider"), python::def("evalExpr", &pykd::evalExpr, evalExpr_(python::args("expression", "scope", "typeProvider"),
"Evaluate C++ expression with typed information")); "Evaluate C++ expression with typed information"));
...@@ -1320,6 +1323,18 @@ void pykd_init() ...@@ -1320,6 +1323,18 @@ void pykd_init()
.def( "__getattr__", TypeInfoProviderAdapter::getTypeAsAttr ) .def( "__getattr__", TypeInfoProviderAdapter::getTypeAsAttr )
; ;
python::class_<kdlib::SymbolEnumerator, kdlib::SymbolEnumeratorPtr, boost::noncopyable>("symbolEnumerator",
"Get symbol enumerator", python::no_init)
.def("__iter__", SymbolEnumeratorAdapter::getIter)
#if PY_VERSION_HEX < 0x03000000
.def("next", &SymbolEnumeratorAdapter::next)
#else
.def("__next__", SymbolEnumeratorAdapter::next)
#endif
;
python::enum_<kdlib::DebugCallbackResult>("eventResult", "Return value of event handler") python::enum_<kdlib::DebugCallbackResult>("eventResult", "Return value of event handler")
.value("Proceed", kdlib::DebugCallbackProceed) .value("Proceed", kdlib::DebugCallbackProceed)
.value("NoChange", kdlib::DebugCallbackNoChange) .value("NoChange", kdlib::DebugCallbackNoChange)
......
...@@ -69,6 +69,12 @@ inline kdlib::TypeInfoProviderPtr getTypeInfoProviderFromSource(const std::wstri ...@@ -69,6 +69,12 @@ inline kdlib::TypeInfoProviderPtr getTypeInfoProviderFromSource(const std::wstri
return kdlib::getTypeInfoProviderFromSource(sourceCode, compileOptions); return kdlib::getTypeInfoProviderFromSource(sourceCode, compileOptions);
} }
inline kdlib::SymbolEnumeratorPtr getSymbolEnumeratorFromSource(const std::wstring& sourceCode, const std::wstring& compileOptions = L"")
{
AutoRestorePyState pystate;
return kdlib::getSymbolEnumeratorFromSource(sourceCode, compileOptions);
}
inline kdlib::TypeInfoProviderPtr getTypeInfoProviderFromPdb(const std::wstring& fileName, kdlib::MEMOFFSET_64 offset = 0UL) inline kdlib::TypeInfoProviderPtr getTypeInfoProviderFromPdb(const std::wstring& fileName, kdlib::MEMOFFSET_64 offset = 0UL)
{ {
AutoRestorePyState pystate; AutoRestorePyState pystate;
...@@ -432,6 +438,25 @@ struct TypeInfoProviderAdapter : public kdlib::TypeInfoProvider ...@@ -432,6 +438,25 @@ struct TypeInfoProviderAdapter : public kdlib::TypeInfoProvider
}; };
struct SymbolEnumeratorAdapter
{
static kdlib::SymbolEnumeratorPtr getIter(kdlib::SymbolEnumeratorPtr& symEnum)
{
return symEnum;
}
static std::wstring next(kdlib::SymbolEnumeratorPtr& symEnum)
{
auto symName = symEnum->Next();
if (symName.empty())
throw StopIteration("No more data.");
return symName;
}
};
struct BaseTypesEnum { struct BaseTypesEnum {
static kdlib::TypeInfoPtr getUInt1B() { return pykd::getTypeInfoByName(L"UInt1B"); } static kdlib::TypeInfoPtr getUInt1B() { return pykd::getTypeInfoByName(L"UInt1B"); }
static kdlib::TypeInfoPtr getUInt2B() { return pykd::getTypeInfoByName(L"UInt2B"); } static kdlib::TypeInfoPtr getUInt2B() { return pykd::getTypeInfoByName(L"UInt2B"); }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment