codegen

package
v2.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomType

type CustomType struct {
	// contains filtered or unexported fields
}

func (*CustomType) CgoFunctionParamType

func (m *CustomType) CgoFunctionParamType(ctx *ProgpV8CodeGenerator) string

func (*CustomType) CgoToGoDecoding

func (m *CustomType) CgoToGoDecoding(paramName string, ctx *ProgpV8CodeGenerator) (string, string)

func (*CustomType) CppArgResourcesFreeing

func (m *CustomType) CppArgResourcesFreeing(paramName string, ctx *ProgpV8CodeGenerator) string

func (*CustomType) CppToCgoParamCall

func (m *CustomType) CppToCgoParamCall(paramName string, ctx *ProgpV8CodeGenerator) string

func (*CustomType) GoValueToCgoValue

func (m *CustomType) GoValueToCgoValue(ctx *ProgpV8CodeGenerator) string

func (*CustomType) ReturnTypeEncoder

func (m *CustomType) ReturnTypeEncoder(ctx *ProgpV8CodeGenerator) string

func (*CustomType) ReturnTypeWrapper

func (m *CustomType) ReturnTypeWrapper(ctx *ProgpV8CodeGenerator) string

func (*CustomType) V8ToCppDecoder

func (m *CustomType) V8ToCppDecoder(ctx *ProgpV8CodeGenerator) string

type IsTypeHandler

type IsTypeHandler interface {
	// CppToCgoParamCall allows casting const char* to char*.
	// Strings coming from v8 are const char*, which allow to remember that they must not be deleted.
	// But CGo requires char* string, so we must cast the parameter before calling.
	//
	// ===> Inside "codeBinding.cpp":
	//
	//		void v8Function_g_progpAdmin_f_pmyFunction(
	//		   ProgpV8ContextPtr ctxPtr,
	//	       const v8::FunctionCallbackInfo<v8::Value> &callInfo,
	//	       const v8::Local<v8::Context> &v8Ctx,
	//	       v8::Isolate *v8Iso) {
	//
	//	   V8CALLARG_EXPECT_ARGCOUNT(1);
	//	   V8CALLARG_EXPECT_CSTRING(p0, 0);
	//
	//		ProgpFunctionReturnVoid resWrapper{};
	//		progpCgoBinding__g_progpAdmin_f_progpSendSignal(&resWrapper, (char*)p0);
	//																	 [^HERE^^^^^^^^^]
	//
	// .
	CppToCgoParamCall(paramName string, ctx *ProgpV8CodeGenerator) string

	// V8ToCppDecoder decode the V8 call parameter from V8 to C++.
	//
	// ===> Inside "codeBinding.cpp":
	//
	//		void v8Function_g_progpDefault_f_myFunction(
	//
	//			ProgpV8ContextPtr ctxPtr,
	//	       	const v8::FunctionCallbackInfo<v8::Value> &callInfo,
	//	       	const v8::Local<v8::Context> &v8Ctx,
	//	       	v8::Isolate *v8Iso) {
	//	   			V8CALLARG_EXPECT_ARGCOUNT(1);					<--- HERE
	//	   			V8CALLARG_EXPECT_FUNCTION(p0, 0);				<--- HERE
	//
	// .
	V8ToCppDecoder(ctx *ProgpV8CodeGenerator) string

	// ReturnTypeWrapper is for the Go and the C++ part.
	// It's allowing our Go function to return a value to the C++ part
	// by avoiding some strange CGo behaviors where directly sending
	// the value with a "return" randomly breaks things.
	//
	// ===> Inside "codeBinding.cpp":
	//
	//		void v8Function_g_progpDefault_f_myFunction(
	//				ProgpV8ContextPtr ctxPtr,
	//	       		const v8::FunctionCallbackInfo<v8::Value> &callInfo,
	//	       		const v8::Local<v8::Context> &v8Ctx,
	//	       		v8::Isolate *v8Iso) {
	//
	//					ProgpFunctionReturnInt resWrapper{};					<--- HERE
	//					progpCgoBinding__g_progpDefault_f_myFunction(&resWrapper);
	//
	// ===> Inside "codeBinding.go"
	//
	//	func progpCgoBinding__g_test1_f_myFunction(res *C.ProgpFunctionReturnInt) {
	//												  	  [^HERE^^^^^^^^^]
	//
	// .
	ReturnTypeWrapper(ctx *ProgpV8CodeGenerator) string

	// ReturnTypeEncoder allows converting a C++ value to a V8 value.
	// It's used in order to encode the return type.
	//
	// ===> Inside "codeBinding.cpp":
	//
	//		progpCgoBinding__g_progpDefault_f_returnInteger(&resWrapper);
	//		// ...
	//	   	auto res = resWrapper.value;
	//	   	callInfo.GetReturnValue().Set(V8VALUE_FROM_INT64(res));
	//									  [^HERE^^^^^^^^^]
	//
	// .
	ReturnTypeEncoder(ctx *ProgpV8CodeGenerator) string

	// CgoFunctionParamType allowing to know the parameters types of the CGo function.
	//
	// ===> Inside "codeBinding.go":
	//
	//	func progpCgoBinding__g_progpDefault_f_myFunctionName(res *C.ProgpFunctionReturnVoid, p0 C.int) {
	//		                                                                                     [^ HERE]
	//
	// .
	CgoFunctionParamType(ctx *ProgpV8CodeGenerator) string

	// CppArgResourcesFreeing free the resources generated by getV8ToCppDecoder
	CppArgResourcesFreeing(paramName string, ctx *ProgpV8CodeGenerator) string

	// CgoToGoDecoding allows decoding a CGo value (pseudo C from Go) and get a pure Go value.
	// It's return two parts. The first one allows "long decoding" and the second "inline decoding".
	//
	// ===> Inside "codeBinding.go":
	//
	//			func progpCgoBinding__g_progpDefault_f_progpExecuteFile(res *C.ProgpFunctionReturnVoid, p1 *C.char, p2 C.int) {
	//	   		var p2_asBool = true				<==
	//	   		if C.int(p2) == 0 {					<== Here : long decoding sample (fist value returned)
	//	       		p2_asBool = false				<==
	//	   		}									<==
	//
	//				JSProgpExecuteFile(resolveV8Context(res.ctx, int(res.contextId)), C.GoString(p1), p2_asBool)
	//	. 												                              [^ HERE: inline decoding (second value returned)]
	//	}
	//
	// .
	CgoToGoDecoding(paramName string, ctx *ProgpV8CodeGenerator) (string, string)

	// GoValueToCgoValue allows converting the return type from pure Go to CGo (pseudo C type).
	// It's doing the inverse of cgoToGoDecoding.
	//
	// ===> Inside "codeBinding.go":
	//
	//	func progpCgoBinding__g_progpDefault_f_returnBool(res *C.ProgpFunctionReturnInt) {
	//			goRes := progpModSample.JsReturnBool()
	//	   		if goRes {									<== HERE
	//	       		res.value = C.int(1)					<== HERE
	//	   		} else {									<== HERE
	//	       		res.value = C.int(0)					<== HERE
	//			}											<== HERE
	//	}
	//
	// .
	GoValueToCgoValue(ctx *ProgpV8CodeGenerator) string
}

type ProgpV8CodeGenerator

type ProgpV8CodeGenerator struct {
	// CurrentFunction is the function currently exported.
	// Is used by the data types.
	CurrentFunction *progpAPI.RegisteredFunction
	// contains filtered or unexported fields
}

func NewProgpV8Codegen

func NewProgpV8Codegen() *ProgpV8CodeGenerator

func (*ProgpV8CodeGenerator) AddNamespace

func (m *ProgpV8CodeGenerator) AddNamespace(namespacePath string)

func (*ProgpV8CodeGenerator) GenerateCode

