We now build a subset of Narya for execution on Tamarin, the server-side AS3 VM.
- We use the ASC compiler, which works quite differently from compc/mxmlc. It doesn't attempt any mapping between class hierarchy and directory structure. You feed it source, that's it. This compiler is under continuous development, and the one shipped in Flex SDK 3 is buggy, so we supply our own in lib/asc.jar for the time being. - Since much of Narya relies on classes that don't exist on Tamarin (e.g. DisplayObject), we have to isolate a specific subset of source. Right now that's done ridiculously explicitly as a list of class files, in etc/asc-files.txt. In the long run we will want to resolve this more elegantly, but there are no trivial solutions at hand. - We have not implemented the full flash.utils.describeType() for Tamarin, but rather a subset of its functionality: one method to see if one type derives from another, and another method to extract the public variable names in an object. The environment-specific code has been isolated to com.threerings.util.env.Environment, and build.xml simply copies either Environment.as-tm or Environment.as-fp into place depending on what it's targeting. - The ASC compilation links against lib/builtin.abc, which supplies information about core classes such as Object, Array, etc, and lib/thane.abc which is our homegrown emulation library containing e.g. flash.net.Socket and other things we need that's not part of the open-source code Adobe donated to Mozilla, but rather still in their proprietary Flash Player code. I'm committing thane.abc and builtin.abc directly now, but they will shortly be built by the Thane project and published as maven whatnots. We could auto-publish lib/asc.jar too, but I think we may want more explicit control over how we version that. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5045 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
<fileset dir="${deploy.dir}/lib" includes="**/*.jar"/>
|
||||
</path>
|
||||
|
||||
|
||||
<!-- generates fields for persistent record classes -->
|
||||
<target name="genrecord" depends="prepare">
|
||||
<taskdef name="grecord" classname="com.samskivert.jdbc.depot.tools.GenRecordTask"
|
||||
@@ -171,9 +172,14 @@
|
||||
<target name="checkaslib">
|
||||
<condition property="no_build_aslib"><or>
|
||||
<not><available file="${flexsdk.dir}/lib/compc.jar"/></not>
|
||||
<uptodate targetfile="${deploy.dir}/${lib.name}lib.swc">
|
||||
<srcfiles dir="src/as" includes="**/*.as"/>
|
||||
</uptodate>
|
||||
<and>
|
||||
<uptodate targetfile="${deploy.dir}/${lib.name}lib.swc">
|
||||
<srcfiles dir="src/as" includes="**/*.as"/>
|
||||
</uptodate>
|
||||
<uptodate targetfile="${deploy.dir}/${lib.name}lib.abc">
|
||||
<srcfiles dir="src/as" includes="**/*.as"/>
|
||||
</uptodate>
|
||||
</and>
|
||||
</or></condition>
|
||||
</target>
|
||||
|
||||
@@ -185,6 +191,9 @@
|
||||
<filter token="lib_name_dir" value="${lib.name}"/>
|
||||
</filterset>
|
||||
</copy>
|
||||
<copy file="src/as/com/threerings/util/env/Environment.as-fp"
|
||||
tofile="src/as/com/threerings/util/env/Environment.as"/>
|
||||
|
||||
<java jar="${flexsdk.dir}/lib/compc.jar" fork="true" failonerror="true">
|
||||
<arg value="-load-config"/>
|
||||
<arg value="${deploy.dir}/aslib-config.xml"/>
|
||||
@@ -195,6 +204,32 @@
|
||||
<arg value="${deploy.dir}/${lib.name}lib.swc"/>
|
||||
</java>
|
||||
<delete file="${deploy.dir}/aslib-config.xml"/>
|
||||
|
||||
<copy file="src/as/com/threerings/util/env/Environment.as-tm"
|
||||
tofile="src/as/com/threerings/util/env/Environment.as"/>
|
||||
<loadfile property="ascfiles" srcFile="etc/asc-files.txt">
|
||||
<filterchain>
|
||||
<prefixlines prefix="src/as/"/>
|
||||
<tokenfilter delimOutput=" "/>
|
||||
</filterchain>
|
||||
</loadfile>
|
||||
<java classname="macromedia.asc.embedding.ScriptCompiler" fork="true" failonerror="true">
|
||||
<classpath>
|
||||
<fileset dir="lib" includes="asc.jar"/>
|
||||
</classpath>
|
||||
<arg value="-AS3"/>
|
||||
<arg value="-strict"/>
|
||||
<arg value="-import"/>
|
||||
<arg value="lib/builtin.abc"/>
|
||||
<arg value="-import"/>
|
||||
<arg value="lib/thane.abc"/>
|
||||
<arg value="-outdir"/>
|
||||
<arg value="${deploy.dir}"/>
|
||||
<arg value="-out"/>
|
||||
<arg value="${lib.name}lib"/>
|
||||
<arg line="${ascfiles}"/>
|
||||
</java>
|
||||
<delete file="src/as/com/threerings/util/env/Environment.as"/>
|
||||
</target>
|
||||
|
||||
<!-- build the native libraries -->
|
||||
|
||||
@@ -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
|
||||
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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);
|
||||
* </code>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(", ");
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
* <code>
|
||||
* if (ClassUtil.isAssignableAs(Streamable, someClass)) {
|
||||
* var s :Streamable = (new someClass() as Streamable);
|
||||
* </code>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
*
|
||||
* <code>
|
||||
* if (ClassUtil.isAssignableAs(Streamable, someClass)) {
|
||||
* var s :Streamable = (new someClass() as Streamable);
|
||||
* </code>
|
||||
*/
|
||||
public static function isAssignableAs (asClass :Class, srcClass :Class) :Boolean
|
||||
{
|
||||
if (asClass != null && srcClass != null) {
|
||||
return Domain.currentDomain.isAssignableAs(asClass, srcClass);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user