-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: parsing symbols using native function (#4)
* feat: parsing symbols using native function * feat: parsing symbols using native function add release
- Loading branch information
Showing
5 changed files
with
53 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package native | ||
|
||
/* | ||
#include "dxfg_api.h" | ||
#include <stdlib.h> | ||
*/ | ||
import "C" | ||
import "unsafe" | ||
|
||
func ParseSymbols(symbols string) ([]any, error) { | ||
var result []any | ||
err := executeInIsolateThread(func(thread *isolateThread) error { | ||
symbolsPtr := C.CString(symbols) | ||
defer C.free(unsafe.Pointer(symbolsPtr)) | ||
return checkCall(func() { | ||
resultPtr := C.dxfg_Tools_parseSymbols(thread.ptr, symbolsPtr) | ||
defer C.dxfg_CList_String_release(thread.ptr, resultPtr) | ||
|
||
if resultPtr == nil || resultPtr.elements == nil || int(resultPtr.size) == 0 { | ||
return | ||
} | ||
|
||
size := int(resultPtr.size) | ||
list := make([]any, size) | ||
elementsSlice := unsafe.Slice(resultPtr.elements, C.size_t(resultPtr.size)) | ||
|
||
for i, event := range elementsSlice { | ||
symbol := C.GoString(event) | ||
list[i] = symbol | ||
} | ||
result = list | ||
}) | ||
}) | ||
|
||
return result, err | ||
} |
19 changes: 8 additions & 11 deletions
19
pkg/common/argument_parser.go → pkg/parser/argument_parser.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters