Ejemplo n.º 1
0
        public Entrypoints(IEnvironment env, Disk disk, IILFactory ilFactory, Converters.Converter convert)
        {
            _environment = env;
            _disk        = disk;
            _convert     = convert;

            UnoType = ilFactory.GetType("Uno.Compiler.ExportTargetInterop.Foreign.Android.ExternBlockHost");
        }
Ejemplo n.º 2
0
 public JavaMethod(ForeignMethod fm, ForeignHelpers helpers, Converters.Converter convert, ExpandInterceptor expandInterceptor, IEnvironment env)
 {
     _convert       = convert;
     _helpers       = helpers;
     _environment   = env;
     _foreignMethod = fm;
     _argsWithTypes = JavaMethodArgs(fm.InitialUnoMethod);
     _argsNoTypes   = JavaMethodArgs(fm.InitialUnoMethod, false);
     Source         = GenJavaMethod(fm.InitialUnoMethod, fm.JavaName, expandInterceptor);
 }
Ejemplo n.º 3
0
 void EnsureInitialized()
 {
     if (!_initialized)
     {
         ExpandInterceptor    = new ExpandInterceptor(InterceptEntity);
         BoxedJavaObject      = ILFactory.GetType("Java.Object");
         _initialized         = true;
         Convert              = new Converters.Converter(BoxedJavaObject, Essentials, ILFactory, Helpers);
         BlockHost            = new Entrypoints(Environment, Disk, ILFactory, Convert);
         UnoToJavaBoxingClass = ILFactory.GetType("Uno.Compiler.ExportTargetInterop.Foreign.Android.JavaUnoObject");
     }
 }
Ejemplo n.º 4
0
		public ForeignMacroExpr(DelegateType d, Converters.Converter convert, ForeignHelpers helpers)
		{
			_convert = convert;
			var source = d.Parameters.ToList();
			source.Insert(0, new Parameter(d.Source, AttributeList.Empty, 0, d, MacroParam.DelegateArgName, null));
			var uparams = source.Select(p => new MacroParam(p, convert, helpers)).ToList();
			EntrypointIncludes.AddRange(CalcImportsForExternBlock(d));
			EntrypointIncludes.AddRange(uparams.SelectMany(x => x.EntrypointIncludes));

			CppSignatureArgs = convert.Signature.GenCppSignature(uparams);
			Params = uparams;
			JniSignature = convert.Signature.GenJniSignature(uparams, d.ReturnType);
			ReturnType = d.ReturnType;
			CallToUno = GenCppToUnoCall(uparams, false, true, d.Name, d, false);
		}
Ejemplo n.º 5
0
            public JavaClass(DataType dt, ForeignHelpers helpers, Converters.Converter convert, Entrypoints blockHost, IEnvironment env)
            {
                _environment = env;
                _blockHost   = blockHost;
                _helpers     = helpers;
                _convert     = convert;

                FullName = convert.Name.ComForeignClassName(dt);
                var split = FullName.LastIndexOf(".", StringComparison.Ordinal);

                _name    = FullName.Substring(split + 1);
                _package = FullName.Substring(0, split);
                _usings.AddRange(helpers.GetForeignIncludes(dt, "Java", env));
                _nested = dt.IsNestedType;
            }
Ejemplo n.º 6
0
		// We use this to get the data we need from the uno function in a form that is easy to use
		// in the generated c++ and java
		public ForeignMacroExpr(Function f, Converters.Converter convert, ForeignHelpers helpers)
		{
			_convert = convert;
			var source = f.Parameters.ToList();
			if (!f.IsStatic)
				source.Insert(0, new Parameter(f.Source, AttributeList.Empty, 0, f.DeclaringType, MacroParam.CppThisArgName, null));
			var uparams = source.Select(p => new MacroParam(p, convert, helpers)).ToList();
			EntrypointIncludes.AddRange(CalcImportsForExternBlock(f));
			EntrypointIncludes.AddRange(uparams.SelectMany(x => x.EntrypointIncludes));

			CppSignatureArgs = convert.Signature.GenCppSignature(uparams);
			Params = uparams;
			JniSignature = convert.Signature.GenJniSignature(uparams, f.ReturnType);
			ReturnType = f.ReturnType;
			CallToUno = GenCppToUnoCall(uparams, f.IsStatic, false, f.UnoName, f.DeclaringType, f.Prototype.IsConstructor);
		}
