Skip to content

Instantly share code, notes, and snippets.

@jlblancoc
Last active December 6, 2019 08:10
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 jlblancoc/6a4a8a079cc6affde30485a118e93a18 to your computer and use it in GitHub Desktop.
Save jlblancoc/6a4a8a079cc6affde30485a118e93a18 to your computer and use it in GitHub Desktop.
wxWidgets: massive port Connect() to Bind() using regular expressions

Regular expression syntax tested with Visual Studio Code (Dec 2019)

Goal: transform:

Connect(
	ID_BUTTON1, wxEVT_COMMAND_BUTTON_CLICKED,
	(wxObjectEventFunction)&CDlgCalibWizardOnline::OnbtnStartClick);

into:

Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CDlgCalibWizardOnline::OnbtnStartClick, this, ID_BUTTON1);

regex groups:

$1: ID $2: event $3: functor

regex "search for" expression:

Connect\([\n\s]*([a-zA-Z_0-9\s|]*)[\n\s]*,[\n\s]*([a-zA-Z_0-9]*)[\n\s]*,[\n\s]*.*&(.*)[\n\s]*\);

regex "replace with" expression:

Bind($2, &$3,this, $1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment