forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
44
Kha/Backends/Kinc-hxcpp/khacpp/test/native/externs/RGB.hx
Normal file
44
Kha/Backends/Kinc-hxcpp/khacpp/test/native/externs/RGB.hx
Normal file
@ -0,0 +1,44 @@
|
||||
package externs;
|
||||
|
||||
import cpp.UInt8;
|
||||
import cpp.Pointer;
|
||||
|
||||
@:include("./../lib/LibInclude.h")
|
||||
@:sourceFile("./../lib/RGB.cpp")
|
||||
@:native("RGB")
|
||||
extern class RGB
|
||||
{
|
||||
public var r:UInt8;
|
||||
public var g:UInt8;
|
||||
public var b:UInt8;
|
||||
|
||||
public function getLuma():Int;
|
||||
public function toInt():Int;
|
||||
|
||||
@:native("new RGB")
|
||||
public static function create(r:Int, g:Int, b:Int):Pointer<RGB>;
|
||||
|
||||
@:native("~RGB")
|
||||
public function deleteMe():Void;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// By extending RGB we keep the same API as far as haxe is concerned, but store the data (not pointer)
|
||||
// The native Reference class knows how to take the reference to the structure
|
||||
@:native("cpp.Reference<RGB>")
|
||||
extern class RGBRef extends RGB
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
// By extending RGBRef, we can keep the same api,
|
||||
// rather than a pointer
|
||||
@:native("cpp.Struct<RGB>")
|
||||
extern class RGBStruct extends RGBRef
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
38
Kha/Backends/Kinc-hxcpp/khacpp/test/native/externs/Rectangle.hx
Executable file
38
Kha/Backends/Kinc-hxcpp/khacpp/test/native/externs/Rectangle.hx
Executable file
@ -0,0 +1,38 @@
|
||||
package externs;
|
||||
|
||||
import externs.RectangleApi;
|
||||
|
||||
@:include("./RectangleDef.h")
|
||||
@:structAccess
|
||||
@:native("Rectangle")
|
||||
extern class Rectangle
|
||||
{
|
||||
@:native("Rectangle::instanceCount")
|
||||
static var instanceCount:Int;
|
||||
|
||||
public var x:Int;
|
||||
public var y:Int;
|
||||
public var width:Int;
|
||||
public var height:Int;
|
||||
|
||||
public function area() : Int;
|
||||
|
||||
@:native("new Rectangle")
|
||||
@:overload( function():cpp.Star<Rectangle>{} )
|
||||
@:overload( function(x:Int):cpp.Star<Rectangle>{} )
|
||||
@:overload( function(x:Int, y:Int):cpp.Star<Rectangle>{} )
|
||||
@:overload( function(x:Int, y:Int, width:Int):cpp.Star<Rectangle>{} )
|
||||
static function create(x:Int, y:Int, width:Int, height:Int):cpp.Star<Rectangle>;
|
||||
|
||||
@:native("Rectangle")
|
||||
@:overload( function():Rectangle {} )
|
||||
@:overload( function(x:Int):Rectangle {} )
|
||||
@:overload( function(x:Int, y:Int):Rectangle {} )
|
||||
@:overload( function(x:Int, y:Int, width:Int):Rectangle {} )
|
||||
static function make(x:Int, y:Int, width:Int, height:Int):Rectangle;
|
||||
|
||||
@:native("~Rectangle")
|
||||
public function delete():Void;
|
||||
}
|
||||
|
||||
typedef RectanglePtr = cpp.Star<Rectangle>;
|
9
Kha/Backends/Kinc-hxcpp/khacpp/test/native/externs/RectangleApi.hx
Executable file
9
Kha/Backends/Kinc-hxcpp/khacpp/test/native/externs/RectangleApi.hx
Executable file
@ -0,0 +1,9 @@
|
||||
package externs;
|
||||
|
||||
// This class acts as a container for the Rectangle implementation, which will get included
|
||||
// in the cpp file, and therfore get compiled and linked with the correct flags
|
||||
@:cppInclude("./RectangleImpl.cpp")
|
||||
@:keep
|
||||
class RectangleApi
|
||||
{
|
||||
}
|
26
Kha/Backends/Kinc-hxcpp/khacpp/test/native/externs/RectangleDef.h
Executable file
26
Kha/Backends/Kinc-hxcpp/khacpp/test/native/externs/RectangleDef.h
Executable file
@ -0,0 +1,26 @@
|
||||
#ifndef RECTANGLE_DEF_INCLUDED
|
||||
#define RECTANGLE_DEF_INCLUDED
|
||||
|
||||
struct Rectangle
|
||||
{
|
||||
static int instanceCount;
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
inline Rectangle(int inX=0, int inY=0, int inW=0, int inH=0) :
|
||||
x(inX), y(inY), width(inW), height(inH)
|
||||
{
|
||||
instanceCount++;
|
||||
}
|
||||
inline ~Rectangle()
|
||||
{
|
||||
instanceCount--;
|
||||
}
|
||||
|
||||
int area();
|
||||
};
|
||||
|
||||
#endif
|
8
Kha/Backends/Kinc-hxcpp/khacpp/test/native/externs/RectangleImpl.cpp
Executable file
8
Kha/Backends/Kinc-hxcpp/khacpp/test/native/externs/RectangleImpl.cpp
Executable file
@ -0,0 +1,8 @@
|
||||
#include "RectangleDef.h"
|
||||
|
||||
int Rectangle::instanceCount = 0;
|
||||
|
||||
int Rectangle::area()
|
||||
{
|
||||
return width*height;
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package externs;
|
||||
|
||||
@:native("short *") @:unreflective
|
||||
extern class ShortPtr { }
|
Reference in New Issue
Block a user