当前位置: 首页>>代码示例>>C#>>正文


C# Generator.EmitLine方法代码示例

本文整理汇总了C#中Generator.EmitLine方法的典型用法代码示例。如果您正苦于以下问题:C# Generator.EmitLine方法的具体用法?C# Generator.EmitLine怎么用?C# Generator.EmitLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Generator的用法示例。


在下文中一共展示了Generator.EmitLine方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EmitCode

        public override void EmitCode(Generator generator, int depth, int ident)
        {
            if ( String.IsNullOrEmpty( GetName() ) )
                return;

            INode returntype;
            bool constness, pointer;

            string types = base.ResolveType( 1, out returntype, out constness, out pointer );

            types = generator.ResolveType( types, constness, pointer, true, false );

            generator.EmitLine( "public enum " + name + " : " + EnumShortCodes[types], depth );
            generator.EmitLine( "{", depth );

            foreach( INode child in children )
            {
                if ( child is EnumConstantNode )
                {
                    generator.EmitLine( String.Format( "{0} = {1},", child.GetName(), child.GetAttribute( "value" ) ), depth + 1 );
                }
            }

            generator.EmitLine( "};", depth );
            generator.EmitLine( "", depth );
        }
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:26,代码来源:EnumNode.cs

示例2: EmitCodeClass

        private void EmitCodeClass(Generator generator, int depth, int ident)
        {
            string className = GetName().Substring(1);
            string macroName = null;

            if(className.StartsWith("Steam"))
            {
                string classValue = className.Substring(0, className.Length - 3).ToUpper();
                string intValue = className.Substring(className.Length - 3, 3);

                macroName = classValue + "_INTERFACE_VERSION_" + intValue;
            }
            else if(className.StartsWith("Client"))
            {
                macroName = className.ToUpper() + "_INTERFACE_VERSION";
            }

            if(macroName != null)
            {
                string macroValue = generator.FindMacroByName(macroName);

                if(macroValue != null)
                {
                    generator.EmitLine("[InterfaceVersion(" + macroValue + ")]", depth);
                }
            }

            generator.EmitLine("public interface " + GetName(), depth);
            generator.EmitLine("{", depth);

            int index = 0;

            foreach (INode child in children)
            {
                if (child is CXXDestructorNode)
                {
                    index++;
                }
                else if (child is CXXMethodNode && ShouldEmitMember(child))
                {
                    child.EmitCode(generator, depth + 1, index++);
                }
            }

            generator.EmitLine("};", depth);
        }
开发者ID:RaptorFactor,项目名称:Steam4NET,代码行数:46,代码来源:CXXRecordNode.cs

示例3: EmitCode

        public override void EmitCode(Generator generator, int depth, int ident)
        {
            generator.EmitLine( "// This file is automatically generated.", depth );
            generator.EmitLine( "using System;", depth );
            generator.EmitLine( "using System.Text;", depth );
            generator.EmitLine( "using System.Runtime.InteropServices;", depth );
            generator.EmitLine( "using Steam4NET.Attributes;", depth );
            generator.EmitLine( "", depth );
            generator.EmitLine( "namespace Steam4NET", depth );
            generator.EmitLine( "{", depth );
            generator.EmitLine( "", depth );

            foreach( INode child in children )
            {
                if ( child is CXXRecordNode )
                {
                    CXXRecordNode recordnode = child as CXXRecordNode;

                    INode basetype;
                    bool constness, pointer;

                    recordnode.ResolveType( 1, out basetype, out constness, out pointer );

                    if ( basetype.GetAttribute( "kind" ) == "class" && recordnode.ContainsVirtualMethods() )
                    {
                        recordnode.EmitCode( generator, depth + 1, 0 );
                    }
                    else if (recordnode.GetChildCount() > 0)
                    {
                        recordnode.EmitCode( generator, depth + 1, 1 );
                    }
                }
                else if ( child is EnumNode )
                {
                    EnumNode enumnode = child as EnumNode;

                    enumnode.EmitCode( generator, depth + 1, ident );
                }
            }

            generator.EmitLine( "}", depth );
            generator.FlushToFile( Path.GetFileNameWithoutExtension( name ) );
        }
开发者ID:RaptorFactor,项目名称:Steam4NET,代码行数:43,代码来源:FileNode.cs

示例4: EmitCodeInnerStructCallback

        public int EmitCodeInnerStructCallback(Generator generator, int depth)
        {
            // don't emit an anonymous enum reference, the real enum is attached through the context
            if (typeNode is EnumNode)
                return -1;

            INode returntype;
            bool constness, pointer;

            string types = base.ResolveType(1, out returntype, out constness, out pointer);

            types = generator.ResolveType(types, constness, pointer, true, false);

            foreach (INode child in children)
            {
                if (child is EnumConstantNode)
                {
                    generator.EmitLine(String.Format("public const {0} {1} = {2};", EnumShortCodes[types], child.GetName(), child.GetAttribute("value")), depth);
                    return Convert.ToInt32(child.GetAttribute("value"));
                }
            }

            return -1;
        }
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:24,代码来源:EnumNode.cs

