Skip to content

Instantly share code, notes, and snippets.

View salortiz's full-sized avatar
💭
unbitroting my p6 modules

Salvador Ortiz salortiz

💭
unbitroting my p6 modules
  • Matías Software Group
  • México
View GitHub Profile
use v6.c;
use NativeCall;
# A proof of concept for NativeCall "varargs" calls,
my $printf = cglobal(Str,'printf',Pointer);
my @sxa := (
(Nil => :(Str --> int32)).Map, # arity 0
(Str => :(Str,Str --> int32), Int => :(Str,Int --> int32)).Map # arity 1
);
@salortiz
salortiz / strftime.pm6
Last active May 7, 2016 05:31
POSIX strftime for Perl6
use v6;
use NativeCall;
constant MAX_BUF_SIZE = 255; # Seems reasonable
constant time_t = size_t; # Best guess.
my class tm is repr('CStruct') { }; # Fields can be added when needed
my sub gmtime(time_t is rw -->tm) is native { * };
my sub strftime(utf8, size_t, Str, tm -->size_t) is native { * };
sub PosixFormat(DateTime:D $time, Str $format) is export {
my time_t $t = $time.posix;
@salortiz
salortiz / MyTest.pm6
Last active May 2, 2016 10:50
Simple test case for "Cannot invoke this object"
BEGIN { -> { note } }();