MCPcopy Create free account
hub / github.com/baldurk/renderdoc / completionOptions

Method completionOptions

qrenderdoc/Code/pyrenderdoc/PythonContext.cpp:1096–1168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1094}
1095
1096QStringList PythonContext::completionOptions(QString base)
1097{
1098 QStringList ret;
1099
1100 if(!m_Completer)
1101 return ret;
1102
1103 QByteArray bytes = base.toUtf8();
1104 const char *input = (const char *)bytes.data();
1105
1106 PyGILState_STATE gil = PyGILState_Ensure();
1107
1108 PyObject *completeFunction = PyObject_SafeGetAttrString(m_Completer, "complete");
1109
1110 if(!completeFunction)
1111 return ret;
1112
1113 int idx = 0;
1114 PyObject *opt = NULL;
1115 do
1116 {
1117 opt = PyObject_CallFunction(completeFunction, "si", input, idx);
1118
1119 if(opt && !Py_IsNone(opt))
1120 {
1121 QString optstr = ToQStr(opt);
1122
1123 bool add = true;
1124
1125 // little hack, remove some of the ugly swig template instantiations that we can't avoid.
1126 if(optstr.contains(lit("renderdoc.rdcarray")) || optstr.contains(lit("renderdoc.rdcstr")) ||
1127 optstr.contains(lit("renderdoc.bytebuf")))
1128 add = false;
1129
1130 if(add)
1131 ret << optstr;
1132 }
1133
1134 idx++;
1135 } while(opt && !Py_IsNone(opt));
1136
1137 // extra hack, remove the swig object functions/data but ONLY if we find a sure-fire identifier
1138 // (thisown) since otherwise we could remove append from a list object
1139 bool containsSwigInternals = false;
1140 for(const QString &optstr : ret)
1141 {
1142 if(optstr.contains(lit(".thisown")))
1143 {
1144 containsSwigInternals = true;
1145 break;
1146 }
1147 }
1148
1149 if(containsSwigInternals)
1150 {
1151 for(int i = 0; i < ret.count();)
1152 {
1153 if(ret[i].endsWith(lit(".acquire(")) || ret[i].endsWith(lit(".append(")) ||

Callers 2

interactive_keypressMethod · 0.80
startAutocompleteMethod · 0.80

Calls 8

toUtf8Method · 0.80
ToQStrFunction · 0.70
dataMethod · 0.45
containsMethod · 0.45
countMethod · 0.45
endsWithMethod · 0.45
removeAtMethod · 0.45

Tested by

no test coverage detected