From 6da01afcabaed46d39be4455451dd6563339161f Mon Sep 17 00:00:00 2001 From: Patrick Gaskin Date: Tue, 5 May 2020 15:13:22 -0400 Subject: [PATCH] Added support for legacy settings constructor (fixes #7) --- src/action_cc.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/action_cc.cc b/src/action_cc.cc index fee2954..9b22c75 100644 --- a/src/action_cc.cc +++ b/src/action_cc.cc @@ -34,8 +34,10 @@ NM_ACTION_(nickel_setting) { NM_ASSERT(Device_getCurrentDevice, "could not dlsym Device::getCurrentDevice"); void *(*Settings_Settings)(Settings*, Device*, bool); + void *(*Settings_SettingsLegacy)(Settings*, Device*); reinterpret_cast(Settings_Settings) = dlsym(RTLD_DEFAULT, "_ZN8SettingsC2ERK6Deviceb"); - NM_ASSERT(Settings_Settings, "could not dlsym Settings constructor"); + reinterpret_cast(Settings_SettingsLegacy) = dlsym(RTLD_DEFAULT, "_ZN8SettingsC2ERK6Device"); + NM_ASSERT(Settings_Settings || Settings_SettingsLegacy, "could not dlsym Settings constructor (new and/or old)"); void *(*Settings_SettingsD)(Settings*); reinterpret_cast(Settings_SettingsD) = dlsym(RTLD_DEFAULT, "_ZN8SettingsD2Ev"); @@ -55,7 +57,10 @@ NM_ACTION_(nickel_setting) { NM_ASSERT(dev, "could not get shared nickel device pointer"); Settings *settings = alloca(128); // way larger than it is, but better to be safe - Settings_Settings(settings, dev, false); + if (Settings_Settings) + Settings_Settings(settings, dev, false); + else if (Settings_SettingsLegacy) + Settings_SettingsLegacy(settings, dev); // to cast the generic Settings into its subclass FeatureSettings, the // vtable pointer at the beginning needs to be replaced with the target