Delphi Pas2Dox + Doxygen - delphi

I am using Delphi and I need to prepare some documentation. One of possible solutions to that is to use Doxygen with Pas2Dox filter.
I am currently using pas2dox-0.50rc1.exe filter and Doxygen wizard 1.8.3.1. I am struggling to setup Doxygen properly to display my comments in Delphi but the thing is that I am not sure anymore what is the proper comment format in Delphi. I searched interenet but I can't find any tutorial or example on how to succesfully generate html documentation with delphi.
Is there maybe somebody who can share me some tips how to achieve that?
My current comments are as:
{*------------------------------------------------------------------------------
test
#param AGraphicsOwner ParameterDescription
#param ASettingsPath ParameterDescription
#param AEngineType ParameterDescription
#return ResultDescription
------------------------------------------------------------------------------*}
constructor TBaseEngine.Create(AGraphicsOwner: HWND;
ASettingsPath: PAnsiChar;
AEngineType: byte);
THANKS!!

I succeeded in creating a nice doxygen documentation with comments formated exactly like yours on my delphi code!
Here is how:
Replace all not-doxygen comments with // :
instead of
(* comment *) or { comment }
have
// comment
Why? According to this blog entry for the pas2dox filter it is crucial not to use (* and *) for commentaries in your delphi file. Furthermore simple one-line commentaries embraced by { and } seem to destroy the doxygen documentation as well.
Put the methods you want to see documented in doxygen into the INTERFACE section:
Only the methods "declared" in the INTERFACE section will be visible in doxygen (I have not quite figured out why, yet)
I tested it with a file that had all types of delphi comment-styles. I replaced the comment-idicators with notepad++'s replace-all function in the following order (I am completely sure there is a more elegant way to do that, but for me it was handy):
replace { with //
replace //$ with {$
replace (* with //
after that, all methods (in the INTERFACE section) appeared in doxygen and I started to comment using the doxygen style from above. I left away the ---, but I don't think this should be an issue =)

Related

Get AST for C fragment, using Clang?

I am building a clang plugin, and I am trying to generate the AST for a C fragment at some point within the plugin. Something like:
std::string c_code = "...";
getAST(c_code);
Can someone point me to, how to go about this?
May be there are several ways to achieve this, but finally I got the following snippet working and to me it looks simple enough:
//arguments to the compiler
std::unique_ptr <std::vector<const char*>> args(new std::vector<const char*>());
args->push_back("my_file.c");
//do the magic
ASTUnit *au = ASTUnit::LoadFromCommandLine(
&(*args)[0],
&(*args)[0] + args->size(),
IntrusiveRefCntPtr<DiagnosticsEngine>(
CompilerInstance::createDiagnostics(new DiagnosticOptions)),
StringRef()
);
//get the translation unit node
Declr *d = au->getASTContext().getTranslationUnitDecl();
Simpler alternatives or suggestions to improve this are welcome.
I don't have a code snipped ready to copy-paste, but the idea that I used before is the following:
Note that clang_parseTranslationUnit has unsaved_files as one of the arguments. So the idea would be to provide a command line g++ main.cpp, and then provide an unsaved file with name main.cpp and the content from your string.

Calling Library in Lua

I have created a Wireshark dissector in Lua for an application over TCP. I am attempting to use zlib compression and base64 decryption. How do I actually create or call an existing c library in Lua?
The documentation I have seen just says that you can get the libraries and use either the require() call or the luaopen_ call, but not how to actually make the program find and recognize the actual library. All of this is being done in Windows.
You can't load any existing C library, which was not created for Lua, with plain Lua. It's not trivial at least.
*.so/*.dll must follow some specific standard, which is bluntly mentioned in programming in Lua#26.2 and lua-users wiki, code sample. Also similar question answered here.
There are two ways You could solve Your problem:
Writing Your own Lua zlib library wrapper, following those standards.
Taking some already finished solution:
zlib#luapower
lua-zlib
ffi
Bigger list #lua-users wiki
The same applies to base64 encoding/decoding. Only difference, there are already plain-Lua libraries for that. Code samples and couple of links #lua-users wiki.
NOTE: Lua module package managers like LuaRocks or
LuaDist MIGHT save You plenty of time.
Also, simply loading a Lua module usually consists of one line:
local zlib = require("zlib")
The module would be searched in places defined in Your Lua interpreter's luaconf.h file.
For 5.1 it's:
#if defined(_WIN32)
/*
** In Windows, any exclamation mark ('!') in the path is replaced by the
** path of the directory of the executable file of the current process.
*/
#define LUA_LDIR "!\\lua\\"
#define LUA_CDIR "!\\"
#define LUA_PATH_DEFAULT \
".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua"
#define LUA_CPATH_DEFAULT \
".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
#else
How do I actually create or call an existing c library in Lua?
An arbitrary library, not written for use by Lua? You generally can't.
A Lua consumable "module" must be linked against the Lua API -- the same version as the host interpreter, such as Lua5.1.dll in the root of the Wireshark directory -- and expose a C-callable function matching the lua_CFunction signature. Lua can load the library and call that function, and it's up to that function to actually expose functionality to Lua using the Lua API.
Your zlib and/or base64 libraries know nothing about Lua. If you had a Lua interpreter with a built-in FFI, or you found a FFI Lua module you could load, you could probably get this to work, but it's really more trouble than it's worth. Writing a Lua module is actually super easy, and you can tailor the interface to be more idiomatic for Lua.
I don't have zlib or a base64 C library handy, so for example's sake lets say we wanted to let our Lua script use the MessageBox function from the user32.dll library in Windows.
#include <windows.h>
#include "lauxlib.h"
static int luaMessageBox (lua_State* L) {
const char* message = luaL_checkstring(L,1);
MessageBox(NULL, message, "", MB_OK);
return 0;
}
int __declspec(dllexport) __cdecl luaopen_messagebox (lua_State* L) {
lua_register(L, "msgbox", luaMessageBox);
return 0;
}
To build this, we need to link against user32.dll (contains MessageBox) and lua5.1.dll (contains the Lua API). You can get Lua5.1.lib from the Wireshark source. Here's using Microsoft's compiler to produce messagebox.dll:
cl /LD /Ilua-5.1.4/src messagebox.c user32.lib lua5.1.lib
Now your Lua scripts can write:
require "messagebox"
msgbox("Hello, World!")
Your only option is to use a library library like alien. See my answer Disabling Desktop Composition using Lua Scripting for other FFI libraries.

openoffice calc with delphi again

I was using search engine and not just here, and got tired of it; just want a simple answer (or a link) for a simple question:
How do I open a calc sheet and write 123 into cell A1 from Delphi (7) code? (Or any hello worlds for calc?)
You can take a look at this demo:
http://sourceforge.net/projects/ooomacros/files/Delphi%20OOo/Version%201.2/Delphi_OOo_v12en.zip/download
I tested the Document part a month ago (which works), and I there is also some spreadsheet code in the examples.pas.
Ok, after some research and using the informations above for I thank yas a lot, here is a simple answer:
uses part
Uses ComObj, OOoMessages, OOoTools, OOoConstants, OOoXray;
main code
open blank document, write 'hello 123' text into a1 then save it on desktop
procedure HelloWorldExample;
var
mentesiOpciok,oSheet,oSheets,myCalc : Variant;
begin
ConnectOpenOffice;
myCalc:=StarDesktop.loadComponentFromURL('private:factory/scalc', '_blank', 0, dummyArray);
oSheets:=myCalc.getSheets;
oSheet:=oSheets.getByIndex(0);
//oSheet.getCellByPosition(0, 0).SetValue(123);
oSheet.getCellByPosition(0, 0).SetFormula('hello 123!');
mentesiOpciok:=CreateProperties(['FilterName', 'MS Excel 97']);
myCalc.storeToURL('file:///C:/Documents and Settings/Zéiksz/Asztal/calcdoc.xls', mentesiOpciok);
showMessage('kész :)');
myCalc.close(true);
DisconnectOpenOffice();
end;
use getcellbyposition(...).setvalue to set numeric values, or setformula for strings (not really sure, but there is a string in it LOL).
Péter
edit: most useful information I found on the Internet is in this forum:
http://www.oooforum.org/forum/viewtopic.phtml?t=4996

OpenOffice automation translate basic code to Delphi

Hello please help to translate the next line of basic code to Delphi for the OOoTools.pas interface.
oChart.Diagram.SymbolType = com.sun.star.chart.ChartSymbolType.SYMBOL1
I know that the SYMBOL1 part is an enumeration and I think I have to use the MakePropertyValue fumction but how?
Have you tried the simpler: oChart.Diagram.SymbolType := SYMBOL1;Just my first shot, btw.

Looking for a more flexible tool than GNU indent

When I run indent with various options I want against my source, it does what I want but also messes with the placement of *s in pointer types:
-int send_pkt(tpkt_t* pkt, void* opt_data);
-void dump(tpkt_t* bp);
+int send_pkt(tpkt_t * pkt, void *opt_data);
+void dump(tpkt * bp);
I know my placement of *s next to the type not the variable is unconventional but how can I get indent to just leave them alone? Or is there another tool that will do what I want? I've looked in the man page, the info page, and visited a half a dozen pages that Google suggested and I can't find an option to do this.
I tried Artistic Style (a.k.a. AStyle) but can't seem to figure out how to make it indent in multiples of 4 but make every 8 a tab. That is:
if ( ... ) {
<4spaces>if ( ... ) {
<tab>...some code here...
<4spaces>}
}
Uncrustify
Uncrustify has several options on how to indent your files.
From the config file:
indent_with_tabs
How to use tabs when indenting code
0=spaces only
1=indent with tabs, align with spaces
2=indent and align with tabs
You can find it here.
BCPP
From the website: "bcpp indents C/C++ source programs, replacing tabs with spaces or the reverse. Unlike indent, it does (by design) not attempt to wrap long statements."
Find it here.
UniversalIndentGUI
It's a tool which supports several beautifiers / formatters. It could lead you to even more alternatives.
Find it here.
Artistic Style
You could try Artistic Style aka AStyle instead (even though it doesn't do what you need it to do, I'll leave it here in case someone else finds it useful).
Hack around and change its behavior editing the code. It's GNU after all. ;-)
As it's probably not the answer you wanted, here's another link: http://www.fnal.gov/docs/working-groups/c++wg/indenting.html.

Resources