Skip to content

Commit ffbfc63

Browse files
committed
Adapt headers for CGO.
1 parent 6627882 commit ffbfc63

8 files changed

+411
-784
lines changed

include/sciter-om-def.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@ typedef SBOOL(*som_any_prop_setter_t)(som_asset_t* thing, UINT64 propSymbol, con
2929
typedef SBOOL(*som_method_t)(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result);
3030
typedef void(*som_dispose_t)(som_asset_t* thing);
3131

32-
struct som_property_def_t {
32+
typedef struct som_property_def_t {
3333
void* reserved;
3434
som_atom_t name;
3535
som_prop_getter_t getter;
3636
som_prop_setter_t setter;
3737
#ifdef __cplusplus
3838
som_property_def_t(const char* n, som_prop_getter_t pg, som_prop_setter_t ps = nullptr) : name(SciterAtomValue(n)), getter(pg), setter(ps) {}
3939
#endif
40-
};
40+
} som_property_def_t;
4141

42-
struct som_method_def_t {
42+
typedef struct som_method_def_t {
4343
void* reserved;
4444
som_atom_t name;
4545
size_t params;
4646
som_method_t func;
4747
#ifdef __cplusplus
4848
som_method_def_t(const char* n, size_t p, som_method_t f) : name(SciterAtomValue(n)), params(p), func(f) {}
4949
#endif
50-
};
50+
} som_method_def_t;
5151

5252
enum som_passport_flags {
5353
SOM_SEALED_OBJECT = 0x00, // not extendable
@@ -56,7 +56,7 @@ enum som_passport_flags {
5656

5757
// definiton of object (the thing) access interface
5858
// this structure should be statically allocated - at least survive last instance of the engine
59-
struct som_passport_t {
59+
typedef struct som_passport_t {
6060
UINT64 flags;
6161
som_atom_t name; // class name
6262
const som_property_def_t* properties; size_t n_properties; // virtual property thunks
@@ -67,7 +67,7 @@ struct som_passport_t {
6767
// any property "inteceptors"
6868
som_any_prop_getter_t prop_getter; // var prop_val = thing.k;
6969
som_any_prop_setter_t prop_setter; // thing.k = prop_val;
70-
};
70+
} som_passport_t;
7171

7272
#ifdef CPP11
7373

@@ -533,7 +533,7 @@ namespace sciter {
533533
};
534534

535535
template <class Type> struct prop_get_accessor;
536-
536+
537537

538538
// bool get_any_prop(const std::string& name, TV& val);
539539
template <class Type, class TV>

include/sciter-om.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@
55

66

77
struct som_passport_t;
8+
struct som_asset_class_t;
89

910
typedef UINT64 som_atom_t;
1011

11-
struct som_asset_t;
12+
typedef struct som_asset_t {
13+
struct som_asset_class_t* isa;
14+
} som_asset_t;
1215

13-
struct som_asset_class_t {
16+
typedef struct som_asset_class_t {
1417
long(*asset_add_ref)(som_asset_t* thing);
1518
long(*asset_release)(som_asset_t* thing);
1619
long(*asset_get_interface)(som_asset_t* thing, const char* name, void** out);
17-
som_passport_t* (*asset_get_passport)(som_asset_t* thing);
18-
};
20+
struct som_passport_t* (*asset_get_passport)(som_asset_t* thing);
21+
} som_asset_class_t;
1922

20-
struct som_asset_t {
21-
som_asset_class_t* isa;
22-
};
2323

2424
inline som_asset_class_t* som_asset_get_class(const som_asset_t* pass)
2525
{
26-
return pass ? pass->isa : nullptr;
26+
return pass ? pass->isa : 0;
2727
}
2828

2929
som_atom_t SCAPI SciterAtomValue(const char* name);
@@ -49,7 +49,7 @@ namespace sciter {
4949
template <class R> class hasset;
5050

5151
// implementation of som_asset_t ISA
52-
// note: does not define asset_add_ref()/asset_release() as they shall be defined in specializations
52+
// note: does not define asset_add_ref()/asset_release() as they shall be defined in specializations
5353
template <class A>
5454
class iasset : public som_asset_t
5555
{
@@ -65,8 +65,8 @@ namespace sciter {
6565
if (out) { this->asset_add_ref(); *out = this; }
6666
return true;
6767
}
68-
virtual som_passport_t* asset_get_passport() const {
69-
return nullptr;
68+
virtual som_passport_t* asset_get_passport() const {
69+
return nullptr;
7070
}
7171

7272
static som_asset_class_t* get_asset_class() {
@@ -87,7 +87,7 @@ namespace sciter {
8787
static const char* interface_name() { return "asset.sciter.com"; }
8888
//template<class C> hasset<C> interface_of() { hasset<C> p; get_interface(C::interface_name(), p.target()); return p; }
8989
};
90-
90+
9191
inline long asset_add_ref(som_asset_t *ptr) {
9292
assert(ptr);
9393
assert(ptr->isa);
@@ -106,7 +106,7 @@ namespace sciter {
106106
assert(ptr->isa->asset_get_interface);
107107
return ptr->isa->asset_get_interface(ptr, name, out);
108108
}
109-
109+
110110
inline som_passport_t* asset_get_passport(som_asset_t *ptr) {
111111
assert(ptr);
112112
assert(ptr->isa);
@@ -118,7 +118,7 @@ namespace sciter {
118118
assert(ptr);
119119
return ptr->isa;
120120
}
121-
121+
122122
//hasset - yet another shared_ptr
123123
// R here is an entity derived from som_asset_t
124124
template <class R> class hasset
@@ -164,9 +164,9 @@ namespace sciter {
164164
void** target() { release(); return (void**)&p; }
165165

166166
};
167-
167+
168168
// reference counted asset, uses intrusive add_ref/release counter
169-
template<class C>
169+
template<class C>
170170
class asset : public iasset<asset<C>>
171171
{
172172
std::atomic<long> _ref_cntr;
@@ -215,4 +215,4 @@ namespace sciter {
215215

216216
#include "sciter-om-def.h"
217217

218-
#endif
218+
#endif

0 commit comments

Comments
 (0)