コード例 #1
0
        protected internal virtual void createJobEntities(BatchEntity batch, DeleteProcessInstanceBatchConfiguration configuration, string deploymentId, IList <string> processInstancesToHandle, int invocationsPerBatchJob)
        {
            CommandContext   commandContext   = Context.CommandContext;
            ByteArrayManager byteArrayManager = commandContext.ByteArrayManager;
            JobManager       jobManager       = commandContext.JobManager;

            int createdJobs = 0;

            while (processInstancesToHandle.Count > 0)
            {
                int lastIdIndex = Math.Min(invocationsPerBatchJob, processInstancesToHandle.Count);
                // view of process instances for this job
                IList <string> idsForJob = processInstancesToHandle.subList(0, lastIdIndex);

                DeleteProcessInstanceBatchConfiguration jobConfiguration = createJobConfiguration(configuration, idsForJob);
                ByteArrayEntity configurationEntity = saveConfiguration(byteArrayManager, jobConfiguration);

                JobEntity job = createBatchJob(batch, configurationEntity);
                job.DeploymentId = deploymentId;

                jobManager.insertAndHintJobExecutor(job);
                createdJobs++;

                idsForJob.Clear();
            }

            // update created jobs for batch
            batch.JobsCreated = batch.JobsCreated + createdJobs;

            // update batch configuration
            batch.ConfigurationBytes = writeConfiguration(configuration);
        }
コード例 #2
0
    public void Run()
    {
        foreach (CodeMemberProperty cmp in GenerateBasicAttributeDefinitions())
        {
            Attribute attr = attributes[cmp.Name];
            CodeMethodReferenceExpression interceptorReference =
                ((attr.GetMethod->flags & (uint)Smoke.MethodFlags.mf_static) == 0)
                                        ? SmokeSupport.interceptor_Invoke
                                        : SmokeSupport.staticInterceptor_Invoke;
            cmp.GetStatements.Add(
                new CodeMethodReturnStatement(
                    new CodeCastExpression(cmp.Type,
                                           new CodeMethodInvokeExpression(
                                               interceptorReference,
                                               new CodePrimitiveExpression(ByteArrayManager.GetString(attr.Smoke->methodNames[attr.GetMethod->name])),
                                               new CodePrimitiveExpression(attr.Smoke->GetMethodSignature(attr.GetMethod)),
                                               new CodeTypeOfExpression(cmp.Type),
                                               new CodePrimitiveExpression(false)))));

            if (cmp.HasSet)
            {
                cmp.SetStatements.Add(
                    new CodeMethodInvokeExpression(interceptorReference,
                                                   new CodePrimitiveExpression(ByteArrayManager.GetString(attr.Smoke->methodNames[attr.Smoke->FindMungedName(attr.SetMethod)])),
                                                   new CodePrimitiveExpression(attr.Smoke->GetMethodSignature(attr.SetMethod)),
                                                   new CodeTypeOfExpression(typeof(void)),
                                                   new CodePrimitiveExpression(false),
                                                   new CodeTypeOfExpression(cmp.Type),
                                                   new CodeArgumentReferenceExpression("value")));
            }

            type.Members.Add(cmp);
        }
    }
コード例 #3
0
ファイル: SmokeMethods.cs プロジェクト: corngood/assemblygen
    public short IDClass(string name)
    {
        byte[] bytes = ByteArrayManager.GetCString(name);
        fixed(byte *c = bytes)
        {
            short imax = numClasses;
            short imin = 1;

            while (imax >= imin)
            {
                short icur = (short)((imin + imax) / 2);
                long  icmp = ByteArrayManager.strcmp(classes[icur].className, c);
                if (icmp == 0)
                {
                    return(icur);
                }
                if (icmp > 0)
                {
                    imax = (short)(icur - 1);
                }
                else
                {
                    imin = (short)(icur + 1);
                }
            }

            return(0);
        }
    }
