Weaver: SyncVarProcessor renamed to SyncVarAttributeProcessor

This commit is contained in:
vis2k 2021-09-24 11:03:51 +08:00
parent a0c3ef1c2c
commit 2d2710f60e
6 changed files with 12 additions and 12 deletions

View File

@ -17,7 +17,7 @@ class NetworkBehaviourProcessor
AssemblyDefinition assembly;
WeaverTypes weaverTypes;
SyncVarAccessLists syncVarAccessLists;
SyncVarProcessor syncVarProcessor;
SyncVarAttributeProcessor syncVarAttributeProcessor;
Writers writers;
Readers readers;
Logger Log;
@ -55,7 +55,7 @@ public NetworkBehaviourProcessor(AssemblyDefinition assembly, WeaverTypes weaver
this.writers = writers;
this.readers = readers;
this.Log = Log;
syncVarProcessor = new SyncVarProcessor(assembly, weaverTypes, syncVarAccessLists, Log);
syncVarAttributeProcessor = new SyncVarAttributeProcessor(assembly, weaverTypes, syncVarAccessLists, Log);
netBehaviourSubclass = td;
}
@ -79,7 +79,7 @@ public bool Process(ref bool WeavingFailed)
MarkAsProcessed(netBehaviourSubclass);
// deconstruct tuple and set fields
(syncVars, syncVarNetIds) = syncVarProcessor.ProcessSyncVars(netBehaviourSubclass, ref WeavingFailed);
(syncVars, syncVarNetIds) = syncVarAttributeProcessor.ProcessSyncVars(netBehaviourSubclass, ref WeavingFailed);
syncObjects = SyncObjectProcessor.FindSyncObjectsFields(writers, readers, Log, netBehaviourSubclass, ref WeavingFailed);
@ -508,7 +508,7 @@ void GenerateSerialization(ref bool WeavingFailed)
void DeserializeField(WeaverTypes weaverTypes, FieldDefinition syncVar, ILProcessor worker, MethodDefinition deserialize, ref bool WeavingFailed)
{
// check for Hook function
MethodDefinition hookMethod = syncVarProcessor.GetHookMethod(netBehaviourSubclass, syncVar, ref WeavingFailed);
MethodDefinition hookMethod = syncVarAttributeProcessor.GetHookMethod(netBehaviourSubclass, syncVar, ref WeavingFailed);
if (syncVar.FieldType.IsDerivedFrom<NetworkBehaviour>())
{
@ -617,7 +617,7 @@ void DeserializeNetworkIdentityField(WeaverTypes weaverTypes, FieldDefinition sy
// call the hook
// Generates: OnValueChanged(oldValue, this.syncVar);
syncVarProcessor.WriteCallHookMethodUsingField(worker, hookMethod, oldSyncVar, syncVar, ref WeavingFailed);
syncVarAttributeProcessor.WriteCallHookMethodUsingField(worker, hookMethod, oldSyncVar, syncVar, ref WeavingFailed);
// Generates: end if (!SyncVarEqual);
worker.Append(syncVarEqualLabel);
@ -718,7 +718,7 @@ void DeserializeNetworkBehaviourField(WeaverTypes weaverTypes, FieldDefinition s
// call the hook
// Generates: OnValueChanged(oldValue, this.syncVar);
syncVarProcessor.WriteCallHookMethodUsingField(worker, hookMethod, oldSyncVar, syncVar, ref WeavingFailed);
syncVarAttributeProcessor.WriteCallHookMethodUsingField(worker, hookMethod, oldSyncVar, syncVar, ref WeavingFailed);
// Generates: end if (!SyncVarEqual);
worker.Append(syncVarEqualLabel);
@ -799,7 +799,7 @@ void DeserializeNormalField(WeaverTypes weaverTypes, FieldDefinition syncVar, IL
// call the hook
// Generates: OnValueChanged(oldValue, this.syncVar);
syncVarProcessor.WriteCallHookMethodUsingField(serWorker, hookMethod, oldValue, syncVar, ref WeavingFailed);
syncVarAttributeProcessor.WriteCallHookMethodUsingField(serWorker, hookMethod, oldValue, syncVar, ref WeavingFailed);
// Generates: end if (!SyncVarEqual);
serWorker.Append(syncVarEqualLabel);

View File

@ -8,7 +8,7 @@
namespace Mirror.Weaver
{
public static class SyncVarAccessReplacer
public static class SyncVarAttributeAccessReplacer
{
// process the module
public static void Process(ModuleDefinition moduleDef, SyncVarAccessLists syncVarAccessLists)

View File

@ -5,9 +5,9 @@
namespace Mirror.Weaver
{
// Processes [SyncVar] in NetworkBehaviour
// Processes [SyncVar] attribute fields in NetworkBehaviour
// not static, because ILPostProcessor is multithreaded
public class SyncVarProcessor
public class SyncVarAttributeProcessor
{
// ulong = 64 bytes
const int SyncVarLimit = 64;
@ -20,7 +20,7 @@ public class SyncVarProcessor
string HookParameterMessage(string hookName, TypeReference ValueType) =>
$"void {hookName}({ValueType} oldValue, {ValueType} newValue)";
public SyncVarProcessor(AssemblyDefinition assembly, WeaverTypes weaverTypes, SyncVarAccessLists syncVarAccessLists, Logger Log)
public SyncVarAttributeProcessor(AssemblyDefinition assembly, WeaverTypes weaverTypes, SyncVarAccessLists syncVarAccessLists, Logger Log)
{
this.assembly = assembly;
this.weaverTypes = weaverTypes;

View File

@ -187,7 +187,7 @@ public bool Weave(AssemblyDefinition assembly, IAssemblyResolver resolver, out b
if (modified)
{
SyncVarAccessReplacer.Process(moduleDefinition, syncVarAccessLists);
SyncVarAttributeAccessReplacer.Process(moduleDefinition, syncVarAccessLists);
// add class that holds read/write functions
moduleDefinition.Types.Add(GeneratedCodeClass);