Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple C++ Header file missing half of the elements in conversion #858

Open
al-sabr opened this issue Jun 10, 2020 · 6 comments
Open

Simple C++ Header file missing half of the elements in conversion #858

al-sabr opened this issue Jun 10, 2020 · 6 comments

Comments

@al-sabr
Copy link

al-sabr commented Jun 10, 2020

On Windows 10

#ifdef WIN32
	typedef unsigned __int32	uint32_t;
	typedef unsigned __int8		uint8_t;
	typedef          __int32	int32_t;
#else
	#include <stdint.h>
#endif

#ifndef FRNATIVEEXTENSIONS_H_
#define FRNATIVEEXTENSIONS_H_

#ifdef __cplusplus
extern "C" {
#endif

typedef void *      FREContext;
typedef void *      FREObject;

/* Initialization *************************************************************/

/**
 * Defines the signature for native calls that can be invoked via an
 * instance of the AS ExtensionContext class.
 *
 * @return    The return value corresponds to the return value
 *            from the AS ExtensionContext class call() method. It defaults to
 *            FRE_INVALID_OBJECT, which is reported as null in AS.
 */

typedef FREObject (*FREFunction)(
        FREContext ctx,
		void*      functionData,
        uint32_t   argc,
        FREObject  argv[]
);

typedef struct FRENamedFunction_ {
    const uint8_t* name;
	void*          functionData;
    FREFunction    function;
} FRENamedFunction;

/**
 * Defines the signature for the initializer that is called each time
 * a new AS ExtensionContext object is created.
 *
 * @param extData The extension client data provided to the FREInitializer function as extDataToSet.
 *
 * @param ctxType Pointer to the contextType string (UTF8) as provided to the AS createExtensionContext call.
 *
 * @param ctx The FREContext being initialized.
 *
 * @param numFunctionsToSet The number of elements in the functionsToSet array.
 *
 * @param functionsToSet A pointer to an array of FRENamedFunction elements.
 */

typedef void (*FREContextInitializer)(
        void*                    extData          ,
        const uint8_t*           ctxType          ,
        FREContext               ctx              ,
        uint32_t*                numFunctionsToSet,
        const FRENamedFunction** functionsToSet
);

/**
 * Defines the signature for the finalizer that is called each time
 * an ExtensionContext instance is disposed.
 */

typedef void (*FREContextFinalizer)(
        FREContext ctx
);

/**
 * The initialization function provided by each extension must conform
 * to the following signature.
 *
 * @param extDataToSet Provided for the extension to store per-extension instance data. 
 *            For example, if the extension creates
 *            globals per-instance, it can store a pointer to them here.
 *
 * @param ctxInitializerToSet Must be set to a pointer to a function
 *            of type FREContextInitializer. Will be invoked whenever
 *            the ActionScript code creates a new context for this extension.
 *
 * @param ctxFinalizerToSet Must be set to a pointer to a function
 *            of type FREContextFinalizer.
 */

typedef void (*FREInitializer)(
        void**                 extDataToSet       ,
        FREContextInitializer* ctxInitializerToSet,
        FREContextFinalizer*   ctxFinalizerToSet
);

/** 
 * Called iff the extension is unloaded from the process. Extensions
 * are not guaranteed to be unloaded; the runtime process may exit without
 * doing so.
 */

typedef void (*FREFinalizer)(
        void* extData
);

/* Result Codes ***************************************************************/
/** 
 * These values must not be changed.
 */

typedef enum {
    FRE_OK                  = 0,
    FRE_NO_SUCH_NAME        = 1,
    FRE_INVALID_OBJECT      = 2,
    FRE_TYPE_MISMATCH       = 3,
    FRE_ACTIONSCRIPT_ERROR  = 4,
    FRE_INVALID_ARGUMENT    = 5,
    FRE_READ_ONLY           = 6,
    FRE_WRONG_THREAD        = 7,
    FRE_ILLEGAL_STATE       = 8,
    FRE_INSUFFICIENT_MEMORY = 9,
	FREResult_ENUMPADDING   = 0xfffff /* will ensure that C and C++ treat this enum as the same size. */
} FREResult;

/* Context Data ************************************************************/

/**
 * @returns FRE_OK
 *          FRE_WRONG_THREAD
 *          FRE_INVALID_ARGUMENT If nativeData is null.
 */

FREResult FREGetContextNativeData( FREContext ctx, void** nativeData );

/**
 * @returns FRE_OK
 *          FRE_INVALID_ARGUMENT
 *          FRE_WRONG_THREAD
 */

FREResult FRESetContextNativeData( FREContext ctx, void*  nativeData );

/**
 * @returns FRE_OK
 *          FRE_WRONG_THREAD
 *          FRE_INVALID_ARGUMENT If actionScriptData is null.
 */

FREResult FREGetContextActionScriptData( FREContext ctx, FREObject *actionScriptData );

/**
 * @returns FRE_OK
 *          FRE_WRONG_THREAD
 */

FREResult FRESetContextActionScriptData( FREContext ctx, FREObject  actionScriptData );

/* Primitive Types ************************************************************/
/**
 * These values must not be changed.
 */

typedef enum {
    FRE_TYPE_OBJECT           = 0,
    FRE_TYPE_NUMBER           = 1,
    FRE_TYPE_STRING           = 2,
    FRE_TYPE_BYTEARRAY        = 3,
    FRE_TYPE_ARRAY            = 4,
    FRE_TYPE_VECTOR           = 5,
    FRE_TYPE_BITMAPDATA       = 6,
	FRE_TYPE_BOOLEAN          = 7,
	FRE_TYPE_NULL             = 8,
	FREObjectType_ENUMPADDING = 0xfffff /* will ensure that C and C++ treat this enum as the same size. */
} FREObjectType;

/**
 * @returns FRE_OK
 *          FRE_INVALID_OBJECT
 *          FRE_WRONG_THREAD
 *          FRE_INVALID_ARGUMENT If objectType is null.
 */

FREResult FREGetObjectType( FREObject object, FREObjectType *objectType );

/**
 * @return  FRE_OK
 *          FRE_TYPE_MISMATCH
 *          FRE_INVALID_OBJECT
 *          FRE_INVALID_ARGUMENT
 *          FRE_WRONG_THREAD
 */

FREResult FREGetObjectAsInt32 ( FREObject object, int32_t  *value );
FREResult FREGetObjectAsUint32( FREObject object, uint32_t *value );
FREResult FREGetObjectAsDouble( FREObject object, double   *value );
FREResult FREGetObjectAsBool  ( FREObject object, uint32_t *value );

/**
 * @return  FRE_OK
 *          FRE_INVALID_ARGUMENT
 *          FRE_WRONG_THREAD
 */

FREResult FRENewObjectFromInt32 ( int32_t  value, FREObject *object );
FREResult FRENewObjectFromUint32( uint32_t value, FREObject *object );
FREResult FRENewObjectFromDouble( double   value, FREObject *object );
FREResult FRENewObjectFromBool  ( uint32_t value, FREObject *object );

/**
 * Retrieves a string representation of the object referred to by
 * the given object. The referenced string is immutable and valid 
 * only for duration of the call to a registered function. If the 
 * caller wishes to keep the the string, they must keep a copy of it.
 *
 * @param object The string to be retrieved.
 *
 * @param length The size, in bytes, of the string. Includes the
 *               null terminator.
 *
 * @param value  A pointer to a possibly temporary copy of the string.
 *
 * @return  FRE_OK
 *          FRE_TYPE_MISMATCH
 *          FRE_INVALID_OBJECT
 *          FRE_INVALID_ARGUMENT
 *          FRE_WRONG_THREAD
 */

FREResult FREGetObjectAsUTF8(
        FREObject       object,
        uint32_t*       length,
        const uint8_t** value
);

/** 
 * Creates a new String object that contains a copy of the specified
 * string.
 *
 * @param length The length, in bytes, of the original string. Must include
 *               the null terminator.
 *
 * @param value  A pointer to the original string.
 *
 * @param object Receives a reference to the new string object.
 * 
 * @return  FRE_OK
 *          FRE_INVALID_ARGUMENT
 *          FRE_WRONG_THREAD
 */

FREResult FRENewObjectFromUTF8(
        uint32_t        length,
        const uint8_t*  value ,
        FREObject*      object
);

/* Object Access **************************************************************/

/**
 * @param className UTF8-encoded name of the class being constructed.
 *
 * @param thrownException A pointer to a handle that can receive the handle of any ActionScript 
 *            Error thrown during execution. May be null if the caller does not
 *            want to receive this handle. If not null and no error occurs, is set an
 *            invalid handle value.
 *
 * @return  FRE_OK
 *          FRE_TYPE_MISMATCH
 *          FRE_INVALID_OBJECT
 *          FRE_INVALID_ARGUMENT
 *          FRE_ACTIONSCRIPT_ERROR If an ActionScript exception results from calling this method.
 *              In this case, thrownException will be set to the handle of the thrown value. 
 *          FRE_ILLEGAL_STATE If a ByteArray or BitmapData has been acquired and not yet released.
 *          FRE_NO_SUCH_NAME
 *          FRE_WRONG_THREAD
 */

FREResult FRENewObject(
        const uint8_t* className      ,
        uint32_t       argc           ,
        FREObject      argv[]         ,
        FREObject*     object         ,
        FREObject*     thrownException
);

/**
 * @param propertyName UTF8-encoded name of the property being fetched.
 *
 * @param thrownException A pointer to a handle that can receive the handle of any ActionScript 
 *            Error thrown during getting the property. May be null if the caller does not
 *            want to receive this handle. If not null and no error occurs, is set an
 *            invalid handle value.
 *
 * @return  FRE_OK
 *          FRE_TYPE_MISMATCH
 *          FRE_INVALID_OBJECT
 *          FRE_INVALID_ARGUMENT
 *
 *          FRE_ACTIONSCRIPT_ERROR If an ActionScript exception results from getting this property.
 *              In this case, thrownException will be set to the handle of the thrown value. 
 *
 *          FRE_NO_SUCH_NAME If the named property doesn't exist, or if the reference is ambiguous
 *              because the property exists in more than one namespace.
 *
 *          FRE_ILLEGAL_STATE If a ByteArray or BitmapData has been acquired and not yet released.
 *
 *          FRE_WRONG_THREAD
 */

FREResult FREGetObjectProperty(
        FREObject       object         ,
        const uint8_t*  propertyName   ,
        FREObject*      propertyValue  ,
        FREObject*      thrownException
);

/**
 * @param propertyName UTF8-encoded name of the property being set.
 *
 * @param thrownException A pointer to a handle that can receive the handle of any ActionScript 
 *            Error thrown during method execution. May be null if the caller does not
 *            want to receive this handle. If not null and no error occurs, is set an
 *            invalid handle value.
 *
 *
 * @return  FRE_OK
 *          FRE_TYPE_MISMATCH
 *          FRE_INVALID_OBJECT
 *          FRE_INVALID_ARGUMENT
 *          FRE_ACTIONSCRIPT_ERROR If an ActionScript exception results from getting this property.
 *              In this case, thrownException will be set to the handle of the thrown value. 
 *
 *          FRE_NO_SUCH_NAME If the named property doesn't exist, or if the reference is ambiguous
 *              because the property exists in more than one namespace.
 *
 *          FRE_ILLEGAL_STATE If a ByteArray or BitmapData has been acquired and not yet released.
 *
 *          FRE_READ_ONLY
 *          FRE_WRONG_THREAD
 */

FREResult FRESetObjectProperty(
        FREObject       object         ,
        const uint8_t*  propertyName   ,
        FREObject       propertyValue  ,
        FREObject*      thrownException
);

/**
 * @param methodName UTF8-encoded null-terminated name of the method being invoked.
 *
 * @param thrownException A pointer to a handle that can receive the handle of any ActionScript 
 *            Error thrown during method execution. May be null if the caller does not
 *            want to receive this handle. If not null and no error occurs, is set an
 *            invalid handle value.
 *
 * @return  FRE_OK
 *          FRE_TYPE_MISMATCH
 *          FRE_INVALID_OBJECT
 *          FRE_INVALID_ARGUMENT
 *          FRE_ACTIONSCRIPT_ERROR If an ActionScript exception results from calling this method.
 *              In this case, thrownException will be set to the handle of the thrown value. 
 *
 *          FRE_NO_SUCH_NAME If the named method doesn't exist, or if the reference is ambiguous
 *              because the method exists in more than one namespace.
 *
 *          FRE_ILLEGAL_STATE If a ByteArray or BitmapData has been acquired and not yet released.
 *
 *          FRE_WRONG_THREAD
 */

FREResult FRECallObjectMethod (
        FREObject      object         ,
        const uint8_t* methodName     ,
        uint32_t       argc           ,
        FREObject      argv[]         ,
        FREObject*     result         ,
        FREObject*     thrownException
);

/* BitmapData Access **********************************************************/

typedef struct {
    uint32_t  width;           /* width of the BitmapData bitmap */
    uint32_t  height;          /* height of the BitmapData bitmap */
    uint32_t  hasAlpha;        /* if non-zero, pixel format is ARGB32, otherwise pixel format is _RGB32, host endianness */
    uint32_t  isPremultiplied; /* pixel color values are premultiplied with alpha if non-zero, un-multiplied if zero */
    uint32_t  lineStride32;    /* line stride in number of 32 bit values, typically the same as width */
    uint32_t* bits32;          /* pointer to the first 32-bit pixel of the bitmap data */
} FREBitmapData;

typedef struct {
    uint32_t  width;           /* width of the BitmapData bitmap */
    uint32_t  height;          /* height of the BitmapData bitmap */
    uint32_t  hasAlpha;        /* if non-zero, pixel format is ARGB32, otherwise pixel format is _RGB32, host endianness */
    uint32_t  isPremultiplied; /* pixel color values are premultiplied with alpha if non-zero, un-multiplied if zero */
    uint32_t  lineStride32;    /* line stride in number of 32 bit values, typically the same as width */
    uint32_t  isInvertedY;     /* if non-zero, last row of pixels starts at bits32, otherwise, first row of pixels starts at bits32. */
    uint32_t* bits32;          /* pointer to the first 32-bit pixel of the bitmap data */
} FREBitmapData2;

/**
 * Referenced data is valid only for duration of the call
 * to a registered function.
 *
 * @return  FRE_OK
 *          FRE_TYPE_MISMATCH
 *          FRE_INVALID_OBJECT
 *          FRE_INVALID_ARGUMENT
 *          FRE_WRONG_THREAD
 *          FRE_ILLEGAL_STATE
 */

FREResult FREAcquireBitmapData(
        FREObject      object         , 
        FREBitmapData* descriptorToSet
);

/**
 * Referenced data is valid only for duration of the call
 * to a registered function.
 *
 * Use of this API requires that the extension and application must be packaged for 
 * the 3.1 namespace or later.
 *
 * @return  FRE_OK
 *          FRE_TYPE_MISMATCH
 *          FRE_INVALID_OBJECT
 *          FRE_INVALID_ARGUMENT
 *          FRE_WRONG_THREAD
 *          FRE_ILLEGAL_STATE
 */

FREResult FREAcquireBitmapData2(
        FREObject      object         , 
        FREBitmapData2* descriptorToSet
);

/**
 * BitmapData must be acquired to call this. Clients must invalidate any region
 * they modify in order to notify AIR of the changes. Only invalidated regions
 * are redrawn.
 *
 * @return  FRE_OK
 *          FRE_INVALID_OBJECT
 *          FRE_WRONG_THREAD
 *          FRE_ILLEGAL_STATE
 *          FRE_TYPE_MISMATCH
 */

FREResult FREInvalidateBitmapDataRect(
        FREObject object,
        uint32_t x      ,
        uint32_t y      ,
        uint32_t width  ,
        uint32_t height
);
/**
 * @return  FRE_OK
 *          FRE_WRONG_THREAD
 *          FRE_ILLEGAL_STATE
 *          FRE_TYPE_MISMATCH
 */

FREResult FREReleaseBitmapData( FREObject object );

/**
 * Referenced data is valid only for duration of the call
 * to a registered function.
 *
 * @return  FRE_OK
 *          FRE_TYPE_MISMATCH
 *          FRE_INVALID_OBJECT
 *          FRE_WRONG_THREAD
 */

/* ByteArray Access ***********************************************************/

typedef struct {
    uint32_t length;
    uint8_t* bytes;
} FREByteArray;

/**
 * Referenced data is valid only for duration of the call
 * to a registered function.
 *
 * @return  FRE_OK
 *          FRE_TYPE_MISMATCH
 *          FRE_INVALID_OBJECT
 *          FRE_INVALID_ARGUMENT
 *          FRE_WRONG_THREAD
 *          FRE_ILLEGAL_STATE
 */

FREResult FREAcquireByteArray(
    FREObject     object        ,
    FREByteArray* byteArrayToSet
);

/**
 * @return  FRE_OK
 *          FRE_INVALID_OBJECT
 *          FRE_ILLEGAL_STATE
 *          FRE_WRONG_THREAD
 */

FREResult FREReleaseByteArray( FREObject object );

/* Array and Vector Access ****************************************************/

/**
 * @return  FRE_OK
 *          FRE_INVALID_OBJECT
 *          FRE_INVALID_ARGUMENT
 *          FRE_ILLEGAL_STATE
 *          FRE_TYPE_MISMATCH
 *          FRE_WRONG_THREAD
 */

FREResult FREGetArrayLength(
        FREObject  arrayOrVector,
        uint32_t*  length
);

/**
 * @return  FRE_OK
 *          FRE_INVALID_OBJECT
 *          FRE_TYPE_MISMATCH
 *          FRE_ILLEGAL_STATE
 *          FRE_INVALID_ARGUMENT If length is greater than 2^32.
 *
 *          FRE_READ_ONLY   If the handle refers to a Vector
 *              of fixed size.
 *
 *          FRE_WRONG_THREAD
 *          FRE_INSUFFICIENT_MEMORY
 */

FREResult FRESetArrayLength(
        FREObject  arrayOrVector,
        uint32_t   length
);

/**
 * If an Array is sparse and an element that isn't defined is requested, the
 * return value will be FRE_OK but the handle value will be invalid.
 *
 * @return  FRE_OK
 *          FRE_ILLEGAL_STATE
 *
 *          FRE_INVALID_ARGUMENT If the handle refers to a vector and the index is
 *              greater than the size of the array.
 *
 *          FRE_INVALID_OBJECT
 *          FRE_TYPE_MISMATCH
 *          FRE_WRONG_THREAD
 */

FREResult FREGetArrayElementAt(
        FREObject  arrayOrVector,
        uint32_t   index        ,
        FREObject* value
);

/**
 *
 * @return  FRE_OK
 *          FRE_INVALID_OBJECT
 *          FRE_ILLEGAL_STATE
 *
 *          FRE_TYPE_MISMATCH If an attempt to made to set a value in a Vector
 *              when the type of the value doesn't match the Vector's item type.
 *
 *          FRE_WRONG_THREAD
 */

FREResult FRESetArrayElementAt(
        FREObject  arrayOrVector,
        uint32_t   index        ,
        FREObject  value
);

/* Callbacks ******************************************************************/

/** 
 * Causes a StatusEvent to be dispatched from the associated
 * ExtensionContext object.
 *
 * Dispatch happens asynchronously, even if this is called during
 * a call to a registered function.
 *
 * The ActionScript portion of this extension can listen for that event
 * and, upon receipt, query the native portion for details of the event
 * that occurred.
 *
 * This call is thread-safe and may be invoked from any thread. The string
 * values are copied before the call returns.
 *
 * @return  FRE_OK In all circumstances, as the referenced object cannot
 *              necessarily be checked for validity on the invoking thread.
 *              However, no event will be dispatched if the object is
 *              invalid or not an EventDispatcher.
 *          FRE_INVALID_ARGUMENT If code or level is NULL
 */

FREResult FREDispatchStatusEventAsync(
        FREContext     ctx  ,
        const uint8_t* code ,
        const uint8_t* level
);

#ifdef __cplusplus
}
#endif

