Beispiel #1
0
 protected virtual void EmitLocalVar(ILGenerator IL, List <ZCLocalVar> localList)
 {
     BuilderUtil.EmitLocalVar(this.GetContextProc(), this.ClassContext.IsStatic(), IL, localList);
     //localList.Reverse();
     //for (int i = 0; i < localList.Count; i++)
     //{
     //    ZCLocalVar varSymbol = localList[i];
     //    varSymbol.VarBuilder = IL.DeclareLocal(ZTypeUtil.GetTypeOrBuilder(varSymbol.GetZType()));
     //    varSymbol.VarBuilder.SetLocalSymInfo(varSymbol.ZName);
     //}
     //for (int i = 0; i < localList.Count; i++)
     //{
     //    ZCLocalVar varSymbol = localList[i];
     //    if(varSymbol.IsNestedClassInstance)
     //    {
     //        LocalBuilder lanmbdaLocalBuilder = this.GetContextProc().NestedInstance.VarBuilder;
     //        ConstructorBuilder newBuilder = this.GetContextProc().GetNestedClassContext().DefaultConstructorBuilder;
     //         IL.Emit(OpCodes.Newobj, newBuilder);
     //        EmitHelper.StormVar(IL, lanmbdaLocalBuilder);
     //        if(! this.ClassContext.IsStatic() )
     //        {
     //            ILGeneratorUtil.LoadLocal(IL, lanmbdaLocalBuilder);
     //            IL.Emit(OpCodes.Ldarg_0);
     //            EmitSymbolHelper.EmitStorm(IL, this.GetContextProc().GetNestedClassContext().MasterClassField);
     //        }
     //    }
     //}
 }
Beispiel #2
0
    // Clears all spawned instances, but retains the renderData object
    void ClearSpawnedInstances()
    {
        if (layers == null)
        {
            return;
        }

        BuilderUtil.HideTileMapPrefabs(this);

        for (int layerIdx = 0; layerIdx < layers.Length; ++layerIdx)
        {
            Layer layer = layers[layerIdx];
            for (int chunkIdx = 0; chunkIdx < layer.spriteChannel.chunks.Length; ++chunkIdx)
            {
                var chunk = layer.spriteChannel.chunks[chunkIdx];

                if (chunk.gameObject == null)
                {
                    continue;
                }

                var transform             = chunk.gameObject.transform;
                List <Transform> children = new List <Transform>();
                for (int i = 0; i < transform.childCount; ++i)
                {
                    children.Add(transform.GetChild(i));
                }
                for (int i = 0; i < children.Count; ++i)
                {
                    tk2dUtil.DestroyImmediate(children[i].gameObject);
                }
            }
        }
    }
Beispiel #3
0
        public void EmitName()
        {
            bool isStatic     = this.ParentProperties.ASTClass.ClassContext.IsStatic();
            var  classBuilder = this.ParentProperties.ASTClass.ClassContext.GetTypeBuilder();

            ZPropertyCompiling.IsStatic = isStatic;
            Type propertyType = null;

            if (PropertyZType is ZLType)
            {
                propertyType = ((ZLType)PropertyZType).SharpType;
            }
            else
            {
                propertyType = ((ZCClassInfo)PropertyZType).ClassBuilder;
            }
            MethodAttributes methodAttr = BuilderUtil.GetMethodAttr(isStatic);
            FieldAttributes  fieldAttr  = BuilderUtil.GetFieldAttr(isStatic);

            _fieldBuilder    = classBuilder.DefineField("_" + PropertyName, propertyType, fieldAttr);
            _propertyBuilder = classBuilder.DefineProperty(PropertyName, PropertyAttributes.None, propertyType, null);

            EmitGet(classBuilder, PropertyName, propertyType, isStatic, _fieldBuilder, _propertyBuilder, methodAttr);
            EmitSet(classBuilder, PropertyName, propertyType, isStatic, _fieldBuilder, _propertyBuilder, methodAttr);
            ASTUtil.SetZAttr(_propertyBuilder, PropertyName);
            ZPropertyCompiling.PropertyBuilder = _propertyBuilder;
        }
