Code Monkey home page Code Monkey logo

xs-fun's Introduction

XS Fun

Any XS guru will tell you XS is easy. I've heard this many times. While it may be true, I realized one thing: XS can be scary.

The purpose of this guide is to make XS fun. Yes, fun. Try it out, if you won't feel as exhilarated as I do as you make your way up the stairs of XS knowledge, I will fully reimburse your tuition.

Ground rules

  1. We use a template instead of h2xs.
  2. We do not bundle an additional C library.
  3. We assume you have at least Perl 5.14.2.

These are the best bits of advice I've received so far and they've proven to be crucial.

h2xs is old and crufty, and thus far seems more like a hurdle. Instead, this guide includes a skeleton for each exercise that you can copy and use each time you start a new project.

Bundling additional C libraries requires hacks with ExtUtils::MakeMaker (which is a war in and of itself), including tab character nightmares and additional recursive Makefiles. One way around the obvious "you need to have this library installed" problem is to provide an Alien package. This guide might go over it at some point but makes no promises.

Eliminating the use of h2xs and bundling any C libraries we use (that we haven't written by ourselves) removes a lot of needless complexity.

Perl 5.14.2 is prevalent enough to consider it a starting ground, though at this point it is not yet necessarily important.

Relevant resources

More advanced or specialized resources

xs-fun's People

Contributors

alewmoose avatar aluaces avatar avereha avatar bulk88 avatar dolmen avatar ericherman avatar gideondsouza avatar ivanych avatar mbarbon avatar mvuets avatar paultcochrane avatar rgs avatar sergeyromanov avatar simbabque avatar tsee avatar xsawyerx avatar zmughal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xs-fun's Issues

chapter_08

First of all: Many thanks for this great tutorial.

Unfortunately the last chapter is not complete. Moreover the example code is broken.

  • The code found in xs-fun/chapter_08/Audio-Chromaprint is not fully covered by chapter_08.pod
  • t/leak-pointer is broken. When I run it with default values of Test::MemoryGrowth (10/10000) I get
t/leak-pointer.t .. 
1..2
ok 1 - use Audio::Chromaprint;
not ok 2 - Does not grow in memory

#   Failed test 'Does not grow in memory'
#   at t/leak-pointer.t line 11.
# Lost 344064 bytes of memory over 10000 calls, average of 34.41 per call
# Looks like you failed 1 test of 2.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests 

chapter_05

What is the line algo = SvIV( ST( i + 1 ) ); needed for?

In the appropriate file Chromaprint.xs this line is missing.

Is that a mistake?

Cover typemaps

Typemaps are a strong feature and probably the most useful one when converting C structures to Perl structures.

However, it seems difficult to grasp fully. I find myself asking numerous question after reading a single line of documentation. This should get at least one chapter.

Does it work with C++ too?

I guess this is really a dumb question but do you have fun with XS and C++ too?
Because, I like the OpenFST library (http://www.openfst.org) and would love to see at least some bindings in Perl, but it's written in C++, not C.
XS fun in the other hand constantly talks about C++.

`PADTMP` doesn't appear in `sv_dump()` output in Chapter 04

In Chapter 04, it is mentioned that sv_dump(value) shows that value has PADTMP in its FLAGS output. This doesn't turn up on (perlbrew-ed) perl-5.16.3, perl-5.18.2, perl-5.20.0 or perl-5.21.2 running on Debian Linux "Jessie" x86_64. Which version of perl was used to generate the output from this example? Or, another way of putting this: what did I do wrong?

clang: error: no input files

When I ran 'perl Makefile.PL && make && make test' I got:

WARNING: Setting ABSTRACT via file 'lib/XSFun.pm' failed
at /System/Library/Perl/5.16/ExtUtils/MakeMaker.pm line 609.

and finally :

cc -mmacosx-version-min=10.9 -arch x86_64 -arch i386 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector -o blib/arch/auto/XSFun/XSFun.bundle

clang: error: no input files
make: *** [blib/arch/auto/XSFun/XSFun.bundle] Error 1

I cut and pasted the file contents from the web pages, the directories and files look good, any suggestions as to what caused this? BTW, I'm new to GitHub and recently to perl, but I am an old C hand.
Thanks
Peter

Audio::Chromaprint support

  • chromaprint_get_version
  • chromaprint_new
  • chromaprint_free
  • chromaprint_get_algorithm (implement, since it's not available)
  • chromaprint_set_option
  • chromaprint_start
  • chromaprint_feed
  • chromaprint_finish
  • chromaprint_get_fingerprint
  • chromaprint_get_raw_fingerprint
  • chromaprint_get_fingerprint_hash
  • chromaprint_encode_fingerprint
  • chromaprint_decode_fingerprint
  • chromaprint_hash_fingerprint
  • chromaprint_dealloc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.