Skip to content

Instantly share code, notes, and snippets.

@jlblancoc
Last active Dec 6, 2019
Embed
What would you like to do?
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