You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 426 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: -for CamlIDL use https://github.com/xavierleroy/camlidl/issues
Bug description
Full_Name: Dmitry Bely
Version: camlidl current cvs
OS: Windows NT 4.0
Submission from: d227.p3.col.ru (195.210.132.227)
(1,3) Extern variables and functions should be declared as 'extern "C"' in c++
mode.
(2) Syntax error -- should be "virtual void STDMETHODCALLTYPE method();"
Also when we generate code for Win32, proper COM-compatible alignment should be
specified.
Original bug ID: 426
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: -for CamlIDL use https://github.com/xavierleroy/camlidl/issues
Bug description
Full_Name: Dmitry Bely
Version: camlidl current cvs
OS: Windows NT 4.0
Submission from: d227.p3.col.ru (195.210.132.227)
Let's consider the following example:
[---cut---]
void f();
[object]
interface ITest: IUnknown
{
void method();
}
[---cut---]
It produces cplusplus.h file which we are going to use in C++ mode:
[---cut---]
/* File generated from cplusplus.idl */
#ifndef _CAMLIDL_CPLUSPLUS_H
#define _CAMLIDL_CPLUSPLUS_H
extern void f(void); /* (1) */
struct ITest;
#ifdef __cplusplus
struct ITest {
virtual HRESULT (STDMETHODCALLTYPE *QueryInterface)(IID *, void **);
virtual ULONG (STDMETHODCALLTYPE *AddRef)();
virtual ULONG (STDMETHODCALLTYPE *Release)();
virtual void (STDMETHODCALLTYPE method)(); / (2) */
};
#else
struct ITestVtbl {
DECLARE_VTBL_PADDING
HRESULT (STDMETHODCALLTYPE *QueryInterface)(struct ITest *, IID *, void **);
ULONG (STDMETHODCALLTYPE *AddRef)(struct ITest *);
ULONG (STDMETHODCALLTYPE *Release)(struct ITest *);
void (STDMETHODCALLTYPE method)(struct ITest * self);
};
struct ITest {
struct ITestVtbl * lpVtbl;
};
#endif
extern IID IID_ITest; / (3) */
#endif /* !_CAMLIDL_CPLUSPLUS_H */
[---cut---]
(1,3) Extern variables and functions should be declared as 'extern "C"' in c++
mode.
(2) Syntax error -- should be "virtual void STDMETHODCALLTYPE method();"
Also when we generate code for Win32, proper COM-compatible alignment should be
specified.
So the following path is proposed:
[---cut---]
Index: compiler/file.ml
RCS file: /caml/bazar-ocaml/camlidl/compiler/file.ml,v
retrieving revision 1.16
diff -u -r1.16 file.ml
--- compiler/file.ml 2001/06/15 16:53:45 1.16
+++ compiler/file.ml 2001/07/09 13:43:25
@@ -216,8 +216,21 @@
fprintf oc "
#ifndef %s\n
#define %s\n\n" symbname symbname;
(* Emit the definitions *)
List.iter (process_definition oc) intf;
fprintf oc "\n
#endif /* !%s */\n" symbname
Index: compiler/funct.ml
RCS file: /caml/bazar-ocaml/camlidl/compiler/funct.ml,v
retrieving revision 1.25
diff -u -r1.25 funct.ml
--- compiler/funct.ml 2001/06/17 10:50:25 1.25
+++ compiler/funct.ml 2001/07/09 13:43:27
@@ -114,7 +114,7 @@
(* Generate the C declaration for a function *)
let c_declaration oc fundecl =
fundecl.fun_res);
begin match fundecl.fun_params with
[] -> fprintf oc "void"
| p1 :: pl ->
Index: compiler/intf.ml
===================================================================
RCS file: /caml/bazar-ocaml/camlidl/compiler/intf.ml,v
retrieving revision 1.20
diff -u -r1.20 intf.ml
--- compiler/intf.ml 2001/06/17 10:50:25 1.20
+++ compiler/intf.ml 2001/07/09 13:43:31
@@ -122,7 +122,7 @@
List.iter
(fun m ->
iprintf oc "virtual %a("
@@ -153,7 +153,7 @@
fprintf oc " struct %sVtbl * lpVtbl;\n" intf.intf_name;
fprintf oc "};\n";
fprintf oc "#endif\n";
end
(* Define the wrapper classes *)
[---cut---]
and now we have
[---cut---]
/* File generated from cplusplus.idl */
#ifndef _CAMLIDL_CPLUSPLUS_H
#define _CAMLIDL_CPLUSPLUS_H
#ifdef __cplusplus
#define _CAMLIDL_EXTERN_C extern "C"
#else
#define _CAMLIDL_EXTERN_C extern
#endif
#ifdef _WIN32
#pragma pack(push,8) /* is necessary for COM interfaces */
#endif
_CAMLIDL_EXTERN_C void f(void);
struct ITest;
#ifdef __cplusplus
struct ITest {
virtual HRESULT STDMETHODCALLTYPE QueryInterface(IID *, void **);
virtual ULONG STDMETHODCALLTYPE AddRef();
virtual ULONG STDMETHODCALLTYPE Release();
virtual void STDMETHODCALLTYPE method();
};
#else
struct ITestVtbl {
DECLARE_VTBL_PADDING
HRESULT (STDMETHODCALLTYPE *QueryInterface)(struct ITest *, IID *, void **);
ULONG (STDMETHODCALLTYPE *AddRef)(struct ITest *);
ULONG (STDMETHODCALLTYPE *Release)(struct ITest *);
void (STDMETHODCALLTYPE *method)(struct ITest * self);
};
struct ITest {
struct ITestVtbl * lpVtbl;
};
#endif
_CAMLIDL_EXTERN_C IID IID_ITest;
#ifdef _WIN32
#pragma pack(pop)
#endif
#endif /* !_CAMLIDL_CPLUSPLUS_H */
[---cut---]
The text was updated successfully, but these errors were encountered: