Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix warning on MODULE_INVENTORY_BEGIN: misleading indentation #2430

Merged
merged 1 commit into from Dec 13, 2021

Conversation

rodolforg
Copy link
Contributor

No description provided.

@rodolforg rodolforg force-pushed the fix-module-h-if-warning branch 2 times, most recently from 6837c9d to 4691517 Compare November 20, 2021 13:21
@rodolforg rodolforg changed the title fix compilation warning on MODULE_INVENTORY_BEGIN: misleading indentation fix warning on MODULE_INVENTORY_BEGIN: misleading indentation Nov 20, 2021
@ice0
Copy link
Collaborator

ice0 commented Dec 4, 2021

I'm not sure if this is correct. I used g++ -E <args> to test this change.
Before:

extern "C" {
    synfig::Module* libmod_example_LTX_new_instance(synfig::ProgressCallback *cb) {
        if (synfig::check_version_(50,sizeof(synfig::Vector),sizeof(synfig::Color), sizeof(synfig::Canvas),sizeof(synfig::Layer)))
        {
            libmod_example_modclass *mod=new libmod_example_modclass(cb);
            mod->constructor_(cb); 
            return mod; 
        }

        if (cb) cb->error("libmod_example"": Unable to load module due to version mismatch."); 
        return nullptr; 
    }
}; 

libmod_example_modclass::libmod_example_modclass(synfig::ProgressCallback * )
{{
  synfig::Layer::register_in_book( synfig::Layer::BookEntry(SimpleCircle::create, SimpleCircle::get_register_name(), synfigcore_localize(SimpleCircle::get_register_local_name()), SimpleCircle::get_register_category(), SimpleCircle::get_register_version()));
  synfig::Layer::register_in_book( synfig::Layer::BookEntry(Metaballs::create, Metaballs::get_register_name(), synfigcore_localize(Metaballs::get_register_local_name()), Metaballs::get_register_category(), Metaballs::get_register_version()));
}}

After:

extern "C" {
    synfig::Module* libmod_example_LTX_new_instance(synfig::ProgressCallback *cb) {
        if (synfig::check_version_(50,sizeof(synfig::Vector),sizeof(synfig::Color), sizeof(synfig::Canvas),sizeof(synfig::Layer)))
        {
            libmod_example_modclass *mod=new libmod_example_modclass(cb);
            mod->constructor_(cb);
            return mod;
        }
        if(cb) {
            cb->error("libmod_example"": Unable to load module due to version mismatch.");
        }
        return nullptr;
    };
    
    libmod_example_modclass::libmod_example_modclass(synfig::ProgressCallback * ) 
    {{
        synfig::Layer::register_in_book( synfig::Layer::BookEntry(SimpleCircle::create, SimpleCircle::get_register_name(), synfigcore_localize(SimpleCircle::get_register_local_name()), SimpleCircle::get_register_category(), SimpleCircle::get_register_version()));
        synfig::Layer::register_in_book( synfig::Layer::BookEntry(Metaballs::create, Metaballs::get_register_name(), synfigcore_localize(Metaballs::get_register_local_name()), Metaballs::get_register_category(), Metaballs::get_register_version()));
    }} 
}

As you may notice, now libmod_example_modclass constructor is inside extern "C" section.

@rodolforg
Copy link
Contributor Author

I did it intentionally lol
Would it be wrong then?

@ice0
Copy link
Collaborator

ice0 commented Dec 10, 2021

I did it intentionally lol
Would it be wrong then?

I think no need to demangle class constructor. This way we will show that the only thing we want to be exported is the ...LTX_new_instance function.

@rodolforg
Copy link
Contributor Author

Fixed

@ice0 ice0 merged commit ec35bd8 into synfig:master Dec 13, 2021
@ice0
Copy link
Collaborator

ice0 commented Dec 13, 2021

Merged. Thank you!

@rodolforg rodolforg deleted the fix-module-h-if-warning branch December 19, 2021 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants