How do you access a macro in the AOT macro node? - x++

I have the following macro in the macro node of the AOT in AX 2012
#localmacro.printSettings
classStr(SrsPrintDestinationSettings), xSession::systemSessionId()
#endmacro
How can I then access this in code? Basically i want to be able to pass certain print settings to the macro and then grab those settings using the macro as well.

The use of macros is all explained here.
Do not make it too complicated, if it is, you are better served using regular methods.

Macros can only manage parameters that make sense to be writed on the source code. They are not intended to receive and manage objects as parameters. If you need so, you'll need to implement a regular method, as Jan B. Kjeldsen stated on their answer.

Related

Does Lua have something analogous to a header file?

Suppose I have a global function called foo() which I've implemented internally outside of Lua and exposed to the user. Ideally I'd like the user's IDE to be aware of this function for things like autocomplete. The closest thing that comes to mind would be a header file for C/C++, where the function is declared without being defined.
Does Lua have any support for this?
There is no cross IDE mechanism for this in Lua.
There is no way to declare a function prototype in Lua. You can only define function values. So unless you don't provide your functions as Lua code no IDE will be able to parse them for autocompletion. So you would have to provide IDE-specific autocomplete files for your API.
Most Lua development is probably done in a simple text editor anyway.
Provide a good documentation for your API and any Lua developer using it will be happy.
As Piglet mentioned there is no out-of-the-box solution for Lua that works across all IDEs. However, I found a typed variant of Lua called Teal which has support for declaration files. Teal seems fairly analogous to Typescript.

How can I call a Dart library created with DDC from JavaScript?

I've created a large library in Dart that need to be called from JavaScript. I'd like to avoid using JS Interop if possible. Can I use the Dart Dev Compiler to do this?
Is it possible to take the JavaScript code generated by DDC and easily call it directly?
I'm guessing you'll need some #JS because otherwise, the tree-shaking will likely remove any need for the very entrypoints you want, and the code won't even be there.

How to get type info from Go compiled packages in language x?

I want to write a simple editor with basic autocomplete functionality for the Go language as a pet project. How would one go about doing it? I took a look at the Go plugins for Eclipse and IntelliJ, but they were too big for me to comprehend (not to mention getting one to compile).
The Go standard library offers the building blocks for a Go parser which
you can use to parse the source files and look for function definitions and the like.
There's also the godoc command which
already does what you want: extracting method definitions and it's documentation. You may look in the
source code to see how godoc is
working or use godoc directly.
This editor written in Go projects has a manageable amount of code,
you may look into it.
The de facto standard approach to this problem is to use nsf's gocode. I have tried it only in Vim - it works very well.
Even though there's ready made support for specific editors, gocode is not editor specific. It's a daemon with a communication protocol. It is thus usable from any program.

any tools which scan code and give a list of functions which call a given function

here's my problem, I'm tidying up some old code which I've modified over the years and removing redundent functions,
I can do it the slow way & comment it out and see if the compiler throws an error.
But I'm just wondering if there are any tools which can which scan code and give a list of functions which call a given function.
I Had a look in ge-experts & icarus, but they only do this at the level of units & classes not down to functions.
any suggestions welcome,
many thanks, Brian
Recent versions of Delphi have "Search for References" available via context menu or Ctrl-Shift-Enter. This has the advantage over a simple "search in files" that it will find only references to the current function under the cursor and not also any function or other identifier with the same name.
Compile your project. Then, in the IDE, those lines that are accessed (rather than being dead code) will have a blue dot in the left margin:
No method is perfect, limitations of the one below are these:
the .MAP file will include functions that the linker cannot eliminate (for instance overrides of methods in classes touched by your code)
it will only give you method names, but if methods are overloaded multiple versions of these methods could be used
The big pro over using .MAP files is that they are easier to scan than blue dots in the code editor.
So it does answer your question to provide a list of functions. But that might not actually what you are after (:
Method using .MAP file:
change your project to include a detailed .MAP file
rebuild your project
the directory of your .EXE file now will include a .MAP file
scan the .MAP file for function names that are included in the .EXE
That .MAP file will exclude functions eliminated by the compiler and linker.
Those are a good indication of what 'dead' code you have.
In a similar way, you could use the JDBG information. That contains more context, but also requires you to write some tooling yourself.
For Pascal this is trivial. First make a list of all the functions, then for each function search for it in the text not following the word "function" and followed by a "(". Awk would be a good tool for doing this.
If your Delphi version is 2007 (or may be prior to it?), I strongly suggest you to consider using DGrok: Give it a try and you will see how capable it is (The demo app will tell).
As it was pointed out by the author, you still need to implement symbol table support, so that the tools can do refactorings or Find References: Roll your own...
Don't worry if you are stuck to Delphi, please head to
PasParse (The Delphi port of the DGrok parser that was originally written in C# !) by Turbo87.
Notice that Turbo87 has forked the original Joe White's Dgrok (latest release in 2008) (Update to VS2010 and add some documentation for LexScanner).

Generating a list of events in a Delphi/BCB Project

I would like to generate a list of events and methods assigned to them in a given BCB project. Is there a way to do this?
I don't think you can do this in a 100% reliable way. But maybe it's enough to just scan all the *.dfm's in your project folder for lines starting with " On".
There are DFM parser code available on the net.
http://www.felix-colibri.com/papers/colibri_utilities/dfm_parser/dfm_parser.html
FWIW, event is simply a property with method type.
I have just recently written a DFM file parser myself. My use case was to load a form and extract and replace some binary information from it. The library is written in Go, it is well-tested with RAD Studio source code and our own production code.
https://github.com/gonutz/dfm
You can use the parser, walk the tree in memory and generate what you need from it.

Resources