Notes, figured out how to make a static initializer.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3932 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -218,3 +218,17 @@ ActionScript
|
|||||||
error (grraah!). There is a compiler option "-compiler.warn-no-constructor"
|
error (grraah!). There is a compiler option "-compiler.warn-no-constructor"
|
||||||
but it generates a flotilla of warnings from standard classes in the flash
|
but it generates a flotilla of warnings from standard classes in the flash
|
||||||
library, so it's slightly useless.
|
library, so it's slightly useless.
|
||||||
|
***Update: What the heck. I noticed today that DSet has no constructor
|
||||||
|
and I've never had any trouble instantiating those. Why would not having
|
||||||
|
a constructor be an error for some classes and not others? Grraahh!
|
||||||
|
|
||||||
|
- Static initializers can be emulated:
|
||||||
|
public class A
|
||||||
|
{
|
||||||
|
private static function staticInit () :void
|
||||||
|
{
|
||||||
|
// whatever
|
||||||
|
}
|
||||||
|
|
||||||
|
staticInit(); // will be placed inside the real static initializer
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,22 +19,22 @@ public class LogDaddy
|
|||||||
*/
|
*/
|
||||||
public static function getLogger (pkg :String) :ILogger
|
public static function getLogger (pkg :String) :ILogger
|
||||||
{
|
{
|
||||||
if (_targ == null) {
|
|
||||||
// goddamn I wish we could just have static initializers
|
|
||||||
_targ = new TraceTarget();
|
|
||||||
_targ.filters = ["*"];
|
|
||||||
_targ.level = LogEventLevel.DEBUG;
|
|
||||||
mx.logging.Log.addTarget(_targ);
|
|
||||||
// we could do some stuff here: set up different targets
|
|
||||||
// with different log levels...
|
|
||||||
}
|
|
||||||
|
|
||||||
return mx.logging.Log.getLogger(pkg);
|
return mx.logging.Log.getLogger(pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The logging target for all packages. Needed only because we
|
/**
|
||||||
* cannot have static initializers, so we need to know in getLogger
|
* Our static (class) initializer.
|
||||||
* if we've set up the target yet or not. */
|
*/
|
||||||
private static var _targ :TraceTarget;
|
private static function staticInit () :void
|
||||||
|
{
|
||||||
|
var targ :TraceTarget = new TraceTarget();
|
||||||
|
targ.filters = ["*"];
|
||||||
|
targ.level = LogEventLevel.DEBUG;
|
||||||
|
mx.logging.Log.addTarget(targ);
|
||||||
|
// we could do some stuff here: set up different targets
|
||||||
|
// with different log levels...
|
||||||
|
}
|
||||||
|
|
||||||
|
staticInit(); // call our static initializer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user