2024-08-06 01:03:23 +00:00
|
|
|
package main
|
|
|
|
|
2024-08-07 06:51:51 +00:00
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2024-08-06 02:29:12 +00:00
|
|
|
type nativeParameter struct {
|
|
|
|
name string
|
|
|
|
typ string
|
|
|
|
}
|
|
|
|
|
2024-08-06 01:03:23 +00:00
|
|
|
type nativeProperty struct {
|
|
|
|
propertyName string
|
|
|
|
propertyType string
|
|
|
|
visibility string
|
|
|
|
}
|
|
|
|
|
|
|
|
type nativeMethod struct {
|
|
|
|
methodName string
|
|
|
|
returnType string
|
2024-08-06 02:29:12 +00:00
|
|
|
parameters []nativeParameter
|
2024-08-06 01:03:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 06:51:51 +00:00
|
|
|
func (nm nativeMethod) SafeMethodName() string {
|
|
|
|
// Operator-overload methods have names not representable in binding
|
|
|
|
// languages. Replace more specific cases first
|
|
|
|
replacer := strings.NewReplacer(
|
|
|
|
|
|
|
|
`==`, `Equal`,
|
|
|
|
`>=`, `GreaterOrEqual`,
|
|
|
|
`<=`, `LesserOrEqual`,
|
|
|
|
`=`, `Assign`,
|
|
|
|
`>`, `Greater`,
|
|
|
|
`<`, `Lesser`,
|
|
|
|
|
|
|
|
`+`, `Plus`,
|
|
|
|
`-`, `Minus`,
|
|
|
|
`*`, `Multiply`,
|
|
|
|
`/`, `Divide`,
|
|
|
|
`%`, `Modulo`,
|
|
|
|
|
|
|
|
`&&`, `LogicalAnd`,
|
|
|
|
`||`, `LogicalOr`,
|
|
|
|
`!`, `Not`,
|
|
|
|
`&`, `BitwiseAnd`,
|
|
|
|
`|`, `BitwiseOr`,
|
|
|
|
`~`, `BitwiseXor`,
|
|
|
|
`^`, `BitwiseNot`,
|
|
|
|
|
|
|
|
`->`, `PointerDereference`,
|
|
|
|
`[]`, `Subscript`,
|
|
|
|
`()`, `Call`,
|
|
|
|
)
|
|
|
|
|
|
|
|
return replacer.Replace(nm.methodName)
|
|
|
|
}
|
|
|
|
|
2024-08-06 01:03:23 +00:00
|
|
|
type nativeClass struct {
|
|
|
|
className string
|
2024-08-06 02:29:12 +00:00
|
|
|
ctors []nativeMethod // only use the parameters
|
2024-08-06 01:03:23 +00:00
|
|
|
extends []string
|
|
|
|
methods []nativeMethod
|
|
|
|
props []nativeProperty
|
|
|
|
}
|
|
|
|
|
|
|
|
type parsedHeader struct {
|
|
|
|
classes []nativeClass
|
|
|
|
}
|