Skip to content

Instantly share code, notes, and snippets.

@kg
Created May 8, 2011 08:31
Show Gist options
  • Save kg/961222 to your computer and use it in GitHub Desktop.
Save kg/961222 to your computer and use it in GitHub Desktop.
JSIL.MakeType = function (baseType, namespace, localName, fullName, isReferenceType) {
if (typeof (namespace[localName]) != "undefined")
throw new Error("Duplicate definition of type " + fullName);
var initType;
var ctor = function () {
JSIL.InitializeStructFields(this, localName);
if (typeof (initType) != "undefined")
initType();
try {
if (typeof (this._ctor) != "undefined")
this._ctor.apply(this, arguments);
} catch (e) {
if (JSIL.CheckType(e, JSIL.MissingOverloadException) && (arguments.length == 0))
return;
else
throw e;
}
};
ctor.prototype = JSIL.MakeProto(baseType, fullName, false);
ctor.prototype.__ShortName__ = localName;
ctor.toString = function () {
return "<Type " + fullName + ">";
};
ctor.Of = function (T) {
return ctor;
};
ctor.__IsReferenceType__ = isReferenceType;
ctor.__TypeInitialized__ = false;
ctor.__LockCount__ = 0;
ctor.__FullName__ = fullName;
initType = function () {
JSIL.InitializeType(ctor);
};
namespace[localName] = ctor;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment