Add is
function.
This commit is contained in:
@@ -4,7 +4,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// <summary>
|
||||
/// Span on the memory of a <see cref="PdtEvaluatorBase" />.
|
||||
/// </summary>
|
||||
public unsafe struct PdtVariableMemory {
|
||||
public unsafe struct PdtVariableMemory : IEquatable<PdtVariableMemory> {
|
||||
readonly byte* _ptr;
|
||||
/// <summary>
|
||||
/// The length of the span.
|
||||
@@ -46,6 +46,14 @@ namespace Cryville.Common.Pdt {
|
||||
for (int i = 0; i < length; i++)
|
||||
dest[destOffset + i] = _ptr[i];
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public bool Equals(PdtVariableMemory obj) {
|
||||
if (Type != obj.Type || Length != obj.Length) return false;
|
||||
for (int i = 0; i < Length; i++) {
|
||||
if (*(_ptr + i) != *(obj._ptr + i)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the memory of the span as a number.
|
||||
/// </summary>
|
||||
|
@@ -164,6 +164,7 @@ namespace Cryville.Crtr {
|
||||
|
||||
_shortops.Add(new PdtOperatorSignature("frame_seq", 3), new func_frame_seq());
|
||||
_shortops.Add(new PdtOperatorSignature("in_area", 1), new func_in_area());
|
||||
_shortops.Add(new PdtOperatorSignature("is", 2), new func_is());
|
||||
}
|
||||
#region Operators
|
||||
#pragma warning disable IDE1006
|
||||
@@ -346,6 +347,17 @@ namespace Cryville.Crtr {
|
||||
hit.CopyTo(ret);
|
||||
}
|
||||
}
|
||||
class func_is : PdtOperator {
|
||||
public func_is() : base(2) { }
|
||||
protected override unsafe void Execute() {
|
||||
var op0 = GetOperand(0);
|
||||
if (op0.Type == PdtInternalType.Error) throw new ArgumentException("Error");
|
||||
var op1 = GetOperand(1);
|
||||
if (op1.Type == PdtInternalType.Error) throw new ArgumentException("Error");
|
||||
var ret = GetReturnFrame(PdtInternalType.Number, sizeof(float));
|
||||
ret.SetNumber(op0.Equals(op1) ? 1 : 0);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Contextual Functions
|
||||
class func_screen_edge : PdtOperator {
|
||||
|
Reference in New Issue
Block a user