-
Notifications
You must be signed in to change notification settings - Fork 11
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
Adds native record encoding to the library #1
base: master
Are you sure you want to change the base?
Conversation
Also various performance increases. Now uses python to perform the parsing.
Allows decoding of spaces
Sometimes applescript will not throw errors when casting a record to text (which allows the user to see the record as raw bytes), a workaround is in place. Some bugs occurred when reading strings with single quotes, this is fixed by letting python read from the stdin Lastly the performance of encoding records is increased because its no longer needed to json encode the string representation. Also when encoding a list with records we use the encodeRecords method to reduce overhead of calling encodeRecords multiple times.
New lines in records made decode crash. Big strings > 256 are now handled by python, due to slow string processing of AppleScript
Hey, I missed this pull request, are you still interested in merging it? |
Yeah sure |
Note: Issue #3 was already resolved in my branch. |
Ok, so this changes a lot of things, and it doesn't merge cleanly any more. Could you break it up into a few patches? Also, why is it useful to call out to Python code? |
Python was mainly because of performance reasons... I use string manipulation to transform a json string to applescript notation, but performing this manipulation in applescript turned out in a later stadium to be rather slow. I can break it up into a few patches, but maybe implementing boolean support on my side is easier. |
This is rather exciting. I have a few suggestions to make it even better, like an aged cheese(!). Is it possible to break the python code out of json.applescript into a new file/module? This way Python can bytecompile the code only once instead of every time on execution (since the code is passed via the I suggest adding a separate build target in the Makefile for Something like this should fit the bill: json.scpt: json.applescript
osacompile -o json.scpt json.applescript
ASUnit/ASUnit.scpt: ASUnit/ASUnit.applescript
osacompile -x -o ASUnit/ASUnit.scpt ASUnit/ASUnit.applescript
test: json.scpt ASUnit/ASUnit.scpt
osascript tests.applescript
.PHONY: test |
@winny- |
That makefile doesn't work, [edit] never mind, I was on the wrong branch. |
I can't merge ASUnit, it's GPL-licensed. But where is it used? |
@mgax Pretty much all my testcases are in ASUnit. Isn't it allowed to use GPL-tools for unit testing only, because it is not really part of the library? |
IANAL: Using ASUnit means the test harness has to call into its code, suggesting that test cases are a derivative work and possibly subject to the GPL. It's ambiguous what the GPL allows for non-linking languages like AppleScript or Python. I looked into how to create a script bundle with a non-AppleScript Resource file. The workflow is something like this:
There is a I hope this helps! |
Adds the possibility to encode records natively without using createDictWith to the library. The output is always lowercase.
Due to introspection to retrieve the contents of a record this method is somewhat slower than the original method.