コード例 #4
0
        public override void LoadBytes(byte[] bytes)
        {
            ByteArrayManager BAM = new ByteArrayManager(bytes);

            base.LoadBytes(BAM.NextBytes(24)); //Load header

            int t = 0;
            List <CarTelemetryData> TelDatas = new List <CarTelemetryData>();

            for (t = 1; t <= 22; t++)
            {
                TelDatas.Add(CarTelemetryData.Create(BAM.NextBytes(58)));
            }
            FieldTelemetryData = TelDatas.ToArray();

            //Button status
            ButtonStatus = BitConverter.ToInt32(BAM.NextBytes(4), 0);

            //MFD Panel Index
            MfdPanelIndex = BAM.NextByte();

            //Secndary player mfd panel index
            SecondaryPlayerMfdPanelIndex = BAM.NextByte();

            //Suggested gear
            SuggestedGear = BAM.NextByte();
        }
コード例 #5
0
ファイル: SmokeMethods.cs プロジェクト: corngood/assemblygen
    public short IDMethodName(string name)
    {
        byte[] bytes = ByteArrayManager.GetCString(name);
        fixed(byte *m = bytes)
        {
            short imax = numMethodNames;
            short imin = 1;

            while (imax >= imin)
            {
                short icur = (short)((imin + imax) / 2);
                long  icmp = ByteArrayManager.strcmp(methodNames[icur], m);
                if (icmp == 0)
                {
                    return(icur);
                }
                if (icmp > 0)
                {
                    imax = (short)(icur - 1);
                }
                else
                {
                    imin = (short)(icur + 1);
                }
            }

            return(0);
        }
    }
コード例 #6
0
        public override void LoadBytes(byte[] bytes)
        {
            ByteArrayManager BAM = new ByteArrayManager(bytes);

            //Load header
            base.LoadBytes(BAM.NextBytes(24));

            this.NumPlayers   = BAM.NextByte();
            this.LobbyPlayers = new LobbyInfoData[22];

            for (int i = 0; i < 22; i++)
            {
                var lobbyInfoData = new LobbyInfoData
                {
                    AiControlled = BAM.NextByte() == 1,
                    TeamId       = CodemastersToolkit.GetTeamFromTeamId(BAM.NextByte()),
                    Nationality  = BAM.NextByte(),
                    Name         = ""
                };

                for (var t = 1; t <= 48; t++)
                {
                    var currentChar = Convert.ToChar(BAM.NextByte());
                    lobbyInfoData.Name += currentChar.ToString();
                }

                var readyStatusByte = BAM.NextByte();
                lobbyInfoData.ReadyStatus = readyStatusByte == 0 ? ReadyStatus.NotReady :
                                            readyStatusByte == 1 ? ReadyStatus.Ready : ReadyStatus.Spectating;

                this.LobbyPlayers[i] = lobbyInfoData;
            }
        }
コード例 #7
0
    private string[] GetMethodArgs(Smoke *smoke, Smoke.Method *method)
    {
        if (method->numArgs == 0)
        {
            return(new string[0]);
        }
        string className = ByteArrayManager.GetString(smoke->classes[method->classId].className);

        className = className.Substring(className.LastIndexOf(":") + 1);
        StringBuilder keyBuilder =
            new StringBuilder(className + "," + ByteArrayManager.GetString(smoke->methodNames[method->name]));

        for (short *typeIndex = smoke->argumentList + method->args; *typeIndex > 0; typeIndex++)
        {
            keyBuilder.Append(',');
            keyBuilder.Append(*typeIndex);
        }
        string key = keyBuilder.ToString();

        if (data.ArgumentNames.ContainsKey(key))
        {
            return(data.ArgumentNames[key]);
        }
        string argNamesFile = data.GetArgNamesFile(smoke);

        if (File.Exists(argNamesFile))
        {
            foreach (string[] strings in File.ReadAllLines(argNamesFile).Select(line => line.Split(';')))
            {
                data.ArgumentNames[strings[0]] = strings[1].Split(',');
            }
            return(data.ArgumentNames[key]);
        }
        return(null);
    }
コード例 #8
0
            public static MarshallZone Create(byte[] bytes)
            {
                MarshallZone     ReturnInstance = new MarshallZone();
                ByteArrayManager BAM            = new ByteArrayManager(bytes);

                //Get zone start
                ReturnInstance.ZoneStart = BitConverter.ToSingle(BAM.NextBytes(4), 0);

                //Get zone flag
                byte nb = BAM.NextByte();

                if (nb == 0)
                {
                    ReturnInstance.ZoneFlag = FiaFlag.None;
                }
                else if (nb == 1)
                {
                    ReturnInstance.ZoneFlag = FiaFlag.Green;
                }
                else if (nb == 2)
                {
                    ReturnInstance.ZoneFlag = FiaFlag.Blue;
                }
                else if (nb == 3)
                {
                    ReturnInstance.ZoneFlag = FiaFlag.Yellow;
                }
                else if (nb == 4)
                {
                    ReturnInstance.ZoneFlag = FiaFlag.Red;
                }

                return(ReturnInstance);
            }
