Skip to content

Commit

Permalink
use param objects to generate constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Mar 6, 2023
1 parent fd37672 commit 05d98f5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions genpp.pl
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,12 @@ =head1 NAME
pp_bless(my $fullclass = "PDL::OpenCV::$c");
pp_addhdr(qq{typedef ${c}Wrapper *PDL__OpenCV__$c;\n});
my $extra_args = $extra_cons_args{$c} || [];
my @cons_pars = map PP::OpenCV->new(0, @$_), ['char *', 'klass'], @$extra_args;
my $doc = $class2doc{$c} // '';
$doc = text_trim doxy2pdlpod(doxyparse($doc)) if $doc;
my $cons_doc = "\@brief Initialize OpenCV $c object.";
my $cons_doxy = doxyparse($cons_doc);
$cons_doxy->{brief}[0] .= make_example('new', 1, [+{}, map PP::OpenCV->new(0, @$_), @$extra_args], [{name=>'obj'}], $fullclass, 1);
$cons_doxy->{brief}[0] .= make_example('new', 1, \@cons_pars, [{name=>'obj'}], $fullclass, 1);
$cons_doc = text_trim doxy2pdlpod($cons_doxy);
pp_addpm(<<EOD);
=head1 METHODS for PDL::OpenCV::$c\n\n
Expand All @@ -357,8 +358,8 @@ =head2 new
EOD
pp_addxs(<<EOF);
MODULE = ${main::PDLMOD} PACKAGE = PDL::OpenCV::$c PREFIX=cw_${c}_
\nPDL__OpenCV__$c cw_${c}_new(char *klass@{[ map ", @$_", @$extra_args ]})
CODE:\n cw_error CW_err = cw_${c}_new(&RETVAL, klass@{[ map ", $_->[1]", @$extra_args ]});
\nPDL__OpenCV__$c cw_${c}_new(@{[join ', ', map $_->xs_par, @cons_pars]})
CODE:\n cw_error CW_err = cw_${c}_new(&RETVAL@{[ map ", $_->{name}", @cons_pars ]});
PDL->barf_if_error(*(pdl_error *)&CW_err);
OUTPUT:\n RETVAL
\nvoid cw_${c}_DESTROY(PDL__OpenCV__$c self)
Expand Down

0 comments on commit 05d98f5

Please sign in to comment.