Skip to content

Instantly share code, notes, and snippets.

@automatonic
Created September 25, 2012 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save automatonic/3783025 to your computer and use it in GitHub Desktop.
Save automatonic/3783025 to your computer and use it in GitHub Desktop.
SWIGing to C#: Batch rename member variable prefixes
//Handle "m_TypeName" cases without lowercase hungarian notation prefix, avoiding the other cases
%rename("%(strip:[m_])s", match$ismember="1", regexmatch$name="m_[^lbsd].*$") "";
//We can interpret the above as:
//Rename all identifiers
// + that are class members
// + and have a "m_" prefix
// + but don't have a "m_s|m_l|m_b|m_d" prefix (they will be dealt with later)
// + from their original text
// + to a "strip"ped version that removes the "m_" portion
//
// "m_MyWorld" -> "MyWorld"
// "m_Another" -> "Another"
// "m_sWalker" -> [Ignored by this %rename]
//Handle strings, doubles, longs, and bools
%rename("%(strip:[m_s])s", match$ismember="1", regexmatch$name="m_s.*$") "";
%rename("%(strip:[m_d])s", match$ismember="1", regexmatch$name="m_d.*$") "";
%rename("%(strip:[m_l])s", match$ismember="1", regexmatch$name="m_l.*$") "";
%rename("%(strip:[m_b])s", match$ismember="1", regexmatch$name="m_b.*$") "";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment