-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpropmacros.h
79 lines (79 loc) · 1.64 KB
/
propmacros.h
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
/*
* propmacros.h
*
* Define macros for setting or getting TJS property or object
* Copyright (C) 2018-2019 khjxiaogu
*
* Author: khjxiaogu
* Web: http://www.khjxiaogu.com
*/
#pragma once
#include <windows.h>
#include "tp_stub.h"
#ifndef MACROS
#define MACROS
#define GETSTR(a) tTJSVariant(a).GetString()
#define CONSTRUCTOR Factory(&Class::Factory)
#define NATIVECLASS(a) NCB_REGISTER_CLASS(a)
#define FUNCTION(a) RawCallback(#a, &Class::##a, 0)
template<class T>
T *alloc(int count=1) {
return new T[count];
}
//put object to object
void PutToObject(const wchar_t* name, iTJSDispatch2* data, iTJSDispatch2* inst) {
tTJSVariant i(data);
inst->PropSet(
TJS_MEMBERENSURE,
name,
NULL,
&i,
inst
);
data->Release();
}
//put object to object by num
void PutToObject(int name, iTJSDispatch2* data, iTJSDispatch2* inst) {
tTJSVariant i(data);
inst->PropSetByNum(
TJS_MEMBERENSURE,
(tjs_int)name,
&i,
inst
);
data->Release();
}
//put most type into object by name
template<class T>
void PutToObject(const wchar_t * name, T data, iTJSDispatch2 * inst) {
tTJSVariant i(data);
inst->PropSet(
TJS_MEMBERENSURE,
name,
NULL,
&i,
inst
);
}
//put most type into object by num
template<class T>
void PutToObject(int name, T data, iTJSDispatch2 * inst) {
tTJSVariant i(data);
inst->PropSetByNum(
TJS_MEMBERENSURE,
(tjs_int)name,
&i,
inst
);
}
tTJSVariant getMember(iTJSDispatch2* dic, tjs_char* key) {
tTJSVariant r;
dic->PropGet(TJS_MEMBERENSURE, key, NULL, &r, dic);
return r;
}
tTJSVariant getMember(iTJSDispatch2* dic, tjs_int key) {
tTJSVariant r;
dic->PropGetByNum(TJS_MEMBERENSURE, key, &r, dic);
return r;
}
#endif