func (m *ProgpV8CodeGenerator) GenerateCode(autoUpdateDir string)

type TypeBool

type TypeBool struct {
}

func (*TypeBool) CgoFunctionParamType

func (m *TypeBool) CgoFunctionParamType(ctx *ProgpV8CodeGenerator) string

func (*TypeBool) CgoToGoDecoding

func (m *TypeBool) CgoToGoDecoding(paramName string, ctx *ProgpV8CodeGenerator) (string, string)

func (*TypeBool) CppArgResourcesFreeing

func (m *TypeBool) CppArgResourcesFreeing(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeBool) CppToCgoParamCall

func (m *TypeBool) CppToCgoParamCall(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeBool) GoValueToCgoValue

func (m *TypeBool) GoValueToCgoValue(ctx *ProgpV8CodeGenerator) string

func (*TypeBool) ReturnTypeEncoder

func (m *TypeBool) ReturnTypeEncoder(ctx *ProgpV8CodeGenerator) string

func (*TypeBool) ReturnTypeWrapper

func (m *TypeBool) ReturnTypeWrapper(ctx *ProgpV8CodeGenerator) string

func (*TypeBool) V8ToCppDecoder

func (m *TypeBool) V8ToCppDecoder(ctx *ProgpV8CodeGenerator) string

type TypeFloat32

type TypeFloat32 struct {
}

func (*TypeFloat32) CgoFunctionParamType

func (m *TypeFloat32) CgoFunctionParamType(ctx *ProgpV8CodeGenerator) string

func (*TypeFloat32) CgoToGoDecoding

func (m *TypeFloat32) CgoToGoDecoding(paramName string, ctx *ProgpV8CodeGenerator) (string, string)

func (*TypeFloat32) CppArgResourcesFreeing

func (m *TypeFloat32) CppArgResourcesFreeing(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeFloat32) CppToCgoParamCall

func (m *TypeFloat32) CppToCgoParamCall(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeFloat32) GoValueToCgoValue

func (m *TypeFloat32) GoValueToCgoValue(ctx *ProgpV8CodeGenerator) string

func (*TypeFloat32) ReturnTypeEncoder

func (m *TypeFloat32) ReturnTypeEncoder(ctx *ProgpV8CodeGenerator) string

func (*TypeFloat32) ReturnTypeWrapper

func (m *TypeFloat32) ReturnTypeWrapper(ctx *ProgpV8CodeGenerator) string

func (*TypeFloat32) V8ToCppDecoder

func (m *TypeFloat32) V8ToCppDecoder(ctx *ProgpV8CodeGenerator) string

type TypeFloat64

type TypeFloat64 struct {
}

func (*TypeFloat64) CgoFunctionParamType

func (m *TypeFloat64) CgoFunctionParamType(ctx *ProgpV8CodeGenerator) string

func (*TypeFloat64) CgoToGoDecoding

func (m *TypeFloat64) CgoToGoDecoding(paramName string, ctx *ProgpV8CodeGenerator) (string, string)

func (*TypeFloat64) CppArgResourcesFreeing

func (m *TypeFloat64) CppArgResourcesFreeing(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeFloat64) CppToCgoParamCall

func (m *TypeFloat64) CppToCgoParamCall(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeFloat64) GoValueToCgoValue

func (m *TypeFloat64) GoValueToCgoValue(ctx *ProgpV8CodeGenerator) string

func (*TypeFloat64) ReturnTypeEncoder

func (m *TypeFloat64) ReturnTypeEncoder(ctx *ProgpV8CodeGenerator) string

func (*TypeFloat64) ReturnTypeWrapper

func (m *TypeFloat64) ReturnTypeWrapper(ctx *ProgpV8CodeGenerator) string

func (*TypeFloat64) V8ToCppDecoder

func (m *TypeFloat64) V8ToCppDecoder(ctx *ProgpV8CodeGenerator) string

type TypeInt

type TypeInt struct {
}