#endif 

Will result to :

/*
	Package main - transpiled by c2go version: v0.26.0 Erbium 2020-03-17

	If you have found any issues, please raise an issue at:
	https://github.com/elliotchance/c2go/
*/

package main

import "unsafe"

type uintptr_t uint32
type va_list *byte
type size_t uint32
type ptrdiff_t int32
type intptr_t int32
type __vcrt_bool int8
type wchar_t uint16
type int8_t int8
type int16_t int16
type int32_t int32
type int64_t int64
type uint8_t uint8
type uint16_t uint16
type uint32_t uint32
type uint64_t uint64
type int_least8_t int8
type int_least16_t int16
type int_least32_t int32
type int_least64_t int64
type uint_least8_t uint8
type uint_least16_t uint16
type uint_least32_t uint32
type uint_least64_t uint64
type int_fast8_t int8
type int_fast16_t int32
type int_fast32_t int32
type int_fast64_t int64
type uint_fast8_t uint8
type uint_fast16_t uint32
type uint_fast32_t uint32
type uint_fast64_t uint64
type intmax_t int64
type uintmax_t uint64
type FREContext unsafe.Pointer
type FREObject unsafe.Pointer
type FREFunction func(FREContext, unsafe.Pointer, uint32, *FREObject) FREObject
type FRENamedFunction_ struct {
	name         *uint8
	functionData unsafe.Pointer
	function     FREFunction
}
type FRENamedFunction FRENamedFunction_
type FREContextInitializer func(unsafe.Pointer, *uint8, FREContext, *uint32, **FRENamedFunction)
type FREContextFinalizer func(FREContext)
type FREInitializer func(*unsafe.Pointer, FREContextInitializer, FREContextFinalizer)
type FREFinalizer func(unsafe.Pointer)