コード例 #9
0
ファイル: SmokeMethods.cs プロジェクト: corngood/assemblygen
    public short IDType(string type)
    {
        byte[] bytes = ByteArrayManager.GetCString(type);
        fixed(byte *t = bytes)
        {
            short imax = numTypes;
            short imin = 1;

            while (imax >= imin)
            {
                short icur = (short)((imin + imax) / 2);
                long  icmp = ByteArrayManager.strcmp(types[icur].name, t);
                if (icmp == 0)
                {
                    return(icur);
                }

                if (icmp > 0)
                {
                    imax = (short)(icur - 1);
                }
                else
                {
                    imin = (short)(icur + 1);
                }
            }

            return(0);
        }
    }
コード例 #10
0
        protected internal virtual ByteArrayEntity saveConfiguration(ByteArrayManager byteArrayManager, T jobConfiguration)
        {
            ByteArrayEntity configurationEntity = new ByteArrayEntity();

            configurationEntity.Bytes = writeConfiguration(jobConfiguration);
            byteArrayManager.insert(configurationEntity);
            return(configurationEntity);
        }
コード例 #11
0
ファイル: DFSPacket.cs プロジェクト: orf53975/hadoop.net
 /// <summary>Release the buffer in this packet to ByteArrayManager.</summary>
 /// <param name="bam"/>
 internal virtual void ReleaseBuffer(ByteArrayManager bam)
 {
     lock (this)
     {
         bam.Release(buf);
         buf = null;
     }
 }
コード例 #12
0
            public static ParticipantData Create(byte[] bytes)
            {
                ParticipantData  ReturnInstance = new ParticipantData();
                ByteArrayManager BAM            = new ByteArrayManager(bytes);

                //Get AI controlled
                byte nb = BAM.NextByte();

                if (nb == 0)
                {
                    ReturnInstance.IsAiControlled = false;
                }
                else if (nb == 1)
                {
                    ReturnInstance.IsAiControlled = true;
                }


                //Get piloting driver
                ReturnInstance.PilotingDriver = CodemastersToolkit.GetDriverFromDriverId(BAM.NextByte(), Game.F1_2019);

                //Get Team
                ReturnInstance.ManufacturingTeam = CodemastersToolkit.GetTeamFromTeamId(BAM.NextByte(), Game.F1_2019);

                //Get race number
                ReturnInstance.CarRaceNumber = BAM.NextByte();

                //Get nationallity ID
                ReturnInstance.NationalityId = BAM.NextByte();

                //Get name
                string FullName = "";
                int    t        = 1;

                for (t = 1; t <= 48; t++)
                {
                    char ThisChar = Convert.ToChar(BAM.NextByte());
                    FullName = FullName + ThisChar.ToString();
                }
                ReturnInstance.Name = FullName.Trim();

                //Get telemetry private or not.
                nb = BAM.NextByte();
                if (nb == 0)
                {
                    ReturnInstance.TelemetryPrivate = false;
                }
                else if (nb == 1)
                {
                    ReturnInstance.TelemetryPrivate = true;
                }


                return(ReturnInstance);
            }
