/
JSCValue.go
1614 lines (1303 loc) · 41.5 KB
/
JSCValue.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by girgen. DO NOT EDIT.
package javascriptcore
import (
"fmt"
"runtime"
"strings"
"unsafe"
"github.com/diamondburned/gotk4/pkg/core/gextras"
coreglib "github.com/diamondburned/gotk4/pkg/core/glib"
"github.com/diamondburned/gotk4/pkg/glib/v2"
)
// #include <stdlib.h>
// #include <glib-object.h>
// #include <jsc/jsc.h>
import "C"
// GType values.
var (
GTypeValue = coreglib.Type(C.jsc_value_get_type())
)
func init() {
coreglib.RegisterGValueMarshalers([]coreglib.TypeMarshaler{
coreglib.TypeMarshaler{T: GTypeValue, F: marshalValue},
})
}
// ValuePropertyFlags flags used when defining properties
// with jsc_value_object_define_property_data() and
// jsc_value_object_define_property_accessor().
type ValuePropertyFlags C.guint
const (
// ValuePropertyConfigurable: type of the property descriptor may be changed
// and the property may be deleted from the corresponding object.
ValuePropertyConfigurable ValuePropertyFlags = 0b1
// ValuePropertyEnumerable: property shows up during enumeration of the
// properties on the corresponding object.
ValuePropertyEnumerable ValuePropertyFlags = 0b10
// ValuePropertyWritable: value associated with the property may be changed
// with an assignment operator. This doesn't have any effect when passed to
// jsc_value_object_define_property_accessor().
ValuePropertyWritable ValuePropertyFlags = 0b100
)
// String returns the names in string for ValuePropertyFlags.
func (v ValuePropertyFlags) String() string {
if v == 0 {
return "ValuePropertyFlags(0)"
}
var builder strings.Builder
builder.Grow(71)
for v != 0 {
next := v & (v - 1)
bit := v - next
switch bit {
case ValuePropertyConfigurable:
builder.WriteString("Configurable|")
case ValuePropertyEnumerable:
builder.WriteString("Enumerable|")
case ValuePropertyWritable:
builder.WriteString("Writable|")
default:
builder.WriteString(fmt.Sprintf("ValuePropertyFlags(0b%b)|", bit))
}
v = next
}
return strings.TrimSuffix(builder.String(), "|")
}
// Has returns true if v contains other.
func (v ValuePropertyFlags) Has(other ValuePropertyFlags) bool {
return (v & other) == other
}
// ValueOverrides contains methods that are overridable.
type ValueOverrides struct {
}
func defaultValueOverrides(v *Value) ValueOverrides {
return ValueOverrides{}
}
// Value represents a reference to a value in a CContext. The JSCValue protects
// the referenced value from being garbage collected.
type Value struct {
_ [0]func() // equal guard
*coreglib.Object
}
var (
_ coreglib.Objector = (*Value)(nil)
)
func init() {
coreglib.RegisterClassInfo[*Value, *ValueClass, ValueOverrides](
GTypeValue,
initValueClass,
wrapValue,
defaultValueOverrides,
)
}
func initValueClass(gclass unsafe.Pointer, overrides ValueOverrides, classInitFunc func(*ValueClass)) {
if classInitFunc != nil {
class := (*ValueClass)(gextras.NewStructNative(gclass))
classInitFunc(class)
}
}
func wrapValue(obj *coreglib.Object) *Value {
return &Value{
Object: obj,
}
}
func marshalValue(p uintptr) (interface{}, error) {
return wrapValue(coreglib.ValueFromNative(unsafe.Pointer(p)).Object()), nil
}
// NewValueArrayFromStrv: create a new CValue referencing an array of strings
// with the items from strv. If array is NULL or empty a new empty array will be
// created.
//
// The function takes the following parameters:
//
// - context: CContext.
// - strv: NULL-terminated array of strings.
//
// The function returns the following values:
//
// - value: CValue.
//
func NewValueArrayFromStrv(context *Context, strv []string) *Value {
var _arg1 *C.JSCContext // out
var _arg2 **C.char // out
var _cret *C.JSCValue // in
_arg1 = (*C.JSCContext)(unsafe.Pointer(coreglib.InternObject(context).Native()))
{
_arg2 = (**C.char)(C.calloc(C.size_t((len(strv) + 1)), C.size_t(unsafe.Sizeof(uint(0)))))
defer C.free(unsafe.Pointer(_arg2))
{
out := unsafe.Slice(_arg2, len(strv)+1)
var zero *C.char
out[len(strv)] = zero
for i := range strv {
out[i] = (*C.char)(unsafe.Pointer(C.CString(strv[i])))
defer C.free(unsafe.Pointer(out[i]))
}
}
}
_cret = C.jsc_value_new_array_from_strv(_arg1, _arg2)
runtime.KeepAlive(context)
runtime.KeepAlive(strv)
var _value *Value // out
_value = wrapValue(coreglib.AssumeOwnership(unsafe.Pointer(_cret)))
return _value
}
// NewValueBoolean: create a new CValue from value.
//
// The function takes the following parameters:
//
// - context: CContext.
// - value: #gboolean.
//
// The function returns the following values:
//
// - ret: CValue.
//
func NewValueBoolean(context *Context, value bool) *Value {
var _arg1 *C.JSCContext // out
var _arg2 C.gboolean // out
var _cret *C.JSCValue // in
_arg1 = (*C.JSCContext)(unsafe.Pointer(coreglib.InternObject(context).Native()))
if value {
_arg2 = C.TRUE
}
_cret = C.jsc_value_new_boolean(_arg1, _arg2)
runtime.KeepAlive(context)
runtime.KeepAlive(value)
var _ret *Value // out
_ret = wrapValue(coreglib.AssumeOwnership(unsafe.Pointer(_cret)))
return _ret
}
// NewValueFromJson: create a new CValue referencing a new value created by
// parsing json.
//
// The function takes the following parameters:
//
// - context: CContext.
// - json: JSON string to be parsed.
//
// The function returns the following values:
//
// - value: CValue.
//
func NewValueFromJson(context *Context, json string) *Value {
var _arg1 *C.JSCContext // out
var _arg2 *C.char // out
var _cret *C.JSCValue // in
_arg1 = (*C.JSCContext)(unsafe.Pointer(coreglib.InternObject(context).Native()))
_arg2 = (*C.char)(unsafe.Pointer(C.CString(json)))
defer C.free(unsafe.Pointer(_arg2))
_cret = C.jsc_value_new_from_json(_arg1, _arg2)
runtime.KeepAlive(context)
runtime.KeepAlive(json)
var _value *Value // out
_value = wrapValue(coreglib.AssumeOwnership(unsafe.Pointer(_cret)))
return _value
}
// NewValueNull: create a new CValue referencing <function>null</function> in
// context.
//
// The function takes the following parameters:
//
// - context: CContext.
//
// The function returns the following values:
//
// - value: CValue.
//
func NewValueNull(context *Context) *Value {
var _arg1 *C.JSCContext // out
var _cret *C.JSCValue // in
_arg1 = (*C.JSCContext)(unsafe.Pointer(coreglib.InternObject(context).Native()))
_cret = C.jsc_value_new_null(_arg1)
runtime.KeepAlive(context)
var _value *Value // out
_value = wrapValue(coreglib.AssumeOwnership(unsafe.Pointer(_cret)))
return _value
}
// NewValueNumber: create a new CValue from number.
//
// The function takes the following parameters:
//
// - context: CContext.
// - number: number.
//
// The function returns the following values:
//
// - value: CValue.
//
func NewValueNumber(context *Context, number float64) *Value {
var _arg1 *C.JSCContext // out
var _arg2 C.double // out
var _cret *C.JSCValue // in
_arg1 = (*C.JSCContext)(unsafe.Pointer(coreglib.InternObject(context).Native()))
_arg2 = C.double(number)
_cret = C.jsc_value_new_number(_arg1, _arg2)
runtime.KeepAlive(context)
runtime.KeepAlive(number)
var _value *Value // out
_value = wrapValue(coreglib.AssumeOwnership(unsafe.Pointer(_cret)))
return _value
}
// NewValueObject: create a new CValue from instance. If instance is NULL a
// new empty object is created. When instance is provided, jsc_class must be
// provided too. jsc_class takes ownership of instance that will be freed by the
// Notify passed to jsc_context_register_class().
//
// The function takes the following parameters:
//
// - context: CContext.
// - instance (optional): object instance or NULL.
// - jscClass (optional) of instance.
//
// The function returns the following values:
//
// - value: CValue.
//
func NewValueObject(context *Context, instance unsafe.Pointer, jscClass *Class) *Value {
var _arg1 *C.JSCContext // out
var _arg2 C.gpointer // out
var _arg3 *C.JSCClass // out
var _cret *C.JSCValue // in
_arg1 = (*C.JSCContext)(unsafe.Pointer(coreglib.InternObject(context).Native()))
_arg2 = (C.gpointer)(unsafe.Pointer(instance))
if jscClass != nil {
_arg3 = (*C.JSCClass)(unsafe.Pointer(coreglib.InternObject(jscClass).Native()))
}
_cret = C.jsc_value_new_object(_arg1, _arg2, _arg3)
runtime.KeepAlive(context)
runtime.KeepAlive(instance)
runtime.KeepAlive(jscClass)
var _value *Value // out
_value = wrapValue(coreglib.AssumeOwnership(unsafe.Pointer(_cret)))
return _value
}
// NewValueString: create a new CValue from string. If you need to
// create a CValue from a string containing null characters, use
// jsc_value_new_string_from_bytes() instead.
//
// The function takes the following parameters:
//
// - context: CContext.
// - str (optional): null-terminated string.
//
// The function returns the following values:
//
// - value: CValue.
//
func NewValueString(context *Context, str string) *Value {
var _arg1 *C.JSCContext // out
var _arg2 *C.char // out
var _cret *C.JSCValue // in
_arg1 = (*C.JSCContext)(unsafe.Pointer(coreglib.InternObject(context).Native()))
if str != "" {
_arg2 = (*C.char)(unsafe.Pointer(C.CString(str)))
defer C.free(unsafe.Pointer(_arg2))
}
_cret = C.jsc_value_new_string(_arg1, _arg2)
runtime.KeepAlive(context)
runtime.KeepAlive(str)
var _value *Value // out
_value = wrapValue(coreglib.AssumeOwnership(unsafe.Pointer(_cret)))
return _value
}
// NewValueStringFromBytes: create a new CValue from bytes.
//
// The function takes the following parameters:
//
// - context: CContext.
// - bytes (optional): #GBytes.
//
// The function returns the following values:
//
// - value: CValue.
//
func NewValueStringFromBytes(context *Context, bytes *glib.Bytes) *Value {
var _arg1 *C.JSCContext // out
var _arg2 *C.GBytes // out
var _cret *C.JSCValue // in
_arg1 = (*C.JSCContext)(unsafe.Pointer(coreglib.InternObject(context).Native()))
if bytes != nil {
_arg2 = (*C.GBytes)(gextras.StructNative(unsafe.Pointer(bytes)))
}
_cret = C.jsc_value_new_string_from_bytes(_arg1, _arg2)
runtime.KeepAlive(context)
runtime.KeepAlive(bytes)
var _value *Value // out
_value = wrapValue(coreglib.AssumeOwnership(unsafe.Pointer(_cret)))
return _value
}
// NewValueTypedArray: create a new typed array containing a given amount of
// elements.
//
// Create a CValue referencing a new typed array with space for length elements
// of a given type. As all typed arrays must have an associated ArrayBuffer,
// a new one of suitable size will be allocated to store the elements, which
// will be initialized to zero.
//
// The type must *not* be JSC_TYPED_ARRAY_NONE.
//
// The function takes the following parameters:
//
// - context: CContext.
// - typ: type of array elements.
// - length: number of elements in the array.
//
// The function returns the following values:
//
// - value: CValue.
//
func NewValueTypedArray(context *Context, typ TypedArrayType, length uint) *Value {
var _arg1 *C.JSCContext // out
var _arg2 C.JSCTypedArrayType // out
var _arg3 C.gsize // out
var _cret *C.JSCValue // in
_arg1 = (*C.JSCContext)(unsafe.Pointer(coreglib.InternObject(context).Native()))
_arg2 = C.JSCTypedArrayType(typ)
_arg3 = C.gsize(length)
_cret = C.jsc_value_new_typed_array(_arg1, _arg2, _arg3)
runtime.KeepAlive(context)
runtime.KeepAlive(typ)
runtime.KeepAlive(length)
var _value *Value // out
_value = wrapValue(coreglib.AssumeOwnership(unsafe.Pointer(_cret)))
return _value
}
// NewValueUndefined: create a new CValue referencing
// <function>undefined</function> in context.
//
// The function takes the following parameters:
//
// - context: CContext.
//
// The function returns the following values:
//
// - value: CValue.
//
func NewValueUndefined(context *Context) *Value {
var _arg1 *C.JSCContext // out
var _cret *C.JSCValue // in
_arg1 = (*C.JSCContext)(unsafe.Pointer(coreglib.InternObject(context).Native()))
_cret = C.jsc_value_new_undefined(_arg1)
runtime.KeepAlive(context)
var _value *Value // out
_value = wrapValue(coreglib.AssumeOwnership(unsafe.Pointer(_cret)))
return _value
}
// ArrayBufferGetData gets a pointer to memory that contains the array buffer
// data.
//
// Obtains a pointer to the memory region that holds the contents of the
// ArrayBuffer; modifications done to the data will be visible to JavaScript
// code. If size is not NULL, the size in bytes of the memory region will also
// be stored in the pointed location.
//
// Note that the pointer returned by this function is not guaranteed to remain
// the same after calls to other JSC API functions. If you plan to access the
// data of the ArrayBuffer later, you can keep a reference to the value and
// obtain the data pointer at a later point. Keep in mind that if JavaScript
// code has a chance to run, for example due to main loop events that result in
// JSC being called, the contents of the memory region might be modified in the
// meantime. Consider taking a copy of the data and using the copy instead in
// asynchronous code.
//
// The function takes the following parameters:
//
// - size (optional): location where to store the size of the memory region.
//
// The function returns the following values:
//
// - gpointer (optional): pointer to memory.
//
func (value *Value) ArrayBufferGetData(size *uint) unsafe.Pointer {
var _arg0 *C.JSCValue // out
var _arg1 *C.gsize // out
var _cret C.gpointer // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
if size != nil {
_arg1 = (*C.gsize)(unsafe.Pointer(size))
}
_cret = C.jsc_value_array_buffer_get_data(_arg0, _arg1)
runtime.KeepAlive(value)
runtime.KeepAlive(size)
var _gpointer unsafe.Pointer // out
_gpointer = (unsafe.Pointer)(unsafe.Pointer(_cret))
return _gpointer
}
// ArrayBufferGetSize gets the size in bytes of the array buffer.
//
// Obtains the size in bytes of the memory region that holds the contents of an
// ArrayBuffer.
//
// The function returns the following values:
//
// - gsize: size, in bytes.
//
func (value *Value) ArrayBufferGetSize() uint {
var _arg0 *C.JSCValue // out
var _cret C.gsize // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
_cret = C.jsc_value_array_buffer_get_size(_arg0)
runtime.KeepAlive(value)
var _gsize uint // out
_gsize = uint(_cret)
return _gsize
}
// ConstructorCall: invoke <function>new</function> with constructor referenced
// by value. If n_parameters is 0 no parameters will be passed to the
// constructor.
//
// The function takes the following parameters:
//
// - parameters (optional) -->s to pass as parameters to the constructor,
// or NULL.
//
// The function returns the following values:
//
// - ret referencing the newly created object instance.
//
func (value *Value) ConstructorCall(parameters []*Value) *Value {
var _arg0 *C.JSCValue // out
var _arg2 **C.JSCValue // out
var _arg1 C.guint
var _cret *C.JSCValue // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
if parameters != nil {
_arg1 = (C.guint)(len(parameters))
_arg2 = (**C.JSCValue)(C.calloc(C.size_t(len(parameters)), C.size_t(unsafe.Sizeof(uint(0)))))
defer C.free(unsafe.Pointer(_arg2))
{
out := unsafe.Slice((**C.JSCValue)(_arg2), len(parameters))
for i := range parameters {
out[i] = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(parameters[i]).Native()))
}
}
}
_cret = C.jsc_value_constructor_callv(_arg0, _arg1, _arg2)
runtime.KeepAlive(value)
runtime.KeepAlive(parameters)
var _ret *Value // out
_ret = wrapValue(coreglib.AssumeOwnership(unsafe.Pointer(_cret)))
return _ret
}
// FunctionCall: call function referenced by value, passing the given
// parameters. If n_parameters is 0 no parameters will be passed to the
// function.
//
// This function always returns a CValue, in case of void functions a CValue
// referencing <function>undefined</function> is returned.
//
// The function takes the following parameters:
//
// - parameters (optional) -->s to pass as parameters to the function,
// or NULL.
//
// The function returns the following values:
//
// - ret with the return value of the function.
//
func (value *Value) FunctionCall(parameters []*Value) *Value {
var _arg0 *C.JSCValue // out
var _arg2 **C.JSCValue // out
var _arg1 C.guint
var _cret *C.JSCValue // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
if parameters != nil {
_arg1 = (C.guint)(len(parameters))
_arg2 = (**C.JSCValue)(C.calloc(C.size_t(len(parameters)), C.size_t(unsafe.Sizeof(uint(0)))))
defer C.free(unsafe.Pointer(_arg2))
{
out := unsafe.Slice((**C.JSCValue)(_arg2), len(parameters))
for i := range parameters {
out[i] = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(parameters[i]).Native()))
}
}
}
_cret = C.jsc_value_function_callv(_arg0, _arg1, _arg2)
runtime.KeepAlive(value)
runtime.KeepAlive(parameters)
var _ret *Value // out
_ret = wrapValue(coreglib.AssumeOwnership(unsafe.Pointer(_cret)))
return _ret
}
// Context: get the CContext in which value was created.
//
// The function returns the following values:
//
// - context: CValue context.
//
func (value *Value) Context() *Context {
var _arg0 *C.JSCValue // out
var _cret *C.JSCContext // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
_cret = C.jsc_value_get_context(_arg0)
runtime.KeepAlive(value)
var _context *Context // out
_context = wrapContext(coreglib.Take(unsafe.Pointer(_cret)))
return _context
}
// IsArray: get whether the value referenced by value is an array.
//
// The function returns the following values:
//
// - ok: whether the value is an array.
//
func (value *Value) IsArray() bool {
var _arg0 *C.JSCValue // out
var _cret C.gboolean // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
_cret = C.jsc_value_is_array(_arg0)
runtime.KeepAlive(value)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// IsArrayBuffer: check whether the value is an ArrayBuffer.
//
// The function returns the following values:
//
// - ok: whether the value is an ArrayBuffer.
//
func (value *Value) IsArrayBuffer() bool {
var _arg0 *C.JSCValue // out
var _cret C.gboolean // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
_cret = C.jsc_value_is_array_buffer(_arg0)
runtime.KeepAlive(value)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// IsBoolean: get whether the value referenced by value is a boolean.
//
// The function returns the following values:
//
// - ok: whether the value is a boolean.
//
func (value *Value) IsBoolean() bool {
var _arg0 *C.JSCValue // out
var _cret C.gboolean // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
_cret = C.jsc_value_is_boolean(_arg0)
runtime.KeepAlive(value)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// IsConstructor: get whether the value referenced by value is a constructor.
//
// The function returns the following values:
//
// - ok: whether the value is a constructor.
//
func (value *Value) IsConstructor() bool {
var _arg0 *C.JSCValue // out
var _cret C.gboolean // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
_cret = C.jsc_value_is_constructor(_arg0)
runtime.KeepAlive(value)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// IsFunction: get whether the value referenced by value is a function.
//
// The function returns the following values:
//
// - ok: whether the value is a function.
//
func (value *Value) IsFunction() bool {
var _arg0 *C.JSCValue // out
var _cret C.gboolean // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
_cret = C.jsc_value_is_function(_arg0)
runtime.KeepAlive(value)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// IsNull: get whether the value referenced by value is
// <function>null</function>.
//
// The function returns the following values:
//
// - ok: whether the value is null.
//
func (value *Value) IsNull() bool {
var _arg0 *C.JSCValue // out
var _cret C.gboolean // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
_cret = C.jsc_value_is_null(_arg0)
runtime.KeepAlive(value)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// IsNumber: get whether the value referenced by value is a number.
//
// The function returns the following values:
//
// - ok: whether the value is a number.
//
func (value *Value) IsNumber() bool {
var _arg0 *C.JSCValue // out
var _cret C.gboolean // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
_cret = C.jsc_value_is_number(_arg0)
runtime.KeepAlive(value)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// IsObject: get whether the value referenced by value is an object.
//
// The function returns the following values:
//
// - ok: whether the value is an object.
//
func (value *Value) IsObject() bool {
var _arg0 *C.JSCValue // out
var _cret C.gboolean // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
_cret = C.jsc_value_is_object(_arg0)
runtime.KeepAlive(value)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// IsString: get whether the value referenced by value is a string.
//
// The function returns the following values:
//
// - ok: whether the value is a string.
//
func (value *Value) IsString() bool {
var _arg0 *C.JSCValue // out
var _cret C.gboolean // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
_cret = C.jsc_value_is_string(_arg0)
runtime.KeepAlive(value)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// IsTypedArray determines whether a value is a typed array.
//
// The function returns the following values:
//
// - ok: whether value is a typed array.
//
func (value *Value) IsTypedArray() bool {
var _arg0 *C.JSCValue // out
var _cret C.gboolean // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
_cret = C.jsc_value_is_typed_array(_arg0)
runtime.KeepAlive(value)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// IsUndefined: get whether the value referenced by value is
// <function>undefined</function>.
//
// The function returns the following values:
//
// - ok: whether the value is undefined.
//
func (value *Value) IsUndefined() bool {
var _arg0 *C.JSCValue // out
var _cret C.gboolean // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
_cret = C.jsc_value_is_undefined(_arg0)
runtime.KeepAlive(value)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// NewTypedArrayWithBuffer: create a new typed array value with elements from an
// array buffer.
//
// Create a CValue referencing a new typed array value containing elements
// of the given type, where the elements are stored at the memory region
// represented by the array_buffer.
//
// The type must *not* be JSC_TYPED_ARRAY_NONE.
//
// The offset and length parameters can be used to indicate which part of the
// array buffer can be accessed through the typed array. If both are omitted
// (passing zero as offset, and -1 as length), the whole array_buffer is exposed
// through the typed array. Omitting the length with a non-zero offset will
// expose the remainder of the array_buffer starting at the indicated offset.
//
// The function takes the following parameters:
//
// - typ: type of array elements.
// - offset: offset, in bytes.
// - length: number of array elements, or -1.
//
// The function returns the following values:
//
// - value: CValue.
//
func (arrayBuffer *Value) NewTypedArrayWithBuffer(typ TypedArrayType, offset uint, length int) *Value {
var _arg0 *C.JSCValue // out
var _arg1 C.JSCTypedArrayType // out
var _arg2 C.gsize // out
var _arg3 C.gssize // out
var _cret *C.JSCValue // in
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(arrayBuffer).Native()))
_arg1 = C.JSCTypedArrayType(typ)
_arg2 = C.gsize(offset)
_arg3 = C.gssize(length)
_cret = C.jsc_value_new_typed_array_with_buffer(_arg0, _arg1, _arg2, _arg3)
runtime.KeepAlive(arrayBuffer)
runtime.KeepAlive(typ)
runtime.KeepAlive(offset)
runtime.KeepAlive(length)
var _value *Value // out
_value = wrapValue(coreglib.AssumeOwnership(unsafe.Pointer(_cret)))
return _value
}
// ObjectDefinePropertyData: define or modify a property with property_name
// in object referenced by value. This is equivalent to JavaScript
// <function>Object.defineProperty()</function> when used with a data
// descriptor.
//
// The function takes the following parameters:
//
// - propertyName: name of the property to define.
// - flags: CValuePropertyFlags.
// - propertyValue (optional): default property value.
//
func (value *Value) ObjectDefinePropertyData(propertyName string, flags ValuePropertyFlags, propertyValue *Value) {
var _arg0 *C.JSCValue // out
var _arg1 *C.char // out
var _arg2 C.JSCValuePropertyFlags // out
var _arg3 *C.JSCValue // out
_arg0 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(value).Native()))
_arg1 = (*C.char)(unsafe.Pointer(C.CString(propertyName)))
defer C.free(unsafe.Pointer(_arg1))
_arg2 = C.JSCValuePropertyFlags(flags)
if propertyValue != nil {
_arg3 = (*C.JSCValue)(unsafe.Pointer(coreglib.InternObject(propertyValue).Native()))
}
C.jsc_value_object_define_property_data(_arg0, _arg1, _arg2, _arg3)
runtime.KeepAlive(value)
runtime.KeepAlive(propertyName)
runtime.KeepAlive(flags)
runtime.KeepAlive(propertyValue)
}
// ObjectDeleteProperty: try to delete property with name from value.