示例5: EmitCodeClass

        private void EmitCodeClass(Generator generator, int depth, int ident)
        {
            generator.EmitLine("[StructLayout(LayoutKind.Sequential,Pack=4)]", depth);
            generator.EmitLine("public class " + name + "VTable", depth);
            generator.EmitLine("{", depth);

            int index = 0;
            foreach (INode child in children)
            {
                if (child is CXXMethodNode && ShouldEmitMember(child))
                {
                    generator.EmitLine("public IntPtr " + child.GetName() + index++ + ";", depth + 1);
                }
                else if (child is CXXDestructorNode)
                {
                    generator.EmitLine("private IntPtr DTor" + GetName() + index++ + ";", depth + 1);
                }
            }

            generator.EmitLine("};", depth);
            generator.EmitLine("", depth);

            string className = GetName().Substring(1);
            string macroName = null;

            if(className.StartsWith("Steam"))
            {
                string classValue = className.Substring(0, className.Length - 3).ToUpper();
                string intValue = className.Substring(className.Length - 3, 3);

                macroName = classValue + "_INTERFACE_VERSION_" + intValue;
            }
            else if(className.StartsWith("Client"))
            {
                macroName = className.ToUpper() + "_INTERFACE_VERSION";
            }

            if(macroName != null)
            {
                string macroValue = generator.FindMacroByName(macroName);
                
                if(macroValue != null)
                {
                    generator.EmitLine("[InteropHelp.InterfaceVersion(" + macroValue + ")]", depth);
                }
            }

            generator.EmitLine("public class " + GetName() + " : InteropHelp.NativeWrapper<" + GetName() + "VTable>", depth);
            generator.EmitLine("{", depth);

            index = 0;

            foreach (INode child in children)
            {
                if (child is CXXDestructorNode)
                {
                    index++;
                }
                else if (child is CXXMethodNode && ShouldEmitMember(child))
                {
                    child.EmitCode(generator, depth + 1, index++);
                }
            }

            generator.EmitLine("};", depth);
        }
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:66,代码来源:CXXRecordNode.cs

示例6: EmitCodeStruct

        private void EmitCodeStruct(Generator generator, int depth, int ident)
        {
            generator.EmitLine("[StructLayout(LayoutKind.Sequential,Pack=8)]", depth);
            int attribMarker = generator.GetMarker();
            generator.EmitLine("public struct " + GetName(), depth);
            generator.EmitLine("{", depth);

            foreach (INode child in children)
            {
                if ( child is FieldNode && !String.IsNullOrEmpty( child.GetName() ) )
                {
                    INode basetype;
                    bool constness, pointer;
                    bool arraytype = false;

                    string size = "";
                    string types = child.ResolveType( 0, out basetype, out constness, out pointer );

                    if ( basetype is ArrayTypeNode )
                    {
                        size = basetype.GetAttribute("size");
                        types = basetype.ResolveType(1, out basetype, out constness, out pointer);

                        pointer = true;
                        arraytype = true;
                    }

                    types = generator.ResolveType( types, constness, pointer, true, false );

                    if ( types == "bool" )
                    {
                        generator.EmitLine( "[MarshalAs(UnmanagedType.I1)]", depth + 1 );
                    }
                    else if ( types == "string" )
                    {
                        if (arraytype)
                        {
                            generator.EmitLine("[MarshalAs(UnmanagedType.ByValTStr, SizeConst = " + size + ")]", depth + 1);
                        }
                        else
                        {
                            types = "string";
                        }
                    }
                    else if ( types == "Byte[]" )
                    {
                        if (arraytype)
                        {
                            generator.EmitLine("[MarshalAs(UnmanagedType.ByValArray, SizeConst = " + size + ")]", depth + 1);
                        }
                        else
                        {
                            types = "IntPtr";
                        }
                    }
                    else if ( types == "CSteamID" || types == "CGameID" )
                    {
                        types = "UInt64";
                    }
                    else if (pointer)
                    {
                        types = "IntPtr";
                    }
                    else if (types == child.GetName())
                    {
                        continue;
                    }

                    generator.EmitLine( String.Format( "public {0} {1};", types, child.GetName() ), depth + 1 );
                }
                else if(child is EnumNode)
                {
                    // anonymous enum declaration
                    EnumNode innerEnum = child as EnumNode;
                    int callback = innerEnum.EmitCodeInnerStructCallback(generator, depth + 1);

                    if(callback > 0)
                    {
                        generator.InsertLine("[InteropHelp.CallbackIdentity(" + callback + ")]", attribMarker, depth);
                    }
                }
                else if(child is FieldNode)
                {
                    //  anonymous field like union
                    // not implemented!
                }
            }

            generator.EmitLine("};", depth);
            generator.EmitLine("", depth);
        }
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:91,代码来源:CXXRecordNode.cs