コード例 #13
0
    public bool Equals(Smoke.ModuleIndex first, Smoke.ModuleIndex second)
    {
        Smoke.Method *firstMeth  = first.smoke->methods + first.index;
        Smoke.Method *secondMeth = second.smoke->methods + second.index;

        bool firstConst  = ((firstMeth->flags & (ushort)Smoke.MethodFlags.mf_const) > 0);
        bool secondConst = ((secondMeth->flags & (ushort)Smoke.MethodFlags.mf_const) > 0);

        bool firstStatic  = ((firstMeth->flags & (ushort)Smoke.MethodFlags.mf_static) > 0);
        bool secondStatic = ((secondMeth->flags & (ushort)Smoke.MethodFlags.mf_static) > 0);

        bool firstAbstract  = ((firstMeth->flags & (ushort)Smoke.MethodFlags.mf_purevirtual) > 0);
        bool secondAbstract = ((secondMeth->flags & (ushort)Smoke.MethodFlags.mf_purevirtual) > 0);

        if (firstConst != secondConst || firstStatic != secondStatic ||
            (m_abstractIsDifference && (firstAbstract != secondAbstract)))
        {
            return(false);
        }

        if (first.smoke == second.smoke)
        {
            // when the methods are in the same module, we can be rather quick
            if (firstMeth->name == secondMeth->name && firstMeth->args == secondMeth->args && firstMeth->ret == secondMeth->ret)
            {
                return(true);
            }
            return(false);
        }
        else
        {
            if (ByteArrayManager.strcmp(first.smoke->methodNames[firstMeth->name], second.smoke->methodNames[secondMeth->name]) == 0 &&
                ByteArrayManager.strcmp(first.smoke->types[firstMeth->ret].name, second.smoke->types[secondMeth->ret].name) == 0 &&
                firstMeth->numArgs == secondMeth->numArgs)
            {
                // name and number of arguments match, now compare the arguments individually
                short *firstMethodArgPtr  = first.smoke->argumentList + firstMeth->args;
                short *secondMethodArgPtr = second.smoke->argumentList + secondMeth->args;

                while ((*firstMethodArgPtr) > 0)
                {
                    if (ByteArrayManager.strcmp(first.smoke->types[*firstMethodArgPtr].name, second.smoke->types[*secondMethodArgPtr].name) != 0)
                    {
                        return(false);
                    }
                    firstMethodArgPtr++;
                    secondMethodArgPtr++;
                }

                return(true);
            }

            return(false);
        }
    }
コード例 #14
0
    public void ScheduleAttributeAccessor(Smoke *smoke, Smoke.Method *meth)
    {
        string name        = ByteArrayManager.GetString(smoke->methodNames[meth->name]);
        bool   isSetMethod = false;

        if (name.StartsWith("set"))
        {
            name        = name.Remove(0, 3);
            isSetMethod = true;
        }
        else
        {
            // capitalize the first letter
            StringBuilder builder = new StringBuilder(name);
            builder[0] = char.ToUpper(builder[0]);
            name       = builder.ToString();
        }

        // If the new name clashes with a name of a type declaration, keep the lower-case name.
        var typesWithSameName = from member in data.GetAccessibleMembers(smoke->classes + meth->classId)
                                where (member.Type == MemberTypes.NestedType ||
                                       member.Type == MemberTypes.Method) &&
                                member.Name == name
                                select member;

        if (typesWithSameName.Any())
        {
            string className = ByteArrayManager.GetString(smoke->classes[meth->classId].className);
            Debug.Print("  |--Conflicting names: property/type: {0} in class {1} - keeping original property name", name,
                        className);
            name = char.ToLower(name[0]) + name.Substring(1);
        }

        Attribute attr;

        if (!attributes.TryGetValue(name, out attr))
        {
            attr       = new Attribute();
            attr.Smoke = smoke;
            attributes.Add(name, attr);
        }

        if (isSetMethod)
        {
            attr.SetMethod = meth;
        }
        else
        {
            attr.GetMethod = meth;
        }
    }
