Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

[[ Resolve File ]] Implement resolve file relative to object#6656

Merged
montegoulding merged 2 commits into
livecode:developfrom
montegoulding:resolvefile
May 14, 2019
Merged

[[ Resolve File ]] Implement resolve file relative to object#6656
montegoulding merged 2 commits into
livecode:developfrom
montegoulding:resolvefile

Conversation

@montegoulding

Copy link
Copy Markdown
Contributor

This patch implements a new LCB statement to resolve a file path relative to a
script object in the same way that relative file paths are resolved in LiveCode
script.

@runrevmark

Copy link
Copy Markdown
Contributor

@montegoulding I wonder if (when in a widget) if there is no 'relative to' then it should use the widget's script object. Obviously for libraries, there is no current widget to use, so defaultStack makes sense. There's actually an issue in 'image from path' in the canvas library which assumes there is a current widget - perhaps we need a general handler in the engine to get 'current object context'?

@livecodeali

Copy link
Copy Markdown
Member

That would fit with the send/post behavior which does exactly the same thing.

@montegoulding

Copy link
Copy Markdown
Contributor Author

Ok

@montegoulding

Copy link
Copy Markdown
Contributor Author

@runrevmark I have resolved anomaly 19137 here for the sake of consistency/sanity.

@montegoulding

Copy link
Copy Markdown
Contributor Author

Hmm... I just noticed the mentioned issue for image from file... will look into it.

@montegoulding

Copy link
Copy Markdown
Contributor Author

rebased and fixed some missing intents in the syntax declaration

@runrevmark

Copy link
Copy Markdown
Contributor

This needs tests for all the cases touched:

  • image file resolution in widgets and in libraries
  • execute script/send/post in widgets and in libraries
  • resolve file in widgets and in libraries

@montegoulding

Copy link
Copy Markdown
Contributor Author

We already have tests covering send & post in widgets and libraries and execute script in libraries.

I've just noticed another anomaly here. the contents of file is relative to the current directory (which there is no access to except via execute script BTW) while image from file is relative to the the current object context. I guess we have the same anomaly in LCS image fileName property v file paths so it makes sense.

@montegoulding

Copy link
Copy Markdown
Contributor Author

I have now added the extra tests and think I have covered all the cases that need to be covered here

@montegoulding montegoulding force-pushed the resolvefile branch 2 times, most recently from e1c8ccd to b78f5ae Compare May 10, 2019 05:56
@runrevmark

Copy link
Copy Markdown
Contributor

@montegoulding I don't think its quite right to lump all the context tests into a 'ContextObject' test as that is an internal abstraction - it would be better if the tests were split up by the features. In particular, we have a TestExtensionExecuteScript test (which still references anomaly 19137) - that should be made to ensure it covers the cases which this touches; and add the widget cases.

There seems to be a duplicate test for resolve file in both the EngineContextTest and the ResolveFileTest (maybe it is slightly different - but if so they should all be in the ResolveFileTest).

Similarly, the image from file tests should go in a TestExtensionImageFromFile test handler.

@runrevmark

Copy link
Copy Markdown
Contributor

Also can you clarify how anomaly 19137 has been resolved? The widget case is obviously clear - it should be the widget's script object.... However, the suggestion made in the bug report for libraries was that it should be the script object which called the library handler - the rationale there is that execute script is do... If you called do from within an engine method it would use the script object which called the engine method; just as using do from LCS does. Maybe that is too big a change though...

@montegoulding

Copy link
Copy Markdown
Contributor Author

OK I will reorganise the tests. Regarding 19137 I can't recall if I discussed it with you... was a while back. Anyway, my thoughts were:

  • it's possible to execute script at the moment when there's no caller (in a foreign callback for example). At least script object access does not appear to be disabled for that (perhaps it should be?).
  • if you want to execute in the context of the caller it's easy enough to do explicitly

I can change it to the caller if you like or change the note to saying it is resolved only for widgets, however, I think it would be good if the implicit object follows consistent rules for all syntax.

@runrevmark

Copy link
Copy Markdown
Contributor

@montegoulding Okay - that's fine :) The key thing is that libraries can have foreign callbacks and so (as you point out) there is no consistent script object context, so using default card of default stack universally for libraries in this case is fine. As you point out, libraries can always use 'the caller' to explicitly specify they want to execute script in the calling script object :)

Perhaps add a note to the anomaly about the resolution (and reason why default card ... makes sense for libraries) - we can consider that anomaly resolved then :)

This patch implements a new LCB statement to resolve a file path relative to a
script object in the same way that relative file paths are resolved in LiveCode
script.
@montegoulding montegoulding force-pushed the resolvefile branch 4 times, most recently from 116ca9b to d86e462 Compare May 13, 2019 07:38
This patch implement `MCEngineCurrentContextObject` to be reused where a function
needs a fallback default object. If the function is called by a widget script the
particular widget is the default object while if it is called by a library the
current card of the defaultStack is the default object.

This patch updates the engine module functions to use `MCEngineCurrentContextObject`
where appropriate.
@runrevmark

Copy link
Copy Markdown
Contributor

@montegoulding The tests look much better - thanks :) Last thing here can you add a section to the 'breaking changes' doc as there is a non-backwards-compatible change here.

@runrevmark

Copy link
Copy Markdown
Contributor

@montegoulding I'm reviewing this as is for the moment as we need it in before we can merge the macstatusmenu feature... If you could submit a seperate PR with the breaking changes update that would be great.

@runrevmark

Copy link
Copy Markdown
Contributor

@livecode-vulcan review ok 857a2fb

@livecode-vulcan

Copy link
Copy Markdown
Contributor

💙 review by @runrevmark ok 857a2fb

livecode-vulcan added a commit that referenced this pull request May 14, 2019
[[ Resolve File ]] Implement resolve file relative to object

This patch implements a new LCB statement to resolve a file path relative to a
script object in the same way that relative file paths are resolved in LiveCode
script.
@livecode-vulcan

Copy link
Copy Markdown
Contributor

😎 test success 857a2fb

  • try-community-armv6-android-sdk26_ndk16r15: success
  • try-community-armv7-android-sdk26_ndk16r15: success
  • try-community-arm64-android-sdk26_ndk16r15: success
  • try-community-x86-android-sdk26_ndk16r15: success
  • try-community-x86_64-android-sdk26_ndk16r15: success
  • try-community-js-emscripten-sdk1.35: success
  • try-community-universal-ios-iphoneos12.1: success
  • try-community-universal-ios-iphonesimulator12.1: success
  • try-community-universal-mac-macosx10.9: success
  • try-community-x86-linux-debian8: success
  • try-community-x86_64-linux-debian8: success
  • try-community-x86-win32: success
  • try-community-x86_64-win32: success

@montegoulding montegoulding merged commit 607ec6d into livecode:develop May 14, 2019
@montegoulding montegoulding deleted the resolvefile branch May 14, 2019 23:42
livecode-vulcan added a commit that referenced this pull request May 15, 2019
[[ Mac Status Menu ]] Implement mac status menu library

This patch is an initial implementation of a mac status menu library.

Depends on #6656
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants