protected XCodeTypeReference BuildDataType(XSharpParser.DatatypeContext context)
        {
            //
            // Datatype is ptrDatatype
            // or arrayDatatype
            // or simpleDatatype
            // or nullableDatatype
            // they all have a TypeName
            XSharpParser.TypeNameContext tn = null;
            var sName = context.GetText();

            if (context is XSharpParser.PtrDatatypeContext)
            {
                XSharpParser.PtrDatatypeContext ptrData = (XSharpParser.PtrDatatypeContext)context;
                tn = ptrData.TypeName;
            }
            else if (context is XSharpParser.ArrayDatatypeContext)
            {
                XSharpParser.ArrayDatatypeContext aData = (XSharpParser.ArrayDatatypeContext)context;
                tn = aData.TypeName;
            }
            else if (context is XSharpParser.SimpleDatatypeContext)
            {
                XSharpParser.SimpleDatatypeContext sdt = (XSharpParser.SimpleDatatypeContext)context;
                tn = sdt.TypeName;
            }
            else if (context is XSharpParser.NullableDatatypeContext)
            {
                XSharpParser.NullableDatatypeContext ndc = context as XSharpParser.NullableDatatypeContext;
                tn = ndc.TypeName;
            }
            XCodeTypeReference expr = null;

            if (tn != null)
            {
                if (tn.NativeType != null)
                {
                    expr = BuildNativeType(tn.NativeType);
                }
                else if (tn.XType != null)
                {
                    expr = BuildXBaseType(tn.XType);
                }
                else if (tn.Name != null)
                {
                    expr = BuildName(tn.Name);
                }
            }
            else
            {
                expr = new XCodeTypeReference(typeof(void));
            }

            if (sName.Contains("[") || sName.Contains(">"))
            {
                // work around to fix type problems with generics and arrays
                expr.UserData[XSharpCodeConstants.USERDATA_CODE] = sName;
            }
            return(expr);
        }
        protected XCodeTypeReference BuildDataType(XSharpParser.DatatypeContext context)
        {
            //
            // Datatype is ptrDatatype
            // or arrayDatatype
            // or simpleDatatype
            // or nullableDatatype
            // they all have a TypeName
            XSharpParser.TypeNameContext tn = null;
            if (context is XSharpParser.PtrDatatypeContext)
            {
                XSharpParser.PtrDatatypeContext ptrData = (XSharpParser.PtrDatatypeContext)context;
                tn = ptrData.TypeName;
            }
            else if (context is XSharpParser.ArrayDatatypeContext)
            {
                XSharpParser.ArrayDatatypeContext aData = (XSharpParser.ArrayDatatypeContext)context;
                tn = aData.TypeName;
            }
            else if (context is XSharpParser.SimpleDatatypeContext)
            {
                XSharpParser.SimpleDatatypeContext sdt = (XSharpParser.SimpleDatatypeContext)context;
                tn = sdt.TypeName;
            }
            else if (context is XSharpParser.NullableDatatypeContext)
            {
                XSharpParser.NullableDatatypeContext ndc = context as XSharpParser.NullableDatatypeContext;
                tn = ndc.TypeName;
            }
            XCodeTypeReference expr = null;

            if (tn != null)
            {
                if (tn.NativeType != null)
                {
                    expr = BuildNativeType(tn.NativeType);
                }
                else if (tn.XType != null)
                {
                    expr = BuildXBaseType(tn.XType);
                }
                else if (tn.Name != null)
                {
                    expr = BuildName(tn.Name);
                }
            }
            else
            {
                expr = new XCodeTypeReference(typeof(void));
            }
            //
            return(expr);
        }