func (*TypeInt) CgoFunctionParamType

func (m *TypeInt) CgoFunctionParamType(ctx *ProgpV8CodeGenerator) string

func (*TypeInt) CgoToGoDecoding

func (m *TypeInt) CgoToGoDecoding(paramName string, ctx *ProgpV8CodeGenerator) (string, string)

func (*TypeInt) CppArgResourcesFreeing

func (m *TypeInt) CppArgResourcesFreeing(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeInt) CppToCgoParamCall

func (m *TypeInt) CppToCgoParamCall(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeInt) GoValueToCgoValue

func (m *TypeInt) GoValueToCgoValue(ctx *ProgpV8CodeGenerator) string

func (*TypeInt) ReturnTypeEncoder

func (m *TypeInt) ReturnTypeEncoder(ctx *ProgpV8CodeGenerator) string

func (*TypeInt) ReturnTypeWrapper

func (m *TypeInt) ReturnTypeWrapper(ctx *ProgpV8CodeGenerator) string

func (*TypeInt) V8ToCppDecoder

func (m *TypeInt) V8ToCppDecoder(ctx *ProgpV8CodeGenerator) string

type TypeJsFunction

type TypeJsFunction struct {
}

func (*TypeJsFunction) CgoFunctionParamType

func (m *TypeJsFunction) CgoFunctionParamType(ctx *ProgpV8CodeGenerator) string

func (*TypeJsFunction) CgoToGoDecoding

func (m *TypeJsFunction) CgoToGoDecoding(paramName string, ctx *ProgpV8CodeGenerator) (string, string)

func (*TypeJsFunction) CppArgResourcesFreeing

func (m *TypeJsFunction) CppArgResourcesFreeing(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeJsFunction) CppToCgoParamCall

func (m *TypeJsFunction) CppToCgoParamCall(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeJsFunction) GoValueToCgoValue

func (m *TypeJsFunction) GoValueToCgoValue(ctx *ProgpV8CodeGenerator) string

func (*TypeJsFunction) ReturnTypeEncoder

func (m *TypeJsFunction) ReturnTypeEncoder(ctx *ProgpV8CodeGenerator) string

func (*TypeJsFunction) ReturnTypeWrapper

func (m *TypeJsFunction) ReturnTypeWrapper(ctx *ProgpV8CodeGenerator) string

func (*TypeJsFunction) V8ToCppDecoder

func (m *TypeJsFunction) V8ToCppDecoder(ctx *ProgpV8CodeGenerator) string

type TypeSharedResource

type TypeSharedResource struct {
}

func (*TypeSharedResource) CgoFunctionParamType

func (m *TypeSharedResource) CgoFunctionParamType(ctx *ProgpV8CodeGenerator) string

func (*TypeSharedResource) CgoToGoDecoding

func (m *TypeSharedResource) CgoToGoDecoding(paramName string, ctx *ProgpV8CodeGenerator) (string, string)

func (*TypeSharedResource) CppArgResourcesFreeing

func (m *TypeSharedResource) CppArgResourcesFreeing(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeSharedResource) CppToCgoParamCall

func (m *TypeSharedResource) CppToCgoParamCall(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeSharedResource) GoValueToCgoValue

func (m *TypeSharedResource) GoValueToCgoValue(ctx *ProgpV8CodeGenerator) string

func (*TypeSharedResource) ReturnTypeEncoder

func (m *TypeSharedResource) ReturnTypeEncoder(ctx *ProgpV8CodeGenerator) string

func (*TypeSharedResource) ReturnTypeWrapper

func (m *TypeSharedResource) ReturnTypeWrapper(ctx *ProgpV8CodeGenerator) string

func (*TypeSharedResource) V8ToCppDecoder

func (m *TypeSharedResource) V8ToCppDecoder(ctx *ProgpV8CodeGenerator) string

type TypeSharedResourceContainer

type TypeSharedResourceContainer struct {
}

func (*TypeSharedResourceContainer) CgoFunctionParamType