コード例 #15
0
    private void GenerateInheritedMethods(Smoke.Class *klass, MethodsGenerator methgen, AttributeGenerator attrgen,
                                          List <Smoke.ModuleIndex> alreadyImplemented)
    {
        // Contains inherited methods that have to be implemented by the current class.
        // We use our custom comparer, so we don't end up with the same method multiple times.
        IDictionary <Smoke.ModuleIndex, string> implementMethods =
            new Dictionary <Smoke.ModuleIndex, string>(SmokeMethodEqualityComparer.DefaultEqualityComparer);

        bool firstParent = true;

        for (short *parent = data.Smoke->inheritanceList + klass->parents; *parent > 0; parent++)
        {
            if (firstParent)
            {
                // we're only interested in parents implemented as interfaces
                firstParent = false;
                continue;
            }
            // collect all methods (+ inherited ones) and add them to the implementMethods Dictionary
            data.Smoke->FindAllMethods(*parent, implementMethods, true);
        }

        foreach (KeyValuePair <Smoke.ModuleIndex, string> pair in implementMethods)
        {
            Smoke.Method *meth       = pair.Key.smoke->methods + pair.Key.index;
            Smoke.Class * ifaceKlass = pair.Key.smoke->classes + meth->classId;

            if ((meth->flags & (ushort)Smoke.MethodFlags.mf_enum) > 0 ||
                (meth->flags & (ushort)Smoke.MethodFlags.mf_ctor) > 0 ||
                (meth->flags & (ushort)Smoke.MethodFlags.mf_copyctor) > 0 ||
                (meth->flags & (ushort)Smoke.MethodFlags.mf_dtor) > 0 ||
                (meth->flags & (ushort)Smoke.MethodFlags.mf_static) > 0 ||
                (meth->flags & (ushort)Smoke.MethodFlags.mf_internal) > 0)
            {
                // no need to check for properties here - QObjects don't support multiple inheritance anyway
                continue;
            }
            if (alreadyImplemented.Contains(pair.Key, SmokeMethodEqualityComparer.DefaultEqualityComparer))
            {
                continue;
            }
            if ((meth->flags & (ushort)Smoke.MethodFlags.mf_attribute) > 0)
            {
                attrgen.ScheduleAttributeAccessor(pair.Key.smoke, meth);
                continue;
            }

            CodeTypeReference type = translator.CppToCSharp(ByteArrayManager.GetString(ifaceKlass->className));
            methgen.GenerateMethod(pair.Key.smoke, meth, pair.Value, type);
        }
    }
コード例 #16
0
ファイル: QyotoHooks.cs プロジェクト: corngood/assemblygen
    private void PostEnumMemberHook(Smoke *smoke, Smoke.Method *smokeMethod, CodeMemberField cmm, CodeTypeDeclaration type)
    {
        CodeTypeDeclaration parentType = this.memberDocumentation.Keys.FirstOrDefault(t => t.Name == (string)type.UserData["parent"]);

        if (parentType != null)
        {
            IList <string> docs     = this.memberDocumentation[parentType];
            string         typeName = Regex.Escape(parentType.Name) + "::" + Regex.Escape(type.Name);
            if (type.Comments.Count == 0)
            {
                for (int i = 0; i < docs.Count; i++)
                {
                    const string enumDoc   = @"enum {0}(\s*flags {1}::\w+\s+)?(?<docsStart>.*?)(\n){{3}}";
                    Match        matchEnum = Regex.Match(docs[i], string.Format(enumDoc, typeName, parentType.Name), RegexOptions.Singleline);
                    if (matchEnum.Success)
                    {
                        string doc = (matchEnum.Groups["docsStart"].Value + matchEnum.Groups["docsEnd1"].Value).Trim();
                        doc = Regex.Replace(doc,
                                            @"(The \S+ type is a typedef for QFlags<\S+>\. It stores an OR combination of \S+ values\.)",
                                            string.Empty);
                        doc = Regex.Replace(doc,
                                            @"ConstantValue(Description)?.*?(((\n){2})|$)",
                                            string.Empty, RegexOptions.Singleline).Trim();
                        if (!string.IsNullOrEmpty(doc))
                        {
                            Util.FormatComment(doc, type, i > 0);
                            break;
                        }
                    }
                }
            }
            string memberName = Regex.Escape(parentType.Name) + "::" +
                                Regex.Escape(ByteArrayManager.GetString(smoke->methodNames[smokeMethod->name]));
            const string memberDoc = @"enum {0}.*{1}\t[^\t\n]+\t(?<docs>.*?)(&\w+;)?(\n)";
            for (int i = 0; i < docs.Count; i++)
            {
                Match match = Regex.Match(docs[i], string.Format(memberDoc, typeName, memberName), RegexOptions.Singleline);
                if (match.Success)
                {
                    string doc = match.Groups["docs"].Value.Trim();
                    if (!string.IsNullOrEmpty(doc))
                    {
                        Util.FormatComment(char.ToUpper(doc[0]) + doc.Substring(1), cmm, i > 0);
                        break;
                    }
                }
            }
        }
    }
