diff --git a/build.xml b/build.xml index a3a9e6c8a..62a36646d 100644 --- a/build.xml +++ b/build.xml @@ -20,6 +20,7 @@ + - - - + + + + + + + + @@ -185,6 +191,9 @@ + + @@ -195,6 +204,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/etc/asc-files.txt b/etc/asc-files.txt new file mode 100644 index 000000000..4333c4ea7 --- /dev/null +++ b/etc/asc-files.txt @@ -0,0 +1,139 @@ +com/threerings/util/ArrayIterator.as +com/threerings/util/ArrayUtil.as +com/threerings/util/Byte.as +com/threerings/util/ClassUtil.as +com/threerings/util/Cloneable.as +com/threerings/util/Comparable.as +com/threerings/util/Comparators.as +com/threerings/util/Equalable.as +com/threerings/util/env/Environment.as +com/threerings/util/Float.as +com/threerings/util/HashMap.as +com/threerings/util/Hashable.as +com/threerings/util/Integer.as +com/threerings/util/Iterator.as +com/threerings/util/Log.as +com/threerings/util/LogTarget.as +com/threerings/util/Long.as +com/threerings/util/Map.as +com/threerings/util/MethodQueue.as +com/threerings/util/Name.as +com/threerings/util/ObserverList.as +com/threerings/util/Random.as +com/threerings/util/ResultListener.as +com/threerings/util/Short.as +com/threerings/util/StreamableArrayList.as +com/threerings/util/StreamableHashMap.as +com/threerings/util/StringBuilder.as +com/threerings/util/StringUtil.as +com/threerings/util/Util.as +com/threerings/util/Wrapped.as +com/threerings/io/ArrayMask.as +com/threerings/io/ClassMapping.as +com/threerings/io/FrameAvailableEvent.as +com/threerings/io/FrameReader.as +com/threerings/io/ObjectInputStream.as +com/threerings/io/ObjectOutputStream.as +com/threerings/io/SimpleStreamableObject.as +com/threerings/io/Streamable.as +com/threerings/io/Streamer.as +com/threerings/io/streamers/ArrayStreamer.as +com/threerings/io/streamers/ByteArrayStreamer.as +com/threerings/io/streamers/ByteStreamer.as +com/threerings/io/streamers/FloatStreamer.as +com/threerings/io/streamers/IntegerStreamer.as +com/threerings/io/streamers/LongStreamer.as +com/threerings/io/streamers/NumberStreamer.as +com/threerings/io/streamers/ShortStreamer.as +com/threerings/io/streamers/StringStreamer.as +com/threerings/io/Translations.as +com/threerings/io/TypedArray.as +com/threerings/presents/client/BasicDirector.as +com/threerings/presents/client/Client.as +com/threerings/presents/client/ClientAdapter.as +com/threerings/presents/client/ClientDObjectMgr.as +com/threerings/presents/client/ClientEvent.as +com/threerings/presents/client/ClientObserver.as +com/threerings/presents/client/Communicator.as +com/threerings/presents/client/ConfirmAdapter.as +com/threerings/presents/client/InvocationAdapter.as +com/threerings/presents/client/InvocationDecoder.as +com/threerings/presents/client/InvocationDirector.as +com/threerings/presents/client/InvocationReceiver.as +com/threerings/presents/client/InvocationReceiver_Registration.as +com/threerings/presents/client/InvocationService.as +com/threerings/presents/client/InvocationService_ConfirmListener.as +com/threerings/presents/client/InvocationService_InvocationListener.as +com/threerings/presents/client/InvocationService_ResultListener.as +com/threerings/presents/client/LogonError.as +com/threerings/presents/client/ResultWrapper.as +com/threerings/presents/client/ServerSwitcher.as +com/threerings/presents/client/SessionObserver.as +com/threerings/presents/client/TimeBaseService.as +com/threerings/presents/client/TimeBaseService_GotTimeBaseListener.as +com/threerings/presents/data/AuthCodes.as +com/threerings/presents/data/ClientObject.as +com/threerings/presents/data/ConMgrStats.as +com/threerings/presents/data/InvocationCodes.as +com/threerings/presents/data/InvocationMarshaller.as +com/threerings/presents/data/InvocationMarshaller_ConfirmMarshaller.as +com/threerings/presents/data/InvocationMarshaller_ListenerMarshaller.as +com/threerings/presents/data/InvocationMarshaller_ResultMarshaller.as +com/threerings/presents/data/TimeBaseMarshaller.as +com/threerings/presents/data/TimeBaseMarshaller_GotTimeBaseMarshaller.as +com/threerings/presents/dobj/AttributeChangeListener.as +com/threerings/presents/dobj/AttributeChangedEvent.as +com/threerings/presents/dobj/ChangeListener.as +com/threerings/presents/dobj/CompoundEvent.as +com/threerings/presents/dobj/DEvent.as +com/threerings/presents/dobj/DObject.as +com/threerings/presents/dobj/DObjectManager.as +com/threerings/presents/dobj/DSet.as +com/threerings/presents/dobj/DSet_Entry.as +com/threerings/presents/dobj/DummyEntry.as +com/threerings/presents/dobj/ElementUpdateListener.as +com/threerings/presents/dobj/ElementUpdatedEvent.as +com/threerings/presents/dobj/EntryAddedEvent.as +com/threerings/presents/dobj/EntryRemovedEvent.as +com/threerings/presents/dobj/EntryUpdatedEvent.as +com/threerings/presents/dobj/EventListener.as +com/threerings/presents/dobj/InvocationNotificationEvent.as +com/threerings/presents/dobj/InvocationRequestEvent.as +com/threerings/presents/dobj/InvocationResponseEvent.as +com/threerings/presents/dobj/MessageAdapter.as +com/threerings/presents/dobj/MessageEvent.as +com/threerings/presents/dobj/MessageListener.as +com/threerings/presents/dobj/NamedEvent.as +com/threerings/presents/dobj/ObjectAccessError.as +com/threerings/presents/dobj/ObjectAddedEvent.as +com/threerings/presents/dobj/ObjectDeathListener.as +com/threerings/presents/dobj/ObjectDestroyedEvent.as +com/threerings/presents/dobj/ObjectRemovedEvent.as +com/threerings/presents/dobj/OidList.as +com/threerings/presents/dobj/OidListListener.as +com/threerings/presents/dobj/ServerMessageEvent.as +com/threerings/presents/dobj/SetAdapter.as +com/threerings/presents/dobj/SetListener.as +com/threerings/presents/dobj/Subscriber.as +com/threerings/presents/dobj/SubscriberAdapter.as +com/threerings/presents/net/AuthRequest.as +com/threerings/presents/net/AuthResponse.as +com/threerings/presents/net/AuthResponseData.as +com/threerings/presents/net/BootstrapData.as +com/threerings/presents/net/BootstrapNotification.as +com/threerings/presents/net/Credentials.as +com/threerings/presents/net/DownstreamMessage.as +com/threerings/presents/net/EventNotification.as +com/threerings/presents/net/FailureResponse.as +com/threerings/presents/net/ForwardEventRequest.as +com/threerings/presents/net/LogoffRequest.as +com/threerings/presents/net/ObjectResponse.as +com/threerings/presents/net/PingRequest.as +com/threerings/presents/net/PongResponse.as +com/threerings/presents/net/SubscribeRequest.as +com/threerings/presents/net/UnsubscribeRequest.as +com/threerings/presents/net/UnsubscribeResponse.as +com/threerings/presents/net/UpstreamMessage.as +com/threerings/presents/net/UsernamePasswordCreds.as +com/threerings/presents/util/PresentsContext.as +com/threerings/presents/util/SafeSubscriber.as diff --git a/lib/asc.jar b/lib/asc.jar new file mode 100644 index 000000000..6a99da645 Binary files /dev/null and b/lib/asc.jar differ diff --git a/lib/builtin.abc b/lib/builtin.abc new file mode 100644 index 000000000..5450b3b70 Binary files /dev/null and b/lib/builtin.abc differ diff --git a/lib/thane.abc b/lib/thane.abc new file mode 100644 index 000000000..7a007b5e7 Binary files /dev/null and b/lib/thane.abc differ diff --git a/src/as/com/threerings/util/ClassUtil.as b/src/as/com/threerings/util/ClassUtil.as index 7c0d07477..97bad3932 100644 --- a/src/as/com/threerings/util/ClassUtil.as +++ b/src/as/com/threerings/util/ClassUtil.as @@ -25,6 +25,8 @@ import flash.utils.describeType; import flash.utils.getQualifiedClassName; import flash.utils.getDefinitionByName; +import com.threerings.util.env.Environment; + public class ClassUtil { /** @@ -111,39 +113,9 @@ public class ClassUtil * var s :Streamable = (new someClass() as Streamable); * */ - public static function isAssignableAs ( - asClass :Class, srcClass :Class) :Boolean + public static function isAssignableAs (asClass :Class, srcClass :Class) :Boolean { - if (asClass == srcClass) { - return true; - - // if not the same class and srcClass is Object, we're done - } else if (srcClass == Object) { - return false; - } - - // ok, let's introspect on the class and see what we've got. - var typeInfo :XMLList = describeType(srcClass).child("factory"); - - // See which classes we extend. - var exts :XMLList = typeInfo.child("extendsClass").attribute("type"); - var type :String; - for each (type in exts) { - if (asClass == getClassByName(type)) { - return true; - } - } - - // See which interfaces we implement. - var imps :XMLList = typeInfo.child("implementsInterface") - .attribute("type"); - for each (type in imps) { - if (asClass == getClassByName(type)) { - return true; - } - } - - return false; + return Environment.isAssignableAs(asClass, srcClass); } } } diff --git a/src/as/com/threerings/util/StringUtil.as b/src/as/com/threerings/util/StringUtil.as index c9b17a607..6935977a5 100644 --- a/src/as/com/threerings/util/StringUtil.as +++ b/src/as/com/threerings/util/StringUtil.as @@ -22,7 +22,8 @@ package com.threerings.util { import flash.utils.ByteArray; -import flash.utils.describeType; // function import + +import com.threerings.util.env.Environment; public class StringUtil { @@ -318,9 +319,8 @@ public class StringUtil */ public static function fieldsToString (buf :StringBuilder, obj :Object) :void { - var desc :XML = describeType(obj); var appended :Boolean = false; - for each (var varName :String in desc..variable.@name) { + for each (var varName :String in Environment.enumerateFields(obj)) { if (appended) { buf.append(", "); } diff --git a/src/as/com/threerings/util/env/Environment.as-fp b/src/as/com/threerings/util/env/Environment.as-fp new file mode 100644 index 000000000..49e926752 --- /dev/null +++ b/src/as/com/threerings/util/env/Environment.as-fp @@ -0,0 +1,89 @@ +// +// $Id: $ +// +// Narya library - tools for developing networked games +// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved +// http://www.threerings.net/code/narya/ +// +// This library is free software; you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +package com.threerings.util.env { + +import flash.utils.describeType; + +import com.threerings.util.ClassUtil; + +/** + * Flash Player specific implementation of Environment. + */ +public class Environment +{ + /** + * Return an array containing all the public field names of the object + */ + public static function enumerateFields (obj :Object) :Array + { + var result :Array = [ ]; + for each (var bit :String in describeType(obj)..variable.@name) { + result.push(bit); + } + return result; + } + + /** + * Returns true if an object of type srcClass is a subclass of or + * implements the interface represented by the asClass paramter. + * + * + * if (ClassUtil.isAssignableAs(Streamable, someClass)) { + * var s :Streamable = (new someClass() as Streamable); + * + */ + public static function isAssignableAs ( + asClass :Class, srcClass :Class) :Boolean + { + if (asClass == srcClass) { + return true; + + // if not the same class and srcClass is Object, we're done + } else if (srcClass == Object) { + return false; + } + + // ok, let's introspect on the class and see what we've got. + var typeInfo :XMLList = describeType(srcClass).child("factory"); + + // See which classes we extend. + var exts :XMLList = typeInfo.child("extendsClass").attribute("type"); + var type :String; + for each (type in exts) { + if (asClass == ClassUtil.getClassByName(type)) { + return true; + } + } + + // See which interfaces we implement. + var imps :XMLList = typeInfo.child("implementsInterface") + .attribute("type"); + for each (type in imps) { + if (asClass == ClassUtil.getClassByName(type)) { + return true; + } + } + + return false; + } +} +} diff --git a/src/as/com/threerings/util/env/Environment.as-tm b/src/as/com/threerings/util/env/Environment.as-tm new file mode 100644 index 000000000..e0bf5236b --- /dev/null +++ b/src/as/com/threerings/util/env/Environment.as-tm @@ -0,0 +1,60 @@ +// +// $Id: $ +// +// Narya library - tools for developing networked games +// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved +// http://www.threerings.net/code/narya/ +// +// This library is free software; you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +package com.threerings.util.env { + +import flash.utils.getQualifiedClassName; +import flash.utils.getDefinitionByName; +import avmplus.*; + +/** + * Tamarin specific implementation of Environment. + */ +public class Environment +{ + /** + * Return an array containing all the public field names of the object + */ + public static function enumerateFields (obj :Object) :Array + { + if (obj != null) { + return Domain.currentDomain.getVariables(obj); + } + } + + /** + * Returns true if an object of type srcClass is a subclass of or + * implements the interface represented by the asClass paramter. + * + * + * if (ClassUtil.isAssignableAs(Streamable, someClass)) { + * var s :Streamable = (new someClass() as Streamable); + * + */ + public static function isAssignableAs (asClass :Class, srcClass :Class) :Boolean + { + if (asClass != null && srcClass != null) { + return Domain.currentDomain.isAssignableAs(asClass, srcClass); + } + return false; + } +} +}