Beispiel #4
0
        public void EmitBody()
        {
            var IL = this.NestedMethodContext.GetILGenerator();
            List <ZCLocalVar> localList = this.NestedMethodContext.LocalManager.LocalVarList;

            BuilderUtil.EmitLocalVar(NestedMethodContext, false, IL, localList);
            //EmitLocalVar(IL, localList);
            ActionExp.Emit();
            //if (!ZTypeUtil.IsVoid(this.RetZType))
            //{
            //    IL.Emit(OpCodes.Ldloc_0);
            //}
            if (this.RetSymbol == null)
            {
                if (!ZTypeUtil.IsVoid(this.ActionExp.RetType))
                {
                    IL.Emit(OpCodes.Pop);
                }
            }
            else
            {
                EmitHelper.StormVar(IL, this.RetSymbol.VarBuilder);
            }
            IL.Emit(OpCodes.Ret);
            //CreateNestedType();
        }
    public void BeginEditMode()
    {
        if (layers == null)
        {
            _inEditMode = true;
            return;
        }

        if (!_inEditMode)
        {
            _inEditMode = true;

            // Destroy all children
            // Only necessary when switching INTO edit mode
            BuilderUtil.HideTileMapPrefabs(this);
            SetPrefabsRootActive(false);
        }

        Build(BuildFlags.ForceBuild);
    }
Beispiel #6
0
    private Uri GetBaseUrl(string endpoint)
    {
        if (string.IsNullOrEmpty(endpoint))
        {
            throw new ArgumentException(
                      string.Format("{0} is the value of the endpoint. It can't be null or empty.", endpoint), "endpoint");
        }
        if (endpoint.EndsWith("/"))
        {
            endpoint = endpoint.Substring(0, endpoint.Length - 1);
        }
        if (!BuilderUtil.IsValidHostnameOrIPAddress(endpoint))
        {
            throw new InvalidEndpointException(string.Format("{0} is invalid hostname.", endpoint), "endpoint");
        }
        string conn_url;

        if (endpoint.StartsWith("http"))
        {
            throw new InvalidEndpointException(
                      string.Format("{0} the value of the endpoint has the scheme (http/https) in it.", endpoint),
                      "endpoint");
        }
        var enable_https = Environment.GetEnvironmentVariable("ENABLE_HTTPS");
        var scheme       = enable_https != null && enable_https.Equals("1") ? "https://" : "http://";

        conn_url = scheme + endpoint;
        var hostnameOfUri = string.Empty;
        Uri url           = null;

        url           = new Uri(conn_url);
        hostnameOfUri = url.Authority;
        if (!string.IsNullOrEmpty(hostnameOfUri) && !BuilderUtil.IsValidHostnameOrIPAddress(hostnameOfUri))
        {
            throw new InvalidEndpointException(string.Format("{0}, {1} is invalid hostname.", endpoint, hostnameOfUri),
                                               "endpoint");
        }

        return(url);
    }
    public void Build(BuildFlags buildFlags)
    {
        if (spriteCollection != null)
        {
            _spriteCollectionInst = spriteCollection.inst;
        }


#if UNITY_EDITOR || !UNITY_FLASH
        // Sanitize tilePrefabs input, to avoid branches later
        if (data != null)
        {
            if (data.tilePrefabs == null)
            {
                data.tilePrefabs = new Object[SpriteCollectionInst.Count];
            }
            else if (data.tilePrefabs.Length != SpriteCollectionInst.Count)
            {
                System.Array.Resize(ref data.tilePrefabs, SpriteCollectionInst.Count);
            }

            // Fix up data if necessary
            BuilderUtil.InitDataStore(this);
        }
        else
        {
            return;
        }

        // Sanitize sprite collection material ids
        if (SpriteCollectionInst)
        {
            SpriteCollectionInst.InitMaterialIds();
        }

        bool forceBuild = (buildFlags & BuildFlags.ForceBuild) != 0;

        // When invalid, everything needs to be rebuilt
        if (SpriteCollectionInst && SpriteCollectionInst.buildKey != spriteCollectionKey)
        {
            forceBuild = true;
        }

        if (forceBuild)
        {
            ClearSpawnedInstances();
        }

        BuilderUtil.CreateRenderData(this, _inEditMode);

        RenderMeshBuilder.Build(this, _inEditMode, forceBuild);

        if (!_inEditMode)
        {
            ColliderBuilder.Build(this, forceBuild);
            BuilderUtil.SpawnPrefabs(this, forceBuild);
        }

        // Clear dirty flag on everything
        foreach (var layer in layers)
        {
            layer.ClearDirtyFlag();
        }
        if (colorChannel != null)
        {
            colorChannel.ClearDirtyFlag();
        }

        // Update sprite collection key
        if (SpriteCollectionInst)
        {
            spriteCollectionKey = SpriteCollectionInst.buildKey;
        }
#endif
    }
Beispiel #8
0
    public void Build(BuildFlags buildFlags)
    {
#if UNITY_EDITOR
        // Sanitize tilePrefabs input, to avoid branches later
        if (data != null && spriteCollection != null)
        {
            if (data.tilePrefabs == null)
            {
                data.tilePrefabs = new GameObject[SpriteCollectionInst.Count];
            }
            else if (data.tilePrefabs.Length != SpriteCollectionInst.Count)
            {
                System.Array.Resize(ref data.tilePrefabs, SpriteCollectionInst.Count);
            }

            // Fix up data if necessary
            BuilderUtil.InitDataStore(this);
        }
        else
        {
            return;
        }

        // Sanitize sprite collection material ids
        if (SpriteCollectionInst)
        {
            SpriteCollectionInst.InitMaterialIds();
        }

        bool forceBuild = (buildFlags & BuildFlags.ForceBuild) != 0;

        // When invalid, everything needs to be rebuilt
        if (SpriteCollectionInst && SpriteCollectionInst.buildKey != spriteCollectionKey)
        {
            forceBuild = true;
        }

        // Remember active layers
        Dictionary <Layer, bool> layersActive = new Dictionary <Layer, bool>();
        if (layers != null)
        {
            for (int layerIdx = 0; layerIdx < layers.Length; ++layerIdx)
            {
                Layer layer = layers[layerIdx];
                if (layer != null && layer.gameObject != null)
                {
#if UNITY_3_5
                    layersActive[layer] = layer.gameObject.active;
#else
                    layersActive[layer] = layer.gameObject.activeSelf;
#endif
                }
            }
        }

        if (forceBuild)
        {
            ClearSpawnedInstances();
        }

        BuilderUtil.CreateRenderData(this, _inEditMode, layersActive);

        RenderMeshBuilder.Build(this, _inEditMode, forceBuild);

        if (!_inEditMode)
        {
#if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2)
            tk2dSpriteDefinition def = SpriteCollectionInst.FirstValidDefinition;
            if (def != null && def.physicsEngine == tk2dSpriteDefinition.PhysicsEngine.Physics2D)
            {
#if !STRIP_PHYSICS_2D
                ColliderBuilder2D.Build(this, forceBuild);
#endif
            }
            else
#endif
            {
#if !STRIP_PHYSICS_3D
                ColliderBuilder3D.Build(this, forceBuild);
#endif
            }
            BuilderUtil.SpawnPrefabs(this, forceBuild);
        }

        // Clear dirty flag on everything
        foreach (var layer in layers)
        {
            layer.ClearDirtyFlag();
        }
        if (colorChannel != null)
        {
            colorChannel.ClearDirtyFlag();
        }

        // Update sprite collection key
        if (SpriteCollectionInst)
        {
            spriteCollectionKey = SpriteCollectionInst.buildKey;
        }
#endif
    }
 /// <summary>
 /// Parses a URI string and constructs a builder.
 /// </summary>
 /// <param name="uri">The URI used to set the builder's initial values.</param>
 public GenericUniformResourceIdentifierBuilder(string uri)
 {
     WithScheme(BuilderUtil.ApplyUriReference(this, uri));
 }
 private static Utility.DelegateFactory <GenericUniformResourceIdentifier> CreateFactory(string scheme)
 {
     return((userInfo, host, port, pathSegments, query, fragment) =>
            BuilderUtil.ApplyUriReference(new GenericUniformResourceIdentifierBuilder().WithScheme(scheme), userInfo, host, port, pathSegments, query, fragment).Build());
 }
Beispiel #11
0
 /// <summary>
 /// Parses a relative reference string and constructs a builder.
 /// </summary>
 /// <param name="relativeReference">The relative reference used to set the builder's initial values.</param>
 public RelativeReferenceBuilder(string relativeReference)
 {
     BuilderUtil.ApplyUriReference(this, relativeReference, null);
 }
Beispiel #12
0
 /// <summary>
 /// Constructs a builder from an existing relative reference.
 /// </summary>
 /// <param name="relativeReference">The relative reference used to set the builder's initial values.</param>
 public RelativeReferenceBuilder(RelativeReference relativeReference)
 {
     BuilderUtil.ApplyUriReference(this, relativeReference);
 }
    public void Build(BuildFlags buildFlags)
    {
        // Sanitize tilePrefabs input, to avoid branches later
        if (data != null)
        {
            if (data.tilePrefabs == null)
            {
                data.tilePrefabs = new Object[spriteCollection.Count];
            }
            else if (data.tilePrefabs.Length != spriteCollection.Count)
            {
                System.Array.Resize(ref data.tilePrefabs, spriteCollection.Count);
            }

            // Fix up data if necessary
            BuilderUtil.InitDataStore(this);
        }
        else
        {
            return;
        }

        // Sanitize sprite collection material ids
        if (spriteCollection)
        {
            spriteCollection.InitMaterialIds();
        }


        bool editMode   = (buildFlags & BuildFlags.EditMode) != 0;
        bool forceBuild = (buildFlags & BuildFlags.ForceBuild) != 0;

        // When invalid, everything needs to be rebuilt
        if (spriteCollection && spriteCollection.buildKey != spriteCollectionKey)
        {
            forceBuild = true;
        }

        BuilderUtil.CreateRenderData(this, editMode);

        RenderMeshBuilder.Build(this, editMode, forceBuild);

        if (!editMode)
        {
            ColliderBuilder.Build(this);
            BuilderUtil.SpawnPrefabs(this);
        }

        // Clear dirty flag on everything
        foreach (var layer in layers)
        {
            layer.ClearDirtyFlag();
        }
        if (colorChannel != null)
        {
            colorChannel.ClearDirtyFlag();
        }

        // One random number to detect undo
        buildKey = Random.Range(0, int.MaxValue);

        // Update sprite collection key
        if (spriteCollection)
        {
            spriteCollectionKey = spriteCollection.buildKey;
        }
    }