コード例 #17
0
 private ClientContext(string name, DFSClient.Conf conf)
 {
     this.name              = name;
     this.confString        = ConfAsString(conf);
     this.shortCircuitCache = new ShortCircuitCache(conf.shortCircuitStreamsCacheSize,
                                                    conf.shortCircuitStreamsCacheExpiryMs, conf.shortCircuitMmapCacheSize, conf.shortCircuitMmapCacheExpiryMs
                                                    , conf.shortCircuitMmapCacheRetryTimeout, conf.shortCircuitCacheStaleThresholdMs
                                                    , conf.shortCircuitSharedMemoryWatcherInterruptCheckMs);
     this.peerCache                 = new PeerCache(conf.socketCacheCapacity, conf.socketCacheExpiry);
     this.keyProviderCache          = new KeyProviderCache(conf.keyProviderCacheExpiryMs);
     this.useLegacyBlockReaderLocal = conf.useLegacyBlockReaderLocal;
     this.domainSocketFactory       = new DomainSocketFactory(conf);
     this.byteArrayManager          = ByteArrayManager.NewInstance(conf.writeByteArrayManagerConf
                                                                   );
 }
コード例 #18
0
        public override void LoadBytes(byte[] bytes)
        {
            ByteArrayManager bam = new ByteArrayManager(bytes);

            base.LoadBytes(bam.NextBytes(24));


            List <CarStatusData> csds = new List <CarStatusData>();
            int t = 1;

            for (t = 1; t <= 22; t++)
            {
                csds.Add(CarStatusData.CreateFromBytes(bam.NextBytes(60)));
            }
            FieldCarStatusData = csds.ToArray();
        }
コード例 #19
0
        public override void LoadBytes(byte[] bytes)
        {
            ByteArrayManager BAM = new ByteArrayManager(bytes);

            base.LoadBytes(BAM.NextBytes(23));

            NumberOfActiveCars = BAM.NextByte();

            List <ParticipantData> PDs = new List <ParticipantData>();
            int t = 1;

            for (t = 1; t <= 20; t++)
            {
                PDs.Add(ParticipantData.Create(BAM.NextBytes(54)));
            }
            FieldParticipantData = PDs.ToArray();
        }
コード例 #20
0
        public override void LoadBytes(byte[] bytes)
        {
            ByteArrayManager BAM = new ByteArrayManager(bytes);

            base.LoadBytes(BAM.NextBytes(23)); //Load header

            int t = 0;
            List <CarTelemetryData> TelDatas = new List <CarTelemetryData>();

            for (t = 1; t <= 20; t++)
            {
                TelDatas.Add(CarTelemetryData.Create(BAM.NextBytes(66)));
            }
            FieldTelemetryData = TelDatas.ToArray();

            //I skipped the field "ButtonStatus".  Doesn't seem needed.
        }
コード例 #21
0
    public List <CodeMemberProperty> GenerateBasicAttributeDefinitions()
    {
        List <CodeMemberProperty> ret = new List <CodeMemberProperty>();

        foreach (KeyValuePair <string, Attribute> pair in attributes)
        {
            Attribute          attr = pair.Value;
            CodeMemberProperty prop = new CodeMemberProperty();
            prop.Name = pair.Key;
            try
            {
                bool isRef;
                prop.Type = translator.CppToCSharp(attr.Smoke->types + attr.GetMethod->ret, out isRef);
            }
            catch (NotSupportedException)
            {
                string className = ByteArrayManager.GetString(attr.Smoke->classes[attr.GetMethod->classId].className);
                Debug.Print("  |--Won't wrap Attribute {0}::{1}", className, prop.Name);
                continue;
            }
            prop.HasGet = true;
            prop.HasSet = attr.SetMethod != (Smoke.Method *) 0;

            if ((attr.GetMethod->flags & (uint)Smoke.MethodFlags.mf_protected) > 0)
            {
                prop.Attributes = MemberAttributes.Family | MemberAttributes.New | MemberAttributes.Final;
            }
            else
            {
                prop.Attributes = MemberAttributes.Public | MemberAttributes.New | MemberAttributes.Final;
            }

            if ((attr.GetMethod->flags & (uint)Smoke.MethodFlags.mf_static) > 0)
            {
                prop.Attributes |= MemberAttributes.Static;
            }

            ret.Add(prop);
            if (PostAttributeProperty != null)
            {
                PostAttributeProperty(prop, type);
            }
        }
        return(ret);
    }
