Ejemplo n.º 1
0
        private bool IsStdType(QualifiedType type)
        {
            var typePrinter = new CppTypePrinter(Driver.TypeDatabase);
            var typeName    = type.Visit(typePrinter);

            return(typeName.Contains("std::"));
        }
Ejemplo n.º 2
0
        private string GenerateDelegateSignature(IEnumerable <Parameter> @params, QualifiedType returnType)
        {
            var typesBuilder = new StringBuilder();

            if (!returnType.Type.IsPrimitiveType(PrimitiveType.Void))
            {
                typesBuilder.Insert(0, returnType.Visit(TypePrinter));
                typesBuilder.Append('_');
            }
            foreach (var parameter in @params)
            {
                typesBuilder.Append(parameter.Visit(TypePrinter));
                typesBuilder.Append('_');
            }
            if (typesBuilder.Length > 0)
            {
                typesBuilder.Remove(typesBuilder.Length - 1, 1);
            }
            var delegateName = FormatTypesStringForIdentifier(typesBuilder);

            if (returnType.Type.IsPrimitiveType(PrimitiveType.Void))
            {
                delegateName.Insert(0, "Action_");
            }
            else
            {
                delegateName.Insert(0, "Func_");
            }

            return(delegateName.ToString());
        }
Ejemplo n.º 3
0
        private bool IsStdType(QualifiedType type)
        {
            var typePrinter = new CppTypePrinter(Driver.TypeDatabase);
            var typeName = type.Visit(typePrinter);

            return typeName.Contains("std::");
        }
Ejemplo n.º 4
0
        public TypePrinterResult PrintNative(QualifiedType type)
        {
            PushContext(TypePrinterContextKind.Native);
            var typePrinterResult = type.Visit(this);

            PopContext();
            return(typePrinterResult);
        }
Ejemplo n.º 5
0
        public void TestVolatile()
        {
            var cppTypePrinter = new CppTypePrinter {
                PrintScopeKind = TypePrintScopeKind.Qualified
            };
            var builtin = new BuiltinType(PrimitiveType.Char);
            var pointee = new QualifiedType(builtin, new TypeQualifiers {
                IsConst = true, IsVolatile = true
            });
            var type = pointee.Visit(cppTypePrinter);

            Assert.That(type, Is.EqualTo("const volatile char"));
        }
Ejemplo n.º 6
0
        public void TestPrintingConstPointerWithConstType()
        {
            var cppTypePrinter = new CppTypePrinter {
                PrintScopeKind = TypePrintScopeKind.Qualified
            };
            var builtin = new BuiltinType(PrimitiveType.Char);
            var pointee = new QualifiedType(builtin, new TypeQualifiers {
                IsConst = true
            });
            var pointer = new QualifiedType(new PointerType(pointee), new TypeQualifiers {
                IsConst = true
            });
            var type = pointer.Visit(cppTypePrinter);

            Assert.That(type, Is.EqualTo("const char* const"));
        }
Ejemplo n.º 7
0
        public string VisitReturnType(QualifiedType type, bool hasName, bool hasModifier)
        {
            bool   savedPrintTypeModifiers  = PrintTypeModifiers;
            bool   savedPrintTypeQualifiers = PrintTypeQualifiers;
            string result = string.Empty;

            PrintTypeModifiers  = hasModifier;
            PrintTypeQualifiers = hasModifier;

            result = type.Visit(this);

            PrintTypeModifiers  = savedPrintTypeModifiers;
            PrintTypeQualifiers = savedPrintTypeQualifiers;

            return(result);
        }
Ejemplo n.º 8
0
        public void TestPrintingConstPointerWithConstType()
        {
            var template       = AstContext.FindDecl <ClassTemplate>("TestSpecializationArguments").First();
            var cppTypePrinter = new CppTypePrinter {
                PrintScopeKind = CppTypePrintScopeKind.Qualified
            };
            var builtin = new BuiltinType(PrimitiveType.Char);
            var pointee = new QualifiedType(builtin, new TypeQualifiers {
                IsConst = true
            });
            var pointer = new QualifiedType(new PointerType(pointee), new TypeQualifiers {
                IsConst = true
            });
            var type = pointer.Visit(cppTypePrinter);

            Assert.AreEqual(type, "const char* const");
        }
Ejemplo n.º 9
0
        public void TestPrintingConstPointerWithConstType()
        {
            var cppTypePrinter = new CppTypePrinter(Context)
            {
                ResolveTypeMaps = false
            };

            cppTypePrinter.PushScope(TypePrintScopeKind.Qualified);
            var builtin = new BuiltinType(PrimitiveType.Char);
            var pointee = new QualifiedType(builtin, new TypeQualifiers {
                IsConst = true
            });
            var pointer = new QualifiedType(new PointerType(pointee), new TypeQualifiers {
                IsConst = true
            });
            string type = pointer.Visit(cppTypePrinter);

            Assert.That(type, Is.EqualTo("const char* const"));
        }
Ejemplo n.º 10
0
 public static void CSharpMarshalToNative(this QualifiedType type,
                                          CSharpMarshalManagedToNativePrinter printer)
 {
     (printer.Context as CSharpMarshalContext).FullType = type;
     type.Visit(printer);
 }
        public static bool IsCovariantType(QualifiedType t1, QualifiedType t2)
        {
            var comparer = new CovariantTypeComparer(t1);

            return(t2.Visit(comparer));
        }
Ejemplo n.º 12
0
 public bool QualifiedTypeIsObject(QualifiedType qualifiedType)
 {
     return(qualifiedType.Visit(this).ToString() == NodeV8IsObject);
 }
Ejemplo n.º 13
0
 public bool QualifiedTypeIsTypedBuffer(QualifiedType qualifiedType)
 {
     return(qualifiedType.Visit(this).ToString() == NodeV8IsTypedBuffer);
 }
Ejemplo n.º 14
0
 public bool QualifiedTypeIsBoolean(QualifiedType qualifiedType)
 {
     return(qualifiedType.Visit(this).ToString() == NodeV8IsBoolean);
 }
Ejemplo n.º 15
0
 public static CSharpTypePrinterResult CSharpType(this QualifiedType type,
                                                  CSharpTypePrinter printer)
 {
     printer.TypePrinterContext.FullType = type;
     return(type.Visit(printer));
 }
Ejemplo n.º 16
0
 public static void CSharpMarshalToManaged(this QualifiedType type,
                                           CSharpMarshalNativeToManagedPrinter printer)
 {
     printer.Context.FullType = type;
     type.Visit(printer);
 }
Ejemplo n.º 17
0
 public bool QualifiedTypeIsArray(QualifiedType qualifiedType)
 {
     return(qualifiedType.Visit(this).ToString() == NodeV8IsArray);
 }