func (m *TypeSharedResourceContainer) CgoFunctionParamType(ctx *ProgpV8CodeGenerator) string

func (*TypeSharedResourceContainer) CgoToGoDecoding

func (m *TypeSharedResourceContainer) CgoToGoDecoding(paramName string, ctx *ProgpV8CodeGenerator) (string, string)

func (*TypeSharedResourceContainer) CppArgResourcesFreeing

func (m *TypeSharedResourceContainer) CppArgResourcesFreeing(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeSharedResourceContainer) CppToCgoParamCall

func (m *TypeSharedResourceContainer) CppToCgoParamCall(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeSharedResourceContainer) GoValueToCgoValue

func (m *TypeSharedResourceContainer) GoValueToCgoValue(ctx *ProgpV8CodeGenerator) string

func (*TypeSharedResourceContainer) ReturnTypeEncoder

func (m *TypeSharedResourceContainer) ReturnTypeEncoder(ctx *ProgpV8CodeGenerator) string

func (*TypeSharedResourceContainer) ReturnTypeWrapper

func (m *TypeSharedResourceContainer) ReturnTypeWrapper(ctx *ProgpV8CodeGenerator) string

func (*TypeSharedResourceContainer) V8ToCppDecoder

type TypeString

type TypeString struct {
}

func (*TypeString) CgoFunctionParamType

func (m *TypeString) CgoFunctionParamType(ctx *ProgpV8CodeGenerator) string

func (*TypeString) CgoToGoDecoding

func (m *TypeString) CgoToGoDecoding(paramName string, ctx *ProgpV8CodeGenerator) (string, string)

func (*TypeString) CppArgResourcesFreeing

func (m *TypeString) CppArgResourcesFreeing(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeString) CppToCgoParamCall

func (m *TypeString) CppToCgoParamCall(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeString) GoValueToCgoValue

func (m *TypeString) GoValueToCgoValue(ctx *ProgpV8CodeGenerator) string

func (*TypeString) ReturnTypeEncoder

func (m *TypeString) ReturnTypeEncoder(ctx *ProgpV8CodeGenerator) string

func (*TypeString) ReturnTypeWrapper

func (m *TypeString) ReturnTypeWrapper(ctx *ProgpV8CodeGenerator) string

func (*TypeString) V8ToCppDecoder

func (m *TypeString) V8ToCppDecoder(ctx *ProgpV8CodeGenerator) string

type TypeStringBuffer

type TypeStringBuffer struct {
}

func (*TypeStringBuffer) CgoFunctionParamType

func (m *TypeStringBuffer) CgoFunctionParamType(ctx *ProgpV8CodeGenerator) string

func (*TypeStringBuffer) CgoToGoDecoding

func (m *TypeStringBuffer) CgoToGoDecoding(paramName string, ctx *ProgpV8CodeGenerator) (string, string)

func (*TypeStringBuffer) CppArgResourcesFreeing

func (m *TypeStringBuffer) CppArgResourcesFreeing(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeStringBuffer) CppToCgoParamCall

func (m *TypeStringBuffer) CppToCgoParamCall(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeStringBuffer) GoValueToCgoValue

func (m *TypeStringBuffer) GoValueToCgoValue(ctx *ProgpV8CodeGenerator) string

func (*TypeStringBuffer) ReturnTypeEncoder

func (m *TypeStringBuffer) ReturnTypeEncoder(ctx *ProgpV8CodeGenerator) string

func (*TypeStringBuffer) ReturnTypeWrapper

func (m *TypeStringBuffer) ReturnTypeWrapper(ctx *ProgpV8CodeGenerator) string

func (*TypeStringBuffer) V8ToCppDecoder

func (m *TypeStringBuffer) V8ToCppDecoder(ctx *ProgpV8CodeGenerator) string

type TypeUIntArray

type TypeUIntArray struct {
}

func (*TypeUIntArray) CgoFunctionParamType