const FRE_OK int32 = 0
const FRE_NO_SUCH_NAME int32 = 1
const FRE_INVALID_OBJECT int32 = 2
const FRE_TYPE_MISMATCH int32 = 3
const FRE_ACTIONSCRIPT_ERROR int32 = 4
const FRE_INVALID_ARGUMENT int32 = 5
const FRE_READ_ONLY int32 = 6
const FRE_WRONG_THREAD int32 = 7
const FRE_ILLEGAL_STATE int32 = 8
const FRE_INSUFFICIENT_MEMORY int32 = 9
const FREResult_ENUMPADDING int32 = 1048575

type FREResult int32

const FRE_TYPE_OBJECT int32 = 0
const FRE_TYPE_NUMBER int32 = 1
const FRE_TYPE_STRING int32 = 2
const FRE_TYPE_BYTEARRAY int32 = 3
const FRE_TYPE_ARRAY int32 = 4
const FRE_TYPE_VECTOR int32 = 5
const FRE_TYPE_BITMAPDATA int32 = 6
const FRE_TYPE_BOOLEAN int32 = 7
const FRE_TYPE_NULL int32 = 8
const FREObjectType_ENUMPADDING int32 = 1048575

type FREObjectType int32
type FREBitmapData struct {
	width           uint32
	height          uint32
	hasAlpha        uint32
	isPremultiplied uint32
	lineStride32    uint32
	bits32          *uint32
}
type FREBitmapData2 struct {
	width           uint32
	height          uint32
	hasAlpha        uint32
	isPremultiplied uint32
	lineStride32    uint32
	isInvertedY     uint32
	bits32          *uint32
}
type FREByteArray struct {
	length uint32
	bytes  *uint8
}

