XS is an actively used programming language created in 2002.

17Years Old 1,020Users 0Jobs
  • XS ranks in the top 20% of languages
  • the XS wikipedia page
  • XS first appeared in 2002
  • See also: perl, c, pod
  • I have 29 facts about XS. just email me if you need more.

Example code from Linguist:

/*
 * This software is copyright (C) by Nick Wellnhofer <wellnhofer@aevum.de>.
 *
 * This is free software; you can redistribute it and/or modify it under
 * the same terms as the Perl 5 programming language system itself.
 *
 * Terms of the Perl programming language system itself
 *
 * a) the GNU General Public License as published by the Free
 *    Software Foundation; either version 1, or (at your option) any
 *    later version, or
 * b) the "Artistic License"
 */

/*
 * Notes on memory management
 *
 * - A pointer to the Perl SV representing a node is stored in the
 *   user data slot of `struct cmark_node`, so there's a 1:1 mapping
 *   between Perl and C objects.
 * - Every node SV keeps a reference to the parent SV. This is done
 *   indirectly by looking up the parent SV and increasing its refcount.
 * - This makes sure that a document isn't freed if the last reference
 *   from Perl to the root node is dropped, as references to child nodes
 *   might still exist.
 * - As a consequence, as long as a node is referenced from Perl, all its
 *   ancestor nodes will also be associated with a Perl object.
 */

#define PERL_NO_GET_CONTEXT

#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#include <stdlib.h>
#include <cmark.h>

#if CMARK_VERSION < 0x001000
    #error libcmark 0.16.0 is required.
#endif

/* Fix prefixes of render functions. */
#define cmark_node_render_html cmark_render_html
#define cmark_node_render_xml  cmark_render_xml
#define cmark_node_render_man  cmark_render_man

static SV*
S_create_or_incref_node_sv(pTHX_ cmark_node *node) {
    SV *new_obj = NULL;

    while (node) {
        SV *obj;
        HV *stash;

        /* Look for existing object. */
        obj = (SV*)cmark_node_get_user_data(node);

        if (obj) {
            /* Incref if found. */
            SvREFCNT_inc_simple_void_NN(obj);
            if (!new_obj) {
                new_obj = obj;
            }
            break;
        }

        /* Create a new SV. */
        o
Edit

Last updated February 11th, 2019