Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
Implemented various XmlReader APIs, notably ReadElementString and dep…
Browse files Browse the repository at this point in the history
…endencies, plus Skip
  • Loading branch information
kg committed Apr 12, 2012
1 parent ddd0a8e commit df72ef2
Show file tree
Hide file tree
Showing 6 changed files with 349 additions and 13 deletions.
13 changes: 13 additions & 0 deletions Libraries/JSIL.Bootstrap.js
Expand Up @@ -3034,6 +3034,19 @@ JSIL.ImplementExternals("System.Activator", function ($) {
return JSIL.CreateInstanceOfType(type, args); return JSIL.CreateInstanceOfType(type, args);
} }
); );

$.Method({Static:true , Public:true }, "CreateInstance",
(new JSIL.MethodSignature($.Object, [
$asms[5].TypeRef("System.Type"), $asms[5].TypeRef("System.Reflection.BindingFlags"),
$asms[5].TypeRef("System.Reflection.Binder"), $jsilcore.TypeRef("System.Array", [$.Object]),
$asms[5].TypeRef("System.Globalization.CultureInfo")
], [])),
function CreateInstance (type, bindingAttr, binder, args, culture) {
// FIXME
return JSIL.CreateInstanceOfType(type, args);
}
);

}); });


JSIL.ImplementExternals("System.Diagnostics.Stopwatch", function ($) { JSIL.ImplementExternals("System.Diagnostics.Stopwatch", function ($) {
Expand Down
19 changes: 11 additions & 8 deletions Libraries/JSIL.Core.js
Expand Up @@ -4085,23 +4085,26 @@ JSIL.CreateInstanceOfType = function (type, constructorName, constructorArgument
} else { } else {
constructor = publicInterface.prototype["_ctor"]; constructor = publicInterface.prototype["_ctor"];


if ((typeof (constructor) !== "function") || (constructor.__IsPlaceholder__)) {
JSIL.Host.warning("Type '" + type.__FullName__ + "' has no default constructor!");
return instance;
}

constructorArguments = constructorName; constructorArguments = constructorName;
constructorName = null; constructorName = null;
} }


if (!JSIL.IsArray(constructorArguments))
constructorArguments = [];

if (type.__IsNativeType__) { if (type.__IsNativeType__) {
// Native types need to be constructed differently. // Native types need to be constructed differently.
return constructor.apply(constructor, constructorArguments); return constructor.apply(constructor, constructorArguments);
} }


if (!JSIL.IsArray(constructorArguments))
constructorArguments = [];

if (type.__IsStruct__ && (constructorArguments.length === 0))
return instance;

if ((typeof (constructor) !== "function") || (constructor.__IsPlaceholder__)) {
JSIL.Host.warning("Type '" + type.__FullName__ + "' has no default constructor!");
return instance;
}

if (typeof (constructor) !== "function") { if (typeof (constructor) !== "function") {
if (typeof(constructorName) === "string") if (typeof(constructorName) === "string")
throw new Error("Type '" + String(type) + "' has no constructor named '" + constructorName + "'."); throw new Error("Type '" + String(type) + "' has no constructor named '" + constructorName + "'.");
Expand Down

0 comments on commit df72ef2

Please sign in to comment.