Skip to content
This repository was archived by the owner on Sep 2, 2023. It is now read-only.

Commit 352462a

Browse files
committed
Add (:background) annotation to all classes
Seeing as applications using this framework will likely need to build the entire application around the injection framework. Ensure that it is fully loaded in the background case. Also update some module scopes that were missed.
1 parent 1e04067 commit 352462a

File tree

7 files changed

+22
-14
lines changed

7 files changed

+22
-14
lines changed

monkey.jungle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
project.manifest = manifest.xml
2-
3-
base.source = source
2+
base.sourcePath = source
43

source/Binding.mc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module Internal {
1010
//!
1111
//!
1212
//!
13+
(:background)
1314
class Binding {
1415
private var resolutionRoot_;
1516
private var classDef_;
@@ -36,10 +37,10 @@ class Binding {
3637
}
3738

3839
if(requiredDependencies.size() == 0) {
39-
return new classDef_();
40+
return new self.classDef_();
4041
}
4142
else {
42-
return new classDef_(configuredDependencies);
43+
return new self.classDef_(configuredDependencies);
4344
}
4445
}
4546
}

source/BindingSpec.mc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ enum {
1313
//!
1414
//!
1515
//!
16+
(:background)
1617
class BindingSpec {
1718
private var interface_;
1819
private var classDef_;

source/Factory.mc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Internal {
88
//!
99
//!
1010
//!
11+
(:background)
1112
class Factory {
1213
private var resolutionRoot_;
1314

source/Kernel.mc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
//
33
// Copyright Greg Caufield 2020
44

5-
class Kernel {
5+
module MonkeyInject {
66

7+
//!
8+
//!
9+
//!
10+
(:background)
11+
class Kernel {
712
private var bindings_;
813

914
function initialize() {
@@ -23,3 +28,4 @@ class Kernel {
2328
return null;
2429
}
2530
}
31+
}

source/Module.mc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// Module.mc
22
//
33
// Copyright 2020 Greg Caufield
4-
5-
64
module MonkeyInject {
75

86
//!
97
//!
108
//!
9+
(:background)
1110
class Module {
1211
private var interfaces;
1312

@@ -16,7 +15,7 @@ class Module {
1615
}
1716

1817
function bind(interface) {
19-
interfaces[interface] = new BindingSpec(interface);
18+
interfaces[interface] = new Internal.BindingSpec(interface);
2019
return interfaces[interface];
2120
}
2221

@@ -27,12 +26,12 @@ class Module {
2726
for(var i = 0; i < keys.size(); i++) {
2827
var spec = interfaces[keys[i]];
2928

30-
if(spec.getScope() == BindingScopeTransient) {
31-
bindings[keys[i]] = new Binding(resolutionRoot, spec);
32-
} else if(spec.getScope() == BindingScopeSingleton) {
33-
bindings[keys[i]] = new SingletonBinding(resolutionRoot, spec);
34-
} else if(spec.getScope() == BindingScopeFactory) {
35-
bindings[keys[i]] = new Factory(resolutionRoot);
29+
if(spec.getScope() == Internal.BindingScopeTransient) {
30+
bindings[keys[i]] = new Internal.Binding(resolutionRoot, spec);
31+
} else if(spec.getScope() == Internal.BindingScopeSingleton) {
32+
bindings[keys[i]] = new Internal.SingletonBinding(resolutionRoot, spec);
33+
} else if(spec.getScope() == Internal.BindingScopeFactory) {
34+
bindings[keys[i]] = new Internal.Factory(resolutionRoot);
3635
}
3736
}
3837
}

source/SingletonBinding.mc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Internal {
88
//!
99
//!
1010
//!
11+
(:background)
1112
class SingletonBinding extends Binding {
1213
private var instance_;
1314

0 commit comments

Comments
 (0)