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: union-name in the discriminated union declaration #2875

Closed
vicuna opened this issue Jul 31, 2001 · 1 comment
Closed

camlidl: union-name in the discriminated union declaration #2875

vicuna opened this issue Jul 31, 2001 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Jul 31, 2001

Original bug ID: 463
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: -for CamlIDL use https://github.com/xavierleroy/camlidl/issues

Bug description

Here is the patch adding support for optional "union-name" parameter in IDL
union definition according to Microsoft specs:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/midl/hh/midl/mi-laref_76i6.asp

[---cut---]
Index: compiler/parse_aux.ml

RCS file: /caml/bazar-ocaml/camlidl/compiler/parse_aux.ml,v
retrieving revision 1.13
diff -u -r1.13 parse_aux.ml
--- compiler/parse_aux.ml 2001/07/30 14:45:40 1.13
+++ compiler/parse_aux.ml 2001/07/31 09:36:03
@@ -263,14 +263,14 @@
let make_fields attrs tybase decls =
List.map (make_field attrs tybase) decls

-let make_discriminated_union name switch_name switch_type body =
+let make_discriminated_union name union_name switch_name switch_type body =
let ty_union =
Type_union({ud_name = ""; ud_mod = ""; ud_stamp = 0; ud_cases = body},
{discriminant = Expr_ident switch_name}) in
{ sd_name = name; sd_mod = ""; sd_stamp = 0;
sd_fields = [ {field_name = switch_name; field_mlname = switch_name;
field_typ = switch_type};

  •              {field_name = "u"; field_mlname = "u";
    
  •              {field_name = union_name; field_mlname = union_name;
                  field_typ = ty_union} ] }
    

let type_names =
Index: compiler/parse_aux.mli

RCS file: /caml/bazar-ocaml/camlidl/compiler/parse_aux.mli,v
retrieving revision 1.8
diff -u -r1.8 parse_aux.mli
--- compiler/parse_aux.mli 2001/06/29 13:30:00 1.8
+++ compiler/parse_aux.mli 2001/07/31 09:36:53
@@ -58,6 +58,7 @@
val make_discriminated_union :
string ->
string ->

  • string ->
    idltype -> union_case list -> struct_decl
    (* Convert a union switch(...) into a struct encapsulating an union *)
    val type_names : StringSet.t ref
    Index: compiler/parser_midl.mly
    ===================================================================
    RCS file: /caml/bazar-ocaml/camlidl/compiler/parser_midl.mly,v
    retrieving revision 1.16
    diff -u -r1.16 parser_midl.mly
    --- compiler/parser_midl.mly 2001/06/29 13:30:00 1.16
    +++ compiler/parser_midl.mly 2001/07/31 09:37:00
    @@ -333,12 +333,18 @@

/* Struct declaration and discriminated unions */

+union_name:

  • ident
  •    { $1 }
    
  • | /* empty */
  •    { "u" }
    

+;
struct_declarator:
STRUCT opt_ident LBRACE field_declarators RBRACE
{ {sd_name = $2; sd_mod = ""; sd_stamp = 0; sd_fields = $4} }

  • | UNION opt_ident SWITCH LPAREN simple_type_spec ident RPAREN
  • | UNION opt_ident SWITCH LPAREN simple_type_spec ident RPAREN union_name
    LBRACE union_body RBRACE
  •    { make_discriminated_union $2 $6 $5 (List.rev $9) }
    
  •    { make_discriminated_union $2 $8 $6 $5 (List.rev $10) }
    

;
field_declarators:
field_declarator
[---cut---]

Microsoft uses that intensively (see also my last followup to PR #410)

Hope to hear from you soon,
Dmitry

@vicuna
Copy link
Author

vicuna commented Jan 15, 2002

Comment author: administrator

Suggested patch applied 2002-01-15 by XL

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