Author: sh-sh-sh Date: Fri Nov 9 19:44:03 2007 New Revision: 41949 URL: http://svn.opensuse.org/viewcvs/yast?rev=41949&view=rev Log: merged from trunk Modified: branches/tmp/sh/mod-ui/core/base/tools/devtools/generateYCPWrappers Modified: branches/tmp/sh/mod-ui/core/base/tools/devtools/generateYCPWrappers URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/base/tools/... ============================================================================== --- branches/tmp/sh/mod-ui/core/base/tools/devtools/generateYCPWrappers (original) +++ branches/tmp/sh/mod-ui/core/base/tools/devtools/generateYCPWrappers Fri Nov 9 19:44:03 2007 @@ -1,5 +1,10 @@ #!/usr/bin/perl -w +# example: +# /* TYPEINFO: boolean (symbol, symbol, any) */ +# YCPValue ChangeWidget ( const YCPSymbol & widget_id, const YCPSymbol & property, const YCPValue & /*nil*/ new_value ); + + my $header_file = shift; my $call_file = shift; my $register_file = shift; @@ -50,6 +55,11 @@ open ( CALL, "> $call_file" ) or die "Cannot open output file"; open ( REGISTER, "> $register_file" ) or die "Cannot open output file"; +my $generated = "\t// This file is generated by generateYCPwrappers from $header_file\n\n"; +print CALL $generated; +print REGISTER $generated; + +print CALL "\t\tstatic const char * err_fmt = "Parameter %d is nil, %s is required";\n"; my $position = 0; while (@exports) @@ -66,21 +76,23 @@ while (@params) { - my @par = split (" ", shift (@params) ); - my $type = $par [0]; - if ( $type =~ /const/ ) - { - $type = $par [1]; - } - $type =~ s/^YCP(\w+)&?/$1/; - - push (@tests, "if (m_param$paramcount->isVoid()) {y2error("ERROR: Parameter $paramcount is nil, ".$type." is required"); return YCPVoid();}"); - - $type = "m_param" . $paramcount . "->as" . $type . "()" ; - push @cppparams, $type; - $paramcount++; + my $par = shift (@params); + $par =~ m{(const\s*)?YCP(\w+)\s*(&\s*)?(/*nil*/)?}; + my $type = $2; + if (defined $4) { # #340523 + push (@tests, "// m_param$paramcount may be nil"); + } + else { + push (@tests, "if (m_param$paramcount->isVoid()) {ycp2error(err_fmt, $paramcount, "$type"); return YCPVoid();}"); + + } + $type = "m_param" . $paramcount . "->as" . $type . "()" ; + push @cppparams, $type; + $paramcount++; } - print CALL "\t\tcase $position: ". join (" ", @tests) . " return m_instance->$func_name (" . join (", ", @cppparams) . "); \n" ; + print CALL "\t\tcase $position: // $func_name\n" . + "\t\t\t". join ("\n\t\t\t", @tests) . "\n" . + "\t\t\treturn m_instance->$func_name (" . join (", ", @cppparams) . "); \n" ; print REGISTER "\tenterSymbol (new SymbolEntry (this, $position, " ; print REGISTER ""$func_name", SymbolEntry::c_function, Type::fromSignature ("$signature") ) );\n"; @@ -91,7 +103,3 @@ close ( CALL ); close ( REGISTER ); - - -0 - -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org