func init() {
}

Half of the functions are missing

@al-sabr
Copy link
Author

al-sabr commented Jun 11, 2020

Am I correct in those manual conversion?

FREResult FREGetContextNativeData( FREContext ctx, void** nativeData );

FREResult FRESetContextNativeData( FREContext ctx, void*  nativeData );

FREResult FREGetContextActionScriptData( FREContext ctx, FREObject *actionScriptData );

FREResult FRESetContextActionScriptData( FREContext ctx, FREObject  actionScriptData );

FREResult FREGetObjectType( FREObject object, FREObjectType *objectType );

FREResult FREGetObjectAsInt32 ( FREObject object, int32_t  *value );
FREResult FREGetObjectAsUint32( FREObject object, uint32_t *value );
FREResult FREGetObjectAsDouble( FREObject object, double   *value );
FREResult FREGetObjectAsBool  ( FREObject object, uint32_t *value );

FREResult FRENewObjectFromInt32 ( int32_t  value, FREObject *object );
FREResult FRENewObjectFromUint32( uint32_t value, FREObject *object );
FREResult FRENewObjectFromDouble( double   value, FREObject *object );
FREResult FRENewObjectFromBool  ( uint32_t value, FREObject *object );

towards Go

func FREGetContextNativeData(FREContext ctx, nativeData *unsafe.Pointer) (FREResult)
func FRESetContextNativeData(FREContext ctx, nativeData *unsafe.Pointer) (FREResult)

