Skip to content
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

camlidl and size_is attribute #2816

Closed
vicuna opened this issue Jun 27, 2001 · 3 comments
Closed

camlidl and size_is attribute #2816

vicuna opened this issue Jun 27, 2001 · 3 comments

Comments

@vicuna
Copy link

vicuna commented Jun 27, 2001

Original bug ID: 412
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: 3.01, camlidl cvs 27.06.01
OS: Windows NT 4.0
Submission from: d009.p3.col.ru (195.210.132.9)

"size_is" attribute is handled wrong for typedefs:

typedef struct {
int len;
[size_is(len)] int* data; /* OK */
} STRUCT1;

typedef int* PINT;
typedef struct {
int len;
[size_is(len)] PINT data; /* Warning: attribute `size_is' unknown, malformed
or not applicable here, ignored. */
} STRUCT2;

This is like the "string" attribute problem I reported before.

@vicuna
Copy link
Author

vicuna commented Jun 29, 2001

Comment author: administrator

"size_is" attribute is handled wrong for typedefs:

typedef struct {
int len;
[size_is(len)] int* data; /* OK */
} STRUCT1;

typedef int* PINT;
typedef struct {
int len;
[size_is(len)] PINT data;
/* Warning: attribute `size_is' unknown, malformed
or not applicable here, ignored. */
} STRUCT2;

For Camlidl, a "typedef" is not a macro -- it's a real declaration
that causes conversion functions for the defined type to be generated.
From this standpoint, it makes no sense to modify the type a posteriori
with a size_is attribute. In other terms, [size_is(...)] is
syntactically part of an array or pointer type
[size_is(...)] ty * foo
or
[size_is(...)] ty foo[]
but cannot be applied a posteriori to a named pointer or array type.

The MIDL spec isn't too clear about this, but all the examples it shows
are of the two forms above.

This is like the "string" attribute problem I reported before.

It's subtly different: your example was

    typedef char MYCHAR;
    [string] MYCHAR * x;

Here [string] is part of a pointer type expression, so it can be
parsed correctly as a string type.

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Jun 29, 2001

Comment author: administrator

Normal behavior.

@vicuna
Copy link
Author

vicuna commented Jun 29, 2001

Comment author: administrator

Xavier Leroy Xavier.Leroy@inria.fr writes:

"size_is" attribute is handled wrong for typedefs:

typedef struct {
int len;
[size_is(len)] int* data; /* OK */
} STRUCT1;

typedef int* PINT;
typedef struct {
int len;
[size_is(len)] PINT data;
/* Warning: attribute `size_is' unknown, malformed
or not applicable here, ignored. */
} STRUCT2;

For Camlidl, a "typedef" is not a macro -- it's a real declaration
that causes conversion functions for the defined type to be generated.
From this standpoint, it makes no sense to modify the type a posteriori
with a size_is attribute. In other terms, [size_is(...)] is
syntactically part of an array or pointer type
[size_is(...)] ty * foo
or
[size_is(...)] ty foo[]
but cannot be applied a posteriori to a named pointer or array type.

The MIDL spec isn't too clear about this, but all the examples it shows
are of the two forms above.

Unfortunately, all examples are taken from the real Microsoft sources
(wtypes.idl):

typedef struct _SECURITY_ATTRIBUTES {
DWORD nLength;
[size_is(nLength)] LPVOID lpSecurityDescriptor;
BOOL bInheritHandle;
} SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;

OK, Microsoft docs has never been accurate, so you can mark it as "not a
bug" -- anyway I can edit that manually, inserting necessary #ifs.

Hope to hear from you soon,
Dmitry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant