Skip to content

Commit

Permalink
work on #750
Browse files Browse the repository at this point in the history
  • Loading branch information
chochos authored and tombentley committed Oct 9, 2015
1 parent e927547 commit e9bda28
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 24 deletions.
4 changes: 2 additions & 2 deletions runtime-js/ceylon/language/jsint/AppliedClass.ceylon
@@ -1,5 +1,5 @@
import ceylon.language.meta.model {
ClosedType=Type, Constructor, Functional, Applicable,
ClosedType=Type, Functional, Applicable,
Member, Class, ClassOrInterface, Attribute, Method,
ClassModel,InterfaceModel,MemberInterface,MemberClass,TypeArgument,
FunctionModel, ValueModel,
Expand All @@ -13,7 +13,7 @@ import ceylon.language.meta.declaration {
shared native class AppliedClass<out Type=Anything, in Arguments=Nothing>() satisfies Class<Type,Arguments>
given Arguments satisfies Anything[] {

shared actual native <CallableConstructor<Type, Arguments>|Class<Type, Arguments>>? defaultConstructor;
shared actual native CallableConstructor<Type, Arguments>? defaultConstructor;
shared actual native CallableConstructor<Type, Arguments>|ValueConstructor<Type>? getConstructor<Arguments>(String name)
given Arguments satisfies Anything[];
shared actual native CallableConstructor<Type, Arguments>|ValueConstructor<Type>? getDeclaredConstructor<Arguments>(String name)
Expand Down
4 changes: 2 additions & 2 deletions runtime-js/ceylon/language/jsint/AppliedMemberClass.ceylon
Expand Up @@ -2,7 +2,7 @@ import ceylon.language.meta.model {
ClosedType=Type, ClassModel, InterfaceModel,
FunctionModel, ValueModel,
Member, Class, ClassOrInterface, Attribute, Method,
MemberInterface,MemberClass,MemberClassConstructor, TypeArgument,
MemberInterface,MemberClass, TypeArgument,
MemberClassValueConstructor,MemberClassCallableConstructor
}
import ceylon.language.meta.declaration {
Expand All @@ -14,7 +14,7 @@ shared native class AppliedMemberClass<in Container, out Type=Anything, in Argum
satisfies MemberClass<Container,Type,Arguments>
given Arguments satisfies Anything[] {
shared actual native Class<Type,Arguments> bind(Object container);
shared actual native <MemberClassCallableConstructor<Container, Type, Arguments>|MemberClass<Container, Type, Arguments>>? defaultConstructor;
shared actual native MemberClassCallableConstructor<Container, Type, Arguments>? defaultConstructor;
shared actual native MemberClassCallableConstructor<Container,Type,Arguments>|MemberClassValueConstructor<Container,Type>? getConstructor<Arguments>(String name)
given Arguments satisfies Anything[];
shared actual native MemberClassCallableConstructor<Container,Type, Arguments>|MemberClassValueConstructor<Container,Type>? getDeclaredConstructor<Arguments>(String name)
Expand Down
Expand Up @@ -70,6 +70,7 @@ shared native class OpenClassWithConstructors(pkg, meta) satisfies ClassWithCons
shared actual String string=>"class ``qualifiedName``";
shared actual Integer hash =>string.hash;

shared native actual CallableConstructorDeclaration? defaultConstructor;
shared native actual <CallableConstructorDeclaration|ValueConstructorDeclaration>? getConstructorDeclaration(String name);
//shared native actual ConstructorDeclaration? defaultConstructorDeclaration;
shared native actual ConstructorDeclaration[] constructorDeclarations();
Expand Down
Expand Up @@ -2,7 +2,7 @@ import ceylon.language { AnnotationType = Annotation }
import ceylon.language.meta.declaration {
ClassDeclaration, ValueDeclaration, Package, Module,
NestableDeclaration, OpenInterfaceType, OpenClassType, OpenType,
FunctionOrValueDeclaration, TypeParameter, ConstructorDeclaration,
FunctionOrValueDeclaration, TypeParameter, CallableConstructorDeclaration,
ClassWithInitializerDeclaration
}
import ceylon.language.meta.model {
Expand Down Expand Up @@ -64,6 +64,9 @@ shared native class OpenClassWithInitializer(pkg, meta) satisfies ClassWithIniti
given Annotation satisfies AnnotationType;
shared native actual Kind[] declaredMemberDeclarations<Kind>()
given Kind satisfies NestableDeclaration;
shared native actual CallableConstructorDeclaration defaultConstructor;
shared native actual CallableConstructorDeclaration[] annotatedConstructorDeclarations<Annotation>()
given Annotation satisfies AnnotationType;

shared native actual ValueDeclaration? objectValue;
shared actual String string=>"class ``qualifiedName``";
Expand Down
6 changes: 3 additions & 3 deletions runtime-js/jsint/AppliedMemberClassCallableConstructor.js
Expand Up @@ -56,9 +56,9 @@ function AppliedMemberClassCallableConstructor$jsint(tipo,$$targs$$,that,myTargs
return AppliedMemberClassCallableConstructor$jsint.$$.prototype.$prop$getString.get.call(that);
},undefined,AppliedMemberClassCallableConstructor$jsint.$$.prototype.$prop$getString.$crtmm$);
}
MemberClassConstructor$meta$model({Type$MemberClassConstructor:$$targs$$.Type$AppliedMemberClassCallableConstructor,
Arguments$MemberClassConstructor:$$targs$$.Arguments$AppliedMemberClassCallableConstructor,
Container$MemberClassConstructor:$$targs$$.Container$AppliedMemberClassCallableConstructor},that);
MemberClassCallableConstructor$meta$model({Type$MemberClassCallableConstructor:$$targs$$.Type$AppliedMemberClassCallableConstructor,
Arguments$MemberClassCallableConstructor:$$targs$$.Arguments$AppliedMemberClassCallableConstructor,
Container$MemberClassCallableConstructor:$$targs$$.Container$AppliedMemberClassCallableConstructor},that);
set_type_args(that,$$targs$$,AppliedMemberClassCallableConstructor$jsint);
that.$targs=myTargs;
that.tipo=tipo;
Expand Down
8 changes: 8 additions & 0 deletions runtime-js/jsint/OpenCallableConstructor/annotated.js
@@ -1,4 +1,12 @@
function($mpt){
if (this.defaultConstructor) {
var mm=getrtmm$$(this.tipo);
if (mm.d[mm.d.length-1] !== '$def') {
//fake constructor
if (extendsType($mpt.Annotation$annotated,{t:SharedAnnotation}))return true;
if (extendsType($mpt.Annotation$annotated,{t:DocAnnotation}))return false;
}
}
var x=annd$annotations(this,{Annotation$annotations:$mpt.Annotation$annotated});
return x&&x.size>0;
}
8 changes: 6 additions & 2 deletions runtime-js/jsint/OpenCallableConstructor/apply.js
Expand Up @@ -8,10 +8,14 @@ function $_apply(targs,mt) {
Container$AppliedMemberClassCallableConstructor:{t:cc.container.tipo},
Arguments$AppliedMemberClassCallableConstructor:mt.Arguments$apply});*/
} else {
var _t=tparms2targs$(getrtmm$$(this.tipo).$cont,targs);
return AppliedCallableConstructor$jsint(this.tipo,
var mm=getrtmm$$(this.tipo);
var fakeConstructor=this.defaultConstructor && mm.d[mm.d.length-1]!=='def$';
var _t=tparms2targs$(fakeConstructor?this.tipo:mm.$cont,targs);
cc=AppliedCallableConstructor$jsint(this.tipo,
{Type$AppliedCallableConstructor:mt.Result$apply,
Arguments$AppliedCallableConstructor:mt.Arguments$apply});
if (fakeConstructor)cc.fakeConstr$=true;
return cc;
}
throw new TypeError("WTF OpenCallableConstructor.apply");
}
10 changes: 8 additions & 2 deletions runtime-js/jsint/OpenCallableConstructor/container.js
@@ -1,5 +1,11 @@
if (this.cont$===undefined) {
var cc=getrtmm$$(this.tipo).$cont;
this.cont$=openClass$jsint(this.containingPackage,cc);
var cc=getrtmm$$(this.tipo);
if (this.defaultConstructor && cc.d[cc.d.length-1]!=='$def') {
//fake constructor
this.cont$=openClass$jsint(this.containingPackage,this.tipo);
} else {
cc=cc.$cont;
this.cont$=openClass$jsint(this.containingPackage,cc);
}
}
return this.cont$;
@@ -1,6 +1,6 @@
if (this.isdef$===undefined) {
//Just by checking the path we can determine this
var mm=getrtmm$$(this.tipo);
this.isdef$ = mm.d[mm.d.length-1] === '$def';
this.isdef$ = mm.d.length<3 || mm.d[mm.d.length-1] === '$def' || mm.d[mm.d.length-1]==='$c';
}
return this.isdef$;
2 changes: 1 addition & 1 deletion runtime-js/jsint/OpenCallableConstructor/shared.js
@@ -1 +1 @@
return (getrtmm$$(this.tipo).pa&1) > 0;
return (getrtmm$$(this.tipo).pa&1) > 0 || this.defaultConstructor;
@@ -1,5 +1,6 @@
function(name){
var pd=this.parameterDeclarations;
if (!pd)return null;
for (var i=0; i < pd.size; i++) {
if (name.equals(pd.$_get(i).name))return pd.$_get(i);
}
Expand Down
@@ -1 +1,2 @@
return FunctionalDeclaration$meta$declaration.$$.prototype.$prop$getParameterDeclarations.get.call(this);
var dc=this.defaultConstructor;
return dc?dc.parameterDeclarations:null;
@@ -1,3 +1,5 @@
function($mpt) {
return empty();
var dc=this.defaultConstructor;
return dc.annotated({Annotation$annotated:$mpt.Annotation$annotatedConstructorDeclarations})?
Singleton(dc,{t:CallableConstructorDeclaration$meta$declaration}):empty();
}
@@ -0,0 +1 @@
return OpenCallableConstructor$jsint(this.pkg_,this.tipo);

This file was deleted.

2 changes: 1 addition & 1 deletion runtime-js/jsint/OpenConstructor/defaultConstructor.js
@@ -1,6 +1,6 @@
if (this.isdef$===undefined) {
//Just by checking the path we can determine this
var mm=getrtmm$$(this.tipo);
this.isdef$ = mm.d[mm.d.length-1] === '$def';
this.isdef$ = mm.d.length<3 || mm.d[mm.d.length-1] === '$def' || mm.d[mm.d.length-1]==='$c';
}
return this.isdef$;

0 comments on commit e9bda28

Please sign in to comment.