-
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: add DefineFunction & DefineProperty
- Loading branch information
Showing
9 changed files
with
543 additions
and
0 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,19 @@ | ||
namespace Hosihikari.VanillaScript.QuickJS.Types; | ||
|
||
/* C function definition */ | ||
public enum JscFunctionEnum | ||
{ | ||
Generic, | ||
GenericMagic, | ||
Constructor, | ||
ConstructorMagic, | ||
ConstructorOrFunc, | ||
ConstructorOrFuncMagic, | ||
F_F, | ||
F_F_F, | ||
Getter, | ||
Setter, | ||
GetterMagic, | ||
SetterMagic, | ||
IteratorNext, | ||
} |
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,107 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Hosihikari.VanillaScript.QuickJS.Types; | ||
|
||
//ref #L965 | ||
|
||
//typedef struct JSCFunctionListEntry | ||
[StructLayout(LayoutKind.Sequential)] | ||
internal unsafe ref struct JsCFunctionListEntry | ||
{ | ||
// const char* name; | ||
public byte* Name; | ||
|
||
// uint8_t prop_flags; | ||
public byte PropFlags; | ||
|
||
// uint8_t def_type; | ||
[MarshalAs(UnmanagedType.U1)] | ||
public byte DefType; | ||
|
||
// int16_t magic; | ||
public short Magic; | ||
public CFunctionListEntryUnion U; | ||
|
||
[StructLayout(LayoutKind.Explicit)] | ||
public ref struct CFunctionListEntryUnion | ||
{ | ||
// union { | ||
public ref struct Func | ||
{ | ||
// struct { | ||
// uint8_t length; /* XXX: should move outside union */ | ||
public byte length; | ||
|
||
// uint8_t cproto; /* XXX: should move outside union */ | ||
public byte cproto; | ||
|
||
// JSCFunctionType cfunc; | ||
public JsCFunctionType cfunc; | ||
// } func; | ||
} | ||
|
||
[FieldOffset(0)] | ||
public Func func; | ||
|
||
public ref struct GetSet | ||
{ | ||
// struct { | ||
// JSCFunctionType get; | ||
public JsCFunctionType get; | ||
|
||
// JSCFunctionType set; | ||
public JsCFunctionType set; | ||
// } getset; | ||
} | ||
|
||
[FieldOffset(0)] | ||
public GetSet getset; | ||
|
||
public ref struct Alias | ||
{ | ||
// struct { | ||
// const char* name; | ||
public byte* name; | ||
|
||
// int base; | ||
public int @base; | ||
// } alias; | ||
} | ||
|
||
[FieldOffset(0)] | ||
public Alias alias; | ||
|
||
public ref struct PropList | ||
{ | ||
// struct { | ||
// const struct JSCFunctionListEntry *tab; | ||
public JsCFunctionListEntry* tab; | ||
|
||
// int len; | ||
public int len; | ||
// } prop_list; | ||
} | ||
|
||
[FieldOffset(0)] | ||
public PropList prop_list; | ||
|
||
// const char* str; | ||
// int32_t i32; | ||
// int64_t i64; | ||
// double f64; | ||
|
||
[FieldOffset(0)] | ||
public nint str; | ||
|
||
[FieldOffset(0)] | ||
public int i32; | ||
|
||
[FieldOffset(0)] | ||
public long i64; | ||
|
||
[FieldOffset(0)] | ||
public double f64; | ||
// } u; | ||
} | ||
} |
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 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Hosihikari.VanillaScript.QuickJS.Types | ||
{ | ||
//ref #L925 | ||
[StructLayout(LayoutKind.Explicit)] | ||
public ref struct JsCFunctionType | ||
{ | ||
[FieldOffset(0)] | ||
public unsafe void* func; | ||
|
||
[FieldOffset(0)] | ||
public double fvalue; | ||
} | ||
|
||
//typedef union JSCFunctionType { | ||
// JSCFunction* generic; | ||
// JSValue(*generic_magic)(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv, int magic); | ||
// JSCFunction* constructor; | ||
// JSValue(*constructor_magic)(JSContext* ctx, JSValueConst new_target, int argc, JSValueConst* argv, int magic); | ||
// JSCFunction* constructor_or_func; | ||
// double (* f_f) (double); | ||
// double (* f_f_f) (double, double); | ||
// JSValue(*getter)(JSContext* ctx, JSValueConst this_val); | ||
// JSValue(*setter)(JSContext* ctx, JSValueConst this_val, JSValueConst val); | ||
// JSValue(*getter_magic)(JSContext* ctx, JSValueConst this_val, int magic); | ||
// JSValue(*setter_magic)(JSContext* ctx, JSValueConst this_val, JSValueConst val, int magic); | ||
// JSValue(*iterator_next)(JSContext* ctx, JSValueConst this_val, | ||
// int argc, JSValueConst* argv, int* pdone, int magic); | ||
//} JSCFunctionType; | ||
} |
Oops, something went wrong.