view dstep/objc/bridge/Type.d @ 2:9fd439a28ce3

Adapted the scripts for the new bridge + a lot more
author Jacob Carlborg <doob@me.com>
date Sun, 05 Jul 2009 17:16:19 +0200
parents 033d260cfc9b
children 19885b43130e
line wrap: on
line source

/**
 * Copyright: Copyright (c) 2009 Jacob Carlborg.
 * Authors: Jacob Carlborg
 * Version: Initial created: May 16, 2009
 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
 */
module dstep.objc.bridge.Type;

version (Tango)
	import tango.core.Tuple;

else
	import std.typetuple;

import dstep.objc.objc;

template ObjcType (T)
{
	static if (needsEncapsulation!(T))
		alias id ObjcType;
	
	else
		alias T ObjcType;
}

template needsEncapsulation (T)
{
	static if (is(T == class))
		const needsEncapsulation = true;
	
	else
		const needsEncapsulation = false;
}

template ObjcTypeTuple (TList...)
{
	alias replaceClasses!(TList).types ObjcTypeTuple;
}

private struct Wrap (TList...)
{
	TList types;
}

private Wrap!(TList) replaceClasses (TList...) ()
{
	alias Tuple!(TList) Types;
	
	foreach (ref type ; Types)
		static if (is(type == class))
			type = id;
	
	return Wrap!(Types);
}