Skip to content

Use flags instead of boolean args for App::run() - #4

Merged
krakjoe merged 1 commit into
krakjoe:masterfrom
DaveRandom:patch/app-run-flags
Oct 24, 2016
Merged

Use flags instead of boolean args for App::run()#4
krakjoe merged 1 commit into
krakjoe:masterfrom
DaveRandom:patch/app-run-flags

Conversation

@DaveRandom

@DaveRandom DaveRandom commented Oct 23, 2016

Copy link
Copy Markdown
Contributor

Untested but pretty simple

Comment thread classes/app.c Outdated
}

uiMainStep(block);
uiMainStep((flags & PHP_UI_APP_RUN_BLOCK) == PHP_UI_APP_RUN_BLOCK);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force arg passed to uiMainStep() to be 1 or 0. This is arguably unnecessary but seems like best practice?

Comment thread classes/app.c Outdated
uiApp_ce = zend_register_internal_class(&ce);
uiApp_ce->create_object = php_ui_app_create;

zend_declare_class_constant_long(uiApp_ce, ZEND_STRL("RUN_LOOP"), PHP_UI_APP_RUN_LOOP);

@krakjoe krakjoe Oct 24, 2016

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ui is using unconventional "Naming" for constants, we need to stick to that ...

But not sure what they should be, here's a suggestion:

  • App::run() should just do uiMain()
  • App::run(App::Loop) should do uiMainStep(0) - so that this will be the non-blocking, no-waiting option
  • App::run(App::Loop | App::Wait) should do uiMainStep(1) - so that this will be the looping and blocking version

How about that ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Will update shortly

@krakjoe krakjoe added this to the v1.0.0 milestone Oct 24, 2016
@DaveRandom

DaveRandom commented Oct 24, 2016

Copy link
Copy Markdown
Contributor Author

Naming fixed, updated example (which I forgot to do in the first place) + squashed for commit log tidiness

@krakjoe
krakjoe merged commit 7cd5679 into krakjoe:master Oct 24, 2016
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.

2 participants