func (m *TypeUIntArray) CgoFunctionParamType(ctx *ProgpV8CodeGenerator) string

func (*TypeUIntArray) CgoToGoDecoding

func (m *TypeUIntArray) CgoToGoDecoding(paramName string, ctx *ProgpV8CodeGenerator) (string, string)

func (*TypeUIntArray) CppArgResourcesFreeing

func (m *TypeUIntArray) CppArgResourcesFreeing(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeUIntArray) CppToCgoParamCall

func (m *TypeUIntArray) CppToCgoParamCall(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeUIntArray) GoValueToCgoValue

func (m *TypeUIntArray) GoValueToCgoValue(ctx *ProgpV8CodeGenerator) string

func (*TypeUIntArray) ReturnTypeEncoder

func (m *TypeUIntArray) ReturnTypeEncoder(ctx *ProgpV8CodeGenerator) string

func (*TypeUIntArray) ReturnTypeWrapper

func (m *TypeUIntArray) ReturnTypeWrapper(ctx *ProgpV8CodeGenerator) string

func (*TypeUIntArray) V8ToCppDecoder

func (m *TypeUIntArray) V8ToCppDecoder(ctx *ProgpV8CodeGenerator) string

type TypeUnsafePointer

type TypeUnsafePointer struct {
}

func (*TypeUnsafePointer) CgoFunctionParamType

func (m *TypeUnsafePointer) CgoFunctionParamType(ctx *ProgpV8CodeGenerator) string

func (*TypeUnsafePointer) CgoToGoDecoding

func (m *TypeUnsafePointer) CgoToGoDecoding(paramName string, ctx *ProgpV8CodeGenerator) (string, string)

func (*TypeUnsafePointer) CppArgResourcesFreeing

func (m *TypeUnsafePointer) CppArgResourcesFreeing(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeUnsafePointer) CppToCgoParamCall

func (m *TypeUnsafePointer) CppToCgoParamCall(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeUnsafePointer) GoValueToCgoValue

func (m *TypeUnsafePointer) GoValueToCgoValue(ctx *ProgpV8CodeGenerator) string

func (*TypeUnsafePointer) ReturnTypeEncoder

func (m *TypeUnsafePointer) ReturnTypeEncoder(ctx *ProgpV8CodeGenerator) string

func (*TypeUnsafePointer) ReturnTypeWrapper

func (m *TypeUnsafePointer) ReturnTypeWrapper(ctx *ProgpV8CodeGenerator) string

func (*TypeUnsafePointer) V8ToCppDecoder

func (m *TypeUnsafePointer) V8ToCppDecoder(ctx *ProgpV8CodeGenerator) string

type TypeVoid

type TypeVoid struct {
}

func (*TypeVoid) CgoFunctionParamType

func (m *TypeVoid) CgoFunctionParamType(ctx *ProgpV8CodeGenerator) string

func (*TypeVoid) CgoToGoDecoding

func (m *TypeVoid) CgoToGoDecoding(paramName string, ctx *ProgpV8CodeGenerator) (string, string)

func (*TypeVoid) CppArgResourcesFreeing

func (m *TypeVoid) CppArgResourcesFreeing(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeVoid) CppToCgoParamCall

func (m *TypeVoid) CppToCgoParamCall(paramName string, ctx *ProgpV8CodeGenerator) string

func (*TypeVoid) GoValueToCgoValue

func (m *TypeVoid) GoValueToCgoValue(ctx *ProgpV8CodeGenerator) string

func (*TypeVoid) ReturnTypeEncoder

func (m *TypeVoid) ReturnTypeEncoder(ctx *ProgpV8CodeGenerator) string

func (*TypeVoid) ReturnTypeWrapper

func (m *TypeVoid) ReturnTypeWrapper(ctx *ProgpV8CodeGenerator) string

func (*TypeVoid) V8ToCppDecoder

func (m *TypeVoid) V8ToCppDecoder(ctx *ProgpV8CodeGenerator) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL