KinoSearch
view release on metacpan or search on metacpan
clownfish/lib/Clownfish/Binding/Perl/Class.pm view on Meta::CPAN
my $documentation = shift;
# Remove double-equals hack needed to fool perldoc, PAUSE, etc. :P
$documentation =~ s/^==/=/mg;
# Change <code>foo</code> to C<< foo >>.
$documentation =~ s#<code>(.*?)</code>#C<< $1 >>#gsm;
# Lowercase all method names: Open_In() => open_in()
$documentation
=~ s/([A-Z][A-Za-z0-9]*(?:_[A-Z][A-Za-z0-9]*)*\(\))/\L$1\E/gsm;
# Change all instances of NULL to 'undef'
$documentation =~ s/NULL/undef/g;
# Change "Err_error" to "KinoSearch->error".
$documentation =~ s/Err_error/KinoSearch->error/g;
return $documentation;
}
1;
__END__
__POD__
=head1 NAME
Clownfish::Binding::Perl::Class - Generate Perl binding code for a
Clownfish::Class.
=head1 CLASS METHODS
=head1 register
Clownfish::Binding::Perl::Class->register(
parcel => 'MyProject' , # required
class_name => 'Foo::FooJr', # required
bind_methods => [qw( Do_Stuff _get_foo|Get_Foo )], # default: undef
bind_constructors => [qw( new _new2|init2 )], # default: undef
make_pod => [qw( get_foo )], # default: undef
xs_code => undef, # default: undef
);
Create a new class binding and lodge it in the registry. May only be called
once for each unique class name, and must be called after all classes have
been parsed (via Clownfish::Hierarchy's build()).
=over
=item * B<parcel> - A L<Clownfish::Parcel> or parcel name.
=item * B<class_name> - The name of the class to be registered.
=item * B<xs_code> - Raw XS code to be included in the final .xs file
generated by Clownfish::Binding::Perl. The XS directives PACKAGE and
MODULE should be specified.
=item * B<bind_methods> - An array of names for novel methods for which XS
bindings should be auto-generated, supplied using Clownfish's C<Macro_Name>
method-naming convention. The Perl subroutine name will be derived by
lowercasing C<Method_Name> to C<method_name>, but this can be overridden by
prepending an alias and a pipe: e.g. C<_get_foo|Get_Foo>.
=item * B<bind_constructors> - An array of constructor names. The default
implementing function is the class's C<init> function, unless it is overridden
using a pipe-separated string: C<_new2|init2> would create a Perl subroutine
"_new2" which would invoke C<myproj_FooJr_init2>.
=item * B<make_pod> - A specification for generating POD. TODO: document this
spec, or break it up into multiple methods. (For now, just see examples from
the source code.)
=back
=head1 registry
my $registry = Clownfish::Binding::Perl::Class->registry;
while ( my $class_name, $class_binding ) = each %$registry ) {
...
}
Return the hash registry used by register(). The keys are class names, and
the values are Clownfish::Binding::Perl::Class objects.
=head1 OBJECT METHODS
=head2 get_class_name get_bind_methods get_bind_methods get_make_pod
get_xs_code get_client
Accessors. C<get_client> retrieves the Clownfish::Class module to be
bound.
=head2 constructor_bindings
my @ctor_bindings = $class_binding->constructor_bindings;
Return a list of Clownfish::Binding::Perl::Constructor objects created as
per the C<bind_constructors> spec.
=head2 method_bindings
my @method_bindings = $class_binding->method_bindings;
Return a list of Clownfish::Binding::Perl::Method objects created as per
the C<bind_methods> spec.
=head2 create_pod
my $pod = $class_binding->create_pod;
Auto-generate POD according to the make_pod spec, if such a spec was supplied.
=head1 COPYRIGHT AND LICENSE
Copyright 2008-2011 Marvin Humphrey
This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
( run in 2.232 seconds using v1.01-cache-2.11-cpan-5c0b1e786e0 )