Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
create a stub Niecza p5 module with Module::Starter
- Loading branch information
Showing
17 changed files
with
7,512 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| use strict; | ||
| use warnings; | ||
| use Module::Build; | ||
|
|
||
| my $builder = Module::Build->new( | ||
| module_name => 'Niecza', | ||
| license => 'perl', | ||
| dist_author => 'Paweł Murias <pawelmurias@gmail.com>', | ||
| dist_version_from => 'lib/Niecza.pm', | ||
| include_dirs => ['.'], | ||
| requires => { | ||
| 'Test::More' => 0, | ||
| }, | ||
| add_to_cleanup => [ 'Niecza-*' ], | ||
| ); | ||
|
|
||
| $builder->create_build_script(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Revision history for Niecza | ||
|
|
||
| 0.01 Date/time | ||
| First version, released on an unsuspecting world. | ||
|
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| Build.PL | ||
| Changes | ||
| lib/Niecza.pm | ||
| lib/Niecza.xs | ||
| lib/typemap | ||
| MANIFEST This list of files | ||
| ppport.h | ||
| README | ||
| t/00-load.t | ||
| t/01-object.t | ||
| t/02-feature.t | ||
| t/manifest.t | ||
| t/pod-coverage.t | ||
| t/pod.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| Niecza | ||
|
|
||
| The README is used to introduce the module and provide instructions on | ||
| how to install the module, any machine dependencies it may have (for | ||
| example C compilers and installed libraries) and any other information | ||
| that should be provided before the module is installed. | ||
|
|
||
| A README file is required for CPAN modules since CPAN extracts the README | ||
| file from a module distribution so that people browsing the archive | ||
| can use it to get an idea of the module's uses. It is usually a good idea | ||
| to provide version information here so that people can decide whether | ||
| fixes for the module are worth downloading. | ||
|
|
||
|
|
||
| INSTALLATION | ||
|
|
||
| To install this module, run the following commands: | ||
|
|
||
| perl Build.PL | ||
| ./Build | ||
| ./Build test | ||
| ./Build install | ||
|
|
||
| SUPPORT AND DOCUMENTATION | ||
|
|
||
| After installing, you can find documentation for this module with the | ||
| perldoc command. | ||
|
|
||
| perldoc Niecza | ||
|
|
||
| You can also look for information at: | ||
|
|
||
| RT, CPAN's request tracker (report bugs here) | ||
| http://rt.cpan.org/NoAuth/Bugs.html?Dist=Niecza | ||
|
|
||
| AnnoCPAN, Annotated CPAN documentation | ||
| http://annocpan.org/dist/Niecza | ||
|
|
||
| CPAN Ratings | ||
| http://cpanratings.perl.org/d/Niecza | ||
|
|
||
| Search CPAN | ||
| http://search.cpan.org/dist/Niecza/ | ||
|
|
||
|
|
||
| LICENSE AND COPYRIGHT | ||
|
|
||
| Copyright (C) 2012 Paweł Murias | ||
|
|
||
| This program is free software; you can redistribute it and/or modify it | ||
| under the terms of either: the GNU General Public License as published | ||
| by the Free Software Foundation; or the Artistic License. | ||
|
|
||
| See http://dev.perl.org/licenses/ for more information. | ||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| blib* | ||
| Makefile | ||
| Makefile.old | ||
| Build | ||
| Build.bat | ||
| _build* | ||
| pm_to_blib* | ||
| *.tar.gz | ||
| .lwpcookies | ||
| cover_db | ||
| pod2htm*.tmp | ||
| Niecza-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| package Niecza; | ||
|
|
||
| use warnings; | ||
| use strict; | ||
|
|
||
| =head1 NAME | ||
| Niecza - The great new Niecza! | ||
| =head1 VERSION | ||
| Version 0.01 | ||
| =cut | ||
|
|
||
| our $VERSION = '0.01'; | ||
|
|
||
| require XSLoader; | ||
| XSLoader::load('Niecza', $VERSION); | ||
|
|
||
| =head1 SYNOPSIS | ||
| Quick summary of what the module does. | ||
| Perhaps a little code snippet. | ||
| use Niecza; | ||
| my $foo = Niecza->new(); | ||
| ... | ||
| =head1 EXPORT | ||
| A list of functions that can be exported. You can delete this section | ||
| if you don't export anything, such as for a purely object-oriented module. | ||
| =head1 FUNCTIONS | ||
| =head2 new | ||
| Creates a new Niecza object. Takes the following optional parameters: | ||
| =over 4 | ||
| =item value | ||
| If you pass a single numeric value, it will be stored in the 'value' slot | ||
| of the object hash. | ||
| =item key/value pair | ||
| A generic input method which takes an unlimited number of key/value pairs | ||
| and stores them in the object hash. Performs no validation. | ||
| =back | ||
| =cut | ||
|
|
||
| #sub new { | ||
| # Defined in the XS code | ||
| #} | ||
|
|
||
| =head2 increment | ||
| An object method which increments the 'value' slot of the the object hash, | ||
| if it exists. Called like this: | ||
| my $obj = Niecza->new(5); | ||
| $obj->increment(); # now equal to 6 | ||
| =cut | ||
|
|
||
| #sub function2 { | ||
| # Defined in the XS code | ||
| #} | ||
|
|
||
| =head1 AUTHOR | ||
| Paweł Murias, C<< <pawelmurias@gmail.com> >> | ||
| =head1 BUGS | ||
| Please report any bugs or feature requests to | ||
| C<bug-niecza@rt.cpan.org>, or through the web interface at | ||
| L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Niecza>. | ||
| I will be notified, and then you'll automatically be notified of progress on | ||
| your bug as I make changes. | ||
| =head1 ACKNOWLEDGEMENTS | ||
| =head1 COPYRIGHT & LICENSE | ||
| Copyright 2012 Paweł Murias, All Rights Reserved. | ||
| This program is free software; you can redistribute it and/or modify it | ||
| under the same terms as Perl itself. | ||
| =cut | ||
|
|
||
| 1; # End of Niecza |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| #include "EXTERN.h" | ||
| #include "perl.h" | ||
| #include "XSUB.h" | ||
|
|
||
| #include "ppport.h" | ||
|
|
||
| typedef SV * Niecza; | ||
|
|
||
| MODULE = Niecza PACKAGE = Niecza | ||
|
|
||
| Niecza | ||
| new(...) | ||
| INIT: | ||
| char *classname; | ||
| /* get the class name if called as an object method */ | ||
| if ( sv_isobject(ST(0)) ) { | ||
| classname = HvNAME(SvSTASH(SvRV(ST(0)))); | ||
| } | ||
| else { | ||
| classname = (char *)SvPV_nolen(ST(0)); | ||
| } | ||
|
|
||
| CODE: | ||
| /* This is a standard hash-based object */ | ||
| RETVAL = (Niecza)newHV(); | ||
|
|
||
| /* Single init value */ | ||
| if ( items == 2 ) | ||
| hv_store((HV *)RETVAL, "value", 5, newSVsv(ST(1)), 0); | ||
| /* name/value pairs */ | ||
| else if ( (items-1)%2 == 0 ) { | ||
| int i; | ||
| for ( i=1; i < items; i += 2 ) { | ||
| hv_store_ent((HV *)RETVAL, ST(i), newSVsv(ST(i+1)), 0); | ||
| } | ||
| } | ||
| /* odd number of parameters */ | ||
| else { | ||
| Perl_croak(aTHX_ | ||
| "Usage: Niecza->new()\n" | ||
| " or Niecza->new(number)\n" | ||
| " or Niecza->new(key => value, ...)\n" | ||
| ); | ||
| } | ||
|
|
||
| OUTPUT: | ||
| RETVAL | ||
|
|
||
| IV | ||
| increment(obj) | ||
| Niecza obj | ||
|
|
||
| INIT: | ||
| RETVAL = 0; | ||
| if ( items > 1 ) | ||
| Perl_croak(aTHX_ "Usage: Niecza->increment()"); | ||
|
|
||
| CODE: | ||
| SV **svp; | ||
| if ((svp = hv_fetch((HV*)obj, "value", 5, FALSE))) { | ||
| RETVAL = SvIV(*svp); | ||
| RETVAL++; | ||
| hv_store((HV *)obj, "value", 5, newSViv(RETVAL), 0); | ||
| } | ||
| OUTPUT: | ||
| RETVAL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
|
|
||
| ############################################################################### | ||
| ## | ||
| ## Typemap for Niecza objects | ||
| ## | ||
| ## Copyright (c) 2012 Paweł Murias | ||
| ## All rights reserved. | ||
| ## | ||
| ## This typemap is designed specifically to make it easier to handle | ||
| ## Perl-style blessed objects in XS. In particular, it takes care of | ||
| ## blessing the object into the correct class (even for derived classes). | ||
| ## | ||
| ## | ||
| ############################################################################### | ||
| ## vi:et:sw=4 ts=4 | ||
|
|
||
| TYPEMAP | ||
|
|
||
| Niecza T_PTROBJ_SPECIAL | ||
|
|
||
| INPUT | ||
| T_PTROBJ_SPECIAL | ||
| if (sv_derived_from($arg, \"${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\")) { | ||
| $var = SvRV($arg); | ||
| } | ||
| else | ||
| croak(\"$var is not of type ${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\") | ||
|
|
||
| OUTPUT | ||
| T_PTROBJ_SPECIAL | ||
| /* inherited new() */ | ||
| if ( strcmp(classname,\"${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\") != 0 ) | ||
| $arg = sv_bless(newRV_noinc($var), | ||
| gv_stashpv(classname,TRUE)); | ||
| else | ||
| $arg = sv_bless(newRV_noinc($var), | ||
| gv_stashpv(\"${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\",TRUE)); |
Oops, something went wrong.