Beispiel #14
0
    public void Build(BuildFlags buildFlags)
    {
        if (spriteCollection != null)
        {
            _spriteCollectionInst = spriteCollection.inst;
        }


#if UNITY_EDITOR || !UNITY_FLASH
        // Sanitize tilePrefabs input, to avoid branches later
        if (data != null && spriteCollection != null)
        {
            if (data.tilePrefabs == null)
            {
                data.tilePrefabs = new Object[SpriteCollectionInst.Count];
            }
            else if (data.tilePrefabs.Length != SpriteCollectionInst.Count)
            {
                System.Array.Resize(ref data.tilePrefabs, SpriteCollectionInst.Count);
            }

            // Fix up data if necessary
            BuilderUtil.InitDataStore(this);
        }
        else
        {
            return;
        }

        // Sanitize sprite collection material ids
        if (SpriteCollectionInst)
        {
            SpriteCollectionInst.InitMaterialIds();
        }

        bool forceBuild = (buildFlags & BuildFlags.ForceBuild) != 0;

        // When invalid, everything needs to be rebuilt
        if (SpriteCollectionInst && SpriteCollectionInst.buildKey != spriteCollectionKey)
        {
            forceBuild = true;
        }

        // Remember active layers
        Dictionary <Layer, bool> layersActive = new Dictionary <Layer, bool>();
        if (layers != null)
        {
            for (int layerIdx = 0; layerIdx < layers.Length; ++layerIdx)
            {
                Layer layer = layers[layerIdx];
                if (layer != null && layer.gameObject != null)
                {
#if UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9
                    layersActive[layer] = layer.gameObject.active;
#else
                    layersActive[layer] = layer.gameObject.activeSelf;
#endif
                }
            }
        }

        if (forceBuild)
        {
            ClearSpawnedInstances();
        }

        BuilderUtil.CreateRenderData(this, _inEditMode, layersActive);

        RenderMeshBuilder.Build(this, _inEditMode, forceBuild);

        if (!_inEditMode)
        {
            ColliderBuilder.Build(this, forceBuild);
            BuilderUtil.SpawnPrefabs(this, forceBuild);
        }

        // Clear dirty flag on everything
        foreach (var layer in layers)
        {
            layer.ClearDirtyFlag();
        }
        if (colorChannel != null)
        {
            colorChannel.ClearDirtyFlag();
        }

        // Update sprite collection key
        if (SpriteCollectionInst)
        {
            spriteCollectionKey = SpriteCollectionInst.buildKey;
        }
#endif
    }
 /// <summary>
 /// Constructs a builder from an existing URI.
 /// </summary>
 /// <param name="uri">The URI used to set the builder's initial values.</param>
 public GenericUniformResourceIdentifierBuilder(GenericUniformResourceIdentifier uri)
 {
     BuilderUtil.ApplyUriReference(this, uri).WithScheme(uri.Scheme);
 }
Beispiel #16
0
 /// <summary>
 /// Constructs a builder from an existing HTTPS URI.
 /// </summary>
 /// <param name="uri">The URI used to set the builder's initial values.</param>
 public HttpsUniformResourceIdentifierBuilder(HttpsUniformResourceIdentifier uri)
 {
     BuilderUtil.ApplyUriReference(this, uri);
 }
Beispiel #17
0
 /// <summary>
 /// Parses a URI string and constructs a builder.
 /// </summary>
 /// <param name="uri">The URI used to set the builder's initial values.</param>
 public HttpsUniformResourceIdentifierBuilder(string uri)
 {
     BuilderUtil.ApplyUriReference(this, uri, HttpsUniformResourceIdentifier.HttpsScheme);
 }
 /// <summary>
 /// Constructs a builder from an existing URI.
 /// </summary>
 /// <param name="uri">The URI used to set the builder's initial values.</param>
 public GenericUniformResourceIdentifierBuilder(GenericUniformResourceIdentifier uri)
 {
     _ = uri ?? throw new ArgumentNullException(nameof(uri));
     BuilderUtil.ApplyUriReference(this, uri).WithScheme(uri.Scheme);
 }