MCPcopy Create free account
hub / github.com/dail8859/NotepadNext / GetConstantName

Method GetConstantName

src/IFaceTable.cpp:81–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81int IFaceTable::GetConstantName(int value, char *nameOut, unsigned nameBufferLen, const char *hint) const {
82 if (nameOut && nameBufferLen > 0) {
83 *nameOut = '\0';
84 }
85
86 // Look in both the constants table and the functions table. Start with functions.
87 for (const auto &func : functions) {
88 if (func.value == value) {
89 int len = static_cast<int>(strlen(func.name) + strlen(prefix));
90 if (nameOut && (static_cast<int>(nameBufferLen) > len)) {
91 strcpy(nameOut, prefix);
92 strcat(nameOut, func.name);
93 // fix case
94 for (char *nm = nameOut + strlen(prefix); *nm; ++nm) {
95 if (*nm >= 'a' && *nm <= 'z') {
96 *nm = static_cast<char>(*nm - 'a' + 'A');
97 }
98 }
99 return len;
100 } else {
101 return -1 - len;
102 }
103 }
104 }
105
106 for (const auto &con : constants) {
107 if (con.value == value && (hint == NULL || strncmp(hint, con.name, strlen(hint)) == 0)) {
108 int len = static_cast<int>(strlen(con.name));
109 if (nameOut && (static_cast<int>(nameBufferLen) > len)) {
110 strcpy(nameOut, con.name);
111 return len;
112 } else {
113 return -1 - len;
114 }
115 }
116 }
117
118 return 0;
119}
120
121const IFaceFunction *IFaceTable::GetFunctionByMessage(int message) const {
122 for (const auto &func : functions) {

Callers 1

cf_npp_constnameFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected