Skip to content

Commit

Permalink
Adding exception to alert user when extern methods are declared that …
Browse files Browse the repository at this point in the history
…are not in a type dervied from JsObject. Fixing functional tests in sample site
  • Loading branch information
Frank Laub committed Nov 2, 2009
1 parent ba11fd6 commit f8575be
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 29 deletions.
2 changes: 1 addition & 1 deletion sample/DotWeb.Sample.Script/Test/Expando.cs
Expand Up @@ -23,7 +23,7 @@
namespace DotWeb.Sample.Script.Test
{
[JsNamespace]
class ExpandoNative
class ExpandoNative : JsObject
{
public extern ExpandoNative(object cfg);
public extern void CallHostedMethod();
Expand Down
4 changes: 2 additions & 2 deletions sample/DotWeb.Sample.Script/Test/NativeCallback.cs
Expand Up @@ -21,15 +21,15 @@
namespace DotWeb.Sample.Script.Test
{
[JsNamespace]
internal class NativeCaller
internal class NativeCaller : JsObject
{
public extern NativeCaller(object cfg);

public extern void Start();
}

[JsNamespace]
internal class NativeObject
internal class NativeObject : JsObject
{
public extern NativeObject();

Expand Down
27 changes: 1 addition & 26 deletions sample/DotWeb.Sample.Script/Tuple.cs
Expand Up @@ -30,33 +30,8 @@ public class Config
public string value;
}

public delegate void ITupleHandler(ITuple tuple, int id);

// [ClassInterface(typeof(TupleClass))]
public interface ITuple
{
TupleClass Class { get; }

object Value { get; set; }

ITupleHandler handler { set; }
void fireEvent();
}

public interface TupleClass
{
ITuple Constructor(object config);

int Sum(int[] args);
void StaticMethod(int x, int y);
ITuple Factory();

void Callback1(Delegate cb);
void Callback2(Delegate cb);
}

[JsNamespace]
public class Tuple
public class Tuple : JsObject
{
public extern Tuple();

Expand Down
9 changes: 9 additions & 0 deletions src/DotWeb.Translator/TranslationContext.cs
Expand Up @@ -100,6 +100,15 @@ public class TranslationContext
};
return ret;
}

if (!method.HasBody || method.Body.Instructions.Count == 0) {
string msg = string.Format(
"{0}\nA method marked extern must either have [JsCode] or be declared in a type derived from JsObject.",
method
);
throw new MissingMethodException(msg);
}

return MethodDecompiler.Parse(method);
}

Expand Down
1 change: 1 addition & 0 deletions src/DotWeb.Translator/TranslationEngine.cs
Expand Up @@ -51,6 +51,7 @@ public class TranslationEngine
public void TranslateType(AssemblyQualifiedTypeName aqtn) {
var asm = resolver.Resolve(aqtn.AssemblyName.FullName);
asm.Resolver = resolver;
asm.MainModule.LoadSymbols();
var typeDef = asm.MainModule.Types[aqtn.TypeName];
TranslateType(typeDef);
}
Expand Down

0 comments on commit f8575be

Please sign in to comment.