コード例 #22
0
ファイル: GeneratorData.cs プロジェクト: corngood/assemblygen
    private void GetAccessibleMembers(Smoke.Class *klass, List <InternalMemberInfo> list)
    {
        if (Debug)
        {
            Console.Error.WriteLine("members from class {0}", ByteArrayManager.GetString(klass->className));
        }
        if (klass->external)
        {
            AddReferencedMembers(klass, list);
            return;
        }

        CodeTypeDeclaration typeDecl;

        if (!SmokeTypeMap.TryGetValue((IntPtr)klass, out typeDecl))
        {
            AddReferencedMembers(klass, list);
            return;
        }
        foreach (CodeTypeMember member in typeDecl.Members)
        {
            if (member is CodeMemberProperty)
            {
                list.Add(new InternalMemberInfo(MemberTypes.Property, member.Name));
            }
            else if (member is CodeMemberMethod)
            {
                list.Add(new InternalMemberInfo(MemberTypes.Method, member.Name));
            }
            else if (member is CodeMemberField)
            {
                list.Add(new InternalMemberInfo(MemberTypes.Field, member.Name));
            }
            else if (member is CodeTypeDeclaration)
            {
                list.Add(new InternalMemberInfo(MemberTypes.NestedType, member.Name));
            }
        }

        for (short *parent = Smoke->inheritanceList + klass->parents; *parent > 0; parent++)
        {
            Smoke.Class *parentClass = Smoke->classes + *parent;
            GetAccessibleMembers(parentClass, list);
        }
    }
コード例 #23
0
ファイル: GeneratorData.cs プロジェクト: corngood/assemblygen
    private void AddReferencedMembers(Smoke.Class *klass, ICollection <InternalMemberInfo> list)
    {
        string smokeClassName = ByteArrayManager.GetString(klass->className);
        Type   type;

        if (!ReferencedTypeMap.TryGetValue(smokeClassName, out type))
        {
            Console.Error.WriteLine("Couldn't find referenced class {0}", smokeClassName);
            return;
        }

        foreach (
            MemberInfo member in
            type.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static))
        {
            list.Add(new InternalMemberInfo(member.MemberType, member.Name));
        }
    }
コード例 #24
0
        public override void LoadBytes(byte[] bytes)
        {
            ByteArrayManager BAM = new ByteArrayManager(bytes);

            //Get header
            base.LoadBytes(BAM.NextBytes(24));



            //Get the next 20 data packages
            List <LapData> LDs = new List <LapData>();
            int            t   = 1;

            for (t = 1; t <= 22; t++)
            {
                LDs.Add(LapData.Create(BAM.NextBytes(53)));
            }
            FieldLapData = LDs.ToArray();
        }
コード例 #25
0
ファイル: EnumGenerator.cs プロジェクト: corngood/assemblygen
    /*
     * convenience overload
     */

    private void DefineEnum(Smoke.Type *type)
    {
        // we want the exact combination: t_enum | tf_stack
        if (type->flags != ((uint)Smoke.TypeId.t_enum | (uint)Smoke.TypeFlags.tf_stack))
        {
            // not an enum type
            return;
        }

        if (type->classId == 0 || data.Smoke->classes[type->classId].external)
        {
            // defined elsewhere
            return;
        }

        string enumName = ByteArrayManager.GetString(type->name);

        this.DefineEnum(enumName);
    }
