/// <summary>Test stub for .ctor(String, Type, String)</summary> ///[PexMethod] internal ROOTObjectCopiedValue Constructor( string varName, Type rootType, string CPPType, string origname ) { ROOTObjectCopiedValue target = new ROOTObjectCopiedValue(varName, rootType, CPPType, origname, "dummy title"); Assert.AreEqual(rootType, target.Type, "reported Type incorrect"); Assert.AreEqual("LoadFromInputList<" + CPPType + ">(\"" + varName + "\")", target.RawValue, "loader string incorrect"); Assert.AreEqual(origname, target.OriginalName, "original name"); Assert.AreEqual("dummy title", target.OriginalTitle, "title bad"); return(target); }
/// <summary>Test stub for .ctor(String, Type, String)</summary> ///[PexMethod] internal ROOTObjectCopiedValue Constructor( string varName, Type rootType, string CPPType, string origname ) { ROOTObjectCopiedValue target = new ROOTObjectCopiedValue(varName, rootType, CPPType, origname, "dummy title"); Assert.AreEqual(rootType, target.Type, "reported Type incorrect"); Assert.AreEqual("LoadFromInputList<" + CPPType + ">(\"" + varName + "\")", target.RawValue, "loader string incorrect"); Assert.AreEqual(origname, target.OriginalName, "original name"); Assert.AreEqual("dummy title", target.OriginalTitle, "title bad"); return target; }
/// <summary> /// For a root variable we create a special variable which holds onto the initial value, and /// also will get loaded at the correct time. /// </summary> /// <param name="expr"></param> /// <param name="codeEnv"></param> /// <returns></returns> public IValue ProcessConstantReference(ConstantExpression expr, IGeneratedQueryCode codeEnv, CompositionContainer container) { /// /// The value is a reference that will do the loading. /// var rootObject = expr.Value as ROOTNET.Interface.NTNamed; if (rootObject == null) { throw new ArgumentException("the object to be stored must derive from NTNamed! It is of type '" + expr.Value.GetType().Name + "' which does not appear to derive from TNamed."); } // // Queue this object for transfer, get a "unique" name back. This will also double check // to see if the object is already up there read to be queued. // var varNameForTransport = codeEnv.QueueForTransfer(rootObject); // // Now, we need to generate an IValue for the object that can be used in our expression parsing. // When in the middle of a tight loop, since finding the object is a "slow" linear lookup, we will cache it in a static // variable. This isn't so pretty when there is a one-time initialization, but it shouldn't add too much. // var staticCache = new ROOTObjectStaticHolder(rootObject.GetType(), rootObject); staticCache.DeclareAsStatic = true; staticCache.InitialValue = new ValSimple("nullptr", staticCache.Type); codeEnv.Add(staticCache); codeEnv.Add(new Statements.StatementFilter(new ValSimple($"{staticCache.RawValue} == nullptr", typeof(bool), new IDeclaredParameter[] { staticCache }))); var CPPType = rootObject.GetType().AsCPPType(); var val = new ROOTObjectCopiedValue(varNameForTransport, rootObject.GetType(), CPPType, rootObject.Name, rootObject.Title); codeEnv.Add(new Statements.StatementAssign(staticCache, val)); codeEnv.Pop(); // And the rest of the code should use the static cache. return(staticCache); }