func FREGetContextActionScriptData(FREContext ctx, actionScriptData FREObject) (FREResult)
func FRESetContextActionScriptData(FREContext ctx, actionScriptData FREObject) (FREResult)

func FREGetObjectType(object FREObject, objectType FREObjectType) (FREResult)

func FREGetObjectAsInt32 (object FREObject , value *int32 ) (FREResult)
func FREGetObjectAsUint32( FREObject object, value *uint32 ) (FREResult)
func FREGetObjectAsDouble( FREObject object, value *float32 ) (FREResult)
func FREGetObjectAsBool  ( FREObject object, value *uint32 ) (FREResult)

func FRENewObjectFromInt32 (value int32, object FREObject ) (FREResult)
func FRENewObjectFromUint32(value uint32, object FREObject ) (FREResult)
func FRENewObjectFromDouble(value float32, object FREObject ) (FREResult)
func FRENewObjectFromBool  (value uint32, object FREObject ) (FREResult)

func FREGetObjectAsUTF8	(object FREObject, length *unsafe.Pointer, const value **unsafe.Pointer) (FREResult)

@elliotchance
Copy link
Owner

Those look like forward declarations (the functions have an missing body) - there is no equivalent of this in Go. You should be transpiling your C files, not the header files.

@al-sabr
Copy link
Author

