Mercurial > flash_v2
comparison host/libcdl/parse.cxx @ 343:fbfd52cf7976
Try to resolve problems caused by API changes in Tcl 8.4, related to
the use of const
| author | bartv |
|---|---|
| date | Sat, 21 Sep 2002 22:05:08 +0000 |
| parents | 0d2b193a635f |
| children |
comparison
equal
deleted
inserted
replaced
| 342:cac491d76066 | 343:fbfd52cf7976 |
|---|---|
| 8 // | 8 // |
| 9 //============================================================================ | 9 //============================================================================ |
| 10 //####COPYRIGHTBEGIN#### | 10 //####COPYRIGHTBEGIN#### |
| 11 // | 11 // |
| 12 // ---------------------------------------------------------------------------- | 12 // ---------------------------------------------------------------------------- |
| 13 // Copyright (C) 2002 Bart Veer | |
| 13 // Copyright (C) 1999, 2000 Red Hat, Inc. | 14 // Copyright (C) 1999, 2000 Red Hat, Inc. |
| 14 // | 15 // |
| 15 // This file is part of the eCos host tools. | 16 // This file is part of the eCos host tools. |
| 16 // | 17 // |
| 17 // This program is free software; you can redistribute it and/or modify it | 18 // This program is free software; you can redistribute it and/or modify it |
| 127 | 128 |
| 128 // Given a list of arguments, concatenate them together into a C++ string. | 129 // Given a list of arguments, concatenate them together into a C++ string. |
| 129 // This makes expression parsing easier. The final argument should be an | 130 // This makes expression parsing easier. The final argument should be an |
| 130 // index into the array, typically the result of a call to skip_argv_options(). | 131 // index into the array, typically the result of a call to skip_argv_options(). |
| 131 std::string | 132 std::string |
| 132 CdlParse::concatenate_argv(int argc, char** argv, int index) | 133 CdlParse::concatenate_argv(int argc, const char* argv[], int index) |
| 133 { | 134 { |
| 134 CYG_REPORT_FUNCNAME("CdlParse::concatenate_argv"); | 135 CYG_REPORT_FUNCNAME("CdlParse::concatenate_argv"); |
| 135 | 136 |
| 136 std::string result = ""; | 137 std::string result = ""; |
| 137 for ( int i = index ; i < argc; i++) { | 138 for ( int i = index ; i < argc; i++) { |
| 218 return result; | 219 return result; |
| 219 } | 220 } |
| 220 | 221 |
| 221 int | 222 int |
| 222 CdlParse::parse_options(CdlInterpreter interp, std::string diag_prefix, char** options, | 223 CdlParse::parse_options(CdlInterpreter interp, std::string diag_prefix, char** options, |
| 223 int argc, char** argv, int index, | 224 int argc, const char* argv[], int index, |
| 224 std::vector<std::pair<std::string,std::string> >& result) | 225 std::vector<std::pair<std::string,std::string> >& result) |
| 225 { | 226 { |
| 226 CYG_REPORT_FUNCNAMETYPE("CdlParse::parse_options", "final index %d"); | 227 CYG_REPORT_FUNCNAMETYPE("CdlParse::parse_options", "final index %d"); |
| 227 CYG_REPORT_FUNCARG4XV(interp, options, argc, argv); | 228 CYG_REPORT_FUNCARG4XV(interp, options, argc, argv); |
| 228 CYG_PRECONDITION_CLASSC(interp); | 229 CYG_PRECONDITION_CLASSC(interp); |
| 239 if (0 == strcmp(argv[index], "--")) { | 240 if (0 == strcmp(argv[index], "--")) { |
| 240 index++; | 241 index++; |
| 241 break; | 242 break; |
| 242 } | 243 } |
| 243 | 244 |
| 244 char* arg_ptr = argv[index]; | 245 const char* arg_ptr = argv[index]; |
| 245 // Skip the initial -, and the second one as well if it is present. | 246 // Skip the initial -, and the second one as well if it is present. |
| 246 if ('-' == *++arg_ptr) { | 247 if ('-' == *++arg_ptr) { |
| 247 arg_ptr++; | 248 arg_ptr++; |
| 248 } | 249 } |
| 249 | 250 |
| 631 // the usual diagnostics process is observed. | 632 // the usual diagnostics process is observed. |
| 632 // | 633 // |
| 633 // This routine should be uninstalled after the parsing is complete, | 634 // This routine should be uninstalled after the parsing is complete, |
| 634 // to avoid e.g. a ParseException when it is not expected. | 635 // to avoid e.g. a ParseException when it is not expected. |
| 635 int | 636 int |
| 636 CdlParse::unknown_command(CdlInterpreter interp, int argc, char** argv) | 637 CdlParse::unknown_command(CdlInterpreter interp, int argc, const char* argv[]) |
| 637 { | 638 { |
| 638 CYG_REPORT_FUNCNAME("CdlParse::unknown_command"); | 639 CYG_REPORT_FUNCNAME("CdlParse::unknown_command"); |
| 639 CYG_REPORT_FUNCARG3XV(interp, argc, argv); | 640 CYG_REPORT_FUNCARG3XV(interp, argc, argv); |
| 640 CYG_PRECONDITIONC(2 <= argc); | 641 CYG_PRECONDITIONC(2 <= argc); |
| 641 CYG_PRECONDITION_CLASSC(interp); | 642 CYG_PRECONDITION_CLASSC(interp); |
| 727 | 728 |
| 728 // ---------------------------------------------------------------------------- | 729 // ---------------------------------------------------------------------------- |
| 729 // A minimal property takes no arguments. | 730 // A minimal property takes no arguments. |
| 730 | 731 |
| 731 int | 732 int |
| 732 CdlParse::parse_minimal_property(CdlInterpreter interp, int argc, char** argv, std::string name, | 733 CdlParse::parse_minimal_property(CdlInterpreter interp, int argc, const char* argv[], std::string name, |
| 733 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_Minimal)) | 734 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_Minimal)) |
| 734 { | 735 { |
| 735 CYG_REPORT_FUNCNAME("parse_minimal_property"); | 736 CYG_REPORT_FUNCNAME("parse_minimal_property"); |
| 736 CYG_PRECONDITION_CLASSC(interp); | 737 CYG_PRECONDITION_CLASSC(interp); |
| 737 | 738 |
| 768 //{{{ parse_string_property() | 769 //{{{ parse_string_property() |
| 769 | 770 |
| 770 // ---------------------------------------------------------------------------- | 771 // ---------------------------------------------------------------------------- |
| 771 | 772 |
| 772 int | 773 int |
| 773 CdlParse::parse_string_property(CdlInterpreter interp, int argc, char** argv, std::string name, | 774 CdlParse::parse_string_property(CdlInterpreter interp, int argc, const char* argv[], std::string name, |
| 774 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_String)) | 775 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_String)) |
| 775 { | 776 { |
| 776 CYG_REPORT_FUNCNAME("parse_string_property"); | 777 CYG_REPORT_FUNCNAME("parse_string_property"); |
| 777 CYG_PRECONDITION_CLASSC(interp); | 778 CYG_PRECONDITION_CLASSC(interp); |
| 778 | 779 |
| 810 //{{{ parse_tclcode_property() | 811 //{{{ parse_tclcode_property() |
| 811 | 812 |
| 812 // ---------------------------------------------------------------------------- | 813 // ---------------------------------------------------------------------------- |
| 813 | 814 |
| 814 int | 815 int |
| 815 CdlParse::parse_tclcode_property(CdlInterpreter interp, int argc, char** argv, std::string name, | 816 CdlParse::parse_tclcode_property(CdlInterpreter interp, int argc, const char* argv[], std::string name, |
| 816 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_TclCode)) | 817 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_TclCode)) |
| 817 { | 818 { |
| 818 CYG_REPORT_FUNCNAME("parse_tclcode_property"); | 819 CYG_REPORT_FUNCNAME("parse_tclcode_property"); |
| 819 CYG_PRECONDITION_CLASSC(interp); | 820 CYG_PRECONDITION_CLASSC(interp); |
| 820 | 821 |
| 826 if (data_index == argc) { | 827 if (data_index == argc) { |
| 827 CdlParse::report_property_parse_error(interp, argv[0], "Missing Tcl code."); | 828 CdlParse::report_property_parse_error(interp, argv[0], "Missing Tcl code."); |
| 828 } else if ((data_index + 1) < argc) { | 829 } else if ((data_index + 1) < argc) { |
| 829 CdlParse::report_property_parse_error(interp, argv[0], std::string("Invalid number of arguments.\n") + | 830 CdlParse::report_property_parse_error(interp, argv[0], std::string("Invalid number of arguments.\n") + |
| 830 "Expecting one argument, a Tcl code fragment."); | 831 "Expecting one argument, a Tcl code fragment."); |
| 831 } else if (!Tcl_CommandComplete(argv[data_index])) { | 832 } else if (!Tcl_CommandComplete(CDL_TCL_CONST_CAST(char*, argv[data_index]))) { |
| 832 CdlParse::report_property_parse_error(interp, argv[0], "Incomplete Tcl code fragment."); | 833 CdlParse::report_property_parse_error(interp, argv[0], "Incomplete Tcl code fragment."); |
| 833 } else { | 834 } else { |
| 834 | 835 |
| 835 CdlNode current_node = interp->get_node(); | 836 CdlNode current_node = interp->get_node(); |
| 836 CYG_ASSERTC(0 != current_node); | 837 CYG_ASSERTC(0 != current_node); |
| 853 //{{{ parse_stringvector_property() | 854 //{{{ parse_stringvector_property() |
| 854 | 855 |
| 855 // ---------------------------------------------------------------------------- | 856 // ---------------------------------------------------------------------------- |
| 856 | 857 |
| 857 int | 858 int |
| 858 CdlParse::parse_stringvector_property(CdlInterpreter interp, int argc, char** argv, std::string name, | 859 CdlParse::parse_stringvector_property(CdlInterpreter interp, int argc, const char* argv[], std::string name, |
| 859 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_StringVector), | 860 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_StringVector), |
| 860 bool allow_empty) | 861 bool allow_empty) |
| 861 { | 862 { |
| 862 CYG_REPORT_FUNCNAME("parse_tclcode_property"); | 863 CYG_REPORT_FUNCNAME("parse_tclcode_property"); |
| 863 CYG_PRECONDITION_CLASSC(interp); | 864 CYG_PRECONDITION_CLASSC(interp); |
| 898 //{{{ parse_reference_property() | 899 //{{{ parse_reference_property() |
| 899 | 900 |
| 900 // ---------------------------------------------------------------------------- | 901 // ---------------------------------------------------------------------------- |
| 901 | 902 |
| 902 int | 903 int |
| 903 CdlParse::parse_reference_property(CdlInterpreter interp, int argc, char** argv, std::string name, | 904 CdlParse::parse_reference_property(CdlInterpreter interp, int argc, const char* argv[], std::string name, |
| 904 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_Reference), | 905 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_Reference), |
| 905 bool allow_empty, CdlUpdateHandler update_handler) | 906 bool allow_empty, CdlUpdateHandler update_handler) |
| 906 { | 907 { |
| 907 CYG_REPORT_FUNCNAME("parse_reference_property"); | 908 CYG_REPORT_FUNCNAME("parse_reference_property"); |
| 908 CYG_PRECONDITION_CLASSC(interp); | 909 CYG_PRECONDITION_CLASSC(interp); |
| 944 //{{{ parse_expression_property() | 945 //{{{ parse_expression_property() |
| 945 | 946 |
| 946 // ---------------------------------------------------------------------------- | 947 // ---------------------------------------------------------------------------- |
| 947 | 948 |
| 948 int | 949 int |
| 949 CdlParse::parse_expression_property(CdlInterpreter interp, int argc, char** argv, std::string name, | 950 CdlParse::parse_expression_property(CdlInterpreter interp, int argc, const char* argv[], std::string name, |
| 950 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_Expression), | 951 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_Expression), |
| 951 CdlUpdateHandler update_handler) | 952 CdlUpdateHandler update_handler) |
| 952 { | 953 { |
| 953 CYG_REPORT_FUNCNAME("parse_expression_property"); | 954 CYG_REPORT_FUNCNAME("parse_expression_property"); |
| 954 CYG_PRECONDITION_CLASSC(interp); | 955 CYG_PRECONDITION_CLASSC(interp); |
| 1003 //{{{ parse_list_expression_property() | 1004 //{{{ parse_list_expression_property() |
| 1004 | 1005 |
| 1005 // ---------------------------------------------------------------------------- | 1006 // ---------------------------------------------------------------------------- |
| 1006 | 1007 |
| 1007 int | 1008 int |
| 1008 CdlParse::parse_listexpression_property(CdlInterpreter interp, int argc, char** argv, std::string name, | 1009 CdlParse::parse_listexpression_property(CdlInterpreter interp, int argc, const char* argv[], std::string name, |
| 1009 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_ListExpression), | 1010 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_ListExpression), |
| 1010 CdlUpdateHandler update_handler) | 1011 CdlUpdateHandler update_handler) |
| 1011 { | 1012 { |
| 1012 CYG_REPORT_FUNCNAME("parse_list_expression_property"); | 1013 CYG_REPORT_FUNCNAME("parse_list_expression_property"); |
| 1013 CYG_PRECONDITION_CLASSC(interp); | 1014 CYG_PRECONDITION_CLASSC(interp); |
| 1057 //{{{ parse_goalexpression_property() | 1058 //{{{ parse_goalexpression_property() |
| 1058 | 1059 |
| 1059 // ---------------------------------------------------------------------------- | 1060 // ---------------------------------------------------------------------------- |
| 1060 | 1061 |
| 1061 int | 1062 int |
| 1062 CdlParse::parse_goalexpression_property(CdlInterpreter interp, int argc, char** argv, std::string name, | 1063 CdlParse::parse_goalexpression_property(CdlInterpreter interp, int argc, const char* argv[], std::string name, |
| 1063 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_GoalExpression), | 1064 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_GoalExpression), |
| 1064 CdlUpdateHandler update_handler) | 1065 CdlUpdateHandler update_handler) |
| 1065 { | 1066 { |
| 1066 CYG_REPORT_FUNCNAMETYPE("parse_goal_expression_property", "result %d"); | 1067 CYG_REPORT_FUNCNAMETYPE("parse_goal_expression_property", "result %d"); |
| 1067 CYG_PRECONDITION_CLASSC(interp); | 1068 CYG_PRECONDITION_CLASSC(interp); |
