Coccinelle release 0.2.5-rc3
[bpt/coccinelle.git] / parsing_c / unparse_cocci.ml
index 6eab5bb..5cc451c 100644 (file)
@@ -460,8 +460,14 @@ and typeC ty =
   | Ast.Array(ty,lb,size,rb) ->
       fullType ty; mcode print_string lb; print_option expression size;
       mcode print_string rb
-  | Ast.EnumName(kind,name) -> mcode print_string kind; pr_space();
-      ident name
+  | Ast.EnumName(kind,name) ->
+      mcode print_string kind;
+      print_option_prespace ident name
+  | Ast.EnumDef(ty,lb,ids,rb) ->
+      fullType ty; ft_space ty;
+      mcode print_string lb;
+      dots force_newline expression ids;
+      mcode print_string rb
   | Ast.StructUnionName(kind,name) ->
       mcode structUnion kind; print_option_prespace ident name
   | Ast.StructUnionDef(ty,lb,decls,rb) ->
@@ -485,6 +491,9 @@ and baseType = function
   | Ast.FloatType -> print_string "float"
   | Ast.LongType -> print_string "long"
   | Ast.LongLongType -> print_string "long long"
+  | Ast.SizeType -> print_string "size_t "
+  | Ast.SSizeType -> print_string "ssize_t "
+  | Ast.PtrDiffType -> print_string "ptrdiff_t "
 
 and structUnion = function
     Ast.Struct -> print_string "struct"
@@ -612,7 +621,16 @@ and initialiser nlcomma i =
             pretty_print_c.Pretty_print_c.init ini
         | _ -> raise Impossible)
   | Ast.InitExpr(exp) -> expression exp
-  | Ast.InitList(_,lb,initlist,rb,[]) ->
+  | Ast.ArInitList(lb,initlist,rb) ->
+      (match Ast.undots initlist with
+       [] -> mcode print_string lb; mcode print_string rb
+      |        _ ->
+         mcode print_string lb; start_block();
+         dots force_newline (initialiser false) initlist;
+         end_block(); mcode print_string rb)
+  | Ast.StrInitList(_,lb,[],rb,[]) ->
+      mcode print_string lb; mcode print_string rb
+  | Ast.StrInitList(_,lb,initlist,rb,[]) ->
       mcode print_string lb; start_block();
       (* awkward, because the comma is separate from the initialiser *)
       let rec loop = function
@@ -621,7 +639,8 @@ and initialiser nlcomma i =
        | x::xs -> initialiser nlcomma x; loop xs in
       loop initlist;
       end_block(); mcode print_string rb
-  | Ast.InitList(_,lb,initlist,rb,_) -> failwith "unexpected whencode in plus"
+  | Ast.StrInitList(_,lb,initlist,rb,_) ->
+      failwith "unexpected whencode in plus"
   | Ast.InitGccExt(designators,eq,ini) ->
       List.iter designator designators; pr_space();
       mcode print_string eq; pr_space(); initialiser nlcomma ini
@@ -630,6 +649,17 @@ and initialiser nlcomma i =
   | Ast.IComma(comma) ->
       mcode print_string comma;
       if nlcomma then force_newline()
+  | Ast.Idots(dots,Some whencode) ->
+      if generating
+      then
+       (mcode print_string dots;
+        print_text "   when != ";
+        initialiser nlcomma whencode)
+      else raise CantBeInPlus
+  | Ast.Idots(dots,None) ->
+      if generating
+      then mcode print_string dots
+      else raise CantBeInPlus
   | Ast.OptIni(ini) | Ast.UniqueIni(ini) ->
       raise CantBeInPlus
 
@@ -764,6 +794,8 @@ and rule_elem arity re =
   | Ast.TopInit(init) -> initialiser false init
   | Ast.Include(inc,s) ->
       mcode print_string inc; print_text " "; mcode inc_file s
+  | Ast.Undef(def,id) ->
+      mcode print_string def; pr_space(); ident id
   | Ast.DefineHeader(def,id,params) ->
       mcode print_string def; pr_space(); ident id;
       print_define_parameters params