Skip to content

Commit 46d0494

Browse files
authored
Update to Sciter 4.4.7.0+ (#1)
Co-authored-by: Dmitriy Seregin <d.seregin@adguard.com>
1 parent a04e052 commit 46d0494

23 files changed

+1145
-925
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Go bindings for Sciter
22

3-
[![Build status](https://ci.appveyor.com/api/projects/status/rphv883klffw9em9/branch/master?svg=true)](https://ci.appveyor.com/project/pravic/go-sciter)
4-
[![Build Status](https://img.shields.io/travis/sciter-sdk/go-sciter/master.svg)](https://travis-ci.org/sciter-sdk/go-sciter)
3+
[![AppVeyor status](https://ci.appveyor.com/api/projects/status/rphv883klffw9em9/branch/master?svg=true)](https://ci.appveyor.com/project/pravic/go-sciter)
4+
[![Travis Status](https://travis-ci.com/sciter-sdk/go-sciter.svg?branch=master)](https://travis-ci.com/sciter-sdk/go-sciter)
55
[![License](https://img.shields.io/github/license/sciter-sdk/go-sciter.svg)](https://github.com/sciter-sdk/go-sciter)
66
[![Join the forums at https://sciter.com/forums](https://img.shields.io/badge/forum-sciter.com-orange.svg)](https://sciter.com/forums)
77

callbacks.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "sciter-x.h"
22
#include "_cgo_export.h"
33

4-
// typedef BOOL SC_CALLBACK SciterElementCallback(HELEMENT he, LPVOID param);
4+
// typedef SBOOL SC_CALLBACK SciterElementCallback(HELEMENT he, LPVOID param);
55

6-
BOOL SC_CALLBACK SciterElementCallback_cgo(HELEMENT he, LPVOID param)
6+
SBOOL SC_CALLBACK SciterElementCallback_cgo(HELEMENT he, LPVOID param)
77
{
88
return goSciterElementCallback(he, param);
99
}
@@ -26,8 +26,8 @@ VOID SC_CALLBACK LPCSTR_RECEIVER_cgo(LPCSTR str, UINT str_length, LPVOID param)
2626
goLPCSTR_RECEIVER(str, str_length, param);
2727
}
2828

29-
// typedef BOOL SC_CALLBACK ElementEventProc(LPVOID tag, HELEMENT he, UINT evtg, LPVOID prms);
30-
BOOL SC_CALLBACK ElementEventProc_cgo(LPVOID tag, HELEMENT he, UINT evtg, LPVOID prms)
29+
// typedef SBOOL SC_CALLBACK ElementEventProc(LPVOID tag, HELEMENT he, UINT evtg, LPVOID prms);
30+
SBOOL SC_CALLBACK ElementEventProc_cgo(LPVOID tag, HELEMENT he, UINT evtg, LPVOID prms)
3131
{
3232
return goElementEventProc(tag, he, evtg, prms);
3333
}
@@ -57,9 +57,9 @@ INT SC_CALLBACK ELEMENT_COMPARATOR_cgo(HELEMENT he1, HELEMENT he2, LPVOID param)
5757
return goELEMENT_COMPARATOR(he1, he2, param);
5858
}
5959

60-
// typedef BOOL SC_CALLBACK KeyValueCallback(LPVOID param, const VALUE* pkey, const VALUE* pval);
60+
// typedef SBOOL SC_CALLBACK KeyValueCallback(LPVOID param, const VALUE* pkey, const VALUE* pval);
6161

62-
BOOL SC_CALLBACK KeyValueCallback_cgo(LPVOID param, const VALUE* pkey, const VALUE* pval)
62+
SBOOL SC_CALLBACK KeyValueCallback_cgo(LPVOID param, const VALUE* pkey, const VALUE* pval)
6363
{
6464
return goKeyValueCallback(param, (VALUE*)pkey, (VALUE*)pval);
6565
}

examples/callback/callback.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"log"
55
"path/filepath"
6-
6+
77
"github.com/sciter-sdk/go-sciter"
88
"github.com/sciter-sdk/go-sciter/window"
99
)

examples/demoes/01/demo1.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"log"
55
"path/filepath"
6-
6+
77
"github.com/sciter-sdk/go-sciter"
88
"github.com/sciter-sdk/go-sciter/window"
99
)

examples/demoes/05/demo5.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"log"
55
"path/filepath"
6-
6+
77
"github.com/sciter-sdk/go-sciter"
88
"github.com/sciter-sdk/go-sciter/window"
99
)

examples/handlers/handlers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"flag"
55
"log"
66
"path/filepath"
7-
7+
88
"github.com/sciter-sdk/go-sciter"
99
"github.com/sciter-sdk/go-sciter/rice"
1010
"github.com/sciter-sdk/go-sciter/window"

examples/textHtml/textHtml.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const (
2424
</form>
2525
</div>
2626
<div id="output">
27-
27+
2828
</div>
2929
</body>
3030
</html>

include/sciter-om-def.h

Lines changed: 197 additions & 60 deletions
Large diffs are not rendered by default.

include/sciter-om.h

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,55 @@
11
#pragma once
22

3-
#include <string.h>
4-
#include <assert.h>
3+
#ifndef __SCITER_OM_H__
4+
#define __SCITER_OM_H__
5+
56

67
struct som_passport_t;
8+
struct som_asset_class_t;
79

810
typedef UINT64 som_atom_t;
911

10-
11-
struct som_asset_class_t;
12-
1312
typedef struct som_asset_t {
1413
struct som_asset_class_t* isa;
1514
} som_asset_t;
1615

17-
struct som_asset_class_t {
16+
typedef struct som_asset_class_t {
1817
long(*asset_add_ref)(som_asset_t* thing);
1918
long(*asset_release)(som_asset_t* thing);
2019
long(*asset_get_interface)(som_asset_t* thing, const char* name, void** out);
2120
struct som_passport_t* (*asset_get_passport)(som_asset_t* thing);
22-
};
21+
} som_asset_class_t;
2322

2423

24+
inline som_asset_class_t* som_asset_get_class(const som_asset_t* pass)
25+
{
26+
return pass ? pass->isa : 0;
27+
}
28+
29+
som_atom_t SCAPI SciterAtomValue(const char* name);
30+
2531
#ifdef CPP11
2632

33+
#include <cstring>
34+
#include <cassert>
2735
#include <atomic>
2836

2937
namespace sciter {
3038

39+
class atom {
40+
som_atom_t _atom;
41+
public:
42+
atom(const char* name) { _atom = SciterAtomValue(name); }
43+
atom(const atom& other) { _atom = other._atom; }
44+
operator som_atom_t() const { return _atom; }
45+
};
46+
3147
namespace om {
3248

3349
template <class R> class hasset;
3450

51+
// implementation of som_asset_t ISA
52+
// note: does not define asset_add_ref()/asset_release() as they shall be defined in specializations
3553
template <class A>
3654
class iasset : public som_asset_t
3755
{
@@ -70,7 +88,6 @@ namespace sciter {
7088
//template<class C> hasset<C> interface_of() { hasset<C> p; get_interface(C::interface_name(), p.target()); return p; }
7189
};
7290

73-
7491
inline long asset_add_ref(som_asset_t *ptr) {
7592
assert(ptr);
7693
assert(ptr->isa);
@@ -97,8 +114,13 @@ namespace sciter {
97114
return ptr->isa->asset_get_passport(ptr);
98115
}
99116

117+
inline som_asset_class_t* asset_get_class(som_asset_t *ptr) {
118+
assert(ptr);
119+
return ptr->isa;
120+
}
121+
100122
//hasset - yet another shared_ptr
101-
// R here is something derived from the iasset (om::iasset) above
123+
// R here is an entity derived from som_asset_t
102124
template <class R> class hasset
103125
{
104126
protected:
@@ -108,10 +130,10 @@ namespace sciter {
108130
typedef R asset_t;
109131

110132
hasset() :p(nullptr) {}
111-
hasset(R* lp) :p(nullptr) { if (lp) (p = lp)->asset_add_ref(); }
112-
hasset(const hasset<R>& cp) :p(nullptr) { if (cp.p) (p = cp.p)->asset_add_ref(); }
133+
hasset(R* lp) :p(nullptr) { if (lp) asset_add_ref(p = lp); }
134+
hasset(const hasset<R>& cp) :p(nullptr) { if (cp.p) asset_add_ref(p = cp.p); }
113135

114-
~hasset() { if (p) p->asset_release(); }
136+
~hasset() { if (p) asset_release(p); }
115137
operator R*() const { return p; }
116138
R* operator->() const { assert(p != 0); return p; }
117139

@@ -121,7 +143,7 @@ namespace sciter {
121143
bool operator==(R* pR) const { return p == pR; }
122144

123145
// release the interface and set it to NULL
124-
void release() { if (p) { R* pt = p; p = 0; pt->asset_release(); } }
146+
void release() { if (p) { R* pt = p; p = 0; asset_release(pt); } }
125147

126148
// attach to an existing interface (does not AddRef)
127149
void attach(R* p2) { asset_release(p); p = p2; }
@@ -130,8 +152,8 @@ namespace sciter {
130152

131153
static R* assign(R* &pp, R* lp)
132154
{
133-
if (lp != 0) lp->asset_add_ref();
134-
if (pp) pp->asset_release();
155+
if (lp != 0) asset_add_ref(lp);
156+
if (pp) asset_release(pp);
135157
pp = lp;
136158
return lp;
137159
}
@@ -143,10 +165,8 @@ namespace sciter {
143165

144166
};
145167

146-
147-
// intrusive add_ref/release counter
148-
149-
template<class C>
168+
// reference counted asset, uses intrusive add_ref/release counter
169+
template<class C>
150170
class asset : public iasset<asset<C>>
151171
{
152172
std::atomic<long> _ref_cntr;
@@ -179,11 +199,20 @@ namespace sciter {
179199
delete static_cast<C*>(this);
180200
}
181201
};
202+
}
182203

183-
204+
template <class AT>
205+
inline AT* value::get_asset() const {
206+
som_asset_t* pass = get_asset();
207+
if (pass && (som_asset_get_class(pass) == AT::get_asset_class()))
208+
return static_cast<AT*>(pass);
209+
return nullptr;
184210
}
211+
185212
}
186213

187214
#endif
188215

189216
#include "sciter-om-def.h"
217+
218+
#endif

0 commit comments

Comments
 (0)