示例7: EmitCode


//.........这里部分代码省略.........
                }

                if ( genericwrapper && argtypes == "string" )
                {
                    maskedparams.Add( i );
                }

                if ( String.IsNullOrEmpty( argname ) )
                {
                    argname = "arg" + i;
                }

                if ( !maskedparams.Contains( i ) )
                    arg.Add( argtypes + " " + argname );

                arg_native_pure.Add(argtypes);

                if (argtypes.Contains("CSteamID") || argtypes.Contains("CGameID"))
                {
                    argtypes = argtypes.Replace("CSteamID", "UInt64").Replace("CGameID", "UInt64");

                    if(argtypes.StartsWith("ref"))
                        sidarg_count++;
                }

                if ( argtypes == "bool" )
                    argtypes = "[MarshalAs(UnmanagedType.I1)] " + argtypes;

                arg_native.Add( argtypes + " " + argname );
            }

            if (returns == "bool")
            {
                generator.EmitLine("[return: MarshalAs(UnmanagedType.I1)]", depth);
            }

            var innerReturns = returns;
            if (returns == "string")
            {
                innerReturns = "IntPtr";
            }
            generator.EmitLine( String.Format( "[UnmanagedFunctionPointer(CallingConvention.ThisCall)] private delegate {0} Native{1}{2}( {3} );", returnbystack ? "void" : innerReturns, GetName(), GetArgIdent(arg_native_pure), String.Join( ", ", arg_native.ToArray() ) ), depth );

            string methodname = GetName();
            string extra = "";

            if ( genericwrapper )
            {
                returns = "TClass";
                methodname = methodname + "<TClass>";
                extra = "where TClass : InteropHelp.INativeWrapper, new()";
            }

            generator.EmitLine( String.Format( "public {0} {1}( {2} ) {3}", returns, methodname, String.Join(", ", arg.ToArray() ), extra), depth );

            generator.EmitLine( "{", depth );

            StringBuilder method = new StringBuilder();

            for (int i = 0; i < sidarg_count; i++)
            {
                method.Append("UInt64 s" + i + " = 0; ");
            }

            if ( returnbystack )
            {
开发者ID:popoklopsi,项目名称:open-steamworks,代码行数:67,代码来源:CXXMethodNode.cs

示例8: EmitCode

        public override void EmitCode(Generator generator, int depth, int ident)
        {
            bool genericwrapper = false;
            List<int> maskedparams = new List<int>();

            INode returntype;
            bool constness, pointer;

            string returns_base = base.ResolveType( 0, out returntype, out constness, out pointer );

            Debug.Assert(returns_base != null);

            if ( returns_base == null )
            {
                returns_base = "(null)";
            }

            string returns = returns_base;

            if ( pointer )
            {
                if ((returntype is RecordNode && returntype.GetAttribute("kind") == "class" && returntype.GetName().StartsWith("I") ) ||
                        (returntype is FundamentalTypeNode && returns == "void"))
                {
                    genericwrapper = true;
                    returns = "IntPtr";
                }
            }

            returns = generator.ResolveType( returns, constness, pointer, true, false );

            /*if (returns == "UInt64" || returns == "Int64")
            {
                returnbystack = true;
            }
            */

            List<INode> args = new List<INode>();

            foreach( INode child in children )
            {
                if ( child is ParmVarNode )
                {
                    args.Add( child );
                }
            }

            List<string> arg = new List<string>();
            List<string> arg_native = new List<string>();
            List<string> arg_native_pure = new List<string>();

            arg_native.Add( "IntPtr thisptr" );

            for (int i = 0; i < args.Count; i++)
            {
                INode argtype;
                bool argconst, argpointer;

                string argname = args[i].GetName();

                string argtypes = args[i].ResolveType(0, out argtype, out argconst, out argpointer);

                Debug.Assert(argtypes != null);

                argtypes = generator.ResolveType(argtypes, argconst, argpointer, false, true);

                if ( genericwrapper && argtypes == "string" )
                {
                    maskedparams.Add( i );
                }

                if ( String.IsNullOrEmpty( argname ) )
                {
                    argname = "arg" + i;
                }

                if ( !maskedparams.Contains( i ) )
                    arg.Add( argtypes + " " + argname );
            }

            string methodname = GetName();
            string extra = "";

            if ( genericwrapper )
            {
                returns = "TClass";
                methodname = methodname + "<TClass>";
                extra = " where TClass : class";
            }

            generator.EmitLine( String.Format( "[VTableSlot({0})]", ident ), depth );
            generator.EmitLine( String.Format( "{0} {1}({2}){3};", returns, methodname, String.Join(", ", arg.ToArray() ), extra), depth );
        }
开发者ID:RaptorFactor,项目名称:Steam4NET,代码行数:93,代码来源:CXXMethodNode.cs


注:本文中的Generator.EmitLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。