コード例 #26
0
        public virtual bool createJobs(BatchEntity batch)
        {
            CommandContext   commandContext   = Context.CommandContext;
            ByteArrayManager byteArrayManager = commandContext.ByteArrayManager;
            JobManager       jobManager       = commandContext.JobManager;

            T configuration = readConfiguration(batch.ConfigurationBytes);

            int batchJobsPerSeed       = batch.BatchJobsPerSeed;
            int invocationsPerBatchJob = batch.InvocationsPerBatchJob;

            IList <string> ids = configuration.Ids;
            int            numberOfItemsToProcess = Math.Min(invocationsPerBatchJob * batchJobsPerSeed, ids.Count);
            // view of process instances to process
            IList <string> processIds = ids.subList(0, numberOfItemsToProcess);

            int createdJobs = 0;

            while (processIds.Count > 0)
            {
                int lastIdIndex = Math.Min(invocationsPerBatchJob, processIds.Count);
                // view of process instances for this job
                IList <string> idsForJob = processIds.subList(0, lastIdIndex);

                T jobConfiguration = createJobConfiguration(configuration, idsForJob);
                ByteArrayEntity configurationEntity = saveConfiguration(byteArrayManager, jobConfiguration);

                JobEntity job = createBatchJob(batch, configurationEntity);
                postProcessJob(configuration, job);
                jobManager.insertAndHintJobExecutor(job);

                idsForJob.Clear();
                createdJobs++;
            }

            // update created jobs for batch
            batch.JobsCreated = batch.JobsCreated + createdJobs;

            // update batch configuration
            batch.ConfigurationBytes = writeConfiguration(configuration);

            return(ids.Count == 0);
        }
コード例 #27
0
ファイル: GeneratorData.cs プロジェクト: corngood/assemblygen
    public string GetArgNamesFile(Smoke *smoke)
    {
        string dest = Destination;

        if (string.IsNullOrEmpty(dest))
        {
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                dest = Path.GetDirectoryName(Path.GetDirectoryName(Environment.GetFolderPath(Environment.SpecialFolder.System)));
            }
            else
            {
                dest = Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture);
            }
        }
        dest = Path.Combine(dest, "share");
        dest = Path.Combine(dest, "smoke");
        return(Path.Combine(dest, ByteArrayManager.GetString(smoke->module_name) + ".argnames.txt"));
    }
コード例 #28
0
        public override void LoadBytes(byte[] bytes)
        {
            ByteArrayManager BAM = new ByteArrayManager(bytes);

            //Get header
            base.LoadBytes(BAM.NextBytes(24));

            //Get number of cars
            NumberOfCars = BAM.NextByte();

            //Get Final Classification Data
            List <FinalClassificationData> fcdata = new List <FinalClassificationData>();

            // int t = 0;
            for (int t = 0; t < 22; t++)
            {
                fcdata.Add(FinalClassificationData.Create(BAM.NextBytes(37)));
            }
            FieldClassificationData = fcdata.ToArray();
        }
コード例 #29
0
ファイル: SmokeMethods.cs プロジェクト: corngood/assemblygen
    public string GetMethodSignature(Method *meth)
    {
        StringBuilder str = new StringBuilder();

        str.Append(ByteArrayManager.GetString(methodNames[meth->name]));
        str.Append('(');
        for (short *typeIndex = argumentList + meth->args; *typeIndex > 0;)
        {
            str.Append(ByteArrayManager.GetString(types[*typeIndex].name));
            if (*(++typeIndex) > 0)
            {
                str.Append(", ");
            }
        }
        str.Append(')');
        if ((meth->flags & (ushort)MethodFlags.mf_const) != 0)
        {
            str.Append(" const");
        }
        return(str.ToString());
    }
コード例 #30
0
ファイル: EnumGenerator.cs プロジェクト: corngood/assemblygen
    /*
     * Generates an Enum member, creating the Enum if necessary.
     */

    public void DefineMember(Smoke.Method *meth)
    {
        if ((meth->flags & (uint)Smoke.MethodFlags.mf_enum) == 0)
        {
            return;
        }

        string typeName = ByteArrayManager.GetString(data.Smoke->types[meth->ret].name);

        if (typeName == "long")         // unnamed enum
        {
            return;
        }

        CodeTypeDeclaration enumType;

        if (!data.EnumTypeMap.TryGetValue(typeName, out enumType))
        {
            enumType = DefineEnum(typeName);
        }
        CodeMemberField member = new CodeMemberField();

        member.Name = ByteArrayManager.GetString(data.Smoke->methodNames[meth->name]);
        long value = GetEnumValue(data.Smoke, meth);

        if (value > int.MaxValue && enumType.BaseTypes.Count == 0)
        {
            // make the enum derive from 'long' if necessary
            enumType.BaseTypes.Add(new CodeTypeReference(typeof(long)));
        }

        member.InitExpression = new CodePrimitiveExpression(value);
        if (PostEnumMemberHook != null)
        {
            PostEnumMemberHook(data.Smoke, meth, member, enumType);
        }
        enumType.Members.Add(member);
    }