emit of the primitive type

master
この中二病に爆焔を! 5 years ago
parent 09f26ee3c1
commit 0e450b3089

@ -20,6 +20,10 @@ Public Class SlaveTask
Me.builder = cli
Me.processor = processor
Me.debugPort = debugPort
For Each [handle] In EmitHandler.PopulatePrimitiveHandles
toBuffers(handle.target) = handle.emit
Next
End Sub
Public Function Emit(Of T)(streamAs As Func(Of T, Stream)) As SlaveTask

@ -0,0 +1,15 @@
Imports System.IO
Imports System.Text
Module EmitHandler
Public Iterator Function PopulatePrimitiveHandles() As IEnumerable(Of (target As Type, emit As Func(Of Object, Stream)))
Yield (GetType(Integer), Function(i) New MemoryStream(BitConverter.GetBytes(DirectCast(i, Integer))))
Yield (GetType(Long), Function(l) New MemoryStream(BitConverter.GetBytes(DirectCast(l, Long))))
Yield (GetType(Single), Function(f) New MemoryStream(BitConverter.GetBytes(DirectCast(f, Single))))
Yield (GetType(Double), Function(d) New MemoryStream(BitConverter.GetBytes(DirectCast(d, Double))))
Yield (GetType(Short), Function(s) New MemoryStream(BitConverter.GetBytes(DirectCast(s, Short))))
Yield (GetType(Boolean), Function(b) New MemoryStream(New Byte() {If(DirectCast(b, Boolean), 1, 0)}))
Yield (GetType(String), Function(s) New MemoryStream(Encoding.UTF8.GetBytes(DirectCast(s, String))))
End Function
End Module

@ -124,10 +124,11 @@
<ItemGroup>
<Compile Include="IpcParallel\IDelegate.vb" />
<Compile Include="IpcParallel\IPCSocket.vb" />
<Compile Include="IpcParallel\ObjectStream.vb" />
<Compile Include="IpcParallel\Stream\EmitHandler.vb" />
<Compile Include="IpcParallel\Stream\ObjectStream.vb" />
<Compile Include="IpcParallel\Protocols.vb" />
<Compile Include="IpcParallel\SlaveTask.vb" />
<Compile Include="IpcParallel\StreamMethods.vb" />
<Compile Include="IpcParallel\Stream\StreamMethods.vb" />
<Compile Include="IpcParallel\TaskBuilder.vb" />
<Compile Include="MemoryMap\UnmanageMemoryRegion.vb" />
<Compile Include="MemoryMap\MapObject.vb" />

Loading…
Cancel
Save