Ejemplo n.º 7
0
 public ForeignMethod(Function f, IEssentials essentials, Converters.Converter convert, ForeignHelpers helpers, List <string> annotations)
 {
     _essentials = essentials;
     Convert     = convert;
     Helpers     = helpers;
     CppHeadersForDeclaringType = new List <string> {
         "jni.h",
         "Uno/JNIHelper.h",
         "@{global::Android.Base.Wrappers.JWrapper:Include}",
         "@{global::Android.Base.Wrappers.JavaObjectHelper:Include}",
         "@{" + ForeignJavaPass.UnoToJavaBoxingClass.FullName + ":Include}"
     };
     Annotations = annotations;
     ValidateMethod(f, essentials);
     InitialUnoMethod = f;
     JavaName         = convert.Name.JavaMethodName(f);
 }
Ejemplo n.º 8
0
		public ForeignMacroExpr(Member f, bool isGetter, Converters.Converter convert, ForeignHelpers helpers)
		{
			_convert = convert;
			var source = new List<Parameter>();
			if (!isGetter)
				source.Insert(0, new Parameter(f.Source, AttributeList.Empty, 0, f.ReturnType, MacroParam.CppSetArgName, null));
			if (!f.IsStatic)
				source.Insert(0, new Parameter(f.Source, AttributeList.Empty, 0, f.DeclaringType, MacroParam.CppThisArgName, null));
			var uparams = source.Select(p => new MacroParam(p, convert, helpers)).ToList();
			EntrypointIncludes.AddRange(uparams.SelectMany(x => x.EntrypointIncludes));
			var returnType = isGetter ? f.ReturnType : convert.Type.Void;

			CppSignatureArgs = convert.Signature.GenCppSignature(uparams);
			Params = uparams;
			JniSignature = convert.Signature.GenJniSignature(uparams, returnType);
			ReturnType = returnType;
			CallToUno = GenCppToUnoGetSet(uparams, f.IsStatic, f.UnoName, f.DeclaringType, isGetter);
		}
Ejemplo n.º 9
0
        public MacroParam(Parameter p, Converters.Converter convert, ForeignHelpers helpers)
        {
            var unoArgName = "uno_" + p.Name;
            var isThis     = (p.Name == CppThisArgName || p.Name == DelegateArgName);
            var callForm   = helpers.IsPrimitive(p.Type) || p.Type.IsEnum || p.Type.IsStruct ? unoArgName : helpers.CastTo(p.Type, unoArgName);

            UnoArgName        = unoArgName;
            Type              = p.Type;
            JniSigType        = convert.Type.UnoToJniSigType(p.Type);
            CppArgName        = p.Name + _javaArgPointerPostfix;
            CppTypedName      = UnoToJniParameter(p, convert);
            JavaArgCast       = "(" + convert.Type.UnoToJavaType(p.Type, false) + ")";
            JavaTypedName     = convert.Param.UnoToJavaParameter(p);
            JniToUnoCoversion = GenToUnoConversion(p, unoArgName, convert, helpers);
            if (!helpers.IsPrimitive(p) && p.Type.IsStruct)
            {
                Console.Write("");
            }
            CallForm      = callForm;
            HasPointerArg = convert.Type.IsJavaObject(p.Type);
            IsThis        = isThis;
        }
Ejemplo n.º 10
0
 // convert the jni type to an uno type
 string GenToUnoConversion(Parameter arg, string unoArgName, Converters.Converter convert, ForeignHelpers helpers)
 {
     EntrypointIncludes.Add(arg.Type);
     return("@{" + arg.Type.FullName + "} " + unoArgName + " = " + convert.Type.CastJniToUno(arg.Type, arg.Name, true) + ";");
 }
Ejemplo n.º 11
0
 static string UnoToJniParameter(Parameter p, Converters.Converter convert)
 {
     return(convert.Type.UnoToJniType(p.Type) + " " + p.Name);
 }