-
Notifications
You must be signed in to change notification settings - Fork 38
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
Nested DllCall conversion #53
Comments
Yes I believe it should be. If you want to take a crack at fixing that, feel free. Lol. Pull requests accepted! |
Sorry, I barely understand this DllCalls and Buffer etc syntax as is and struggle if my copy&pasted examlpes misbehave, unlikely would be able to help much in writing a translation code to fix it :( I might take a look at it as it might be as simple as adding Just to understand your testing framework — is there currently a way to test the files directly, e.g. |
The original way I did the testing framework was to use the Tests.ahk file But @dmtr99 added his new way of testing using the ah1 and ah2 files with the QuickConvertor script. You can try running that and playing around with it. I'm not exactly sure how it works to be honest |
I've finished the tests that adds extra parenthesis to match the example, they passed, but then setting So I guess there is no point in submitting the fix, this example should just manually be rewritten Let me know if you feel the fix is still useful for something and I'll submit it anyway, just disabling the |
I saw your attempted fix in your branch, I added a comment there. The proper fix would be complicated, and that would be to check if the replacement is inside another expression (which i have no idea how we'd determine that), and then if so, add parens around the whole replacement. Otherwise, maybe a simpler fix that would work for this specific case, would be to change this line: AHK-v2-script-converter/ConvertFuncs.ahk Line 3162 in 11a0d14
to
but that will end up always putting parens around all of these replacements, even if they are on a line by themselves |
Yeah, that's what my "fix" actually does, and I haven't noticed that since there was not a unit test for the non-
maybe that's the proper general way, but for this can't we "just" change the parser not to finish at the ending |
If you don't mind another opinion in the thread... |
…ied by a number Adds a new regex trick that tries to match "func()_post_regex_rule" to oResult.Post and passes an extra parameter to signal the need to (guard) Issue: mmikeww#53
Check out this new hack, that should force |
…ied by a number Adds a new regex trick that tries to match "func()_post_regex_rule" to oResult.Post and passes an extra parameter to signal the need to (guard) Issue: mmikeww#53
yeah, that's the hard part ;) maybe @mmikeww knows AHK syntax enough to set the proper rules |
Do we really need the OrderedMap? A quick look and it doesn't seem to offer any real benefits. You could've just moved the strings to other files
This is great work. As long as all the existing unit tests pass, I'm fine with merging it. Overall, this project is just a bunch of hacks thrown together. That's why the unit tests are so valuable, because we can easily see if we broke something that used to work. Only suggestion is I think you should merge the tests commit with the implementation commit, so that they are one distinct commit.
Could this:
Yes very quickly, we can start to question, can this work for more expressions? I think you are on the right path with your idea. Whereas eugene just tried to solve a very specific case, your plan could be generalized for many more. Sadly, I do not really have the time currently to revisit this project. If you guys are capable of implementing this stuff, along with associated unit tests, and all existing tests pass, then I'm happy to merge the changes in. |
Well, then we'd have to worry about properly splittng on
Fully agree on the value of unit tests. I only have one broken test
Merged
Maybe? In general, this doesn't make much sense due to the change in types: |
…ied by a number - Adds a new regex trick that tries to match "func()_post_regex_rule" to oResult.Post and passes an extra parameter to signal the need to (guard) - Adds unit-tests for VarSetCapacity (with and without multiplication). Since the result is invalid in v2 (can't multiply a buffer by zero), removed FileAppend test Issue: mmikeww#53
True. Before we weren't using regexmatches I don't believe, so there was no concern about the stray pipe. I think your solution was the first to use a regex.
Good point, but then, if the conversion is invalid, why should I converter give this as a result? In other instances, we would insert a comment line with some explanation instead of giving false conversion |
Well, the conversion is valid (in the case Re. the other |
Should we only convert this valid case then?
Initially there was no support for moving replacements on previous/next lines, but I don't recall if @dmtr99 added this feature when he was overhauling the converter. However....
There are cases where we simply replace multiple lines instead of one. The output string just includes `n chars. Example of comment: AHK-v2-script-converter/ConvertFuncs.ahk Line 3026 in 11a0d14
Example of multi line replace: AHK-v2-script-converter/ConvertFuncs.ahk Lines 3177 to 3181 in 11a0d14
I believe these have to go in the custom replacement funcs
I don't know, I haven't kept up with this project and won't have time in the near future. If you want to take some initiative, I can give you write access to the repository as well, like i did with dmtr99 |
That was the my idea behind only the
So the rule should be something like this: v1
OR in the absence of a previous-line-comment feature we can use this hack: So I'll implement this hack then and leave the proper commented conversion for when there is a previous-line-comment feature
Yeah, unfortunately, this wouldn't work in complex inline cases as we don't really know all the contexts in which they can appear (it's not just DllCalls, but also loops, but then also I have no clue what else) :(
Likely nope as I've seen with the
Thanks, though given my limited knowledge of the syntax and ahk language, I'd prefer if someone reviews the changes |
@dmtr99 have you by any chanced added a feature to display additional commens on a new previous line during conversion so that we can signal some warnings to the user? |
…ied by a number - Adds a new regex trick that tries to match "func()_post_regex_rule" to oResult.Post and passes an extra parameter to signal the need to (guard) - Adds unit-tests for VarSetCapacity (with and without multiplication). Since the result is invalid in v2 (can't multiply a buffer by zero), removed FileAppend test Issue: mmikeww#53
No, you could add it to the line itself, or adding an extra global variable in the line: Note: I would certainly test it if this does not cause errors for multi-line commands. |
Thanks, this seems to work! I reset it to By the way, is the whole line available to me inside the conversion function (e.g. |
Inside the custom func replacements themselves (that we've prefixed with But you can preceed the output line with a comment, by just doing something like:
|
I think I can partially get around that by passing
I don't think I can since my |
Ok, think I've done everything structural related to VarSet, now it can add new buffers to new previous lines, zero out with I've added a warning than if there is an un{guarded} control flow statement and there is a new line(s) created so that the user should guard it manually, but can the parser track it? |
I don't believe our parser can track that |
Can the parser convey this info about the current line? |
I don't believe we even track control flow statements as a single group The The |
v1
DllCall("oleacc\AccessibleChildren", "Ptr", ComObjValue(Acc), "Int", 0, "Int", cChildren, "Ptr", VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*", cChildren)
v1→v2 converter
DllCall("oleacc\AccessibleChildren", "Ptr", ComObjValue(Acc), "Int", 0, "Int", cChildren, "Ptr", varChildren := Buffer(cChildren*(8+2*A_PtrSize), 0)*0+&varChildren, "Int*", &cChildren := 0)
Shouldn't
varChildren := Buffer(cChildren*(8+2*A_PtrSize), 0)*0 +&varChildren
instead be(varChildren:= Buffer(cChildren*(8+2*A_PtrSize), 0))*0+&varChildren
?The text was updated successfully, but these errors were encountered: