snu-quiqcl / qiwis

QuIqcl Widget Integration Software
MIT License
5 stars 2 forks source link

Kangz12345/136/simplify swift call request #147

Closed kangz12345 closed 1 year ago

kangz12345 commented 1 year ago

I implemented the simplified swift-call interface. The newly introduced usage is as follows:

  1. Every BaseApp has a new attribute: swiftcall.

  2. From that, one can call any swift-call just like calling a method, e.g., self.swiftcall.destroyApp(name="logger"). All the arguments must be given as keyword arguments, for clarity.

  3. It will return a SwiftcallResult instance. It is updated when the swift-call is done and the result comes back via the swiftcallReturned signal. One may want to keep it to check the result, e.g.:

    result = self.swiftcall.destroyApp(name="logger")
    ...
    if result.done:
    if result.success:
    print(f"returned value is {result.value}.")
    else:
    print(f"failed: {result.error}.")
  4. One must not block on the result to be done, e.g., while not result.done: ..., in the main thread, since it will freeze the entire GUI process.

I have tested createApp() and destroyApp(). As I test it, I fixed a bug in swift module that I implemented in #142.

This closes #136.

BECATRUE commented 1 year ago

First of all, I wonder how you tested createdApp() and destroyApp(). Concretely, how did you check if result is updated not using while not result.done: ...?

kangz12345 commented 1 year ago

First of all, I wonder how you tested createdApp() and destroyApp(). Concretely, how did you check if result is updated not using while not result.done: ...?

I'm sorry for the missing test codes... 😄 I used the interactive console for testing. So I import swift and load the setup.json file, and then I call the swift-calls. Then I click the OK button from the prompt, and finally I check if the result object is updated.

kangz12345 commented 1 year ago

I applied the reviews and add one more feature in the last commit.