Skip to content

Instantly share code, notes, and snippets.

@jpf91
jpf91 / formatter.d
Created March 14, 2011 15:36
jpf.http.formatter
/**
* Contains functions to format the jpf.http.types types
* into the HTTP format (formatValue, formatHeader).
*
* TODO:
* Remove trailing zeros with floating point numbers
* Spec allows this, but it wastes bandwidth
*
* Not implemented headers:
* Authorization
final class HeaderCollection
{
private:
struct Entry
{
//Case preserved
string Key;
string Value;
}
Entry[string] storage;
@jpf91
jpf91 / gist:937492
Created April 22, 2011 20:15
Swig4D class cast proposal
/*
* C++ Class structure:
*
* Shape
* |- Circle
* |- Rectangle
* |-Square
*
*/
@jpf91
jpf91 / gist:938408
Created April 23, 2011 06:36
Swig4D Bug1
%module bug;
//Use swig2.0 -Wall -d -d2 -c++ bug.i
//Then in the generated files:
//in Test/Test.d:
//"class Tag : ..strList {"
template <class T> class List
{
public:
@jpf91
jpf91 / gist:938547
Created April 23, 2011 11:17
Swig4D Bug 2
%module bug;
//Use swig2.0 -Wall -d -d2 -c++ bug.i
//Then in the generated files:
//in Test/Test.d:
//"class AttachedPictureFrame : Test.Frame {"
//should be
//"class AttachedPictureFrame : Test.Test.Frame {"
namespace Test {
import std.datetime;
import std.array;
import std.conv;
import std.string;
import std.algorithm;
struct PackageVersion
{
enum VersionType
{
/**
* Original libev documentation:
* $(LINK2 http://pod.tst.eu/http://cvs.schmorp.de/_libev/ev.pod?pathrev=rel-3__9, version 3.9)
* $(LINK2 http://pod.tst.eu/http://cvs.schmorp.de/_libev/ev.pod?pathrev=rel-4__04, version 4.04)
* $(LINK2 http://pod.tst.eu/http://cvs.schmorp.de/_libev/ev.pod, most recent version)
*/
module jpf.c.libev;
/*
* libev native API header
struct File
{
private struct Impl
{
uint refs = uint.max / 2;
//Other 'by-reference' members ...
this(uint r)
{
refs = r;
}
struct File
{
private struct Impl
{
uint refs = uint.max / 2;
//Other 'by-reference' members ...
this(uint r)
{
refs = r;
}
import std.stdio;
import std.typecons;
void main()
{
auto wrap1 = Wrapper(1);
}
void free(ref int _payload)
{