NormObject Refactor

* Updated NormObjectGetInfo to use byte array

* Updated design
pull/85/head
mullerj 2024-08-27 21:06:13 -04:00 committed by GitHub
parent 022e1204ca
commit 32c3eb5239
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 17 deletions

View File

@ -91,7 +91,7 @@ class NormApi <<static>> {
+ {static} <<extern>> NormObjectGetType(objectHandle:long) : NormObjectType
+ {static} <<extern>> NormObjectHasInfo(objectHandle:long) : bool
+ {static} <<extern>> NormObjectGetInfoLength(objectHandle:long) : int
+ {static} <<extern>> NormObjectGetInfo(objectHandle:long, buffer:nint, bufferLen:int) : int
+ {static} <<extern>> NormObjectGetInfo(objectHandle:long, buffer:byte[], bufferLen:int) : int
+ {static} <<extern>> NormObjectGetSize(objectHandle:long) : int
+ {static} <<extern>> NormObjectGetBytesPending(objectHandle:long) : long
+ {static} <<extern>> NormObjectCancel(objectHandle:long) : void

View File

@ -2,7 +2,7 @@
class NormFile {
+ <<const>> FILENAME_MAX : int = 260
<<internal>> NormFile(handle:long)
+ Name : string <<get>>
+ <<unsafe>> Name : string <<get>>
+ Rename(filePath:string) : void
}
NormObject <|-- NormFile

View File

@ -961,7 +961,7 @@ namespace Mil.Navy.Nrl.Norm
/// function can be used to determine the length of NORM_INFO content for the object even if a NULL buffer value and
/// zero bufferLen is provided. A zero value is returned if NORM_INFO content has not yet been received (or is nonexistent) for the specified object.</returns>
[DllImport(NORM_LIBRARY)]
public static extern int NormObjectGetInfo(long objectHandle, nint buffer, int bufferLen);
public static extern int NormObjectGetInfo(long objectHandle, [Out] byte[] buffer, int bufferLen);
/// <summary>
/// This function can be used to determine the size (in bytes) of the transport object specified by the objectHandle parameter.

View File

@ -1,6 +1,4 @@
using System.Runtime.InteropServices;
namespace Mil.Navy.Nrl.Norm
namespace Mil.Navy.Nrl.Norm
{
/// <summary>
/// The base transport object.
@ -44,17 +42,7 @@ namespace Mil.Navy.Nrl.Norm
var length = NormObjectGetInfoLength(_handle);
var buffer = new byte[length];
var bufferHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
try
{
var bufferPtr = bufferHandle.AddrOfPinnedObject();
NormObjectGetInfo(_handle, bufferPtr, length);
}
finally
{
bufferHandle.Free();
}
NormObjectGetInfo(_handle, buffer, length);
return buffer;
}