Example #1
0
        /// <summary>
        /// Load interface description from YAML file
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static KeyValuePair<InterfaceId, JstpDescInterface> LoadDescriptionInterface([NotNull] string file)
        {
            if (file == null) throw new ArgumentNullException("file");

            Logger.Info("Load model from file {0}",file);
            try
            {
                JstpDescInterface ifc;
                using (var rdr = new StreamReader(file))
                {
                    ifc = new Deserializer(ignoreUnmatched: true).Deserialize<JstpDescInterface>(rdr);
                }
                ifc.Validate();
                var key = new InterfaceId(ifc.Name, Version.Parse(ifc.Version));
                Logger.Debug("Load interface '{0}' version '{1}'", key.Name, key.Version);
                return new KeyValuePair<InterfaceId, JstpDescInterface>(key,ifc);
            }
            catch (Exception ex)
            {
                Logger.Error(ex,"Filed to load interface description from file {0}",file);
                throw;
            }
        }
        public Error GetInterfaces(ReferenceTypeId referenceType, out InterfaceId[] interfaces)
        {
            interfaces = null;

            JniEnvironment nativeEnvironment;
            JvmtiEnvironment environment;
            jvmtiError error = GetEnvironment(out environment, out nativeEnvironment);
            if (error != jvmtiError.None)
                return GetStandardError(error);

            using (var classHandle = VirtualMachine.GetLocalReferenceForClass(nativeEnvironment, referenceType))
            {
                if (!classHandle.IsAlive)
                    return Error.InvalidClass;

                TaggedReferenceTypeId[] taggedInterfaces;
                error = environment.GetImplementedInterfaces(nativeEnvironment, classHandle.Value, out taggedInterfaces);
                if (error != jvmtiError.None)
                    return GetStandardError(error);

                interfaces = Array.ConvertAll(taggedInterfaces, i => (InterfaceId)i);
                return Error.None;
            }
        }
        public Error GetInterfaces(out InterfaceId[] interfaces, ReferenceTypeId referenceType)
        {
            byte[] packet = new byte[HeaderSize + ReferenceTypeIdSize];
            int id = GetMessageId();
            SerializeHeader(packet, id, ReferenceTypeCommand.Interfaces);
            WriteReferenceTypeId(packet, HeaderSize, referenceType);

            byte[] response = SendPacket(id, packet);
            Error errorCode = ReadErrorCode(response);
            if (errorCode != Error.None)
            {
                interfaces = null;
                return errorCode;
            }

            int offset = HeaderSize;
            int interfaceCount = ReadInt32(response, ref offset);
            interfaces = new InterfaceId[interfaceCount];
            for (int i = 0; i < interfaceCount; i++)
            {
                interfaces[i] = (InterfaceId)ReadReferenceTypeId(response, ref offset);
            }

            return Error.None;
        }
Example #4
0
        internal InterfaceType GetMirrorOf(InterfaceId interfaceId)
        {
            if (interfaceId == default(InterfaceId))
                return null;

            return new InterfaceType(this, interfaceId);
        }