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

[ffi] Support alignment on objects #739

Merged
merged 1 commit into from Mar 6, 2019

Conversation

Projects
None yet
2 participants
@sfanxiang
Copy link
Contributor

commented Mar 6, 2019

Closes #736.

@@ -333,8 +333,11 @@ fn generate_unions(w: &mut Write, env: &Env, unions: &[&Union]) -> Result<()> {
if !env.type_status_sys(&full_name).need_generate() {
continue;
}
let config = env.config.objects.get(&full_name);
let align = config.and_then(|c| c.align);

This comment has been minimized.

Copy link
@EPashkin

EPashkin Mar 6, 2019

Member

Can you move config acquisition before status check and use it instead env.type_status_sys,
maybe with some new function in Env

pub fn unwrap_status_sys(status: Option<GStatus>) -> GStatus {
    status.unwrap_or(GStatus::Generate)
}

This comment has been minimized.

Copy link
@EPashkin

EPashkin Mar 6, 2019

Member

.. or in global namespace with code near GStatus definition

This comment has been minimized.

Copy link
@EPashkin

EPashkin Mar 6, 2019

Member

Sorry, forgot about .map(|o| o.status)

pub fn unwrap_status_sys(object: Option<GObject>) -> GStatus {
    if let Some(object) = object {
       object.status
    } else {
        GStatus::Generate
    }
}

This comment has been minimized.

Copy link
@sfanxiang

sfanxiang Mar 6, 2019

Author Contributor

Other code in this file does it in a way that makes it easier to spot what's going on without increasing LOC:

if let Some(false) = config.map(|c| c.status.need_generate()) {
    continue;
}

I actually prefer this one. Let me know if you still want unwrap_status_sys().

This comment has been minimized.

Copy link
@EPashkin

EPashkin Mar 6, 2019

Member

This is better solution and Env::type_status_sys maybe unneeded now. Thanks.

This comment has been minimized.

Copy link
@EPashkin
Show resolved Hide resolved src/config/gobjects.rs Outdated
@EPashkin

This comment has been minimized.

Copy link
Member

commented Mar 6, 2019

Thanks.

@sfanxiang sfanxiang force-pushed the sfanxiang:align branch from 9cfe1d2 to 2cc89b3 Mar 6, 2019

@sfanxiang sfanxiang force-pushed the sfanxiang:align branch from 2cc89b3 to c7f5e86 Mar 6, 2019

@EPashkin

This comment has been minimized.

Copy link
Member

commented Mar 6, 2019

Thanks

@EPashkin EPashkin merged commit 7f03627 into gtk-rs:master Mar 6, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@sfanxiang sfanxiang deleted the sfanxiang:align branch Mar 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.