Lex.h (pymol-open-source-2.2.0) | : | Lex.h (pymol-open-source-2.3.0) | ||
---|---|---|---|---|
skipping to change at line 15 | skipping to change at line 15 | |||
* Handling of "interned" strings in PyMOLGlobals::Lexicon | * Handling of "interned" strings in PyMOLGlobals::Lexicon | |||
*/ | */ | |||
#pragma once | #pragma once | |||
#include "PyMOLGlobals.h" | #include "PyMOLGlobals.h" | |||
#include "OVLexicon.h" | #include "OVLexicon.h" | |||
#define LexDec(G, i) OVLexicon_DecRef(G->Lexicon, i) | #define LexDec(G, i) OVLexicon_DecRef(G->Lexicon, i) | |||
#define LexInc(G, i) OVLexicon_IncRef(G->Lexicon, i) | #define LexInc(G, i) OVLexicon_IncRef(G->Lexicon, i) | |||
#define LexNumeric(i) (i) | ||||
/* | /* | |||
* Get the pointer to the internal string storage for reference `i`. | * Get the pointer to the internal string storage for reference `i`. | |||
*/ | */ | |||
inline const char * LexStr(PyMOLGlobals * G, const lexidx_t & i) { | inline const char * LexStr(PyMOLGlobals * G, const lexidx_t & i) { | |||
return (i) ? OVLexicon_FetchCString(G->Lexicon, i) : ""; | return (i) ? OVLexicon_FetchCString(G->Lexicon, i) : ""; | |||
} | } | |||
/* | /* | |||
* Lookup or insert new string `s` into the global lexicon and return | * Lookup or insert new string `s` into the global lexicon and return | |||
skipping to change at line 47 | skipping to change at line 48 | |||
i = j; | i = j; | |||
LexInc(G, i); | LexInc(G, i); | |||
} | } | |||
} | } | |||
inline void LexAssign(PyMOLGlobals * G, lexidx_t& i, const char * s) { | inline void LexAssign(PyMOLGlobals * G, lexidx_t& i, const char * s) { | |||
LexDec(G, i); | LexDec(G, i); | |||
i = LexIdx(G, s); | i = LexIdx(G, s); | |||
} | } | |||
#define LEX_BORROW_NOTFOUND -1 | ||||
/* | /* | |||
* Lookup string `s` without inserting or incrementing the ref count. If | * Lookup string `s` without inserting or incrementing the ref count. If | |||
* `s` is not in the lexicon, return -1. | * `s` is not in the lexicon, return -1. | |||
*/ | */ | |||
inline lexidx_t LexBorrow(PyMOLGlobals * G, const char * s) { | inline lexidx_t LexBorrow(PyMOLGlobals * G, const char * s) { | |||
auto result = OVLexicon_BorrowFromCString(G->Lexicon, s); | auto result = OVLexicon_BorrowFromCString(G->Lexicon, s); | |||
return (result.status == OVstatus_SUCCESS) ? result.word : -1; | return (result.status == OVstatus_SUCCESS) ? result.word : LEX_BORROW_NOTFOUND ; | |||
} | } | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 4 lines changed or added |