al-sabr commented Jun 12, 2020

The only way for me to get rid of C++ and use Golang to build DLL/SO is to be able to port this header file can you help out?

This is the only header I need to switch my whole environment.

I don't fully understand Golang deepness to be able to achieve that

@elliotchance
Copy link
Owner

It sounds like you need to use cgo which will let you link your go code against compiled C++ code. This project, c2go, is a transpiler tool that attempts to convert C source code itself to Go code. It also does not support C++ source code.

@al-sabr
Copy link
Author

al-sabr commented Jun 24, 2020

I am writting many of those small libraries for speed purpose because C++ is really fast.

Actually my goal was to ditch C++ completely and use Golang to just write those DLLs and use the exports so that the VM recognize the initial functions and load those DLLs and make them available at runtime.

This is an example of a really simple C++ Native Extension for Adobe AIR VM : https://github.com/StackAndHeap/joystick-ane/blob/master/native/win/JoystickManager/JoystickManager/JoystickANE.c

As you can see it exports few functions like:

https://github.com/StackAndHeap/joystick-ane/blob/17b031464c4fb3de5947b460f04b93ad83d4c452/native/win/JoystickManager/JoystickManager/JoystickANE.c#L8

https://github.com/StackAndHeap/joystick-ane/blob/17b031464c4fb3de5947b460f04b93ad83d4c452/native/win/JoystickManager/JoystickManager/JoystickANE.c#L9

Here comes the initialization:

https://github.com/StackAndHeap/joystick-ane/blob/17b031464c4fb3de5947b460f04b93ad83d4c452/native/win/JoystickManager/JoystickManager/JoystickANE.c#L150

Finalization:

https://github.com/StackAndHeap/joystick-ane/blob/17b031464c4fb3de5947b460f04b93ad83d4c452/native/win/JoystickManager/JoystickManager/JoystickANE.c#L176

2 simple exported function which are called by the VM when loaded

https://github.com/StackAndHeap/joystick-ane/blob/17b031464c4fb3de5947b460f04b93ad83d4c452/native/win/JoystickManager/JoystickManager/JoystickANE.c#L180

https://github.com/StackAndHeap/joystick-ane/blob/17b031464c4fb3de5947b460f04b93ad83d4c452/native/win/JoystickManager/JoystickManager/JoystickANE.c#L186

Do you still think that it will be impossible to achieve all that within Golang?

Thank you for your support.

@elliotchance
Copy link
Owner

@al-sabr I can't speak to what you should or shouldn't do, but you have two options:

  1. Use your existing C++ code by binding it to Go code with cgo (not c2go).
  2. Rewrite your C++ into Go manually. c2go won't help with this because you're dealing with non trivial code with that project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants