Jump to content

Data from C++ header file to AutoIt


Recommended Posts

C++ header files are unfamiliar to me, but I'm trying to figure something out.
My intention is to automatically extract from these files the necessary information to be able to then use them in the ObjCreateInterface() and/or ObjectFromTag() function.
To get started I followed some guidance from this post by @LarsJ : https://www.autoitscript.com/forum/topic/205154-using-objcreateinterface-and-objectfromtag-functions

This script is a first draft to try to translate variable types from MSDN types to AutoIt types.
A lot of this code could definitely be improved by replacing some parts with more effective regular expressions (if only I could....).
For some of the conversions I used a function posted in this post by @wolf9228 from some time ago (https://www.autoitscript.com/forum/topic/113824-windows-data-types/).
With that function it is possible to translate the default types, but I see that there are types in the header that are not foreseen in that function. They look like types declared elsewhere in the header itself.
also sometimes the type declaration contains 2 strings where the first of the 2 appears to be the type declaration, but sometimes it contains three, where the first of the three strings may be for example 'const' or something different and in that case the declaration of type is the second string. So it would be necessary to find a way to parse that group of strings which is variable.
In this draft script I tried in the case of 3 strings not to consider the first one, but surely this method is not infallible and perhaps the possible cases could include even more than 3 strings in the declaration of a type? Is there anyone who can give some suggestions on how to proceed in those cases?

To run this script, you also need to save a C++ header file in the same directory. I used the header file related to webview2 WebView2.h which can be found in this post by @LarsJ (https://www.autoitscript.com/forum/topic/205154-using-objcreateinterface-and-objectfromtag-functions) in the file ObjectFromTag.7z inside the 'Includes' folder.

The script returns a draft of the intended result where unrecognized types are marked with ?????.
The output script is also copied to the clipboard so that it can be easily pasted into the SciTE editor for better analysis.

immediately below the translated declarations, the declarations of the original types are also reported, as a reminder.

welcome to anyone who is interested in developing this script or has useful suggestions for converting a c++ header to AutoIt.

Thank you

 

Header_Parser.au3

Edited by Gianni
added some global variables generation in the listing

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...