File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
sources/ClangSharp.PInvokeGenerator Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -191,18 +191,28 @@ private void VisitCallExpr(CallExpr callExpr)
191
191
{
192
192
case "memcpy" :
193
193
{
194
+ var args = callExpr . Args ;
195
+
194
196
if ( Config . GenerateLatestCode )
195
197
{
196
198
outputBuilder . AddUsingDirective ( "System.Runtime.InteropServices" ) ;
197
199
outputBuilder . Write ( "NativeMemory.Copy" ) ;
200
+
201
+ if ( args . Count == 3 )
202
+ {
203
+ // Swap the operands around:
204
+ // * NativeMemory.Copy takes: source, dest, count
205
+ // * memcpy takes: dest, source, count
206
+ args = [ args [ 1 ] , args [ 0 ] , args [ 2 ] ] ;
207
+ }
198
208
}
199
209
else
200
210
{
201
211
outputBuilder . AddUsingDirective ( "System.Runtime.CompilerServices" ) ;
202
212
outputBuilder . Write ( "Unsafe.CopyBlockUnaligned" ) ;
203
213
}
204
214
205
- VisitArgs ( callExpr ) ;
215
+ VisitArgs ( callExpr , args ) ;
206
216
break ;
207
217
}
208
218
You can’t perform that action at this time.
0 commit comments