]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/MKlib_gen.sh
ncurses 5.7 - patch 20110122
[ncurses.git] / ncurses / base / MKlib_gen.sh
index 12a83e049680d88cd9a3e964ef082076c695c0db..66ae295c607cbbed974cc2d4cdff8f357ff460cc 100755 (executable)
@@ -2,10 +2,10 @@
 #
 # MKlib_gen.sh -- generate sources from curses.h macro definitions
 #
 #
 # MKlib_gen.sh -- generate sources from curses.h macro definitions
 #
-# ($Id: MKlib_gen.sh,v 1.40 2010/03/30 22:42:16 tom Exp $)
+# ($Id: MKlib_gen.sh,v 1.43 2011/01/22 19:47:29 tom Exp $)
 #
 ##############################################################################
 #
 ##############################################################################
-# Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2010,2011 Free Software Foundation, Inc.                #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -200,6 +200,7 @@ $0 !~ /^P_/ {
                }
        }
        second = first + 1;
                }
        }
        second = first + 1;
+       returnCast = "";
        if ( $first == "chtype" ) {
                returnType = "Chtype";
        } else if ( $first == "SCREEN" ) {
        if ( $first == "chtype" ) {
                returnType = "Chtype";
        } else if ( $first == "SCREEN" ) {
@@ -207,7 +208,8 @@ $0 !~ /^P_/ {
        } else if ( $first == "WINDOW" ) {
                returnType = "Win";
        } else if ( $first == "attr_t" || $second == "attrset" || $second == "standout" || $second == "standend" || $second == "wattrset" || $second == "wstandout" || $second == "wstandend" ) {
        } else if ( $first == "WINDOW" ) {
                returnType = "Win";
        } else if ( $first == "attr_t" || $second == "attrset" || $second == "standout" || $second == "standend" || $second == "wattrset" || $second == "wstandout" || $second == "wstandend" ) {
-               returnType = "Attr";
+               returnType = "IntAttr";
+               returnCast = "(attr_t)";
        } else if ( $first == "bool" || $first == "NCURSES_BOOL" ) {
                returnType = "Bool";
        } else if ( $second == "*" ) {
        } else if ( $first == "bool" || $first == "NCURSES_BOOL" ) {
                returnType = "Bool";
        } else if ( $second == "*" ) {
@@ -264,24 +266,26 @@ $0 !~ /^P_/ {
        argtype = ""
        for (i = myfunc; i <= NF; i++) {
                ch = $i;
        argtype = ""
        for (i = myfunc; i <= NF; i++) {
                ch = $i;
-               if ( ch == "*" )
+               if ( ch == "*" ) {
                        pointer = 1;
                        pointer = 1;
-               else if ( ch == "va_list" )
+               } else if ( ch == "va_list" ) {
                        va_list = 1;
                        va_list = 1;
-               else if ( ch == "..." )
+               } else if ( ch == "..." ) {
                        varargs = 1;
                        varargs = 1;
-               else if ( ch == "char" )
+               } else if ( ch == "char" ) {
                        argtype = "char";
                        argtype = "char";
-               else if ( ch == "int" )
+               } else if ( ch == "int" ) {
                        argtype = "int";
                        argtype = "int";
-               else if ( ch == "short" )
+               } else if ( ch == "short" ) {
                        argtype = "short";
                        argtype = "short";
-               else if ( ch == "chtype" )
+               } else if ( ch == "chtype" ) {
                        argtype = "chtype";
                        argtype = "chtype";
-               else if ( ch == "attr_t" || ch == "NCURSES_ATTR_T" )
+               } else if ( ch == "attr_t" || ch == "NCURSES_ATTR_T" ) {
                        argtype = "attr";
                        argtype = "attr";
+               }
 
                if ( ch == "," || ch == ")" ) {
 
                if ( ch == "," || ch == ")" ) {
+                       argcast = "";
                        if (va_list) {
                                call = call "%s"
                        } else if (varargs) {
                        if (va_list) {
                                call = call "%s"
                        } else if (varargs) {
@@ -302,6 +306,9 @@ $0 !~ /^P_/ {
                                } else if ( argtype != "" ) {
                                        call = call "%s"
                                        comma = comma "_trace" argtype "2(" num ","
                                } else if ( argtype != "" ) {
                                        call = call "%s"
                                        comma = comma "_trace" argtype "2(" num ","
+                                       if (argtype == "attr") {
+                                               argcast = "(chtype)";
+                                       }
                                } else {
                                        call = call "%#lx"
                                        comma = comma "(long)"
                                } else {
                                        call = call "%#lx"
                                        comma = comma "(long)"
@@ -315,7 +322,7 @@ $0 !~ /^P_/ {
                                } else if ( varargs ) {
                                        args = args comma "\"...\""
                                } else {
                                } else if ( varargs ) {
                                        args = args comma "\"...\""
                                } else {
-                                       args = args comma "z"
+                                       args = args comma argcast "z"
                                }
                        }
                        call = call ch
                                }
                        }
                        call = call ch
@@ -337,12 +344,16 @@ $0 !~ /^P_/ {
        if (dotrace)
                printf "%s", call
 
        if (dotrace)
                printf "%s", call
 
-       if (match($0, "^void"))
+       if (match($0, "^void")) {
                call = ""
                call = ""
-       else if (dotrace)
+       } else if (dotrace) {
                call = sprintf("return%s( ", returnType);
                call = sprintf("return%s( ", returnType);
-       else
+               if (returnCast != "") {
+                       call = call returnCast;
+               }
+       } else {
                call = "@@return ";
                call = "@@return ";
+       }
 
        call = call $myfunc "(";
        for (i = 1; i < argcount; i++) {
 
        call = call $myfunc "(";
        for (i = 1; i < argcount; i++) {
@@ -357,8 +368,9 @@ $0 !~ /^P_/ {
        }
        if (!match($0, "^void"))
                call = call ") ";
        }
        if (!match($0, "^void"))
                call = call ") ";
-       if (dotrace)
+       if (dotrace) {
                call = call ")";
                call = call ")";
+       }
        print call ";"
 
        if (match($0, "^void"))
        print call ";"
 
        if (match($0, "^void"))