blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 3
264
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
85
| license_type
stringclasses 2
values | repo_name
stringlengths 5
140
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 905
values | visit_date
timestamp[us]date 2015-08-09 11:21:18
2023-09-06 10:45:07
| revision_date
timestamp[us]date 1997-09-14 05:04:47
2023-09-17 19:19:19
| committer_date
timestamp[us]date 1997-09-14 05:04:47
2023-09-06 06:22:19
| github_id
int64 3.89k
681M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us]date 2012-06-07 00:51:45
2023-09-14 21:58:39
⌀ | gha_created_at
timestamp[us]date 2008-03-27 23:40:48
2023-08-21 23:17:38
⌀ | gha_language
stringclasses 141
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
10.4M
| extension
stringclasses 115
values | content
stringlengths 3
10.4M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
158
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8509db00d5956419e156d9bd8eb3fd0b9d3fea63 | c776476e9d06b3779d744641e758ac3a2c15cddc | /examples/litmus/c/run-scripts/tmp_5/MP+dmb.sy+pos-[fr-rf]-addr-ctrlisb.c.cbmc.cpp | f65c54549fd285cf4ebe15e10d0d163e990ea5a4 | [] | no_license | ashutosh0gupta/llvm_bmc | aaac7961c723ba6f7ffd77a39559e0e52432eade | 0287c4fb180244e6b3c599a9902507f05c8a7234 | refs/heads/master | 2023-08-02T17:14:06.178723 | 2023-07-31T10:46:53 | 2023-07-31T10:46:53 | 143,100,825 | 3 | 4 | null | 2023-05-25T05:50:55 | 2018-08-01T03:47:00 | C++ | UTF-8 | C++ | false | false | 56,232 | cpp | // Global variabls:
// 0:vars:3
// 3:atom_1_X0_1:1
// 4:atom_1_X2_1:1
// 5:atom_1_X3_2:1
// 6:atom_1_X7_0:1
// Local global variabls:
// 0:thr0:1
// 1:thr1:1
// 2:thr2:1
#define ADDRSIZE 7
#define LOCALADDRSIZE 3
#define NTHREAD 4
#define NCONTEXT 5
#define ASSUME(stmt) __CPROVER_assume(stmt)
#define ASSERT(stmt) __CPROVER_assert(stmt, "error")
#define max(a,b) (a>b?a:b)
char __get_rng();
char get_rng( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
char get_rng_th( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
int main(int argc, char **argv) {
// Declare arrays for intial value version in contexts
int local_mem[LOCALADDRSIZE];
// Dumping initializations
local_mem[0+0] = 0;
local_mem[1+0] = 0;
local_mem[2+0] = 0;
int cstart[NTHREAD];
int creturn[NTHREAD];
// declare arrays for contexts activity
int active[NCONTEXT];
int ctx_used[NCONTEXT];
// declare arrays for intial value version in contexts
int meminit_[ADDRSIZE*NCONTEXT];
#define meminit(x,k) meminit_[(x)*NCONTEXT+k]
int coinit_[ADDRSIZE*NCONTEXT];
#define coinit(x,k) coinit_[(x)*NCONTEXT+k]
int deltainit_[ADDRSIZE*NCONTEXT];
#define deltainit(x,k) deltainit_[(x)*NCONTEXT+k]
// declare arrays for running value version in contexts
int mem_[ADDRSIZE*NCONTEXT];
#define mem(x,k) mem_[(x)*NCONTEXT+k]
int co_[ADDRSIZE*NCONTEXT];
#define co(x,k) co_[(x)*NCONTEXT+k]
int delta_[ADDRSIZE*NCONTEXT];
#define delta(x,k) delta_[(x)*NCONTEXT+k]
// declare arrays for local buffer and observed writes
int buff_[NTHREAD*ADDRSIZE];
#define buff(x,k) buff_[(x)*ADDRSIZE+k]
int pw_[NTHREAD*ADDRSIZE];
#define pw(x,k) pw_[(x)*ADDRSIZE+k]
// declare arrays for context stamps
char cr_[NTHREAD*ADDRSIZE];
#define cr(x,k) cr_[(x)*ADDRSIZE+k]
char iw_[NTHREAD*ADDRSIZE];
#define iw(x,k) iw_[(x)*ADDRSIZE+k]
char cw_[NTHREAD*ADDRSIZE];
#define cw(x,k) cw_[(x)*ADDRSIZE+k]
char cx_[NTHREAD*ADDRSIZE];
#define cx(x,k) cx_[(x)*ADDRSIZE+k]
char is_[NTHREAD*ADDRSIZE];
#define is(x,k) is_[(x)*ADDRSIZE+k]
char cs_[NTHREAD*ADDRSIZE];
#define cs(x,k) cs_[(x)*ADDRSIZE+k]
char crmax_[NTHREAD*ADDRSIZE];
#define crmax(x,k) crmax_[(x)*ADDRSIZE+k]
char sforbid_[ADDRSIZE*NCONTEXT];
#define sforbid(x,k) sforbid_[(x)*NCONTEXT+k]
// declare arrays for synchronizations
int cl[NTHREAD];
int cdy[NTHREAD];
int cds[NTHREAD];
int cdl[NTHREAD];
int cisb[NTHREAD];
int caddr[NTHREAD];
int cctrl[NTHREAD];
__LOCALS__
buff(0,0) = 0;
pw(0,0) = 0;
cr(0,0) = 0;
iw(0,0) = 0;
cw(0,0) = 0;
cx(0,0) = 0;
is(0,0) = 0;
cs(0,0) = 0;
crmax(0,0) = 0;
buff(0,1) = 0;
pw(0,1) = 0;
cr(0,1) = 0;
iw(0,1) = 0;
cw(0,1) = 0;
cx(0,1) = 0;
is(0,1) = 0;
cs(0,1) = 0;
crmax(0,1) = 0;
buff(0,2) = 0;
pw(0,2) = 0;
cr(0,2) = 0;
iw(0,2) = 0;
cw(0,2) = 0;
cx(0,2) = 0;
is(0,2) = 0;
cs(0,2) = 0;
crmax(0,2) = 0;
buff(0,3) = 0;
pw(0,3) = 0;
cr(0,3) = 0;
iw(0,3) = 0;
cw(0,3) = 0;
cx(0,3) = 0;
is(0,3) = 0;
cs(0,3) = 0;
crmax(0,3) = 0;
buff(0,4) = 0;
pw(0,4) = 0;
cr(0,4) = 0;
iw(0,4) = 0;
cw(0,4) = 0;
cx(0,4) = 0;
is(0,4) = 0;
cs(0,4) = 0;
crmax(0,4) = 0;
buff(0,5) = 0;
pw(0,5) = 0;
cr(0,5) = 0;
iw(0,5) = 0;
cw(0,5) = 0;
cx(0,5) = 0;
is(0,5) = 0;
cs(0,5) = 0;
crmax(0,5) = 0;
buff(0,6) = 0;
pw(0,6) = 0;
cr(0,6) = 0;
iw(0,6) = 0;
cw(0,6) = 0;
cx(0,6) = 0;
is(0,6) = 0;
cs(0,6) = 0;
crmax(0,6) = 0;
cl[0] = 0;
cdy[0] = 0;
cds[0] = 0;
cdl[0] = 0;
cisb[0] = 0;
caddr[0] = 0;
cctrl[0] = 0;
cstart[0] = get_rng(0,NCONTEXT-1);
creturn[0] = get_rng(0,NCONTEXT-1);
buff(1,0) = 0;
pw(1,0) = 0;
cr(1,0) = 0;
iw(1,0) = 0;
cw(1,0) = 0;
cx(1,0) = 0;
is(1,0) = 0;
cs(1,0) = 0;
crmax(1,0) = 0;
buff(1,1) = 0;
pw(1,1) = 0;
cr(1,1) = 0;
iw(1,1) = 0;
cw(1,1) = 0;
cx(1,1) = 0;
is(1,1) = 0;
cs(1,1) = 0;
crmax(1,1) = 0;
buff(1,2) = 0;
pw(1,2) = 0;
cr(1,2) = 0;
iw(1,2) = 0;
cw(1,2) = 0;
cx(1,2) = 0;
is(1,2) = 0;
cs(1,2) = 0;
crmax(1,2) = 0;
buff(1,3) = 0;
pw(1,3) = 0;
cr(1,3) = 0;
iw(1,3) = 0;
cw(1,3) = 0;
cx(1,3) = 0;
is(1,3) = 0;
cs(1,3) = 0;
crmax(1,3) = 0;
buff(1,4) = 0;
pw(1,4) = 0;
cr(1,4) = 0;
iw(1,4) = 0;
cw(1,4) = 0;
cx(1,4) = 0;
is(1,4) = 0;
cs(1,4) = 0;
crmax(1,4) = 0;
buff(1,5) = 0;
pw(1,5) = 0;
cr(1,5) = 0;
iw(1,5) = 0;
cw(1,5) = 0;
cx(1,5) = 0;
is(1,5) = 0;
cs(1,5) = 0;
crmax(1,5) = 0;
buff(1,6) = 0;
pw(1,6) = 0;
cr(1,6) = 0;
iw(1,6) = 0;
cw(1,6) = 0;
cx(1,6) = 0;
is(1,6) = 0;
cs(1,6) = 0;
crmax(1,6) = 0;
cl[1] = 0;
cdy[1] = 0;
cds[1] = 0;
cdl[1] = 0;
cisb[1] = 0;
caddr[1] = 0;
cctrl[1] = 0;
cstart[1] = get_rng(0,NCONTEXT-1);
creturn[1] = get_rng(0,NCONTEXT-1);
buff(2,0) = 0;
pw(2,0) = 0;
cr(2,0) = 0;
iw(2,0) = 0;
cw(2,0) = 0;
cx(2,0) = 0;
is(2,0) = 0;
cs(2,0) = 0;
crmax(2,0) = 0;
buff(2,1) = 0;
pw(2,1) = 0;
cr(2,1) = 0;
iw(2,1) = 0;
cw(2,1) = 0;
cx(2,1) = 0;
is(2,1) = 0;
cs(2,1) = 0;
crmax(2,1) = 0;
buff(2,2) = 0;
pw(2,2) = 0;
cr(2,2) = 0;
iw(2,2) = 0;
cw(2,2) = 0;
cx(2,2) = 0;
is(2,2) = 0;
cs(2,2) = 0;
crmax(2,2) = 0;
buff(2,3) = 0;
pw(2,3) = 0;
cr(2,3) = 0;
iw(2,3) = 0;
cw(2,3) = 0;
cx(2,3) = 0;
is(2,3) = 0;
cs(2,3) = 0;
crmax(2,3) = 0;
buff(2,4) = 0;
pw(2,4) = 0;
cr(2,4) = 0;
iw(2,4) = 0;
cw(2,4) = 0;
cx(2,4) = 0;
is(2,4) = 0;
cs(2,4) = 0;
crmax(2,4) = 0;
buff(2,5) = 0;
pw(2,5) = 0;
cr(2,5) = 0;
iw(2,5) = 0;
cw(2,5) = 0;
cx(2,5) = 0;
is(2,5) = 0;
cs(2,5) = 0;
crmax(2,5) = 0;
buff(2,6) = 0;
pw(2,6) = 0;
cr(2,6) = 0;
iw(2,6) = 0;
cw(2,6) = 0;
cx(2,6) = 0;
is(2,6) = 0;
cs(2,6) = 0;
crmax(2,6) = 0;
cl[2] = 0;
cdy[2] = 0;
cds[2] = 0;
cdl[2] = 0;
cisb[2] = 0;
caddr[2] = 0;
cctrl[2] = 0;
cstart[2] = get_rng(0,NCONTEXT-1);
creturn[2] = get_rng(0,NCONTEXT-1);
buff(3,0) = 0;
pw(3,0) = 0;
cr(3,0) = 0;
iw(3,0) = 0;
cw(3,0) = 0;
cx(3,0) = 0;
is(3,0) = 0;
cs(3,0) = 0;
crmax(3,0) = 0;
buff(3,1) = 0;
pw(3,1) = 0;
cr(3,1) = 0;
iw(3,1) = 0;
cw(3,1) = 0;
cx(3,1) = 0;
is(3,1) = 0;
cs(3,1) = 0;
crmax(3,1) = 0;
buff(3,2) = 0;
pw(3,2) = 0;
cr(3,2) = 0;
iw(3,2) = 0;
cw(3,2) = 0;
cx(3,2) = 0;
is(3,2) = 0;
cs(3,2) = 0;
crmax(3,2) = 0;
buff(3,3) = 0;
pw(3,3) = 0;
cr(3,3) = 0;
iw(3,3) = 0;
cw(3,3) = 0;
cx(3,3) = 0;
is(3,3) = 0;
cs(3,3) = 0;
crmax(3,3) = 0;
buff(3,4) = 0;
pw(3,4) = 0;
cr(3,4) = 0;
iw(3,4) = 0;
cw(3,4) = 0;
cx(3,4) = 0;
is(3,4) = 0;
cs(3,4) = 0;
crmax(3,4) = 0;
buff(3,5) = 0;
pw(3,5) = 0;
cr(3,5) = 0;
iw(3,5) = 0;
cw(3,5) = 0;
cx(3,5) = 0;
is(3,5) = 0;
cs(3,5) = 0;
crmax(3,5) = 0;
buff(3,6) = 0;
pw(3,6) = 0;
cr(3,6) = 0;
iw(3,6) = 0;
cw(3,6) = 0;
cx(3,6) = 0;
is(3,6) = 0;
cs(3,6) = 0;
crmax(3,6) = 0;
cl[3] = 0;
cdy[3] = 0;
cds[3] = 0;
cdl[3] = 0;
cisb[3] = 0;
caddr[3] = 0;
cctrl[3] = 0;
cstart[3] = get_rng(0,NCONTEXT-1);
creturn[3] = get_rng(0,NCONTEXT-1);
// Dumping initializations
mem(0+0,0) = 0;
mem(0+1,0) = 0;
mem(0+2,0) = 0;
mem(3+0,0) = 0;
mem(4+0,0) = 0;
mem(5+0,0) = 0;
mem(6+0,0) = 0;
// Dumping context matching equalities
co(0,0) = 0;
delta(0,0) = -1;
mem(0,1) = meminit(0,1);
co(0,1) = coinit(0,1);
delta(0,1) = deltainit(0,1);
mem(0,2) = meminit(0,2);
co(0,2) = coinit(0,2);
delta(0,2) = deltainit(0,2);
mem(0,3) = meminit(0,3);
co(0,3) = coinit(0,3);
delta(0,3) = deltainit(0,3);
mem(0,4) = meminit(0,4);
co(0,4) = coinit(0,4);
delta(0,4) = deltainit(0,4);
co(1,0) = 0;
delta(1,0) = -1;
mem(1,1) = meminit(1,1);
co(1,1) = coinit(1,1);
delta(1,1) = deltainit(1,1);
mem(1,2) = meminit(1,2);
co(1,2) = coinit(1,2);
delta(1,2) = deltainit(1,2);
mem(1,3) = meminit(1,3);
co(1,3) = coinit(1,3);
delta(1,3) = deltainit(1,3);
mem(1,4) = meminit(1,4);
co(1,4) = coinit(1,4);
delta(1,4) = deltainit(1,4);
co(2,0) = 0;
delta(2,0) = -1;
mem(2,1) = meminit(2,1);
co(2,1) = coinit(2,1);
delta(2,1) = deltainit(2,1);
mem(2,2) = meminit(2,2);
co(2,2) = coinit(2,2);
delta(2,2) = deltainit(2,2);
mem(2,3) = meminit(2,3);
co(2,3) = coinit(2,3);
delta(2,3) = deltainit(2,3);
mem(2,4) = meminit(2,4);
co(2,4) = coinit(2,4);
delta(2,4) = deltainit(2,4);
co(3,0) = 0;
delta(3,0) = -1;
mem(3,1) = meminit(3,1);
co(3,1) = coinit(3,1);
delta(3,1) = deltainit(3,1);
mem(3,2) = meminit(3,2);
co(3,2) = coinit(3,2);
delta(3,2) = deltainit(3,2);
mem(3,3) = meminit(3,3);
co(3,3) = coinit(3,3);
delta(3,3) = deltainit(3,3);
mem(3,4) = meminit(3,4);
co(3,4) = coinit(3,4);
delta(3,4) = deltainit(3,4);
co(4,0) = 0;
delta(4,0) = -1;
mem(4,1) = meminit(4,1);
co(4,1) = coinit(4,1);
delta(4,1) = deltainit(4,1);
mem(4,2) = meminit(4,2);
co(4,2) = coinit(4,2);
delta(4,2) = deltainit(4,2);
mem(4,3) = meminit(4,3);
co(4,3) = coinit(4,3);
delta(4,3) = deltainit(4,3);
mem(4,4) = meminit(4,4);
co(4,4) = coinit(4,4);
delta(4,4) = deltainit(4,4);
co(5,0) = 0;
delta(5,0) = -1;
mem(5,1) = meminit(5,1);
co(5,1) = coinit(5,1);
delta(5,1) = deltainit(5,1);
mem(5,2) = meminit(5,2);
co(5,2) = coinit(5,2);
delta(5,2) = deltainit(5,2);
mem(5,3) = meminit(5,3);
co(5,3) = coinit(5,3);
delta(5,3) = deltainit(5,3);
mem(5,4) = meminit(5,4);
co(5,4) = coinit(5,4);
delta(5,4) = deltainit(5,4);
co(6,0) = 0;
delta(6,0) = -1;
mem(6,1) = meminit(6,1);
co(6,1) = coinit(6,1);
delta(6,1) = deltainit(6,1);
mem(6,2) = meminit(6,2);
co(6,2) = coinit(6,2);
delta(6,2) = deltainit(6,2);
mem(6,3) = meminit(6,3);
co(6,3) = coinit(6,3);
delta(6,3) = deltainit(6,3);
mem(6,4) = meminit(6,4);
co(6,4) = coinit(6,4);
delta(6,4) = deltainit(6,4);
// Dumping thread 1
int ret_thread_1 = 0;
cdy[1] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[1] >= cstart[1]);
T1BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !40, metadata !DIExpression()), !dbg !49
// br label %label_1, !dbg !50
goto T1BLOCK1;
T1BLOCK1:
// call void @llvm.dbg.label(metadata !48), !dbg !51
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !41, metadata !DIExpression()), !dbg !52
// call void @llvm.dbg.value(metadata i64 1, metadata !44, metadata !DIExpression()), !dbg !52
// store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !53
// ST: Guess
iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l22_c3
old_cw = cw(1,0);
cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l22_c3
// Check
ASSUME(active[iw(1,0)] == 1);
ASSUME(active[cw(1,0)] == 1);
ASSUME(sforbid(0,cw(1,0))== 0);
ASSUME(iw(1,0) >= 0);
ASSUME(iw(1,0) >= 0);
ASSUME(cw(1,0) >= iw(1,0));
ASSUME(cw(1,0) >= old_cw);
ASSUME(cw(1,0) >= cr(1,0));
ASSUME(cw(1,0) >= cl[1]);
ASSUME(cw(1,0) >= cisb[1]);
ASSUME(cw(1,0) >= cdy[1]);
ASSUME(cw(1,0) >= cdl[1]);
ASSUME(cw(1,0) >= cds[1]);
ASSUME(cw(1,0) >= cctrl[1]);
ASSUME(cw(1,0) >= caddr[1]);
// Update
caddr[1] = max(caddr[1],0);
buff(1,0) = 1;
mem(0,cw(1,0)) = 1;
co(0,cw(1,0))+=1;
delta(0,cw(1,0)) = -1;
ASSUME(creturn[1] >= cw(1,0));
// call void (...) @dmbsy(), !dbg !54
// dumbsy: Guess
old_cdy = cdy[1];
cdy[1] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[1] >= old_cdy);
ASSUME(cdy[1] >= cisb[1]);
ASSUME(cdy[1] >= cdl[1]);
ASSUME(cdy[1] >= cds[1]);
ASSUME(cdy[1] >= cctrl[1]);
ASSUME(cdy[1] >= cw(1,0+0));
ASSUME(cdy[1] >= cw(1,0+1));
ASSUME(cdy[1] >= cw(1,0+2));
ASSUME(cdy[1] >= cw(1,3+0));
ASSUME(cdy[1] >= cw(1,4+0));
ASSUME(cdy[1] >= cw(1,5+0));
ASSUME(cdy[1] >= cw(1,6+0));
ASSUME(cdy[1] >= cr(1,0+0));
ASSUME(cdy[1] >= cr(1,0+1));
ASSUME(cdy[1] >= cr(1,0+2));
ASSUME(cdy[1] >= cr(1,3+0));
ASSUME(cdy[1] >= cr(1,4+0));
ASSUME(cdy[1] >= cr(1,5+0));
ASSUME(cdy[1] >= cr(1,6+0));
ASSUME(creturn[1] >= cdy[1]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !45, metadata !DIExpression()), !dbg !55
// call void @llvm.dbg.value(metadata i64 1, metadata !47, metadata !DIExpression()), !dbg !55
// store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !56
// ST: Guess
iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l24_c3
old_cw = cw(1,0+1*1);
cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l24_c3
// Check
ASSUME(active[iw(1,0+1*1)] == 1);
ASSUME(active[cw(1,0+1*1)] == 1);
ASSUME(sforbid(0+1*1,cw(1,0+1*1))== 0);
ASSUME(iw(1,0+1*1) >= 0);
ASSUME(iw(1,0+1*1) >= 0);
ASSUME(cw(1,0+1*1) >= iw(1,0+1*1));
ASSUME(cw(1,0+1*1) >= old_cw);
ASSUME(cw(1,0+1*1) >= cr(1,0+1*1));
ASSUME(cw(1,0+1*1) >= cl[1]);
ASSUME(cw(1,0+1*1) >= cisb[1]);
ASSUME(cw(1,0+1*1) >= cdy[1]);
ASSUME(cw(1,0+1*1) >= cdl[1]);
ASSUME(cw(1,0+1*1) >= cds[1]);
ASSUME(cw(1,0+1*1) >= cctrl[1]);
ASSUME(cw(1,0+1*1) >= caddr[1]);
// Update
caddr[1] = max(caddr[1],0);
buff(1,0+1*1) = 1;
mem(0+1*1,cw(1,0+1*1)) = 1;
co(0+1*1,cw(1,0+1*1))+=1;
delta(0+1*1,cw(1,0+1*1)) = -1;
ASSUME(creturn[1] >= cw(1,0+1*1));
// ret i8* null, !dbg !57
ret_thread_1 = (- 1);
goto T1BLOCK_END;
T1BLOCK_END:
// Dumping thread 2
int ret_thread_2 = 0;
cdy[2] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[2] >= cstart[2]);
T2BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !60, metadata !DIExpression()), !dbg !88
// br label %label_2, !dbg !70
goto T2BLOCK1;
T2BLOCK1:
// call void @llvm.dbg.label(metadata !86), !dbg !90
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !62, metadata !DIExpression()), !dbg !91
// %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !73
// LD: Guess
old_cr = cr(2,0+1*1);
cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l30_c15
// Check
ASSUME(active[cr(2,0+1*1)] == 2);
ASSUME(cr(2,0+1*1) >= iw(2,0+1*1));
ASSUME(cr(2,0+1*1) >= 0);
ASSUME(cr(2,0+1*1) >= cdy[2]);
ASSUME(cr(2,0+1*1) >= cisb[2]);
ASSUME(cr(2,0+1*1) >= cdl[2]);
ASSUME(cr(2,0+1*1) >= cl[2]);
// Update
creg_r0 = cr(2,0+1*1);
crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1));
caddr[2] = max(caddr[2],0);
if(cr(2,0+1*1) < cw(2,0+1*1)) {
r0 = buff(2,0+1*1);
ASSUME((!(( (cw(2,0+1*1) < 1) && (1 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,1)> 0));
ASSUME((!(( (cw(2,0+1*1) < 2) && (2 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,2)> 0));
ASSUME((!(( (cw(2,0+1*1) < 3) && (3 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,3)> 0));
ASSUME((!(( (cw(2,0+1*1) < 4) && (4 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,4)> 0));
} else {
if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) {
ASSUME(cr(2,0+1*1) >= old_cr);
}
pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1));
r0 = mem(0+1*1,cr(2,0+1*1));
}
ASSUME(creturn[2] >= cr(2,0+1*1));
// call void @llvm.dbg.value(metadata i64 %0, metadata !64, metadata !DIExpression()), !dbg !91
// %conv = trunc i64 %0 to i32, !dbg !74
// call void @llvm.dbg.value(metadata i32 %conv, metadata !61, metadata !DIExpression()), !dbg !88
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !66, metadata !DIExpression()), !dbg !94
// %1 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !76
// LD: Guess
old_cr = cr(2,0+1*1);
cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l31_c15
// Check
ASSUME(active[cr(2,0+1*1)] == 2);
ASSUME(cr(2,0+1*1) >= iw(2,0+1*1));
ASSUME(cr(2,0+1*1) >= 0);
ASSUME(cr(2,0+1*1) >= cdy[2]);
ASSUME(cr(2,0+1*1) >= cisb[2]);
ASSUME(cr(2,0+1*1) >= cdl[2]);
ASSUME(cr(2,0+1*1) >= cl[2]);
// Update
creg_r1 = cr(2,0+1*1);
crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1));
caddr[2] = max(caddr[2],0);
if(cr(2,0+1*1) < cw(2,0+1*1)) {
r1 = buff(2,0+1*1);
ASSUME((!(( (cw(2,0+1*1) < 1) && (1 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,1)> 0));
ASSUME((!(( (cw(2,0+1*1) < 2) && (2 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,2)> 0));
ASSUME((!(( (cw(2,0+1*1) < 3) && (3 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,3)> 0));
ASSUME((!(( (cw(2,0+1*1) < 4) && (4 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,4)> 0));
} else {
if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) {
ASSUME(cr(2,0+1*1) >= old_cr);
}
pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1));
r1 = mem(0+1*1,cr(2,0+1*1));
}
ASSUME(creturn[2] >= cr(2,0+1*1));
// call void @llvm.dbg.value(metadata i64 %1, metadata !68, metadata !DIExpression()), !dbg !94
// %conv4 = trunc i64 %1 to i32, !dbg !77
// call void @llvm.dbg.value(metadata i32 %conv4, metadata !65, metadata !DIExpression()), !dbg !88
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !70, metadata !DIExpression()), !dbg !97
// %2 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !79
// LD: Guess
old_cr = cr(2,0+1*1);
cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l32_c15
// Check
ASSUME(active[cr(2,0+1*1)] == 2);
ASSUME(cr(2,0+1*1) >= iw(2,0+1*1));
ASSUME(cr(2,0+1*1) >= 0);
ASSUME(cr(2,0+1*1) >= cdy[2]);
ASSUME(cr(2,0+1*1) >= cisb[2]);
ASSUME(cr(2,0+1*1) >= cdl[2]);
ASSUME(cr(2,0+1*1) >= cl[2]);
// Update
creg_r2 = cr(2,0+1*1);
crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1));
caddr[2] = max(caddr[2],0);
if(cr(2,0+1*1) < cw(2,0+1*1)) {
r2 = buff(2,0+1*1);
ASSUME((!(( (cw(2,0+1*1) < 1) && (1 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,1)> 0));
ASSUME((!(( (cw(2,0+1*1) < 2) && (2 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,2)> 0));
ASSUME((!(( (cw(2,0+1*1) < 3) && (3 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,3)> 0));
ASSUME((!(( (cw(2,0+1*1) < 4) && (4 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,4)> 0));
} else {
if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) {
ASSUME(cr(2,0+1*1) >= old_cr);
}
pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1));
r2 = mem(0+1*1,cr(2,0+1*1));
}
ASSUME(creturn[2] >= cr(2,0+1*1));
// call void @llvm.dbg.value(metadata i64 %2, metadata !72, metadata !DIExpression()), !dbg !97
// %conv8 = trunc i64 %2 to i32, !dbg !80
// call void @llvm.dbg.value(metadata i32 %conv8, metadata !69, metadata !DIExpression()), !dbg !88
// %xor = xor i32 %conv8, %conv8, !dbg !81
creg_r3 = creg_r2;
r3 = r2 ^ r2;
// call void @llvm.dbg.value(metadata i32 %xor, metadata !73, metadata !DIExpression()), !dbg !88
// %add = add nsw i32 2, %xor, !dbg !82
creg_r4 = max(0,creg_r3);
r4 = 2 + r3;
// %idxprom = sext i32 %add to i64, !dbg !82
// %arrayidx = getelementptr inbounds [3 x i64], [3 x i64]* @vars, i64 0, i64 %idxprom, !dbg !82
r5 = 0+r4*1;
creg_r5 = creg_r4;
// call void @llvm.dbg.value(metadata i64* %arrayidx, metadata !75, metadata !DIExpression()), !dbg !102
// %3 = load atomic i64, i64* %arrayidx monotonic, align 8, !dbg !82
// LD: Guess
old_cr = cr(2,r5);
cr(2,r5) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l34_c16
// Check
ASSUME(active[cr(2,r5)] == 2);
ASSUME(cr(2,r5) >= iw(2,r5));
ASSUME(cr(2,r5) >= creg_r5);
ASSUME(cr(2,r5) >= cdy[2]);
ASSUME(cr(2,r5) >= cisb[2]);
ASSUME(cr(2,r5) >= cdl[2]);
ASSUME(cr(2,r5) >= cl[2]);
// Update
creg_r6 = cr(2,r5);
crmax(2,r5) = max(crmax(2,r5),cr(2,r5));
caddr[2] = max(caddr[2],creg_r5);
if(cr(2,r5) < cw(2,r5)) {
r6 = buff(2,r5);
ASSUME((!(( (cw(2,r5) < 1) && (1 < crmax(2,r5)) )))||(sforbid(r5,1)> 0));
ASSUME((!(( (cw(2,r5) < 2) && (2 < crmax(2,r5)) )))||(sforbid(r5,2)> 0));
ASSUME((!(( (cw(2,r5) < 3) && (3 < crmax(2,r5)) )))||(sforbid(r5,3)> 0));
ASSUME((!(( (cw(2,r5) < 4) && (4 < crmax(2,r5)) )))||(sforbid(r5,4)> 0));
} else {
if(pw(2,r5) != co(r5,cr(2,r5))) {
ASSUME(cr(2,r5) >= old_cr);
}
pw(2,r5) = co(r5,cr(2,r5));
r6 = mem(r5,cr(2,r5));
}
ASSUME(creturn[2] >= cr(2,r5));
// call void @llvm.dbg.value(metadata i64 %3, metadata !77, metadata !DIExpression()), !dbg !102
// %conv12 = trunc i64 %3 to i32, !dbg !84
// call void @llvm.dbg.value(metadata i32 %conv12, metadata !74, metadata !DIExpression()), !dbg !88
// %tobool = icmp ne i32 %conv12, 0, !dbg !85
creg__r6__0_ = max(0,creg_r6);
// br i1 %tobool, label %if.then, label %if.else, !dbg !87
old_cctrl = cctrl[2];
cctrl[2] = get_rng(0,NCONTEXT-1);
ASSUME(cctrl[2] >= old_cctrl);
ASSUME(cctrl[2] >= creg__r6__0_);
if((r6!=0)) {
goto T2BLOCK2;
} else {
goto T2BLOCK3;
}
T2BLOCK2:
// br label %lbl_LC00, !dbg !88
goto T2BLOCK4;
T2BLOCK3:
// br label %lbl_LC00, !dbg !89
goto T2BLOCK4;
T2BLOCK4:
// call void @llvm.dbg.label(metadata !87), !dbg !109
// call void (...) @isb(), !dbg !91
// isb: Guess
cisb[2] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cisb[2] >= cdy[2]);
ASSUME(cisb[2] >= cctrl[2]);
ASSUME(cisb[2] >= caddr[2]);
ASSUME(creturn[2] >= cisb[2]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !79, metadata !DIExpression()), !dbg !111
// %4 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !93
// LD: Guess
old_cr = cr(2,0);
cr(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l38_c16
// Check
ASSUME(active[cr(2,0)] == 2);
ASSUME(cr(2,0) >= iw(2,0));
ASSUME(cr(2,0) >= 0);
ASSUME(cr(2,0) >= cdy[2]);
ASSUME(cr(2,0) >= cisb[2]);
ASSUME(cr(2,0) >= cdl[2]);
ASSUME(cr(2,0) >= cl[2]);
// Update
creg_r7 = cr(2,0);
crmax(2,0) = max(crmax(2,0),cr(2,0));
caddr[2] = max(caddr[2],0);
if(cr(2,0) < cw(2,0)) {
r7 = buff(2,0);
ASSUME((!(( (cw(2,0) < 1) && (1 < crmax(2,0)) )))||(sforbid(0,1)> 0));
ASSUME((!(( (cw(2,0) < 2) && (2 < crmax(2,0)) )))||(sforbid(0,2)> 0));
ASSUME((!(( (cw(2,0) < 3) && (3 < crmax(2,0)) )))||(sforbid(0,3)> 0));
ASSUME((!(( (cw(2,0) < 4) && (4 < crmax(2,0)) )))||(sforbid(0,4)> 0));
} else {
if(pw(2,0) != co(0,cr(2,0))) {
ASSUME(cr(2,0) >= old_cr);
}
pw(2,0) = co(0,cr(2,0));
r7 = mem(0,cr(2,0));
}
ASSUME(creturn[2] >= cr(2,0));
// call void @llvm.dbg.value(metadata i64 %4, metadata !81, metadata !DIExpression()), !dbg !111
// %conv16 = trunc i64 %4 to i32, !dbg !94
// call void @llvm.dbg.value(metadata i32 %conv16, metadata !78, metadata !DIExpression()), !dbg !88
// %cmp = icmp eq i32 %conv, 1, !dbg !95
creg__r0__1_ = max(0,creg_r0);
// %conv17 = zext i1 %cmp to i32, !dbg !95
// call void @llvm.dbg.value(metadata i32 %conv17, metadata !82, metadata !DIExpression()), !dbg !88
// store i32 %conv17, i32* @atom_1_X0_1, align 4, !dbg !96, !tbaa !97
// ST: Guess
iw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l40_c15
old_cw = cw(2,3);
cw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l40_c15
// Check
ASSUME(active[iw(2,3)] == 2);
ASSUME(active[cw(2,3)] == 2);
ASSUME(sforbid(3,cw(2,3))== 0);
ASSUME(iw(2,3) >= creg__r0__1_);
ASSUME(iw(2,3) >= 0);
ASSUME(cw(2,3) >= iw(2,3));
ASSUME(cw(2,3) >= old_cw);
ASSUME(cw(2,3) >= cr(2,3));
ASSUME(cw(2,3) >= cl[2]);
ASSUME(cw(2,3) >= cisb[2]);
ASSUME(cw(2,3) >= cdy[2]);
ASSUME(cw(2,3) >= cdl[2]);
ASSUME(cw(2,3) >= cds[2]);
ASSUME(cw(2,3) >= cctrl[2]);
ASSUME(cw(2,3) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,3) = (r0==1);
mem(3,cw(2,3)) = (r0==1);
co(3,cw(2,3))+=1;
delta(3,cw(2,3)) = -1;
ASSUME(creturn[2] >= cw(2,3));
// %cmp18 = icmp eq i32 %conv4, 1, !dbg !101
creg__r1__1_ = max(0,creg_r1);
// %conv19 = zext i1 %cmp18 to i32, !dbg !101
// call void @llvm.dbg.value(metadata i32 %conv19, metadata !83, metadata !DIExpression()), !dbg !88
// store i32 %conv19, i32* @atom_1_X2_1, align 4, !dbg !102, !tbaa !97
// ST: Guess
iw(2,4) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l42_c15
old_cw = cw(2,4);
cw(2,4) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l42_c15
// Check
ASSUME(active[iw(2,4)] == 2);
ASSUME(active[cw(2,4)] == 2);
ASSUME(sforbid(4,cw(2,4))== 0);
ASSUME(iw(2,4) >= creg__r1__1_);
ASSUME(iw(2,4) >= 0);
ASSUME(cw(2,4) >= iw(2,4));
ASSUME(cw(2,4) >= old_cw);
ASSUME(cw(2,4) >= cr(2,4));
ASSUME(cw(2,4) >= cl[2]);
ASSUME(cw(2,4) >= cisb[2]);
ASSUME(cw(2,4) >= cdy[2]);
ASSUME(cw(2,4) >= cdl[2]);
ASSUME(cw(2,4) >= cds[2]);
ASSUME(cw(2,4) >= cctrl[2]);
ASSUME(cw(2,4) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,4) = (r1==1);
mem(4,cw(2,4)) = (r1==1);
co(4,cw(2,4))+=1;
delta(4,cw(2,4)) = -1;
ASSUME(creturn[2] >= cw(2,4));
// %cmp20 = icmp eq i32 %conv8, 2, !dbg !103
creg__r2__2_ = max(0,creg_r2);
// %conv21 = zext i1 %cmp20 to i32, !dbg !103
// call void @llvm.dbg.value(metadata i32 %conv21, metadata !84, metadata !DIExpression()), !dbg !88
// store i32 %conv21, i32* @atom_1_X3_2, align 4, !dbg !104, !tbaa !97
// ST: Guess
iw(2,5) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l44_c15
old_cw = cw(2,5);
cw(2,5) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l44_c15
// Check
ASSUME(active[iw(2,5)] == 2);
ASSUME(active[cw(2,5)] == 2);
ASSUME(sforbid(5,cw(2,5))== 0);
ASSUME(iw(2,5) >= creg__r2__2_);
ASSUME(iw(2,5) >= 0);
ASSUME(cw(2,5) >= iw(2,5));
ASSUME(cw(2,5) >= old_cw);
ASSUME(cw(2,5) >= cr(2,5));
ASSUME(cw(2,5) >= cl[2]);
ASSUME(cw(2,5) >= cisb[2]);
ASSUME(cw(2,5) >= cdy[2]);
ASSUME(cw(2,5) >= cdl[2]);
ASSUME(cw(2,5) >= cds[2]);
ASSUME(cw(2,5) >= cctrl[2]);
ASSUME(cw(2,5) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,5) = (r2==2);
mem(5,cw(2,5)) = (r2==2);
co(5,cw(2,5))+=1;
delta(5,cw(2,5)) = -1;
ASSUME(creturn[2] >= cw(2,5));
// %cmp22 = icmp eq i32 %conv16, 0, !dbg !105
creg__r7__0_ = max(0,creg_r7);
// %conv23 = zext i1 %cmp22 to i32, !dbg !105
// call void @llvm.dbg.value(metadata i32 %conv23, metadata !85, metadata !DIExpression()), !dbg !88
// store i32 %conv23, i32* @atom_1_X7_0, align 4, !dbg !106, !tbaa !97
// ST: Guess
iw(2,6) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l46_c15
old_cw = cw(2,6);
cw(2,6) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l46_c15
// Check
ASSUME(active[iw(2,6)] == 2);
ASSUME(active[cw(2,6)] == 2);
ASSUME(sforbid(6,cw(2,6))== 0);
ASSUME(iw(2,6) >= creg__r7__0_);
ASSUME(iw(2,6) >= 0);
ASSUME(cw(2,6) >= iw(2,6));
ASSUME(cw(2,6) >= old_cw);
ASSUME(cw(2,6) >= cr(2,6));
ASSUME(cw(2,6) >= cl[2]);
ASSUME(cw(2,6) >= cisb[2]);
ASSUME(cw(2,6) >= cdy[2]);
ASSUME(cw(2,6) >= cdl[2]);
ASSUME(cw(2,6) >= cds[2]);
ASSUME(cw(2,6) >= cctrl[2]);
ASSUME(cw(2,6) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,6) = (r7==0);
mem(6,cw(2,6)) = (r7==0);
co(6,cw(2,6))+=1;
delta(6,cw(2,6)) = -1;
ASSUME(creturn[2] >= cw(2,6));
// ret i8* null, !dbg !107
ret_thread_2 = (- 1);
goto T2BLOCK_END;
T2BLOCK_END:
// Dumping thread 3
int ret_thread_3 = 0;
cdy[3] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[3] >= cstart[3]);
T3BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !129, metadata !DIExpression()), !dbg !134
// br label %label_3, !dbg !47
goto T3BLOCK1;
T3BLOCK1:
// call void @llvm.dbg.label(metadata !133), !dbg !136
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !130, metadata !DIExpression()), !dbg !137
// call void @llvm.dbg.value(metadata i64 2, metadata !132, metadata !DIExpression()), !dbg !137
// store atomic i64 2, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !50
// ST: Guess
iw(3,0+1*1) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW _l52_c3
old_cw = cw(3,0+1*1);
cw(3,0+1*1) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM _l52_c3
// Check
ASSUME(active[iw(3,0+1*1)] == 3);
ASSUME(active[cw(3,0+1*1)] == 3);
ASSUME(sforbid(0+1*1,cw(3,0+1*1))== 0);
ASSUME(iw(3,0+1*1) >= 0);
ASSUME(iw(3,0+1*1) >= 0);
ASSUME(cw(3,0+1*1) >= iw(3,0+1*1));
ASSUME(cw(3,0+1*1) >= old_cw);
ASSUME(cw(3,0+1*1) >= cr(3,0+1*1));
ASSUME(cw(3,0+1*1) >= cl[3]);
ASSUME(cw(3,0+1*1) >= cisb[3]);
ASSUME(cw(3,0+1*1) >= cdy[3]);
ASSUME(cw(3,0+1*1) >= cdl[3]);
ASSUME(cw(3,0+1*1) >= cds[3]);
ASSUME(cw(3,0+1*1) >= cctrl[3]);
ASSUME(cw(3,0+1*1) >= caddr[3]);
// Update
caddr[3] = max(caddr[3],0);
buff(3,0+1*1) = 2;
mem(0+1*1,cw(3,0+1*1)) = 2;
co(0+1*1,cw(3,0+1*1))+=1;
delta(0+1*1,cw(3,0+1*1)) = -1;
ASSUME(creturn[3] >= cw(3,0+1*1));
// ret i8* null, !dbg !51
ret_thread_3 = (- 1);
goto T3BLOCK_END;
T3BLOCK_END:
// Dumping thread 0
int ret_thread_0 = 0;
cdy[0] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[0] >= cstart[0]);
T0BLOCK0:
// %thr0 = alloca i64, align 8
// %thr1 = alloca i64, align 8
// %thr2 = alloca i64, align 8
// call void @llvm.dbg.value(metadata i32 %argc, metadata !147, metadata !DIExpression()), !dbg !183
// call void @llvm.dbg.value(metadata i8** %argv, metadata !148, metadata !DIExpression()), !dbg !183
// %0 = bitcast i64* %thr0 to i8*, !dbg !81
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #7, !dbg !81
// call void @llvm.dbg.declare(metadata i64* %thr0, metadata !149, metadata !DIExpression()), !dbg !185
// %1 = bitcast i64* %thr1 to i8*, !dbg !83
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #7, !dbg !83
// call void @llvm.dbg.declare(metadata i64* %thr1, metadata !153, metadata !DIExpression()), !dbg !187
// %2 = bitcast i64* %thr2 to i8*, !dbg !85
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %2) #7, !dbg !85
// call void @llvm.dbg.declare(metadata i64* %thr2, metadata !154, metadata !DIExpression()), !dbg !189
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !155, metadata !DIExpression()), !dbg !190
// call void @llvm.dbg.value(metadata i64 0, metadata !157, metadata !DIExpression()), !dbg !190
// store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !88
// ST: Guess
iw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l61_c3
old_cw = cw(0,0+2*1);
cw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l61_c3
// Check
ASSUME(active[iw(0,0+2*1)] == 0);
ASSUME(active[cw(0,0+2*1)] == 0);
ASSUME(sforbid(0+2*1,cw(0,0+2*1))== 0);
ASSUME(iw(0,0+2*1) >= 0);
ASSUME(iw(0,0+2*1) >= 0);
ASSUME(cw(0,0+2*1) >= iw(0,0+2*1));
ASSUME(cw(0,0+2*1) >= old_cw);
ASSUME(cw(0,0+2*1) >= cr(0,0+2*1));
ASSUME(cw(0,0+2*1) >= cl[0]);
ASSUME(cw(0,0+2*1) >= cisb[0]);
ASSUME(cw(0,0+2*1) >= cdy[0]);
ASSUME(cw(0,0+2*1) >= cdl[0]);
ASSUME(cw(0,0+2*1) >= cds[0]);
ASSUME(cw(0,0+2*1) >= cctrl[0]);
ASSUME(cw(0,0+2*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+2*1) = 0;
mem(0+2*1,cw(0,0+2*1)) = 0;
co(0+2*1,cw(0,0+2*1))+=1;
delta(0+2*1,cw(0,0+2*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+2*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !158, metadata !DIExpression()), !dbg !192
// call void @llvm.dbg.value(metadata i64 0, metadata !160, metadata !DIExpression()), !dbg !192
// store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !90
// ST: Guess
iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l62_c3
old_cw = cw(0,0+1*1);
cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l62_c3
// Check
ASSUME(active[iw(0,0+1*1)] == 0);
ASSUME(active[cw(0,0+1*1)] == 0);
ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(cw(0,0+1*1) >= iw(0,0+1*1));
ASSUME(cw(0,0+1*1) >= old_cw);
ASSUME(cw(0,0+1*1) >= cr(0,0+1*1));
ASSUME(cw(0,0+1*1) >= cl[0]);
ASSUME(cw(0,0+1*1) >= cisb[0]);
ASSUME(cw(0,0+1*1) >= cdy[0]);
ASSUME(cw(0,0+1*1) >= cdl[0]);
ASSUME(cw(0,0+1*1) >= cds[0]);
ASSUME(cw(0,0+1*1) >= cctrl[0]);
ASSUME(cw(0,0+1*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+1*1) = 0;
mem(0+1*1,cw(0,0+1*1)) = 0;
co(0+1*1,cw(0,0+1*1))+=1;
delta(0+1*1,cw(0,0+1*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+1*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !161, metadata !DIExpression()), !dbg !194
// call void @llvm.dbg.value(metadata i64 0, metadata !163, metadata !DIExpression()), !dbg !194
// store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !92
// ST: Guess
iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l63_c3
old_cw = cw(0,0);
cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l63_c3
// Check
ASSUME(active[iw(0,0)] == 0);
ASSUME(active[cw(0,0)] == 0);
ASSUME(sforbid(0,cw(0,0))== 0);
ASSUME(iw(0,0) >= 0);
ASSUME(iw(0,0) >= 0);
ASSUME(cw(0,0) >= iw(0,0));
ASSUME(cw(0,0) >= old_cw);
ASSUME(cw(0,0) >= cr(0,0));
ASSUME(cw(0,0) >= cl[0]);
ASSUME(cw(0,0) >= cisb[0]);
ASSUME(cw(0,0) >= cdy[0]);
ASSUME(cw(0,0) >= cdl[0]);
ASSUME(cw(0,0) >= cds[0]);
ASSUME(cw(0,0) >= cctrl[0]);
ASSUME(cw(0,0) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0) = 0;
mem(0,cw(0,0)) = 0;
co(0,cw(0,0))+=1;
delta(0,cw(0,0)) = -1;
ASSUME(creturn[0] >= cw(0,0));
// store i32 0, i32* @atom_1_X0_1, align 4, !dbg !93, !tbaa !94
// ST: Guess
iw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l64_c15
old_cw = cw(0,3);
cw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l64_c15
// Check
ASSUME(active[iw(0,3)] == 0);
ASSUME(active[cw(0,3)] == 0);
ASSUME(sforbid(3,cw(0,3))== 0);
ASSUME(iw(0,3) >= 0);
ASSUME(iw(0,3) >= 0);
ASSUME(cw(0,3) >= iw(0,3));
ASSUME(cw(0,3) >= old_cw);
ASSUME(cw(0,3) >= cr(0,3));
ASSUME(cw(0,3) >= cl[0]);
ASSUME(cw(0,3) >= cisb[0]);
ASSUME(cw(0,3) >= cdy[0]);
ASSUME(cw(0,3) >= cdl[0]);
ASSUME(cw(0,3) >= cds[0]);
ASSUME(cw(0,3) >= cctrl[0]);
ASSUME(cw(0,3) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,3) = 0;
mem(3,cw(0,3)) = 0;
co(3,cw(0,3))+=1;
delta(3,cw(0,3)) = -1;
ASSUME(creturn[0] >= cw(0,3));
// store i32 0, i32* @atom_1_X2_1, align 4, !dbg !98, !tbaa !94
// ST: Guess
iw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l65_c15
old_cw = cw(0,4);
cw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l65_c15
// Check
ASSUME(active[iw(0,4)] == 0);
ASSUME(active[cw(0,4)] == 0);
ASSUME(sforbid(4,cw(0,4))== 0);
ASSUME(iw(0,4) >= 0);
ASSUME(iw(0,4) >= 0);
ASSUME(cw(0,4) >= iw(0,4));
ASSUME(cw(0,4) >= old_cw);
ASSUME(cw(0,4) >= cr(0,4));
ASSUME(cw(0,4) >= cl[0]);
ASSUME(cw(0,4) >= cisb[0]);
ASSUME(cw(0,4) >= cdy[0]);
ASSUME(cw(0,4) >= cdl[0]);
ASSUME(cw(0,4) >= cds[0]);
ASSUME(cw(0,4) >= cctrl[0]);
ASSUME(cw(0,4) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,4) = 0;
mem(4,cw(0,4)) = 0;
co(4,cw(0,4))+=1;
delta(4,cw(0,4)) = -1;
ASSUME(creturn[0] >= cw(0,4));
// store i32 0, i32* @atom_1_X3_2, align 4, !dbg !99, !tbaa !94
// ST: Guess
iw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l66_c15
old_cw = cw(0,5);
cw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l66_c15
// Check
ASSUME(active[iw(0,5)] == 0);
ASSUME(active[cw(0,5)] == 0);
ASSUME(sforbid(5,cw(0,5))== 0);
ASSUME(iw(0,5) >= 0);
ASSUME(iw(0,5) >= 0);
ASSUME(cw(0,5) >= iw(0,5));
ASSUME(cw(0,5) >= old_cw);
ASSUME(cw(0,5) >= cr(0,5));
ASSUME(cw(0,5) >= cl[0]);
ASSUME(cw(0,5) >= cisb[0]);
ASSUME(cw(0,5) >= cdy[0]);
ASSUME(cw(0,5) >= cdl[0]);
ASSUME(cw(0,5) >= cds[0]);
ASSUME(cw(0,5) >= cctrl[0]);
ASSUME(cw(0,5) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,5) = 0;
mem(5,cw(0,5)) = 0;
co(5,cw(0,5))+=1;
delta(5,cw(0,5)) = -1;
ASSUME(creturn[0] >= cw(0,5));
// store i32 0, i32* @atom_1_X7_0, align 4, !dbg !100, !tbaa !94
// ST: Guess
iw(0,6) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l67_c15
old_cw = cw(0,6);
cw(0,6) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l67_c15
// Check
ASSUME(active[iw(0,6)] == 0);
ASSUME(active[cw(0,6)] == 0);
ASSUME(sforbid(6,cw(0,6))== 0);
ASSUME(iw(0,6) >= 0);
ASSUME(iw(0,6) >= 0);
ASSUME(cw(0,6) >= iw(0,6));
ASSUME(cw(0,6) >= old_cw);
ASSUME(cw(0,6) >= cr(0,6));
ASSUME(cw(0,6) >= cl[0]);
ASSUME(cw(0,6) >= cisb[0]);
ASSUME(cw(0,6) >= cdy[0]);
ASSUME(cw(0,6) >= cdl[0]);
ASSUME(cw(0,6) >= cds[0]);
ASSUME(cw(0,6) >= cctrl[0]);
ASSUME(cw(0,6) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,6) = 0;
mem(6,cw(0,6)) = 0;
co(6,cw(0,6))+=1;
delta(6,cw(0,6)) = -1;
ASSUME(creturn[0] >= cw(0,6));
// %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #7, !dbg !101
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[1] >= cdy[0]);
// %call5 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #7, !dbg !102
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[2] >= cdy[0]);
// %call6 = call i32 @pthread_create(i64* noundef %thr2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t2, i8* noundef null) #7, !dbg !103
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[3] >= cdy[0]);
// %3 = load i64, i64* %thr0, align 8, !dbg !104, !tbaa !105
r9 = local_mem[0];
// %call7 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !107
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[1]);
// %4 = load i64, i64* %thr1, align 8, !dbg !108, !tbaa !105
r10 = local_mem[1];
// %call8 = call i32 @pthread_join(i64 noundef %4, i8** noundef null), !dbg !109
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[2]);
// %5 = load i64, i64* %thr2, align 8, !dbg !110, !tbaa !105
r11 = local_mem[2];
// %call9 = call i32 @pthread_join(i64 noundef %5, i8** noundef null), !dbg !111
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[3]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !165, metadata !DIExpression()), !dbg !211
// %6 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !113
// LD: Guess
old_cr = cr(0,0);
cr(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l77_c13
// Check
ASSUME(active[cr(0,0)] == 0);
ASSUME(cr(0,0) >= iw(0,0));
ASSUME(cr(0,0) >= 0);
ASSUME(cr(0,0) >= cdy[0]);
ASSUME(cr(0,0) >= cisb[0]);
ASSUME(cr(0,0) >= cdl[0]);
ASSUME(cr(0,0) >= cl[0]);
// Update
creg_r12 = cr(0,0);
crmax(0,0) = max(crmax(0,0),cr(0,0));
caddr[0] = max(caddr[0],0);
if(cr(0,0) < cw(0,0)) {
r12 = buff(0,0);
ASSUME((!(( (cw(0,0) < 1) && (1 < crmax(0,0)) )))||(sforbid(0,1)> 0));
ASSUME((!(( (cw(0,0) < 2) && (2 < crmax(0,0)) )))||(sforbid(0,2)> 0));
ASSUME((!(( (cw(0,0) < 3) && (3 < crmax(0,0)) )))||(sforbid(0,3)> 0));
ASSUME((!(( (cw(0,0) < 4) && (4 < crmax(0,0)) )))||(sforbid(0,4)> 0));
} else {
if(pw(0,0) != co(0,cr(0,0))) {
ASSUME(cr(0,0) >= old_cr);
}
pw(0,0) = co(0,cr(0,0));
r12 = mem(0,cr(0,0));
}
ASSUME(creturn[0] >= cr(0,0));
// call void @llvm.dbg.value(metadata i64 %6, metadata !167, metadata !DIExpression()), !dbg !211
// %conv = trunc i64 %6 to i32, !dbg !114
// call void @llvm.dbg.value(metadata i32 %conv, metadata !164, metadata !DIExpression()), !dbg !183
// %cmp = icmp eq i32 %conv, 1, !dbg !115
creg__r12__1_ = max(0,creg_r12);
// %conv10 = zext i1 %cmp to i32, !dbg !115
// call void @llvm.dbg.value(metadata i32 %conv10, metadata !168, metadata !DIExpression()), !dbg !183
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !170, metadata !DIExpression()), !dbg !215
// %7 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !117
// LD: Guess
old_cr = cr(0,0+1*1);
cr(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l79_c13
// Check
ASSUME(active[cr(0,0+1*1)] == 0);
ASSUME(cr(0,0+1*1) >= iw(0,0+1*1));
ASSUME(cr(0,0+1*1) >= 0);
ASSUME(cr(0,0+1*1) >= cdy[0]);
ASSUME(cr(0,0+1*1) >= cisb[0]);
ASSUME(cr(0,0+1*1) >= cdl[0]);
ASSUME(cr(0,0+1*1) >= cl[0]);
// Update
creg_r13 = cr(0,0+1*1);
crmax(0,0+1*1) = max(crmax(0,0+1*1),cr(0,0+1*1));
caddr[0] = max(caddr[0],0);
if(cr(0,0+1*1) < cw(0,0+1*1)) {
r13 = buff(0,0+1*1);
ASSUME((!(( (cw(0,0+1*1) < 1) && (1 < crmax(0,0+1*1)) )))||(sforbid(0+1*1,1)> 0));
ASSUME((!(( (cw(0,0+1*1) < 2) && (2 < crmax(0,0+1*1)) )))||(sforbid(0+1*1,2)> 0));
ASSUME((!(( (cw(0,0+1*1) < 3) && (3 < crmax(0,0+1*1)) )))||(sforbid(0+1*1,3)> 0));
ASSUME((!(( (cw(0,0+1*1) < 4) && (4 < crmax(0,0+1*1)) )))||(sforbid(0+1*1,4)> 0));
} else {
if(pw(0,0+1*1) != co(0+1*1,cr(0,0+1*1))) {
ASSUME(cr(0,0+1*1) >= old_cr);
}
pw(0,0+1*1) = co(0+1*1,cr(0,0+1*1));
r13 = mem(0+1*1,cr(0,0+1*1));
}
ASSUME(creturn[0] >= cr(0,0+1*1));
// call void @llvm.dbg.value(metadata i64 %7, metadata !172, metadata !DIExpression()), !dbg !215
// %conv14 = trunc i64 %7 to i32, !dbg !118
// call void @llvm.dbg.value(metadata i32 %conv14, metadata !169, metadata !DIExpression()), !dbg !183
// %cmp15 = icmp eq i32 %conv14, 2, !dbg !119
creg__r13__2_ = max(0,creg_r13);
// %conv16 = zext i1 %cmp15 to i32, !dbg !119
// call void @llvm.dbg.value(metadata i32 %conv16, metadata !173, metadata !DIExpression()), !dbg !183
// %8 = load i32, i32* @atom_1_X0_1, align 4, !dbg !120, !tbaa !94
// LD: Guess
old_cr = cr(0,3);
cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l81_c13
// Check
ASSUME(active[cr(0,3)] == 0);
ASSUME(cr(0,3) >= iw(0,3));
ASSUME(cr(0,3) >= 0);
ASSUME(cr(0,3) >= cdy[0]);
ASSUME(cr(0,3) >= cisb[0]);
ASSUME(cr(0,3) >= cdl[0]);
ASSUME(cr(0,3) >= cl[0]);
// Update
creg_r14 = cr(0,3);
crmax(0,3) = max(crmax(0,3),cr(0,3));
caddr[0] = max(caddr[0],0);
if(cr(0,3) < cw(0,3)) {
r14 = buff(0,3);
ASSUME((!(( (cw(0,3) < 1) && (1 < crmax(0,3)) )))||(sforbid(3,1)> 0));
ASSUME((!(( (cw(0,3) < 2) && (2 < crmax(0,3)) )))||(sforbid(3,2)> 0));
ASSUME((!(( (cw(0,3) < 3) && (3 < crmax(0,3)) )))||(sforbid(3,3)> 0));
ASSUME((!(( (cw(0,3) < 4) && (4 < crmax(0,3)) )))||(sforbid(3,4)> 0));
} else {
if(pw(0,3) != co(3,cr(0,3))) {
ASSUME(cr(0,3) >= old_cr);
}
pw(0,3) = co(3,cr(0,3));
r14 = mem(3,cr(0,3));
}
ASSUME(creturn[0] >= cr(0,3));
// call void @llvm.dbg.value(metadata i32 %8, metadata !174, metadata !DIExpression()), !dbg !183
// %9 = load i32, i32* @atom_1_X2_1, align 4, !dbg !121, !tbaa !94
// LD: Guess
old_cr = cr(0,4);
cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l82_c13
// Check
ASSUME(active[cr(0,4)] == 0);
ASSUME(cr(0,4) >= iw(0,4));
ASSUME(cr(0,4) >= 0);
ASSUME(cr(0,4) >= cdy[0]);
ASSUME(cr(0,4) >= cisb[0]);
ASSUME(cr(0,4) >= cdl[0]);
ASSUME(cr(0,4) >= cl[0]);
// Update
creg_r15 = cr(0,4);
crmax(0,4) = max(crmax(0,4),cr(0,4));
caddr[0] = max(caddr[0],0);
if(cr(0,4) < cw(0,4)) {
r15 = buff(0,4);
ASSUME((!(( (cw(0,4) < 1) && (1 < crmax(0,4)) )))||(sforbid(4,1)> 0));
ASSUME((!(( (cw(0,4) < 2) && (2 < crmax(0,4)) )))||(sforbid(4,2)> 0));
ASSUME((!(( (cw(0,4) < 3) && (3 < crmax(0,4)) )))||(sforbid(4,3)> 0));
ASSUME((!(( (cw(0,4) < 4) && (4 < crmax(0,4)) )))||(sforbid(4,4)> 0));
} else {
if(pw(0,4) != co(4,cr(0,4))) {
ASSUME(cr(0,4) >= old_cr);
}
pw(0,4) = co(4,cr(0,4));
r15 = mem(4,cr(0,4));
}
ASSUME(creturn[0] >= cr(0,4));
// call void @llvm.dbg.value(metadata i32 %9, metadata !175, metadata !DIExpression()), !dbg !183
// %10 = load i32, i32* @atom_1_X3_2, align 4, !dbg !122, !tbaa !94
// LD: Guess
old_cr = cr(0,5);
cr(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l83_c13
// Check
ASSUME(active[cr(0,5)] == 0);
ASSUME(cr(0,5) >= iw(0,5));
ASSUME(cr(0,5) >= 0);
ASSUME(cr(0,5) >= cdy[0]);
ASSUME(cr(0,5) >= cisb[0]);
ASSUME(cr(0,5) >= cdl[0]);
ASSUME(cr(0,5) >= cl[0]);
// Update
creg_r16 = cr(0,5);
crmax(0,5) = max(crmax(0,5),cr(0,5));
caddr[0] = max(caddr[0],0);
if(cr(0,5) < cw(0,5)) {
r16 = buff(0,5);
ASSUME((!(( (cw(0,5) < 1) && (1 < crmax(0,5)) )))||(sforbid(5,1)> 0));
ASSUME((!(( (cw(0,5) < 2) && (2 < crmax(0,5)) )))||(sforbid(5,2)> 0));
ASSUME((!(( (cw(0,5) < 3) && (3 < crmax(0,5)) )))||(sforbid(5,3)> 0));
ASSUME((!(( (cw(0,5) < 4) && (4 < crmax(0,5)) )))||(sforbid(5,4)> 0));
} else {
if(pw(0,5) != co(5,cr(0,5))) {
ASSUME(cr(0,5) >= old_cr);
}
pw(0,5) = co(5,cr(0,5));
r16 = mem(5,cr(0,5));
}
ASSUME(creturn[0] >= cr(0,5));
// call void @llvm.dbg.value(metadata i32 %10, metadata !176, metadata !DIExpression()), !dbg !183
// %11 = load i32, i32* @atom_1_X7_0, align 4, !dbg !123, !tbaa !94
// LD: Guess
old_cr = cr(0,6);
cr(0,6) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l84_c13
// Check
ASSUME(active[cr(0,6)] == 0);
ASSUME(cr(0,6) >= iw(0,6));
ASSUME(cr(0,6) >= 0);
ASSUME(cr(0,6) >= cdy[0]);
ASSUME(cr(0,6) >= cisb[0]);
ASSUME(cr(0,6) >= cdl[0]);
ASSUME(cr(0,6) >= cl[0]);
// Update
creg_r17 = cr(0,6);
crmax(0,6) = max(crmax(0,6),cr(0,6));
caddr[0] = max(caddr[0],0);
if(cr(0,6) < cw(0,6)) {
r17 = buff(0,6);
ASSUME((!(( (cw(0,6) < 1) && (1 < crmax(0,6)) )))||(sforbid(6,1)> 0));
ASSUME((!(( (cw(0,6) < 2) && (2 < crmax(0,6)) )))||(sforbid(6,2)> 0));
ASSUME((!(( (cw(0,6) < 3) && (3 < crmax(0,6)) )))||(sforbid(6,3)> 0));
ASSUME((!(( (cw(0,6) < 4) && (4 < crmax(0,6)) )))||(sforbid(6,4)> 0));
} else {
if(pw(0,6) != co(6,cr(0,6))) {
ASSUME(cr(0,6) >= old_cr);
}
pw(0,6) = co(6,cr(0,6));
r17 = mem(6,cr(0,6));
}
ASSUME(creturn[0] >= cr(0,6));
// call void @llvm.dbg.value(metadata i32 %11, metadata !177, metadata !DIExpression()), !dbg !183
// %and = and i32 %10, %11, !dbg !124
creg_r18 = max(creg_r16,creg_r17);
r18 = r16 & r17;
// call void @llvm.dbg.value(metadata i32 %and, metadata !178, metadata !DIExpression()), !dbg !183
// %and17 = and i32 %9, %and, !dbg !125
creg_r19 = max(creg_r15,creg_r18);
r19 = r15 & r18;
// call void @llvm.dbg.value(metadata i32 %and17, metadata !179, metadata !DIExpression()), !dbg !183
// %and18 = and i32 %8, %and17, !dbg !126
creg_r20 = max(creg_r14,creg_r19);
r20 = r14 & r19;
// call void @llvm.dbg.value(metadata i32 %and18, metadata !180, metadata !DIExpression()), !dbg !183
// %and19 = and i32 %conv16, %and18, !dbg !127
creg_r21 = max(creg__r13__2_,creg_r20);
r21 = (r13==2) & r20;
// call void @llvm.dbg.value(metadata i32 %and19, metadata !181, metadata !DIExpression()), !dbg !183
// %and20 = and i32 %conv10, %and19, !dbg !128
creg_r22 = max(creg__r12__1_,creg_r21);
r22 = (r12==1) & r21;
// call void @llvm.dbg.value(metadata i32 %and20, metadata !182, metadata !DIExpression()), !dbg !183
// %cmp21 = icmp eq i32 %and20, 1, !dbg !129
creg__r22__1_ = max(0,creg_r22);
// br i1 %cmp21, label %if.then, label %if.end, !dbg !131
old_cctrl = cctrl[0];
cctrl[0] = get_rng(0,NCONTEXT-1);
ASSUME(cctrl[0] >= old_cctrl);
ASSUME(cctrl[0] >= creg__r22__1_);
if((r22==1)) {
goto T0BLOCK1;
} else {
goto T0BLOCK2;
}
T0BLOCK1:
// call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([119 x i8], [119 x i8]* @.str.1, i64 0, i64 0), i32 noundef 90, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #8, !dbg !132
// unreachable, !dbg !132
r23 = 1;
goto T0BLOCK_END;
T0BLOCK2:
// %12 = bitcast i64* %thr2 to i8*, !dbg !135
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %12) #7, !dbg !135
// %13 = bitcast i64* %thr1 to i8*, !dbg !135
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %13) #7, !dbg !135
// %14 = bitcast i64* %thr0 to i8*, !dbg !135
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %14) #7, !dbg !135
// ret i32 0, !dbg !136
ret_thread_0 = 0;
goto T0BLOCK_END;
T0BLOCK_END:
ASSUME(meminit(0,1) == mem(0,0));
ASSUME(coinit(0,1) == co(0,0));
ASSUME(deltainit(0,1) == delta(0,0));
ASSUME(meminit(0,2) == mem(0,1));
ASSUME(coinit(0,2) == co(0,1));
ASSUME(deltainit(0,2) == delta(0,1));
ASSUME(meminit(0,3) == mem(0,2));
ASSUME(coinit(0,3) == co(0,2));
ASSUME(deltainit(0,3) == delta(0,2));
ASSUME(meminit(0,4) == mem(0,3));
ASSUME(coinit(0,4) == co(0,3));
ASSUME(deltainit(0,4) == delta(0,3));
ASSUME(meminit(1,1) == mem(1,0));
ASSUME(coinit(1,1) == co(1,0));
ASSUME(deltainit(1,1) == delta(1,0));
ASSUME(meminit(1,2) == mem(1,1));
ASSUME(coinit(1,2) == co(1,1));
ASSUME(deltainit(1,2) == delta(1,1));
ASSUME(meminit(1,3) == mem(1,2));
ASSUME(coinit(1,3) == co(1,2));
ASSUME(deltainit(1,3) == delta(1,2));
ASSUME(meminit(1,4) == mem(1,3));
ASSUME(coinit(1,4) == co(1,3));
ASSUME(deltainit(1,4) == delta(1,3));
ASSUME(meminit(2,1) == mem(2,0));
ASSUME(coinit(2,1) == co(2,0));
ASSUME(deltainit(2,1) == delta(2,0));
ASSUME(meminit(2,2) == mem(2,1));
ASSUME(coinit(2,2) == co(2,1));
ASSUME(deltainit(2,2) == delta(2,1));
ASSUME(meminit(2,3) == mem(2,2));
ASSUME(coinit(2,3) == co(2,2));
ASSUME(deltainit(2,3) == delta(2,2));
ASSUME(meminit(2,4) == mem(2,3));
ASSUME(coinit(2,4) == co(2,3));
ASSUME(deltainit(2,4) == delta(2,3));
ASSUME(meminit(3,1) == mem(3,0));
ASSUME(coinit(3,1) == co(3,0));
ASSUME(deltainit(3,1) == delta(3,0));
ASSUME(meminit(3,2) == mem(3,1));
ASSUME(coinit(3,2) == co(3,1));
ASSUME(deltainit(3,2) == delta(3,1));
ASSUME(meminit(3,3) == mem(3,2));
ASSUME(coinit(3,3) == co(3,2));
ASSUME(deltainit(3,3) == delta(3,2));
ASSUME(meminit(3,4) == mem(3,3));
ASSUME(coinit(3,4) == co(3,3));
ASSUME(deltainit(3,4) == delta(3,3));
ASSUME(meminit(4,1) == mem(4,0));
ASSUME(coinit(4,1) == co(4,0));
ASSUME(deltainit(4,1) == delta(4,0));
ASSUME(meminit(4,2) == mem(4,1));
ASSUME(coinit(4,2) == co(4,1));
ASSUME(deltainit(4,2) == delta(4,1));
ASSUME(meminit(4,3) == mem(4,2));
ASSUME(coinit(4,3) == co(4,2));
ASSUME(deltainit(4,3) == delta(4,2));
ASSUME(meminit(4,4) == mem(4,3));
ASSUME(coinit(4,4) == co(4,3));
ASSUME(deltainit(4,4) == delta(4,3));
ASSUME(meminit(5,1) == mem(5,0));
ASSUME(coinit(5,1) == co(5,0));
ASSUME(deltainit(5,1) == delta(5,0));
ASSUME(meminit(5,2) == mem(5,1));
ASSUME(coinit(5,2) == co(5,1));
ASSUME(deltainit(5,2) == delta(5,1));
ASSUME(meminit(5,3) == mem(5,2));
ASSUME(coinit(5,3) == co(5,2));
ASSUME(deltainit(5,3) == delta(5,2));
ASSUME(meminit(5,4) == mem(5,3));
ASSUME(coinit(5,4) == co(5,3));
ASSUME(deltainit(5,4) == delta(5,3));
ASSUME(meminit(6,1) == mem(6,0));
ASSUME(coinit(6,1) == co(6,0));
ASSUME(deltainit(6,1) == delta(6,0));
ASSUME(meminit(6,2) == mem(6,1));
ASSUME(coinit(6,2) == co(6,1));
ASSUME(deltainit(6,2) == delta(6,1));
ASSUME(meminit(6,3) == mem(6,2));
ASSUME(coinit(6,3) == co(6,2));
ASSUME(deltainit(6,3) == delta(6,2));
ASSUME(meminit(6,4) == mem(6,3));
ASSUME(coinit(6,4) == co(6,3));
ASSUME(deltainit(6,4) == delta(6,3));
ASSERT(r23== 0);
}
| [
"[email protected]"
] | |
6de3d96f0587935d59dfb1a997db920e436d9874 | 220d0209b916b1cdf6527ae0af239f5f3718aa0a | /Slave/Slave.ino | a7a90b3a5faa3408856d586961e56de5e69ccafc | [] | no_license | Igorlinharesb/Projeto-Final-IoT | d9d39c493c12afd8b278f87a178a0d308ccd5798 | 2f258d29c71849afbf147f2ea421490e88c4937e | refs/heads/master | 2020-04-08T14:02:31.705222 | 2018-11-28T00:39:23 | 2018-11-28T00:39:23 | 159,419,284 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,971 | ino | //LDR
#define LDR A0
#define AUTH D1
#define LAMP D0
int luz;
int autent;
// *Incluindo bibliotecas do DHT*
#include <DHT.h>
#include <Blynk.h>
#include <BlynkSimpleEsp8266.h>
#include <ESP8266WiFi.h>
// *Adicionando conexão com o protocolo Wi-Fi*
// Autenticando ao ThingSpeak e Blynk
String apiKey = "R42VDGDQK5MEXWYP"; // <-- seu Write API key do site ThingSpeak
char auth[] = "73d6f080daac4ed9a5e036ebed2029d5"; // <--authtoken do blynk
char ssid[] = "REDEIOT"; // <-- substitua com o ssid e senha da rede Wifi
char pass[] = "iotnet18";
const char* server = "api.thingspeak.com";
#define DHTPIN 0 //<-- pin onde o dht11 está conectado d3 = 0
DHT dht(DHTPIN, DHT11);
BlynkTimer timer;
WiFiClient client;
extern "C" {
#include <espnow.h> //Biblioteca do ESP-Now
}
//Estruturas de dados que será enviada
struct DADOS {
uint16_t valor = 0;
uint32_t tempo = 0;
};
//LED na porta digital D1
#define LED D1
//Modo de operação do protocolo
#define MASTER 1 //Pareia e envia os dados
#define SLAVE 2 //É pareado e recebe os dados
#define MASTER_SLAVE 3 //Pareia, envia e recebe dados
//Definindo o modo de operação
#define MODO SLAVE
//Métodos úteis para o protocolo ESP-Now
void IniciaESPNow() { //Inicia ESP-Now
if (esp_now_init() != 0) {
Serial.println("Falha ao iniciar protocolo ESP-Now; Reiniciando...");
ESP.restart();
delay(1);
}
esp_now_set_self_role(MODO); //Setando modo de operação
}
void Recebeu(uint8_t *mac, uint8_t *data, uint8_t len) { //Callback chamado sempre que recebe um novo pacote
char MACmestre[6];
sprintf(MACmestre, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
Serial.print("Recepcao do ESP de MAC: ");
Serial.println(MACmestre);
DADOS dados;
memcpy(&dados, data, sizeof(dados));
WidgetLED led1(V8);
if (dados.valor == 1) {
Serial.print("Valor Recebido: ");
Serial.print(dados.valor);
Serial.print(", Tempo Recebido: ");
Serial.println(dados.tempo);
autent = 1;
digitalWrite(LED, HIGH);//Escreve o valor recebido na porta
led1.on();
Blynk.notify("Bem vindo Sr. Rayon");
} else {
Serial.print("Valor Recebido: ");
Serial.print(dados.valor);
Serial.print(", Tempo Recebido: ");
Serial.println(dados.tempo);
digitalWrite(LED, LOW);
led1.off();
Blynk.notify("Até mais Sr. Rayon!");
autent = 0;
}
}
void readLDR() {
luz = analogRead(LDR);
Serial.print("Luminosidade: ");
Serial.println(luz);
if (luz <= 900) {
digitalWrite(LAMP, HIGH);
} else {
digitalWrite(LAMP, LOW);
}
Blynk.virtualWrite(V7, luz);
}
void sendSensor() {
float h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
}
void setup() {
// LED LDR
pinMode (LAMP, OUTPUT);
pinMode (LED, OUTPUT);
IniciaESPNow();
//Setando Callback de recebimento do ESP-Now
esp_now_register_recv_cb(Recebeu);
//funçoes do DHT
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
dht.begin();
// Executa a função sendSensor a cada 1000ms
timer.setInterval(1000L, sendSensor);
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
}
void loop() {
//LDR
if (autent == 1){
readLDR();
}
// DHT
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
delay(2000);
return;
}
Blynk.run();
timer.run();
if (client.connect(server, 80)) { // "184.106.153.149" or api.thingspeak.com
String postStr = apiKey;
postStr += "&field1="; //<-- atenção, esse é o campo 1 que você escolheu no canal do ThingSpeak
postStr += String(t);
postStr += "&field2=";
postStr += String(h);
postStr += "\r\n\r\n";
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" degrees Celcius, Humidity: ");
Serial.print(h);
Serial.println("%. Send to Thingspeak.");
}
client.stop();
Serial.println("Waiting...");
// thingspeak needs minimum 15 sec delay between updates, i've set it to 20 seconds
delay(5000);
}
| [
"[email protected]"
] | |
48c45ca6abdb3fb2ad92b8d296b762a2eaba1dd7 | e6f6ed474a804d900becb293e55cc74507b0ba85 | /swmachine.h | dbf5761a5afef80e636bbb7f4cfe00ddb36d8674 | [] | no_license | alevya/SWMControl | be271c19713660c6415ef1866587d83c03bed815 | 29e881a3c1bb2783e6d3d7644a69a82e7bb8dc83 | refs/heads/master | 2021-02-17T18:57:36.097669 | 2020-03-14T10:50:40 | 2020-03-14T10:50:40 | 245,119,534 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 111 | h | #ifndef SWMACHINE_H
#define SWMACHINE_H
class SWMachine
{
public:
SWMachine();
};
#endif // SWMACHINE_H
| [
"[email protected]"
] | |
a265ca9979721f66ee04f6e61fe43b817ac29193 | f36040d73ef68b6e362f7334db6f112d498a4d95 | /src/renderer/entity/plane.cpp | 2e7c593e15e90cf6b276bed137fb860c3f157b88 | [] | no_license | sbroadhead/lray | 66d7a45fd82e3913a019802e953137ffb912b6c0 | 825e2958aae3c2561422c8e928ac03ff0c490832 | refs/heads/master | 2021-01-10T04:02:40.685981 | 2015-10-17T16:35:20 | 2015-10-17T16:35:20 | 44,445,288 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,036 | cpp | #include "common.h"
#include "renderer/entity/plane.h"
#include "renderer/intersection.h"
#include "math/math.h"
namespace raytrace {;
/**
*/
Box PlaneEntity::BoundingBox() const {
return Box(Point(-INFINITY, -INFINITY, -INFINITY),
Point(INFINITY, INFINITY, INFINITY));
}
/**
*/
bool PlaneEntity::Intersect(Ray const& ray, Intersection *out) const
{
double cos_angle = Dot(ray.direction, direction::up);
Ray new_ray = transformation.Inverse().Apply(ray);
if (fabs(cos_angle) > EPS) {
Vector ray_diff = Point(0, 0, 0) - new_ray.origin;
double dist = Dot(ray_diff, direction::up) / cos_angle;
if (dist >= new_ray.min_dist && dist <= new_ray.max_dist) {
Point point = new_ray.origin + dist * new_ray.direction;
if (out) {
out->entity = this;
out->distance = dist;
out->geometry.normal = transformation.Apply(Normal(direction::up));
}
return true;
} else {
int a = 0;
}
}
return false;
}
} | [
"[email protected]"
] | |
5bfdd0baa35e483dd65fb2c53b780959432768d5 | 193a66bee070ed11b6c795a9d40502d4c502667b | /codeforces/1560D.cpp | 1cbfc14c82b8c296786b6e4967c765e4de2f2c0e | [] | no_license | 1tygoime/a | d3603b0f9dc043f3249b2574af060ed487193ac2 | a5ca1c8193959e8619adebf3430d35b652f5d399 | refs/heads/main | 2023-08-11T09:53:13.925780 | 2021-10-11T16:28:49 | 2021-10-11T16:28:49 | 416,415,399 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,000 | cpp | #include<bits/stdc++.h>
using namespace std;
vector<int> v;
string s[60];
int dp[25][25];
int check(string x, string y){
// x = " " + x;
// y = " " + y;
int i = 1, j = 1, s = 0;
int n = x.size(), m = y.size();
while (i <= n){
while (j <= m){
if (y[j] == x[i]){
s++;
j++;
break;
}
j++;
}
if (s < i) break;
i++;
}
return s;
}
void solve(){
int n, res = 1e9;
cin >> n;
string f = ' ' + to_string(n);
for(string cc : s){
// memset(dp, 0, sizeof(dp));
// int c = 0;
// for(int i = 1; i < f.size(); i++)
// for(int j = 1; j < cc.size(); j++)
// if(f[i] == cc[j]) ++c;
res = min(res, (int)check(f, cc));
}
cout << res << '\n';
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
for(int i = 0; i <= 59; i++)
s[i] = ' ' + to_string(1LL << i);
int t;
for(cin >> t; t--; ) solve();
}
| [
"[email protected]"
] | |
0485e1ed1f8521dd8bc7b804b0a8ea86b7d46112 | 83bacfbdb7ad17cbc2fc897b3460de1a6726a3b1 | /gen/blink/modules/filesystem/FileSystemFlags.h | 4d818952e96efb9e26e4a5fcf30ff813f2752205 | [
"Apache-2.0"
] | permissive | cool2528/miniblink49 | d909e39012f2c5d8ab658dc2a8b314ad0050d8ea | 7f646289d8074f098cf1244adc87b95e34ab87a8 | refs/heads/master | 2020-06-05T03:18:43.211372 | 2019-06-01T08:57:37 | 2019-06-01T08:59:56 | 192,294,645 | 2 | 0 | Apache-2.0 | 2019-06-17T07:16:28 | 2019-06-17T07:16:27 | null | UTF-8 | C++ | false | false | 1,135 | h | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
#ifndef FileSystemFlags_h
#define FileSystemFlags_h
#include "bindings/core/v8/Nullable.h"
#include "modules/ModulesExport.h"
#include "platform/heap/Handle.h"
namespace blink {
class MODULES_EXPORT FileSystemFlags {
ALLOW_ONLY_INLINE_ALLOCATION();
public:
FileSystemFlags();
bool hasCreateFlag() const { return !m_createFlag.isNull(); }
bool createFlag() const { return m_createFlag.get(); }
void setCreateFlag(bool value) { m_createFlag = value; }
bool hasExclusive() const { return !m_exclusive.isNull(); }
bool exclusive() const { return m_exclusive.get(); }
void setExclusive(bool value) { m_exclusive = value; }
DECLARE_VIRTUAL_TRACE();
private:
Nullable<bool> m_createFlag;
Nullable<bool> m_exclusive;
friend class V8FileSystemFlags;
};
} // namespace blink
#endif // FileSystemFlags_h
| [
"[email protected]"
] | |
d1d169e44c2bfe672743952bea43a415ce0ba105 | ff77c0fa20fb5d7bf7ec0ee33a67ab1bf90328ac | /src/engine/FlatCamera.h | a73225c85f1c72014cc39258761190609a425065 | [] | no_license | borman/mgraph04-raytracer | b5ac39460f4e956c9de4d8fa79fec844fd11b9a8 | 17954e87e9b88967e819655eb75042a9caff7735 | refs/heads/master | 2021-01-23T18:09:57.811766 | 2011-12-07T20:18:52 | 2011-12-07T20:18:52 | 3,058,363 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 486 | h | #ifndef FLATCAMERA_H
#define FLATCAMERA_H
#include "float3.h"
class FlatCamera
{
public:
FlatCamera() {}
FlatCamera(float fov, float aspect,
const float3 &cam, const float3 &lookat, const float3 &up);
// map (x, y) to a ray; x and y vary from 0.0 to 1.0
float3 project(float x, float y) const { return vnormalize(m_origin + x*m_x + y*m_y); }
float3 pos() const { return m_pos; }
private:
float3 m_pos;
float3 m_origin, m_x, m_y;
};
#endif // FLATCAMERA_H
| [
"[email protected]"
] | |
b856f06970beb976397a3fc1ea2777d7a7634cd0 | 775acebaa6559bb12365c930330a62365afb0d98 | /source/public/interfaces/interactive/IMediaContent.h | 89fdb91ce86fc449d69408f385bd5e48b2e262d0 | [] | no_license | Al-ain-Developers/indesing_plugin | 3d22c32d3d547fa3a4b1fc469498de57643e9ee3 | 36a09796b390e28afea25456b5d61597b20de850 | refs/heads/main | 2023-08-14T13:34:47.867890 | 2021-10-05T07:57:35 | 2021-10-05T07:57:35 | 339,970,603 | 1 | 1 | null | 2021-10-05T07:57:36 | 2021-02-18T07:33:40 | C++ | UTF-8 | C++ | false | false | 3,777 | h | //========================================================================================
//
// $File: //depot/devtech/16.0.x/plugin/source/public/interfaces/interactive/IMediaContent.h $
//
// Owner: wtislar
//
// $Author: pmbuilder $
//
// $DateTime: 2020/11/06 13:08:29 $
//
// $Revision: #2 $
//
// $Change: 1088580 $
//
// Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
//
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
// with the terms of the Adobe license agreement accompanying it. If you have received
// this file from a source other than Adobe, then your use, modification, or
// distribution of it requires the prior written permission of Adobe.
//
//========================================================================================
#pragma once
#ifndef __IMediaContent__
#define __IMediaContent__
#include "IPMUnknown.h"
#include "MediaID.h"
#include "MediaLocation.h"
#include "IMediaAttributes.h"
/**
Provides access to media content.
*/
class IMediaContent : public IPMUnknown
{
public:
enum { kDefaultIID = IID_IMEDIACONTENT };
enum MediaType
{
enUndefined,
enVideo,
enAudio,
enLegacyVideo = 4, // pre-CS5 video types
enLegacyAudio // pre-CS5 audio types
};
/**
Provides an IPMStream to read the media content.
@param rawContentRequired set to kTrue to assure that the stream provides raw,
unfiltered content. For file-based content, this is equivalent to reading directly
from the file.
*/
virtual IPMStream * CreateContentStreamRead( bool16 rawContentRequired = kFalse ) = 0;
/** Retrieves the standard MIME type for the media content.
@return a PMString populated with the mime type; if the MIME type is unknown or
unavailable, returns a null string.
*/
virtual PMString GetMimeType() = 0;
/** Retrieves the location of the media content.
@return MediaLocation object.
@see MediaLocation.
*/
virtual const MediaLocation GetLocation() const = 0;
/** Retrieves the media base file name (without the path).
@return a PMString object representing the base file name of the media content.
The string may be null; i.e., it may have zero length.
*/
virtual const PMString GetMediaFileName() const = 0;
/** Retrieves the full media file path.
@return a PMString object representing the absolute path to the media content.
The string may be null; i.e., it may have zero length.
*/
virtual const PMString GetMediaFilePath() const = 0;
/** Retrieves the full path for a poster image.
@return a PMString representing the absolute local path to an image file.
*/
virtual const PMString GetPosterPath() const = 0;
/** Retrieves the IMediaAttributes::PosterType for the media page item.
@return the IMediaAttributes::PosterType.
*/
virtual IMediaAttributes::PosterType GetPosterType() const = 0;
/** Retrieves the UID of the media poster page item.
@return a page item UID. If the poster page item does not exist, returns kInvalidUID.
*/
virtual const UID GetPosterUID() const = 0;
/** Tests if content has been set. Useful to test when deciding if the media page item
can be exported or is simply acting as a placeholder.
@return kTrue if there is content; kFalse if there is none.
*/
virtual bool16 HasContent() const = 0;
/** Tests if a poster is available by determining if
(1) the content has a poster, and
(2) the content can be accessed to obtain the poster.
@return kTrue if poster can be accessed; kFalse if not.
*/
virtual bool16 IsPosterAvailable() const = 0;
/** Retrieves the MediaType.
@return IMediaContent::MediaType.
*/
virtual IMediaContent::MediaType GetMediaType() const = 0;
}; // end IMediaContent interface
#endif // __IMediaContent__
| [
"[email protected]"
] | |
c72612f523dce0a8fb347c09e2fae33faafb3372 | d649cb8ad89a28f0baa2160a3ee58bc007ceae04 | /chrome/browser/previews/previews_infobar_delegate.cc | d1cce99234847cefd53d42907083c327d9b40760 | [
"BSD-3-Clause"
] | permissive | yzyz/chromium | 6ee310fcbbed07caa228985a3e66ac70b13b56ee | 5f4bb2f552aeb48610c1b59fe9a555e4c9ac78fa | refs/heads/master | 2023-01-13T12:30:09.212664 | 2017-07-13T20:32:26 | 2017-07-13T20:32:26 | 93,433,050 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,328 | cc | // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/previews/previews_infobar_delegate.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_macros.h"
#include "base/optional.h"
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/android/android_theme_resources.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_factory.h"
#include "chrome/browser/previews/previews_infobar_tab_helper.h"
#include "chrome/grit/generated_resources.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
#include "components/infobars/core/infobar.h"
#include "components/network_time/network_time_tracker.h"
#include "components/previews/core/previews_features.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h"
#if defined(OS_ANDROID)
#include "chrome/browser/ui/android/infobars/previews_infobar.h"
#endif
namespace {
const char kMinStalenessParamName[] = "min_staleness_in_minutes";
const char kMaxStalenessParamName[] = "max_staleness_in_minutes";
const int kMinStalenessParamDefaultValue = 2;
const int kMaxStalenessParamDefaultValue = 1440;
void RecordPreviewsInfoBarAction(
previews::PreviewsType previews_type,
PreviewsInfoBarDelegate::PreviewsInfoBarAction action) {
int32_t max_limit =
static_cast<int32_t>(PreviewsInfoBarDelegate::INFOBAR_INDEX_BOUNDARY);
base::LinearHistogram::FactoryGet(
base::StringPrintf("Previews.InfoBarAction.%s",
GetStringNameForType(previews_type).c_str()),
1, max_limit, max_limit + 1,
base::HistogramBase::kUmaTargetedHistogramFlag)
->Add(static_cast<int32_t>(action));
}
void RecordStaleness(PreviewsInfoBarDelegate::PreviewsInfoBarTimestamp value) {
UMA_HISTOGRAM_ENUMERATION("Previews.InfoBarTimestamp", value,
PreviewsInfoBarDelegate::TIMESTAMP_INDEX_BOUNDARY);
}
// Sends opt out information to the pingback service based on a key value in the
// infobar tab helper. Sending this information in the case of a navigation that
// should not send a pingback (or is not a server preview) will not alter the
// pingback.
void ReportPingbackInformation(content::WebContents* web_contents) {
auto* data_reduction_proxy_settings =
DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
web_contents->GetBrowserContext());
PreviewsInfoBarTabHelper* infobar_tab_helper =
PreviewsInfoBarTabHelper::FromWebContents(web_contents);
if (infobar_tab_helper &&
infobar_tab_helper->committed_data_saver_navigation_id()) {
data_reduction_proxy_settings->data_reduction_proxy_service()
->pingback_client()
->AddOptOut(
infobar_tab_helper->committed_data_saver_navigation_id().value());
}
}
// Increments the prefs-based opt out information for data reduction proxy when
// the user is not already transitioned to the PreviewsBlackList.
void IncrementDataReductionProxyPrefs(content::WebContents* web_contents) {
auto* data_reduction_proxy_settings =
DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
web_contents->GetBrowserContext());
data_reduction_proxy_settings->IncrementLoFiUserRequestsForImages();
}
// Reloads the content of the page without previews.
void ReloadWithoutPreviews(previews::PreviewsType previews_type,
content::WebContents* web_contents) {
switch (previews_type) {
case previews::PreviewsType::LITE_PAGE:
case previews::PreviewsType::OFFLINE:
// Prevent LoFi and lite page modes from showing after reload.
// TODO(ryansturm): rename DISABLE_LOFI_MODE to DISABLE_PREVIEWS.
// crbug.com/707272
web_contents->GetController().Reload(
content::ReloadType::DISABLE_LOFI_MODE, true);
break;
case previews::PreviewsType::LOFI:
web_contents->ReloadLoFiImages();
break;
case previews::PreviewsType::NONE:
case previews::PreviewsType::LAST:
break;
}
}
} // namespace
PreviewsInfoBarDelegate::~PreviewsInfoBarDelegate() {
if (!on_dismiss_callback_.is_null())
on_dismiss_callback_.Run(false);
RecordPreviewsInfoBarAction(previews_type_, infobar_dismissed_action_);
}
// static
void PreviewsInfoBarDelegate::Create(
content::WebContents* web_contents,
previews::PreviewsType previews_type,
base::Time previews_freshness,
bool is_data_saver_user,
bool is_reload,
const OnDismissPreviewsInfobarCallback& on_dismiss_callback) {
PreviewsInfoBarTabHelper* infobar_tab_helper =
PreviewsInfoBarTabHelper::FromWebContents(web_contents);
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents);
// The WebContents may not have TabHelpers set. If TabHelpers are not set,
// don't show Previews infobars.
if (!infobar_tab_helper || !infobar_service)
return;
if (infobar_tab_helper->displayed_preview_infobar())
return;
std::unique_ptr<PreviewsInfoBarDelegate> delegate(new PreviewsInfoBarDelegate(
infobar_tab_helper, previews_type, previews_freshness, is_data_saver_user,
is_reload, on_dismiss_callback));
#if defined(OS_ANDROID)
std::unique_ptr<infobars::InfoBar> infobar_ptr(
PreviewsInfoBar::CreateInfoBar(infobar_service, std::move(delegate)));
#else
std::unique_ptr<infobars::InfoBar> infobar_ptr(
infobar_service->CreateConfirmInfoBar(std::move(delegate)));
#endif
infobars::InfoBar* infobar =
infobar_service->AddInfoBar(std::move(infobar_ptr));
if (infobar && (previews_type == previews::PreviewsType::LITE_PAGE ||
previews_type == previews::PreviewsType::LOFI)) {
auto* data_reduction_proxy_settings =
DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
web_contents->GetBrowserContext());
data_reduction_proxy_settings->IncrementLoFiUIShown();
}
RecordPreviewsInfoBarAction(previews_type, INFOBAR_SHOWN);
infobar_tab_helper->set_displayed_preview_infobar(true);
}
PreviewsInfoBarDelegate::PreviewsInfoBarDelegate(
PreviewsInfoBarTabHelper* infobar_tab_helper,
previews::PreviewsType previews_type,
base::Time previews_freshness,
bool is_data_saver_user,
bool is_reload,
const OnDismissPreviewsInfobarCallback& on_dismiss_callback)
: ConfirmInfoBarDelegate(),
infobar_tab_helper_(infobar_tab_helper),
previews_type_(previews_type),
previews_freshness_(previews_freshness),
is_reload_(is_reload),
infobar_dismissed_action_(INFOBAR_DISMISSED_BY_TAB_CLOSURE),
message_text_(l10n_util::GetStringUTF16(
is_data_saver_user ? IDS_PREVIEWS_INFOBAR_SAVED_DATA_TITLE
: IDS_PREVIEWS_INFOBAR_FASTER_PAGE_TITLE)),
on_dismiss_callback_(on_dismiss_callback) {}
infobars::InfoBarDelegate::InfoBarIdentifier
PreviewsInfoBarDelegate::GetIdentifier() const {
return DATA_REDUCTION_PROXY_PREVIEW_INFOBAR_DELEGATE;
}
int PreviewsInfoBarDelegate::GetIconId() const {
#if defined(OS_ANDROID)
return IDR_ANDROID_INFOBAR_PREVIEWS;
#else
return kNoIconID;
#endif
}
bool PreviewsInfoBarDelegate::ShouldExpire(
const NavigationDetails& details) const {
infobar_dismissed_action_ = details.is_reload
? INFOBAR_DISMISSED_BY_RELOAD
: INFOBAR_DISMISSED_BY_NAVIGATION;
return InfoBarDelegate::ShouldExpire(details);
}
void PreviewsInfoBarDelegate::InfoBarDismissed() {
infobar_dismissed_action_ = INFOBAR_DISMISSED_BY_USER;
}
base::string16 PreviewsInfoBarDelegate::GetMessageText() const {
// Android has a custom infobar that calls GetTimestampText() and adds the
// timestamp in a separate description view. Other OS's can enable previews
// for debugging purposes and don't have a custom infobar with a description
// view, so the timestamp should be appended to the message.
#if defined(OS_ANDROID)
return message_text_;
#else
base::string16 timestamp = GetTimestampText();
if (timestamp.empty())
return message_text_;
return message_text_ + base::ASCIIToUTF16(" ") + timestamp;
#endif
}
int PreviewsInfoBarDelegate::GetButtons() const {
return BUTTON_NONE;
}
base::string16 PreviewsInfoBarDelegate::GetLinkText() const {
return l10n_util::GetStringUTF16(IDS_PREVIEWS_INFOBAR_LINK);
}
bool PreviewsInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
infobar_dismissed_action_ = INFOBAR_LOAD_ORIGINAL_CLICKED;
if (!on_dismiss_callback_.is_null())
on_dismiss_callback_.Run(true);
on_dismiss_callback_.Reset();
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
ReportPingbackInformation(web_contents);
if ((previews_type_ == previews::PreviewsType::LITE_PAGE ||
previews_type_ == previews::PreviewsType::LOFI) &&
!data_reduction_proxy::params::IsBlackListEnabledForServerPreviews()) {
IncrementDataReductionProxyPrefs(web_contents);
}
ReloadWithoutPreviews(previews_type_, web_contents);
return true;
}
base::string16 PreviewsInfoBarDelegate::GetTimestampText() const {
if (previews_freshness_.is_null())
return base::string16();
if (!base::FeatureList::IsEnabled(
previews::features::kStalePreviewsTimestamp)) {
return base::string16();
}
int min_staleness_in_minutes = base::GetFieldTrialParamByFeatureAsInt(
previews::features::kStalePreviewsTimestamp, kMinStalenessParamName,
kMinStalenessParamDefaultValue);
int max_staleness_in_minutes = base::GetFieldTrialParamByFeatureAsInt(
previews::features::kStalePreviewsTimestamp, kMaxStalenessParamName,
kMaxStalenessParamDefaultValue);
if (min_staleness_in_minutes <= 0 || max_staleness_in_minutes <= 0) {
NOTREACHED();
return base::string16();
}
base::Time network_time;
if (g_browser_process->network_time_tracker()->GetNetworkTime(&network_time,
nullptr) !=
network_time::NetworkTimeTracker::NETWORK_TIME_AVAILABLE) {
// When network time has not been initialized yet, simply rely on the
// machine's current time.
network_time = base::Time::Now();
}
if (network_time < previews_freshness_) {
RecordStaleness(TIMESTAMP_NOT_SHOWN_STALENESS_NEGATIVE);
return base::string16();
}
int staleness_in_minutes = (network_time - previews_freshness_).InMinutes();
if (staleness_in_minutes < min_staleness_in_minutes) {
if (is_reload_) {
RecordStaleness(TIMESTAMP_UPDATED_NOW_SHOWN);
if (infobar_tab_helper_)
infobar_tab_helper_->set_displayed_preview_timestamp(true);
return l10n_util::GetStringUTF16(
IDS_PREVIEWS_INFOBAR_TIMESTAMP_UPDATED_NOW);
}
RecordStaleness(TIMESTAMP_NOT_SHOWN_PREVIEW_NOT_STALE);
return base::string16();
}
if (staleness_in_minutes > max_staleness_in_minutes) {
RecordStaleness(TIMESTAMP_NOT_SHOWN_STALENESS_GREATER_THAN_MAX);
return base::string16();
}
RecordStaleness(TIMESTAMP_SHOWN);
if (infobar_tab_helper_)
infobar_tab_helper_->set_displayed_preview_timestamp(true);
if (staleness_in_minutes < 60) {
return l10n_util::GetStringFUTF16(
IDS_PREVIEWS_INFOBAR_TIMESTAMP_MINUTES,
base::IntToString16(staleness_in_minutes));
} else if (staleness_in_minutes < 120) {
return l10n_util::GetStringUTF16(IDS_PREVIEWS_INFOBAR_TIMESTAMP_ONE_HOUR);
} else {
return l10n_util::GetStringFUTF16(
IDS_PREVIEWS_INFOBAR_TIMESTAMP_HOURS,
base::IntToString16(staleness_in_minutes / 60));
}
}
| [
"[email protected]"
] | |
a903b0ba822f06882a7b332ff8f52e81a36e361d | 06bd2b6fd35381452cd321382e6549475c48c7a0 | /알고리즘 준비 9월/소수구하기_1929.cpp | 4d8a2f1d6ef64c5eb258252c721211a3e8fd15d0 | [] | no_license | toywwy/9M_algorithm | 188f667a147346e0182e8658f8d9d6a2430bc80a | 890822ec7662e3720f7b1ef248daaa5cdc98c105 | refs/heads/master | 2021-01-18T00:43:34.523529 | 2019-05-10T16:45:20 | 2019-05-10T16:45:20 | 68,367,712 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 635 | cpp | /*
문제 : 소수구하기
문제 번호: 1929
풀이법 : 에라토네스체
날짜 : 20161002
기타 :
*/
#include<iostream>
#define SIZE 1000000
using namespace std;
//(1≤M≤N≤1, 000, 000)
bool check[SIZE];
int main(void)
{
int from,to;
cin >> from >> to;
check[0] = 1;
check[1] = 1;
check[2] = false; //2는 소수다
for (int i = 2; i <= to; i++) //to까지 소숭인지 판별하면된다.
{
if (check[i]) continue; //소수가 아니면 안해
for (int j = 2; i*j <= to; j++)
check[i*j] = 1;
}
for (int i = from; i <= to; i++)
if (!check[i]) printf("%d ", i);
cout << endl;
return 0;
} | [
"[email protected]"
] | |
e04fee7dbe17fc8a082cfe02a0e53858a45ff8db | dd80a584130ef1a0333429ba76c1cee0eb40df73 | /external/chromium_org/content/browser/renderer_host/pepper/pepper_file_ref_host.cc | 75350a03632f653bbf5b098c1674fb40f38a3dd9 | [
"MIT",
"BSD-3-Clause"
] | permissive | karunmatharu/Android-4.4-Pay-by-Data | 466f4e169ede13c5835424c78e8c30ce58f885c1 | fcb778e92d4aad525ef7a995660580f948d40bc9 | refs/heads/master | 2021-03-24T13:33:01.721868 | 2017-02-18T17:48:49 | 2017-02-18T17:48:49 | 81,847,777 | 0 | 2 | MIT | 2020-03-09T00:02:12 | 2017-02-13T16:47:00 | null | UTF-8 | C++ | false | false | 8,350 | cc | // Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/renderer_host/pepper/pepper_file_ref_host.h"
#include <string>
#include "content/browser/renderer_host/pepper/pepper_external_file_ref_backend.h"
#include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h"
#include "content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/pp_file_info.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/host/dispatch_host_message.h"
#include "ppapi/host/ppapi_host.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/file_ref_util.h"
#include "webkit/browser/fileapi/file_permission_policy.h"
using ppapi::host::ResourceHost;
namespace content {
PepperFileRefBackend::~PepperFileRefBackend() {
}
PepperFileRefHost::PepperFileRefHost(BrowserPpapiHost* host,
PP_Instance instance,
PP_Resource resource,
PP_Resource file_system,
const std::string& path)
: ResourceHost(host->GetPpapiHost(), instance, resource),
host_(host),
fs_type_(PP_FILESYSTEMTYPE_INVALID) {
if (!ppapi::IsValidInternalPath(path))
return;
int render_process_id;
int unused;
if (!host->GetRenderViewIDsForInstance(instance,
&render_process_id,
&unused)) {
return;
}
ResourceHost* fs_resource_host =
host->GetPpapiHost()->GetResourceHost(file_system);
if (fs_resource_host == NULL) {
DLOG(ERROR) << "Couldn't find FileSystem host: " << resource
<< " path: " << path;
return;
}
if (!fs_resource_host->IsFileSystemHost()) {
DLOG(ERROR) << "Filesystem PP_Resource is not PepperFileSystemBrowserHost";
return;
}
PepperFileSystemBrowserHost* file_system_host =
static_cast<PepperFileSystemBrowserHost*>(fs_resource_host);
file_system_host_ = file_system_host->AsWeakPtr();
fs_type_ = file_system_host->GetType();
if ((fs_type_ != PP_FILESYSTEMTYPE_LOCALPERSISTENT) &&
(fs_type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY) &&
(fs_type_ != PP_FILESYSTEMTYPE_ISOLATED)) {
DLOG(ERROR) << "Unsupported filesystem type: " << fs_type_;
return;
}
backend_.reset(new PepperInternalFileRefBackend(
host->GetPpapiHost(),
render_process_id,
file_system_host->AsWeakPtr(),
path));
}
PepperFileRefHost::PepperFileRefHost(BrowserPpapiHost* host,
PP_Instance instance,
PP_Resource resource,
const base::FilePath& external_path)
: ResourceHost(host->GetPpapiHost(), instance, resource),
host_(host),
fs_type_(PP_FILESYSTEMTYPE_EXTERNAL) {
if (!ppapi::IsValidExternalPath(external_path))
return;
int render_process_id;
int unused;
if (!host->GetRenderViewIDsForInstance(instance,
&render_process_id,
&unused)) {
return;
}
backend_.reset(new PepperExternalFileRefBackend(host->GetPpapiHost(),
render_process_id,
external_path));
}
PepperFileRefHost::~PepperFileRefHost() {
}
bool PepperFileRefHost::IsFileRefHost() {
return true;
}
PP_FileSystemType PepperFileRefHost::GetFileSystemType() const {
return fs_type_;
}
fileapi::FileSystemURL PepperFileRefHost::GetFileSystemURL() const {
if (backend_)
return backend_->GetFileSystemURL();
return fileapi::FileSystemURL();
}
base::FilePath PepperFileRefHost::GetExternalFilePath() const {
if (backend_)
return backend_->GetExternalFilePath();
return base::FilePath();
}
base::WeakPtr<PepperFileSystemBrowserHost>
PepperFileRefHost::GetFileSystemHost() const {
return file_system_host_;
}
int32_t PepperFileRefHost::CanRead() const {
if (backend_)
return backend_->CanRead();
return PP_ERROR_FAILED;
}
int32_t PepperFileRefHost::CanWrite() const {
if (backend_)
return backend_->CanWrite();
return PP_ERROR_FAILED;
}
int32_t PepperFileRefHost::CanCreate() const {
if (backend_)
return backend_->CanCreate();
return PP_ERROR_FAILED;
}
int32_t PepperFileRefHost::CanReadWrite() const {
if (backend_)
return backend_->CanReadWrite();
return PP_ERROR_FAILED;
}
int32_t PepperFileRefHost::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
if (!backend_)
return PP_ERROR_FAILED;
IPC_BEGIN_MESSAGE_MAP(PepperFileRefHost, msg)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileRef_MakeDirectory,
OnMakeDirectory);
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileRef_Touch,
OnTouch);
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileRef_Delete,
OnDelete);
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileRef_Rename,
OnRename);
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileRef_Query,
OnQuery);
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
PpapiHostMsg_FileRef_ReadDirectoryEntries,
OnReadDirectoryEntries);
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileRef_GetAbsolutePath,
OnGetAbsolutePath);
IPC_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
int32_t PepperFileRefHost::OnMakeDirectory(
ppapi::host::HostMessageContext* context,
bool make_ancestors) {
int32_t rv = CanCreate();
if (rv != PP_OK)
return rv;
return backend_->MakeDirectory(context->MakeReplyMessageContext(),
make_ancestors);
}
int32_t PepperFileRefHost::OnTouch(ppapi::host::HostMessageContext* context,
PP_Time last_access_time,
PP_Time last_modified_time) {
// TODO(teravest): Change this to be kWriteFilePermissions here and in
// fileapi_message_filter.
int32_t rv = CanCreate();
if (rv != PP_OK)
return rv;
return backend_->Touch(context->MakeReplyMessageContext(),
last_access_time,
last_modified_time);
}
int32_t PepperFileRefHost::OnDelete(ppapi::host::HostMessageContext* context) {
int32_t rv = CanWrite();
if (rv != PP_OK)
return rv;
return backend_->Delete(context->MakeReplyMessageContext());
}
int32_t PepperFileRefHost::OnRename(ppapi::host::HostMessageContext* context,
PP_Resource new_file_ref) {
int32_t rv = CanReadWrite();
if (rv != PP_OK)
return rv;
ResourceHost* resource_host =
host_->GetPpapiHost()->GetResourceHost(new_file_ref);
if (!resource_host)
return PP_ERROR_BADRESOURCE;
PepperFileRefHost* file_ref_host = NULL;
if (resource_host->IsFileRefHost())
file_ref_host = static_cast<PepperFileRefHost*>(resource_host);
if (!file_ref_host)
return PP_ERROR_BADRESOURCE;
rv = file_ref_host->CanCreate();
if (rv != PP_OK)
return rv;
return backend_->Rename(context->MakeReplyMessageContext(),
file_ref_host);
}
int32_t PepperFileRefHost::OnQuery(ppapi::host::HostMessageContext* context) {
int32_t rv = CanRead();
if (rv != PP_OK)
return rv;
return backend_->Query(context->MakeReplyMessageContext());
}
int32_t PepperFileRefHost::OnReadDirectoryEntries(
ppapi::host::HostMessageContext* context) {
int32_t rv = CanRead();
if (rv != PP_OK)
return rv;
return backend_->ReadDirectoryEntries(context->MakeReplyMessageContext());
}
int32_t PepperFileRefHost::OnGetAbsolutePath(
ppapi::host::HostMessageContext* context) {
if (!host_->GetPpapiHost()->permissions().HasPermission(
ppapi::PERMISSION_PRIVATE))
return PP_ERROR_NOACCESS;
return backend_->GetAbsolutePath(context->MakeReplyMessageContext());
}
} // namespace content
| [
"[email protected]"
] | |
2e0101e2a8801a0b20db103023b82c82ea82b6dd | b7b6cd7ae9e82f2bb031fab13093fb49a8e17f82 | /src/bstrwrap.cpp | 9fd7ba612c01eb8b682031d4666546d778c4798b | [] | no_license | pahsrov/rov-code-2016 | 34c5dbcb8934a0a01ddad992204f33830b71b7e2 | 6b18ac4175bcb5c5db30e09d3aa1033b83e8c03e | refs/heads/master | 2021-01-10T06:04:20.889050 | 2015-11-20T02:16:56 | 2015-11-20T02:16:56 | 49,216,201 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 41,657 | cpp | /*
* This source file is part of the bstring string library. This code was
* written by Paul Hsieh in 2002-2010, and is covered by either the 3-clause
* BSD open source license or GPL v2.0. Refer to the accompanying documentation
* for details on usage and license.
*/
/*
* bstrwrap.c
*
* This file is the C++ wrapper for the bstring functions.
*/
#if defined (_MSC_VER)
# define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <limits.h>
#include "../include/bstrwrap.h"
#if defined(MEMORY_DEBUG) || defined(BSTRLIB_MEMORY_DEBUG)
#include "memdbg.h"
#endif
#ifndef bstr__alloc
#define bstr__alloc(x) malloc (x)
#endif
#ifndef bstr__free
#define bstr__free(p) free (p)
#endif
#ifndef bstr__realloc
#define bstr__realloc(p,x) realloc ((p), (x))
#endif
#ifndef bstr__memcpy
#define bstr__memcpy(d,s,l) memcpy ((d), (s), (l))
#endif
#ifndef bstr__memmove
#define bstr__memmove(d,s,l) memmove ((d), (s), (l))
#endif
#ifndef bstr__memset
#define bstr__memset(d,c,l) memset ((d), (c), (l))
#endif
#ifndef bstr__memcmp
#define bstr__memcmp(d,c,l) memcmp ((d), (c), (l))
#endif
#ifndef bstr__memchr
#define bstr__memchr(s,c,l) memchr ((s), (c), (l))
#endif
#if defined(BSTRLIB_CAN_USE_IOSTREAM)
#include <iostream>
#endif
namespace Bstrlib {
// Constructors.
CBString::CBString () {
slen = 0;
mlen = 8;
data = (unsigned char *) bstr__alloc (mlen);
if (!data) {
mlen = 0;
bstringThrow ("Failure in default constructor");
} else {
data[0] = '\0';
}
}
CBString::CBString (const void * blk, int len) {
data = NULL;
if (len >= 0) {
mlen = len + 1;
slen = len;
data = (unsigned char *) bstr__alloc (mlen);
}
if (!data) {
mlen = slen = 0;
bstringThrow ("Failure in block constructor");
} else {
if (slen > 0) bstr__memcpy (data, blk, slen);
data[slen] = '\0';
}
}
CBString::CBString (char c, int len) {
data = NULL;
if (len >= 0) {
mlen = len + 1;
slen = len;
data = (unsigned char *) bstr__alloc (mlen);
}
if (!data) {
mlen = slen = 0;
bstringThrow ("Failure in repeat(char) constructor");
} else {
if (slen > 0) bstr__memset (data, c, slen);
data[slen] = '\0';
}
}
CBString::CBString (char c) {
mlen = 2;
slen = 1;
if (NULL == (data = (unsigned char *) bstr__alloc (mlen))) {
mlen = slen = 0;
bstringThrow ("Failure in (char) constructor");
} else {
data[0] = (unsigned char) c;
data[1] = '\0';
}
}
CBString::CBString (unsigned char c) {
mlen = 2;
slen = 1;
if (NULL == (data = (unsigned char *) bstr__alloc (mlen))) {
mlen = slen = 0;
bstringThrow ("Failure in (char) constructor");
} else {
data[0] = c;
data[1] = '\0';
}
}
CBString::CBString (const char *s) {
if (s) {
size_t sslen = strlen (s);
if (sslen >= INT_MAX) bstringThrow ("Failure in (char *) constructor, string too large")
slen = (int) sslen;
mlen = slen + 1;
if (NULL != (data = (unsigned char *) bstr__alloc (mlen))) {
bstr__memcpy (data, s, mlen);
return;
}
}
data = NULL;
bstringThrow ("Failure in (char *) constructor");
}
CBString::CBString (int len, const char *s) {
if (s) {
size_t sslen = strlen (s);
if (sslen >= INT_MAX) bstringThrow ("Failure in (char *) constructor, string too large")
slen = (int) sslen;
mlen = slen + 1;
if (mlen < len) mlen = len;
if (NULL != (data = (unsigned char *) bstr__alloc (mlen))) {
bstr__memcpy (data, s, slen + 1);
return;
}
}
data = NULL;
bstringThrow ("Failure in (int len, char *) constructor");
}
CBString::CBString (const CBString& b) {
slen = b.slen;
mlen = slen + 1;
data = NULL;
if (mlen > 0) data = (unsigned char *) bstr__alloc (mlen);
if (!data) {
bstringThrow ("Failure in (CBString) constructor");
} else {
bstr__memcpy (data, b.data, slen);
data[slen] = '\0';
}
}
CBString::CBString (const tagbstring& x) {
slen = x.slen;
mlen = slen + 1;
data = NULL;
if (slen >= 0 && x.data != NULL) data = (unsigned char *) bstr__alloc (mlen);
if (!data) {
bstringThrow ("Failure in (tagbstring) constructor");
} else {
bstr__memcpy (data, x.data, slen);
data[slen] = '\0';
}
}
// Destructor.
CBString::~CBString () {
if (data != NULL) {
bstr__free (data);
data = NULL;
}
mlen = 0;
slen = -__LINE__;
}
// = operator.
const CBString& CBString::operator = (char c) {
if (mlen <= 0) bstringThrow ("Write protection error");
if (2 >= mlen) alloc (2);
if (!data) {
mlen = slen = 0;
bstringThrow ("Failure in =(char) operator");
} else {
slen = 1;
data[0] = (unsigned char) c;
data[1] = '\0';
}
return *this;
}
const CBString& CBString::operator = (unsigned char c) {
if (mlen <= 0) bstringThrow ("Write protection error");
if (2 >= mlen) alloc (2);
if (!data) {
mlen = slen = 0;
bstringThrow ("Failure in =(char) operator");
} else {
slen = 1;
data[0] = c;
data[1] = '\0';
}
return *this;
}
const CBString& CBString::operator = (const char *s) {
size_t tmpSlen;
if (mlen <= 0) bstringThrow ("Write protection error");
if (NULL == s) s = "";
if ((tmpSlen = strlen (s)) >= (size_t) mlen) {
if (tmpSlen >= INT_MAX-1) bstringThrow ("Failure in =(const char *) operator, string too large");
alloc ((int) tmpSlen);
}
if (data) {
slen = (int) tmpSlen;
bstr__memcpy (data, s, tmpSlen + 1);
} else {
mlen = slen = 0;
bstringThrow ("Failure in =(const char *) operator");
}
return *this;
}
const CBString& CBString::operator = (const CBString& b) {
if (mlen <= 0) bstringThrow ("Write protection error");
if (b.slen >= mlen) alloc (b.slen);
slen = b.slen;
if (!data) {
mlen = slen = 0;
bstringThrow ("Failure in =(CBString) operator");
} else {
bstr__memcpy (data, b.data, slen);
data[slen] = '\0';
}
return *this;
}
const CBString& CBString::operator = (const tagbstring& x) {
if (mlen <= 0) bstringThrow ("Write protection error");
if (x.slen < 0) bstringThrow ("Failure in =(tagbstring) operator, badly formed tagbstring");
if (x.slen >= mlen) alloc (x.slen);
slen = x.slen;
if (!data) {
mlen = slen = 0;
bstringThrow ("Failure in =(tagbstring) operator");
} else {
bstr__memcpy (data, x.data, slen);
data[slen] = '\0';
}
return *this;
}
const CBString& CBString::operator += (const CBString& b) {
if (BSTR_ERR == bconcat (this, (bstring) &b)) {
bstringThrow ("Failure in concatenate");
}
return *this;
}
const CBString& CBString::operator += (const char *s) {
char * d;
int i, l;
if (mlen <= 0) bstringThrow ("Write protection error");
/* Optimistically concatenate directly */
l = mlen - slen;
d = (char *) &data[slen];
for (i=0; i < l; i++) {
if ((*d++ = *s++) == '\0') {
slen += i;
return *this;
}
}
slen += i;
if (BSTR_ERR == bcatcstr (this, s)) {
bstringThrow ("Failure in concatenate");
}
return *this;
}
const CBString& CBString::operator += (char c) {
if (BSTR_ERR == bconchar (this, c)) {
bstringThrow ("Failure in concatenate");
}
return *this;
}
const CBString& CBString::operator += (unsigned char c) {
if (BSTR_ERR == bconchar (this, (char) c)) {
bstringThrow ("Failure in concatenate");
}
return *this;
}
const CBString& CBString::operator += (const tagbstring& x) {
if (mlen <= 0) bstringThrow ("Write protection error");
if (x.slen < 0) bstringThrow ("Failure in +=(tagbstring) operator, badly formed tagbstring");
alloc (x.slen + slen + 1);
if (!data) {
mlen = slen = 0;
bstringThrow ("Failure in +=(tagbstring) operator");
} else {
bstr__memcpy (data + slen, x.data, x.slen);
slen += x.slen;
data[slen] = '\0';
}
return *this;
}
const CBString CBString::operator + (char c) const {
CBString retval (*this);
retval += c;
return retval;
}
const CBString CBString::operator + (unsigned char c) const {
CBString retval (*this);
retval += c;
return retval;
}
const CBString CBString::operator + (const CBString& b) const {
CBString retval (*this);
retval += b;
return retval;
}
const CBString CBString::operator + (const char *s) const {
if (s == NULL) bstringThrow ("Failure in + (char *) operator, NULL");
CBString retval (*this);
retval += s;
return retval;
}
const CBString CBString::operator + (const unsigned char *s) const {
if (s == NULL) bstringThrow ("Failure in + (unsigned char *) operator, NULL");
CBString retval (*this);
retval += (const char *) s;
return retval;
}
const CBString CBString::operator + (const tagbstring& x) const {
if (x.slen < 0) bstringThrow ("Failure in + (tagbstring) operator, badly formed tagbstring");
CBString retval (*this);
retval += x;
return retval;
}
bool CBString::operator == (const CBString& b) const {
int retval;
if (BSTR_ERR == (retval = biseq ((bstring)this, (bstring)&b))) {
bstringThrow ("Failure in compare (==)");
}
return retval > 0;
}
bool CBString::operator == (const char * s) const {
int retval;
if (NULL == s) {
bstringThrow ("Failure in compare (== NULL)");
}
if (BSTR_ERR == (retval = biseqcstr ((bstring) this, s))) {
bstringThrow ("Failure in compare (==)");
}
return retval > 0;
}
bool CBString::operator == (const unsigned char * s) const {
int retval;
if (NULL == s) {
bstringThrow ("Failure in compare (== NULL)");
}
if (BSTR_ERR == (retval = biseqcstr ((bstring) this, (const char *) s))) {
bstringThrow ("Failure in compare (==)");
}
return retval > 0;
}
bool CBString::operator != (const CBString& b) const {
return ! ((*this) == b);
}
bool CBString::operator != (const char * s) const {
return ! ((*this) == s);
}
bool CBString::operator != (const unsigned char * s) const {
return ! ((*this) == s);
}
bool CBString::operator < (const CBString& b) const {
int retval;
if (SHRT_MIN == (retval = bstrcmp ((bstring) this, (bstring)&b))) {
bstringThrow ("Failure in compare (<)");
}
return retval < 0;
}
bool CBString::operator < (const char * s) const {
if (s == NULL) {
bstringThrow ("Failure in compare (<)");
}
return strcmp ((const char *)this->data, s) < 0;
}
bool CBString::operator < (const unsigned char * s) const {
if (s == NULL) {
bstringThrow ("Failure in compare (<)");
}
return strcmp ((const char *)this->data, (const char *)s) < 0;
}
bool CBString::operator <= (const CBString& b) const {
int retval;
if (SHRT_MIN == (retval = bstrcmp ((bstring) this, (bstring)&b))) {
bstringThrow ("Failure in compare (<=)");
}
return retval <= 0;
}
bool CBString::operator <= (const char * s) const {
if (s == NULL) {
bstringThrow ("Failure in compare (<=)");
}
return strcmp ((const char *)this->data, s) <= 0;
}
bool CBString::operator <= (const unsigned char * s) const {
if (s == NULL) {
bstringThrow ("Failure in compare (<=)");
}
return strcmp ((const char *)this->data, (const char *)s) <= 0;
}
bool CBString::operator > (const CBString& b) const {
return ! ((*this) <= b);
}
bool CBString::operator > (const char * s) const {
return ! ((*this) <= s);
}
bool CBString::operator > (const unsigned char * s) const {
return ! ((*this) <= s);
}
bool CBString::operator >= (const CBString& b) const {
return ! ((*this) < b);
}
bool CBString::operator >= (const char * s) const {
return ! ((*this) < s);
}
bool CBString::operator >= (const unsigned char * s) const {
return ! ((*this) < s);
}
CBString::operator double () const {
double d = 0;
if (1 != sscanf ((const char *)this->data, "%lf", &d)) {
bstringThrow ("Unable to convert to a double");
}
return d;
}
CBString::operator float () const {
float d = 0;
if (1 != sscanf ((const char *)this->data, "%f", &d)) {
bstringThrow ("Unable to convert to a float");
}
return d;
}
CBString::operator int () const {
int d = 0;
if (1 != sscanf ((const char *)this->data, "%d", &d)) {
bstringThrow ("Unable to convert to an int");
}
return d;
}
CBString::operator unsigned int () const {
unsigned int d = 0;
if (1 != sscanf ((const char *)this->data, "%u", &d)) {
bstringThrow ("Unable to convert to an unsigned int");
}
return d;
}
#ifdef __TURBOC__
# ifndef BSTRLIB_NOVSNP
# define BSTRLIB_NOVSNP
# endif
#endif
/* Give WATCOM C/C++, MSVC some latitude for their non-support of vsnprintf */
#if defined(__WATCOMC__) || defined(_MSC_VER)
#define exvsnprintf(r,b,n,f,a) {r = _vsnprintf (b,n,f,a);}
#else
#ifdef BSTRLIB_NOVSNP
/* This is just a hack. If you are using a system without a vsnprintf, it is
not recommended that bformat be used at all. */
#define exvsnprintf(r,b,n,f,a) {vsprintf (b,f,a); r = -1;}
#define START_VSNBUFF (256)
#else
#if defined (__GNUC__) && !defined (__PPC__)
/* Something is making gcc complain about this prototype not being here, so
I've just gone ahead and put it in. */
extern "C" {
extern int vsnprintf (char *buf, size_t count, const char *format, va_list arg);
}
#endif
#define exvsnprintf(r,b,n,f,a) {r = vsnprintf (b,n,f,a);}
#endif
#endif
#ifndef START_VSNBUFF
#define START_VSNBUFF (16)
#endif
/*
* Yeah I'd like to just call a vformat function or something, but because of
* the ANSI specified brokeness of the va_* macros, it is actually not
* possible to do this correctly.
*/
void CBString::format (const char * fmt, ...) {
bstring b;
va_list arglist;
int r, n;
if (mlen <= 0) bstringThrow ("Write protection error");
if (fmt == NULL) {
*this = "<NULL>";
bstringThrow ("CBString::format (NULL, ...) is erroneous.");
} else {
if ((b = bfromcstr ("")) == NULL) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("CBString::format out of memory.");
#else
*this = "<NULL>";
#endif
} else {
if ((n = (int) (2 * (strlen) (fmt))) < START_VSNBUFF) n = START_VSNBUFF;
for (;;) {
if (BSTR_OK != balloc (b, n + 2)) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("CBString::format out of memory.");
#else
b = bformat ("<NULL>");
break;
#endif
}
va_start (arglist, fmt);
exvsnprintf (r, (char *) b->data, n + 1, fmt, arglist);
va_end (arglist);
b->data[n] = '\0';
b->slen = (int) (strlen) ((char *) b->data);
if (b->slen < n) break;
if (r > n) n = r; else n += n;
}
*this = *b;
bdestroy (b);
}
}
}
void CBString::formata (const char * fmt, ...) {
bstring b;
va_list arglist;
int r, n;
if (mlen <= 0) bstringThrow ("Write protection error");
if (fmt == NULL) {
*this += "<NULL>";
bstringThrow ("CBString::formata (NULL, ...) is erroneous.");
} else {
if ((b = bfromcstr ("")) == NULL) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("CBString::format out of memory.");
#else
*this += "<NULL>";
#endif
} else {
if ((n = (int) (2 * (strlen) (fmt))) < START_VSNBUFF) n = START_VSNBUFF;
for (;;) {
if (BSTR_OK != balloc (b, n + 2)) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("CBString::format out of memory.");
#else
b = bformat ("<NULL>");
break;
#endif
}
va_start (arglist, fmt);
exvsnprintf (r, (char *) b->data, n + 1, fmt, arglist);
va_end (arglist);
b->data[n] = '\0';
b->slen = (int) (strlen) ((char *) b->data);
if (b->slen < n) break;
if (r > n) n = r; else n += n;
}
*this += *b;
bdestroy (b);
}
}
}
int CBString::caselessEqual (const CBString& b) const {
int ret;
if (BSTR_ERR == (ret = biseqcaseless ((bstring) this, (bstring) &b))) {
bstringThrow ("CBString::caselessEqual Unable to compare");
}
return ret;
}
int CBString::caselessCmp (const CBString& b) const {
int ret;
if (SHRT_MIN == (ret = bstricmp ((bstring) this, (bstring) &b))) {
bstringThrow ("CBString::caselessCmp Unable to compare");
}
return ret;
}
int CBString::find (const CBString& b, int pos) const {
return binstr ((bstring) this, pos, (bstring) &b);
}
/*
int CBString::find (const char * b, int pos) const;
Uses and unrolling and sliding paired indexes character matching. Since
the unrolling is the primary real world impact the true purpose of this
algorithm choice is maximize the effectiveness of the unrolling. The
idea is to scan until at least one match of the current indexed character
from each string, and then shift indexes of both down by and repeat until
the last character form b matches. When the last character from b
matches if the were no mismatches in previous strlen(b) characters then
we know we have a full match, otherwise shift both indexes back strlen(b)
characters and continue.
In general, if there is any character in b that is not at all in this
CBString, then this algorithm is O(slen). The algorithm does not easily
degenerate into O(slen * strlen(b)) performance except in very uncommon
situations. Thus from a real world perspective, the overhead of
precomputing suffix shifts in the Boyer-Moore algorithm is avoided, while
delivering an unrolled matching inner loop most of the time.
*/
int CBString::find (const char * b, int pos) const {
int ii, j;
unsigned char c0;
register int i, l;
register unsigned char cx;
register unsigned char * pdata;
if (NULL == b) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("CBString::find NULL.");
#else
return BSTR_ERR;
#endif
}
if ((unsigned int) pos > (unsigned int) slen) return BSTR_ERR;
if ('\0' == b[0]) return pos;
if (pos == slen) return BSTR_ERR;
if ('\0' == b[1]) return find (b[0], pos);
cx = c0 = (unsigned char) b[0];
l = slen - 1;
pdata = data;
for (ii = -1, i = pos, j = 0; i < l;) {
/* Unrolled current character test */
if (cx != pdata[i]) {
if (cx != pdata[1+i]) {
i += 2;
continue;
}
i++;
}
/* Take note if this is the start of a potential match */
if (0 == j) ii = i;
/* Shift the test character down by one */
j++;
i++;
/* If this isn't past the last character continue */
if ('\0' != (cx = b[j])) continue;
N0:;
/* If no characters mismatched, then we matched */
if (i == ii+j) return ii;
/* Shift back to the beginning */
i -= j;
j = 0;
cx = c0;
}
/* Deal with last case if unrolling caused a misalignment */
if (i == l && cx == pdata[i] && '\0' == b[j+1]) goto N0;
return BSTR_ERR;
}
int CBString::caselessfind (const CBString& b, int pos) const {
return binstrcaseless ((bstring) this, pos, (bstring) &b);
}
int CBString::caselessfind (const char * b, int pos) const {
struct tagbstring t;
if (NULL == b) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("CBString::caselessfind NULL.");
#else
return BSTR_ERR;
#endif
}
if ((unsigned int) pos > (unsigned int) slen) return BSTR_ERR;
if ('\0' == b[0]) return pos;
if (pos == slen) return BSTR_ERR;
btfromcstr (t, b);
return binstrcaseless ((bstring) this, pos, (bstring) &t);
}
int CBString::find (char c, int pos) const {
if (pos < 0) return BSTR_ERR;
for (;pos < slen; pos++) {
if (data[pos] == (unsigned char) c) return pos;
}
return BSTR_ERR;
}
int CBString::reversefind (const CBString& b, int pos) const {
return binstrr ((bstring) this, pos, (bstring) &b);
}
int CBString::reversefind (const char * b, int pos) const {
struct tagbstring t;
if (NULL == b) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("CBString::reversefind NULL.");
#else
return BSTR_ERR;
#endif
}
cstr2tbstr (t, b);
return binstrr ((bstring) this, pos, &t);
}
int CBString::caselessreversefind (const CBString& b, int pos) const {
return binstrrcaseless ((bstring) this, pos, (bstring) &b);
}
int CBString::caselessreversefind (const char * b, int pos) const {
struct tagbstring t;
if (NULL == b) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("CBString::caselessreversefind NULL.");
#else
return BSTR_ERR;
#endif
}
if ((unsigned int) pos > (unsigned int) slen) return BSTR_ERR;
if ('\0' == b[0]) return pos;
if (pos == slen) return BSTR_ERR;
btfromcstr (t, b);
return binstrrcaseless ((bstring) this, pos, (bstring) &t);
}
int CBString::reversefind (char c, int pos) const {
if (pos > slen) return BSTR_ERR;
if (pos == slen) pos--;
for (;pos >= 0; pos--) {
if (data[pos] == (unsigned char) c) return pos;
}
return BSTR_ERR;
}
int CBString::findchr (const CBString& b, int pos) const {
return binchr ((bstring) this, pos, (bstring) &b);
}
int CBString::findchr (const char * s, int pos) const {
struct tagbstring t;
if (NULL == s) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("CBString::findchr NULL.");
#else
return BSTR_ERR;
#endif
}
cstr2tbstr (t, s);
return binchr ((bstring) this, pos, (bstring) &t);
}
int CBString::nfindchr (const CBString& b, int pos) const {
return bninchr ((bstring) this, pos, (bstring) &b);
}
int CBString::nfindchr (const char * s, int pos) const {
struct tagbstring t;
if (NULL == s) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("CBString::nfindchr NULL.");
#else
return BSTR_ERR;
#endif
}
cstr2tbstr (t, s);
return bninchr ((bstring) this, pos, &t);
}
int CBString::reversefindchr (const CBString& b, int pos) const {
return binchrr ((bstring) this, pos, (bstring) &b);
}
int CBString::reversefindchr (const char * s, int pos) const {
struct tagbstring t;
if (NULL == s) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("CBString::reversefindchr NULL.");
#else
return BSTR_ERR;
#endif
}
cstr2tbstr (t, s);
return binchrr ((bstring) this, pos, &t);
}
int CBString::nreversefindchr (const CBString& b, int pos) const {
return bninchrr ((bstring) this, pos, (bstring) &b);
}
int CBString::nreversefindchr (const char * s, int pos) const {
struct tagbstring t;
if (NULL == s) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("CBString::nreversefindchr NULL.");
#else
return BSTR_ERR;
#endif
}
cstr2tbstr (t, s);
return bninchrr ((bstring) this, pos, &t);
}
const CBString CBString::midstr (int left, int len) const {
struct tagbstring t;
if (left < 0) {
len += left;
left = 0;
}
if (len > slen - left) len = slen - left;
if (len <= 0) return CBString ("");
blk2tbstr (t, data + left, len);
return CBString (t);
}
void CBString::alloc (int len) {
if (BSTR_ERR == balloc ((bstring)this, len)) {
bstringThrow ("Failure in alloc");
}
}
void CBString::fill (int len, unsigned char cfill) {
slen = 0;
if (BSTR_ERR == bsetstr (this, len, NULL, cfill)) {
bstringThrow ("Failure in fill");
}
}
void CBString::setsubstr (int pos, const CBString& b, unsigned char cfill) {
if (BSTR_ERR == bsetstr (this, pos, (bstring) &b, cfill)) {
bstringThrow ("Failure in setsubstr");
}
}
void CBString::setsubstr (int pos, const char * s, unsigned char cfill) {
struct tagbstring t;
if (NULL == s) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("setsubstr NULL.");
#else
return;
#endif
}
cstr2tbstr (t, s);
if (BSTR_ERR == bsetstr (this, pos, &t, cfill)) {
bstringThrow ("Failure in setsubstr");
}
}
void CBString::insert (int pos, const CBString& b, unsigned char cfill) {
if (BSTR_ERR == binsert (this, pos, (bstring) &b, cfill)) {
bstringThrow ("Failure in insert");
}
}
void CBString::insert (int pos, const char * s, unsigned char cfill) {
struct tagbstring t;
if (NULL == s) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("insert NULL.");
#else
return;
#endif
}
cstr2tbstr (t, s);
if (BSTR_ERR == binsert (this, pos, &t, cfill)) {
bstringThrow ("Failure in insert");
}
}
void CBString::insertchrs (int pos, int len, unsigned char cfill) {
if (BSTR_ERR == binsertch (this, pos, len, cfill)) {
bstringThrow ("Failure in insertchrs");
}
}
void CBString::replace (int pos, int len, const CBString& b, unsigned char cfill) {
if (BSTR_ERR == breplace (this, pos, len, (bstring) &b, cfill)) {
bstringThrow ("Failure in replace");
}
}
void CBString::replace (int pos, int len, const char * s, unsigned char cfill) {
struct tagbstring t;
size_t q;
if (mlen <= 0) bstringThrow ("Write protection error");
if (NULL == s || (pos|len) < 0) {
bstringThrow ("Failure in replace");
} else {
if (pos + len >= slen) {
cstr2tbstr (t, s);
if (BSTR_ERR == bsetstr (this, pos, &t, cfill)) {
bstringThrow ("Failure in replace");
} else if (pos + t.slen < slen) {
slen = pos + t.slen;
data[slen] = '\0';
}
} else {
/* Aliasing case */
if ((unsigned int) (data - (unsigned char *) s) < (unsigned int) slen) {
replace (pos, len, CBString(s), cfill);
return;
}
if ((q = strlen (s)) > (size_t) len || len < 0) {
if (slen + q - len >= INT_MAX) bstringThrow ("Failure in replace, result too long.");
alloc ((int) (slen + q - len));
if (NULL == data) return;
}
if ((int) q != len) bstr__memmove (data + pos + q, data + pos + len, slen - (pos + len));
bstr__memcpy (data + pos, s, q);
slen += ((int) q) - len;
data[slen] = '\0';
}
}
}
void CBString::findreplace (const CBString& sfind, const CBString& repl, int pos) {
if (BSTR_ERR == bfindreplace (this, (bstring) &sfind, (bstring) &repl, pos)) {
bstringThrow ("Failure in findreplace");
}
}
void CBString::findreplace (const CBString& sfind, const char * repl, int pos) {
struct tagbstring t;
if (NULL == repl) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("findreplace NULL.");
#else
return;
#endif
}
cstr2tbstr (t, repl);
if (BSTR_ERR == bfindreplace (this, (bstring) &sfind, (bstring) &t, pos)) {
bstringThrow ("Failure in findreplace");
}
}
void CBString::findreplace (const char * sfind, const CBString& repl, int pos) {
struct tagbstring t;
if (NULL == sfind) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("findreplace NULL.");
#else
return;
#endif
}
cstr2tbstr (t, sfind);
if (BSTR_ERR == bfindreplace (this, (bstring) &t, (bstring) &repl, pos)) {
bstringThrow ("Failure in findreplace");
}
}
void CBString::findreplace (const char * sfind, const char * repl, int pos) {
struct tagbstring t, u;
if (NULL == repl || NULL == sfind) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("findreplace NULL.");
#else
return;
#endif
}
cstr2tbstr (t, sfind);
cstr2tbstr (u, repl);
if (BSTR_ERR == bfindreplace (this, (bstring) &t, (bstring) &u, pos)) {
bstringThrow ("Failure in findreplace");
}
}
void CBString::findreplacecaseless (const CBString& sfind, const CBString& repl, int pos) {
if (BSTR_ERR == bfindreplacecaseless (this, (bstring) &sfind, (bstring) &repl, pos)) {
bstringThrow ("Failure in findreplacecaseless");
}
}
void CBString::findreplacecaseless (const CBString& sfind, const char * repl, int pos) {
struct tagbstring t;
if (NULL == repl) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("findreplacecaseless NULL.");
#else
return;
#endif
}
cstr2tbstr (t, repl);
if (BSTR_ERR == bfindreplacecaseless (this, (bstring) &sfind, (bstring) &t, pos)) {
bstringThrow ("Failure in findreplacecaseless");
}
}
void CBString::findreplacecaseless (const char * sfind, const CBString& repl, int pos) {
struct tagbstring t;
if (NULL == sfind) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("findreplacecaseless NULL.");
#else
return;
#endif
}
cstr2tbstr (t, sfind);
if (BSTR_ERR == bfindreplacecaseless (this, (bstring) &t, (bstring) &repl, pos)) {
bstringThrow ("Failure in findreplacecaseless");
}
}
void CBString::findreplacecaseless (const char * sfind, const char * repl, int pos) {
struct tagbstring t, u;
if (NULL == repl || NULL == sfind) {
#ifdef BSTRLIB_THROWS_EXCEPTIONS
bstringThrow ("findreplacecaseless NULL.");
#else
return;
#endif
}
cstr2tbstr (t, sfind);
cstr2tbstr (u, repl);
if (BSTR_ERR == bfindreplacecaseless (this, (bstring) &t, (bstring) &u, pos)) {
bstringThrow ("Failure in findreplacecaseless");
}
}
void CBString::remove (int pos, int len) {
if (BSTR_ERR == bdelete (this, pos, len)) {
bstringThrow ("Failure in remove");
}
}
void CBString::trunc (int len) {
if (len < 0) {
bstringThrow ("Failure in trunc");
}
if (len < slen) {
slen = len;
data[len] = '\0';
}
}
void CBString::ltrim (const CBString& b) {
int l = nfindchr (b, 0);
if (l == BSTR_ERR) l = slen;
remove (0, l);
}
void CBString::rtrim (const CBString& b) {
int l = nreversefindchr (b, slen - 1);
#if BSTR_ERR != -1
if (l == BSTR_ERR) l = -1;
#endif
slen = l + 1;
if (mlen > slen) data[slen] = '\0';
}
void CBString::toupper () {
if (BSTR_ERR == btoupper ((bstring) this)) {
bstringThrow ("Failure in toupper");
}
}
void CBString::tolower () {
if (BSTR_ERR == btolower ((bstring) this)) {
bstringThrow ("Failure in tolower");
}
}
void CBString::repeat (int count) {
count *= slen;
if (count == 0) {
trunc (0);
return;
}
if (count < 0 || BSTR_ERR == bpattern (this, count)) {
bstringThrow ("Failure in repeat");
}
}
int CBString::gets (bNgetc getcPtr, void * parm, char terminator) {
if (mlen <= 0) bstringThrow ("Write protection error");
bstring b = bgets (getcPtr, parm, terminator);
if (b == NULL) {
slen = 0;
return -1;
}
*this = *b;
bdestroy (b);
return 0;
}
int CBString::read (bNread readPtr, void * parm) {
if (mlen <= 0) bstringThrow ("Write protection error");
bstring b = bread (readPtr, parm);
if (b == NULL) {
slen = 0;
return -1;
}
*this = *b;
bdestroy (b);
return 0;
}
const CBString operator + (const char *a, const CBString& b) {
return CBString(a) + b;
}
const CBString operator + (const unsigned char *a, const CBString& b) {
return CBString((const char *)a) + b;
}
const CBString operator + (char c, const CBString& b) {
return CBString(c) + b;
}
const CBString operator + (unsigned char c, const CBString& b) {
return CBString(c) + b;
}
const CBString operator + (const tagbstring& x, const CBString& b) {
return CBString(x) + b;
}
void CBString::writeprotect () {
if (mlen >= 0) mlen = -1;
}
void CBString::writeallow () {
if (mlen == -1) mlen = slen + (slen == 0);
else if (mlen < 0) {
bstringThrow ("Cannot unprotect a constant");
}
}
#if defined(BSTRLIB_CAN_USE_STL)
// Constructors.
CBString::CBString (const CBStringList& l) {
int c;
size_t i;
for (c=1, i=0; i < l.size(); i++) {
c += l.at(i).slen;
}
mlen = c;
slen = 0;
data = (unsigned char *) bstr__alloc (c);
if (!data) {
mlen = slen = 0;
bstringThrow ("Failure in (CBStringList) constructor");
} else {
for (i=0; i < l.size(); i++) {
*this += l.at(i);
}
}
}
CBString::CBString (const struct CBStringList& l, const CBString& sep) {
int c, sl = sep.length ();
size_t i;
for (c=1, i=0; i < l.size(); i++) {
c += l.at(i).slen + sl;
}
mlen = c;
slen = 0;
data = (unsigned char *) bstr__alloc (mlen);
if (!data) {
mlen = slen = 0;
bstringThrow ("Failure in (CBStringList) constructor");
} else {
for (i=0; i < l.size(); i++) {
if (i > 0) *this += sep;
*this += l.at(i);
}
}
}
CBString::CBString (const struct CBStringList& l, char sep) {
int c;
size_t i;
for (c=1, i=0; i < l.size(); i++) {
c += l.at(i).slen + 1;
}
mlen = c;
slen = 0;
data = (unsigned char *) bstr__alloc (mlen);
if (!data) {
mlen = slen = 0;
bstringThrow ("Failure in (CBStringList) constructor");
} else {
for (i=0; i < l.size(); i++) {
if (i > 0) *this += sep;
*this += l.at(i);
}
}
}
CBString::CBString (const struct CBStringList& l, unsigned char sep) {
int c;
size_t i;
for (c=1, i=0; i < l.size(); i++) {
c += l.at(i).slen + 1;
}
mlen = c;
slen = 0;
data = (unsigned char *) bstr__alloc (mlen);
if (!data) {
mlen = slen = 0;
bstringThrow ("Failure in (CBStringList) constructor");
} else {
for (i=0; i < l.size(); i++) {
if (i > 0) *this += sep;
*this += l.at(i);
}
}
}
void CBString::join (const struct CBStringList& l) {
int c;
size_t i;
if (mlen <= 0) {
bstringThrow ("Write protection error");
}
for (c=1, i=0; i < l.size(); i++) {
c += l.at(i).slen;
if (c < 0) bstringThrow ("Failure in (CBStringList) constructor, too long");
}
alloc (c);
slen = 0;
if (!data) {
mlen = slen = 0;
bstringThrow ("Failure in (CBStringList) constructor");
} else {
for (i=0; i < l.size(); i++) {
*this += l.at(i);
}
}
}
void CBString::join (const struct CBStringList& l, const CBString& sep) {
int c, sl = sep.length();
size_t i;
if (mlen <= 0) {
bstringThrow ("Write protection error");
}
for (c=1, i=0; i < l.size(); i++) {
c += l.at(i).slen + sl;
if (c < sl) bstringThrow ("Failure in (CBStringList) constructor, too long");
}
alloc (c);
slen = 0;
if (!data) {
mlen = slen = 0;
bstringThrow ("Failure in (CBStringList) constructor");
} else {
for (i=0; i < l.size(); i++) {
if (i > 0) *this += sep;
*this += l.at(i);
}
}
}
void CBString::join (const struct CBStringList& l, char sep) {
int c;
size_t i;
if (mlen <= 0) {
bstringThrow ("Write protection error");
}
for (c=1, i=0; i < l.size(); i++) {
c += l.at(i).slen + 1;
if (c <= 0) bstringThrow ("Failure in (CBStringList) constructor, too long");
}
alloc (c);
slen = 0;
if (!data) {
mlen = slen = 0;
bstringThrow ("Failure in (CBStringList) constructor");
} else {
for (i=0; i < l.size(); i++) {
if (i > 0) *this += sep;
*this += l.at(i);
}
}
}
void CBString::join (const struct CBStringList& l, unsigned char sep) {
int c;
size_t i;
if (mlen <= 0) {
bstringThrow ("Write protection error");
}
for (c=1, i=0; i < l.size(); i++) {
c += l.at(i).slen + 1;
if (c <= 0) bstringThrow ("Failure in (CBStringList) constructor, too long");
}
alloc (c);
slen = 0;
if (!data) {
mlen = slen = 0;
bstringThrow ("Failure in (CBStringList) constructor");
} else {
for (i=0; i < l.size(); i++) {
if (i > 0) *this += sep;
*this += l.at(i);
}
}
}
// Split functions.
void CBStringList::split (const CBString& b, unsigned char splitChar) {
int p, i;
p = 0;
do {
for (i = p; i < b.length (); i++) {
if (b.character (i) == splitChar) break;
}
if (i >= p) this->push_back (CBString (&(b.data[p]), i - p));
p = i + 1;
} while (p <= b.length ());
}
void CBStringList::split (const CBString& b, const CBString& s) {
struct { unsigned long content[(1 << CHAR_BIT) / 32]; } chrs;
unsigned char c;
int p, i;
if (s.length() == 0) bstringThrow ("Null splitstring failure");
if (s.length() == 1) {
this->split (b, s.character (0));
} else {
for (i=0; i < ((1 << CHAR_BIT) / 32); i++) chrs.content[i] = 0x0;
for (i=0; i < s.length(); i++) {
c = s.character (i);
chrs.content[c >> 5] |= ((long)1) << (c & 31);
}
p = 0;
do {
for (i = p; i < b.length (); i++) {
c = b.character (i);
if (chrs.content[c >> 5] & ((long)1) << (c & 31)) break;
}
if (i >= p) this->push_back (CBString (&(b.data[p]), i - p));
p = i + 1;
} while (p <= b.length ());
}
}
void CBStringList::splitstr (const CBString& b, const CBString& s) {
int p, i;
if (s.length() == 1) {
this->split (b, s.character (0));
} else if (s.length() == 0) {
for (i=0; i < b.length (); i++) {
this->push_back (CBString (b.data[i]));
}
} else {
for (p=0; (i = b.find (s, p)) >= 0; p = i + s.length ()) {
this->push_back (b.midstr (p, i - p));
}
if (p <= b.length ()) {
this->push_back (b.midstr (p, b.length () - p));
}
}
}
static int streamSplitCb (void * parm, int ofs, const_bstring entry) {
CBStringList * r = (CBStringList *) parm;
ofs = ofs;
r->push_back (CBString (*entry));
return 0;
}
void CBStringList::split (const CBStream& b, const CBString& s) {
if (0 > bssplitscb (b.m_s, (bstring) &s, streamSplitCb,
(void *) this)) {
bstringThrow ("Split bstream failure");
}
}
void CBStringList::split (const CBStream& b, unsigned char splitChar) {
CBString sc (splitChar);
if (0 > bssplitscb (b.m_s, (bstring) &sc,
streamSplitCb, (void *) this)) {
bstringThrow ("Split bstream failure");
}
}
void CBStringList::splitstr (const CBStream& b, const CBString& s) {
if (0 > bssplitstrcb (b.m_s, (bstring) &s, streamSplitCb,
(void *) this)) {
bstringThrow ("Split bstream failure");
}
}
#endif
#if defined(BSTRLIB_CAN_USE_IOSTREAM)
std::ostream& operator << (std::ostream& sout, CBString b) {
return sout.write ((const char *)b, b.length());
}
#include <ctype.h>
static int istreamGets (void * parm) {
char c = '\n';
((std::istream *)parm)->get(c);
if (isspace (c)) c = '\n';
return c;
}
std::istream& operator >> (std::istream& sin, CBString& b) {
do {
b.gets ((bNgetc) istreamGets, &sin, '\n');
if (b.slen > 0 && b.data[b.slen-1] == '\n') b.slen--;
} while (b.slen == 0 && !sin.eof ());
return sin;
}
struct sgetc {
std::istream * sin;
char terminator;
};
static int istreamGetc (void * parm) {
char c = ((struct sgetc *)parm)->terminator;
((struct sgetc *)parm)->sin->get(c);
return c;
}
std::istream& getline (std::istream& sin, CBString& b, char terminator) {
struct sgetc parm;
parm.sin = &sin;
parm.terminator = terminator;
b.gets ((bNgetc) istreamGetc, &parm, terminator);
if (b.slen > 0 && b.data[b.slen-1] == terminator) b.slen--;
return sin;
}
#endif
CBStream::CBStream (bNread readPtr, void * parm) {
m_s = bsopen (readPtr, parm);
}
CBStream::~CBStream () {
bsclose (m_s);
}
int CBStream::buffLengthSet (int sz) {
if (sz <= 0) {
bstringThrow ("buffLengthSet parameter failure");
}
return bsbufflength (m_s, sz);
}
int CBStream::buffLengthGet () {
return bsbufflength (m_s, 0);
}
CBString CBStream::readLine (char terminator) {
CBString ret("");
if (0 > bsreadln ((bstring) &ret, m_s, terminator) && eof () < 0) {
bstringThrow ("Failed readLine");
}
return ret;
}
CBString CBStream::readLine (const CBString& terminator) {
CBString ret("");
if (0 > bsreadlns ((bstring) &ret, m_s, (bstring) &terminator) && eof () < 0) {
bstringThrow ("Failed readLine");
}
return ret;
}
void CBStream::readLine (CBString& s, char terminator) {
if (0 > bsreadln ((bstring) &s, m_s, terminator) && eof () < 0) {
bstringThrow ("Failed readLine");
}
}
void CBStream::readLine (CBString& s, const CBString& terminator) {
if (0 > bsreadlns ((bstring) &s, m_s, (bstring) &terminator) && eof () < 0) {
bstringThrow ("Failed readLine");
}
}
void CBStream::readLineAppend (CBString& s, char terminator) {
if (0 > bsreadlna ((bstring) &s, m_s, terminator) && eof () < 0) {
bstringThrow ("Failed readLineAppend");
}
}
void CBStream::readLineAppend (CBString& s, const CBString& terminator) {
if (0 > bsreadlnsa ((bstring) &s, m_s, (bstring) &terminator) && eof () < 0) {
bstringThrow ("Failed readLineAppend");
}
}
#define BS_BUFF_SZ (1024)
CBString CBStream::read () {
CBString ret("");
while (!bseof (m_s)) {
if (0 > bsreada ((bstring) &ret, m_s, BS_BUFF_SZ) && eof () < 0) {
bstringThrow ("Failed read");
}
}
return ret;
}
CBString& CBStream::operator >> (CBString& s) {
while (!bseof (m_s)) {
if (0 > bsreada ((bstring) &s, m_s, BS_BUFF_SZ) && eof () < 0) {
bstringThrow ("Failed read");
}
}
return s;
}
CBString CBStream::read (int n) {
CBString ret("");
if (0 > bsread ((bstring) &ret, m_s, n) && eof () < 0) {
bstringThrow ("Failed read");
}
return ret;
}
void CBStream::read (CBString& s) {
s.slen = 0;
while (!bseof (m_s)) {
if (0 > bsreada ((bstring) &s, m_s, BS_BUFF_SZ)) {
bstringThrow ("Failed read");
}
}
}
void CBStream::read (CBString& s, int n) {
if (0 > bsread ((bstring) &s, m_s, n)) {
bstringThrow ("Failed read");
}
}
void CBStream::readAppend (CBString& s) {
while (!bseof (m_s)) {
if (0 > bsreada ((bstring) &s, m_s, BS_BUFF_SZ)) {
bstringThrow ("Failed readAppend");
}
}
}
void CBStream::readAppend (CBString& s, int n) {
if (0 > bsreada ((bstring) &s, m_s, n)) {
bstringThrow ("Failed readAppend");
}
}
void CBStream::unread (const CBString& s) {
if (0 > bsunread (m_s, (bstring) &s)) {
bstringThrow ("Failed unread");
}
}
CBString CBStream::peek () const {
CBString ret ("");
if (0 > bspeek ((bstring) &ret, m_s)) {
bstringThrow ("Failed peek");
}
return ret;
}
void CBStream::peek (CBString& s) const {
s.slen = 0;
if (0 > bspeek ((bstring) &s, m_s)) {
bstringThrow ("Failed peek");
}
}
void CBStream::peekAppend (CBString& s) const {
if (0 > bspeek ((bstring) &s, m_s)) {
bstringThrow ("Failed peekAppend");
}
}
int CBStream::eof () const {
int ret = bseof (m_s);
if (0 > ret) {
bstringThrow ("Failed eof");
}
return ret;
}
} // namespace Bstrlib
| [
"[email protected]"
] | |
3d67b1a975c6514665096389b99761e34951985b | 82dc3cc4c97c05e384812cc9aa07938e2dbfe24b | /tahoe/src-mirror/nodes/KBC_controllers/TorsionKBCT.cpp | 9677524f633547b1a3f4a068d61c472a5ea881e6 | [
"BSD-3-Clause"
] | permissive | samanseifi/Tahoe | ab40da0f8d952491943924034fa73ee5ecb2fecd | 542de50ba43645f19ce4b106ac8118c4333a3f25 | refs/heads/master | 2020-04-05T20:24:36.487197 | 2017-12-02T17:09:11 | 2017-12-02T17:24:23 | 38,074,546 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 65 | cpp | /home/saman/Tahoe/tahoe/src/nodes/KBC_controllers/TorsionKBCT.cpp | [
"saman@bu.(none)"
] | saman@bu.(none) |
5b5a9eca8a0eaf47fd595246acbf7688b4ad3ba7 | 74f50032f2f0ebe0881133bc4933bf3a87c49b12 | /CSC_343_COMPUTER_ORG2/Mei, Sunny/CSC 342/Take Home Test/TEST 3/Code/oppforarray/oppforarray/arrayopt.cpp | 22e3259686c969825b0fcf5b18b244d8e83d1293 | [] | no_license | MohamedSondo/SPRING_2017 | 7034e0df529f695255fdd5eb257f59df72c35fb3 | b114264083f66476093923640aa4eb9471919e9f | refs/heads/master | 2021-08-07T20:01:49.401425 | 2017-11-08T20:56:55 | 2017-11-08T20:56:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,186 | cpp | #include <stdio.h>
#include <windows.h>
#include <iostream>
using namespace std;
extern "C" {void ClearUsingIndex(int Array[], int size); }
int main() {
const int size = 10000000;
static int inputArray[size];
__int64 ctr1 = 0, ctr2 = 0, freq = 0;
int acc = 0, i = 0;
int x;// just here to call cin at the end to stop the debug box from going away
// Start timing the code.
if (QueryPerformanceCounter((LARGE_INTEGER *)&ctr1) != 0)
{
// Code segment is being timed.
//int i;
//for (i = 0; i < size; i += 1)
//inputArray[i] = 0;
ClearUsingIndex(inputArray, size);
// Finish timing the code.
QueryPerformanceCounter((LARGE_INTEGER *)&ctr2);
printf("Start Value: %d\n", ctr1);
printf("End Value: %d\n", ctr2);
QueryPerformanceFrequency((LARGE_INTEGER *)&freq);
printf("QueryPerformanceCounter minimum resolution: 1/%d Seconds.\n", freq);
printf("ctr2 - ctr1: %d\n counts.", (ctr2 - ctr1));
printf("Increments time in millisec: %f milliseconds. \n", ((ctr2 - ctr1) * 1000.0 / freq));
}
else
{
unsigned int dwError = GetLastError();
printf("Error code: %d", dwError);
}
cin >> x;
return 0;
} | [
"[email protected]"
] | |
056648c50e703dc8d4394ef346fc3cc518bdfcb9 | df44650aadacf19ee0e4b59d90679315411f9823 | /src/Input/DeviceManager.cpp | dacf3ea223f7229e728354dfb61b8a09689fc34d | [] | no_license | Thornolf/Gauntlet | 96c18e60a528286a26cbefac2089de44b107bf65 | 56111f47c89b685f8210e99634a44631dd544769 | refs/heads/master | 2022-03-17T06:39:50.749875 | 2019-11-28T18:14:47 | 2019-11-28T18:14:47 | 106,101,126 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 880 | cpp | /*
** DeviceManager.cpp for OgreApp
**
** Made by Guillaume CAUCHOIS
** Login <[email protected]>
**
** Started on Wed May 31 09:04:05 2017 Guillaume CAUCHOIS
** Last update Wed May 31 09:04:05 2017 Guillaume CAUCHOIS
*/
#include "Input/DeviceManager.hpp"
DeviceManager::DeviceManager(Ogre::RenderWindow *win)
{
OIS::ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;
win->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
this->_iManager = OIS::InputManager::createInputSystem(pl);
}
DeviceManager::~DeviceManager() {}
OIS::InputManager *DeviceManager::getIManager(void) const
{
return (this->_iManager);
}
OIS::Object *DeviceManager::createObject(OIS::Type type) const
{
return (this->_iManager->createInputObject(type, false));
} | [
"[email protected]"
] | |
c5045b4b581e64700829054fdf599a9aec17ce60 | 0c394d231f95a76405f0d9feeafbcb8d431d9ea3 | /NewJourney/NewJourney/Common/D3DApp.cpp | b0105ef8a732f00d9a5da0cc5ddfd7d54a73e12b | [] | no_license | kristyfuwa/Departure | 53b6abee884e4a1d27cc6bf5465881383e051931 | 6fe2cda281693e254797cbc969d22d06055c4c82 | refs/heads/master | 2020-08-08T09:22:10.755056 | 2019-10-12T11:50:40 | 2019-10-12T11:50:40 | 213,803,374 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 10,764 | cpp | #include "D3DApp.h"
#include <sstream>
#include <WindowsX.h>
#include "D3DUtil.h"
#include <assert.h>
namespace
{
D3DApp* g_d3dApp = 0;
}
LRESULT CALLBACK
MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
// Forward hwnd on because we can get messages (e.g., WM_CREATE)
// before CreateWindow returns, and thus before mhMainWnd is valid.
return g_d3dApp->MsgProc(hwnd, msg, wParam, lParam);
}
D3DApp::D3DApp(HINSTANCE hInstance)
:m_hAppInst(hInstance),
m_sMainWndCaption(L"D3D Application"),
m_D3dDriverType(D3D_DRIVER_TYPE_HARDWARE),
m_iClientWidth(800),
m_iClientHeight(600),
m_bEnable4xMsaa(false),
m_hMainWnd(0),
m_bAppPaused(false),
m_bMaximized(false),
m_bMinimized(false),
m_bResizing(false),
m_ui4xMsaaQuality(0),
m_pD3dDevice(0),
m_pD3dImmediateContext(0),
m_pDepthStencilView(0),
m_pRenderTargetView(0),
m_pSwapChain(0),
m_pDepthStencilBuffer(0)
{
ZeroMemory(&m_ScreenViewport, sizeof(D3D11_VIEWPORT));
g_d3dApp = this;
}
D3DApp::~D3DApp()
{
ReleaseCom(m_pDepthStencilView);
ReleaseCom(m_pRenderTargetView);
ReleaseCom(m_pSwapChain);
ReleaseCom(m_pDepthStencilBuffer);
// Restore all default settings.
if (m_pD3dImmediateContext)
m_pD3dImmediateContext->ClearState();
ReleaseCom(m_pD3dImmediateContext);
ReleaseCom(m_pD3dDevice);
}
HINSTANCE D3DApp::AppInst() const
{
return m_hAppInst;
}
HWND D3DApp::MainWnd() const
{
return m_hMainWnd;
}
float D3DApp::AspectRatio() const
{
return static_cast<float>(m_iClientWidth) / m_iClientHeight;
}
int D3DApp::Run()
{
MSG msg;
ZeroMemory(&msg, sizeof(msg));
m_Timer.Reset();
while (msg.message != WM_QUIT)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
m_Timer.Tick();
if (!m_bAppPaused)
{
CalculateFrameStats();
UpdateScene(m_Timer.DeltaTime());
DrawScene();
}
else
m_Timer.Stop();
}
}
return (int)msg.wParam;
}
bool D3DApp::Init()
{
if (!InitMainWindow())
return false;
if (!InitDirect3D())
return false;
return true;
}
void D3DApp::OnResize()
{
assert(m_pD3dDevice);
assert(m_pD3dImmediateContext);
assert(m_pSwapChain);
ReleaseCom(m_pRenderTargetView);
ReleaseCom(m_pDepthStencilView);
ReleaseCom(m_pDepthStencilBuffer);
HR(m_pSwapChain->ResizeBuffers(1, m_iClientWidth, m_iClientHeight, DXGI_FORMAT_R8G8B8A8_UNORM, 0));
ID3D11Texture2D* backBuffer;
HR(m_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&backBuffer));//每次调用一次GetBuffer,后台缓冲区COM引用计数会+1;
HR(m_pD3dDevice->CreateRenderTargetView(backBuffer, 0, &m_pRenderTargetView));
ReleaseCom(backBuffer);
D3D11_TEXTURE2D_DESC depthStencilDesc;
depthStencilDesc.Width = m_iClientWidth;
depthStencilDesc.Height = m_iClientHeight;
depthStencilDesc.MipLevels = 1;
depthStencilDesc.ArraySize = 1;
depthStencilDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
if (m_bEnable4xMsaa)
{
depthStencilDesc.SampleDesc.Count = 4;
depthStencilDesc.SampleDesc.Quality = m_ui4xMsaaQuality-1;
}
else
{
depthStencilDesc.SampleDesc.Count = 1;
depthStencilDesc.SampleDesc.Quality = 0;
}
depthStencilDesc.Usage = D3D11_USAGE_DEFAULT;
depthStencilDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
depthStencilDesc.CPUAccessFlags = 0;
depthStencilDesc.MiscFlags = 0;
HR(m_pD3dDevice->CreateTexture2D(&depthStencilDesc, 0, &m_pDepthStencilBuffer));
HR(m_pD3dDevice->CreateDepthStencilView(m_pDepthStencilBuffer, 0, &m_pDepthStencilView));
//第二个参数,这个结构体描述了资源中这个元素数据 类型(格式)。如果资源是一个有类型的格式(非 typeless),这个参数可以为空值,表示创 建一个资源的第一个 mipmap 等级的视图(深度/模板缓冲也只能使用一个 mipmap 等级)。 因为我们指定了深度/模板缓冲的格式,所以将这个参数设置为空值。
m_pD3dImmediateContext->OMSetRenderTargets(1, &m_pRenderTargetView, m_pDepthStencilView);
D3D11_VIEWPORT viewPort;
viewPort.TopLeftX = 0;
viewPort.TopLeftY = 0;
viewPort.Width = (float)m_iClientWidth;
viewPort.Height = (float)m_iClientHeight;
viewPort.MinDepth = 0;
viewPort.MaxDepth = 1;
m_pD3dImmediateContext->RSSetViewports(1, &viewPort);
}
LRESULT D3DApp::MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_ACTIVATE:
{
if (LOWORD(wParam) == WA_INACTIVE)
{
m_bAppPaused = true;
m_Timer.Stop();
}
else
{
m_bAppPaused = false;
m_Timer.Start();
}
return 0;
}
case WM_KEYDOWN:
{
OnKeyDown(wParam);
return 0;
}
case WM_KEYUP:
{
OnKeyUp(wParam);
return 0;
}
case WM_ENTERSIZEMOVE:
{
m_bAppPaused = true;
m_bResizing = true;
m_Timer.Stop();
return 0;
}
case WM_EXITSIZEMOVE:
{
m_bAppPaused = false;
m_bResizing = false;
m_Timer.Start();
OnResize();
return 0;
}
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
case WM_MOUSEWHEEL:
{
OnMouseWheel((short)HIWORD(wParam));
return 0;
}
case WM_MENUCHAR:
{
return MAKELRESULT(0,MNC_CLOSE);
}
case WM_GETMINMAXINFO:
{
((MINMAXINFO*)lParam)->ptMinTrackSize.x = 200;
((MINMAXINFO*)lParam)->ptMinTrackSize.y = 200;
return 0;
}
case WM_SIZE:
{
m_iClientWidth = LOWORD(lParam);
m_iClientHeight = HIWORD(lParam);
if (m_pD3dDevice)
{
if (wParam == SIZE_MINIMIZED)
{
m_bMinimized = true;
m_bMaximized = false;
m_bAppPaused = true;
}
else if (wParam == SIZE_MAXIMIZED)
{
m_bMinimized = false;
m_bMaximized = true;
m_bAppPaused = false;
OnResize();
}
else if (wParam == SIZE_RESTORED)
{
if (m_bMinimized)
{
m_bAppPaused = false;
m_bMinimized = false;
OnResize();
}
else if (m_bMaximized)
{
m_bMaximized = false;
m_bAppPaused = false;
OnResize();
}
else if (m_bResizing)
{
// If user is dragging the resize bars, we do not resize
// the buffers here because as the user continuously
// drags the resize bars, a stream of WM_SIZE messages are
// sent to the window, and it would be pointless (and slow)
// to resize for each WM_SIZE message received from dragging
// the resize bars. So instead, we reset after the user is
// done resizing the window and releases the resize bars, which
// sends a WM_EXITSIZEMOVE message.
}
else
{
OnResize();
}
}
}
return 0;
}
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
OnMouseDown(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
return 0;
case WM_LBUTTONUP:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
OnMouseUp(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
return 0;
case WM_MOUSEMOVE:
OnMouseMove(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
return 0;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
bool D3DApp::InitMainWindow()
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = m_hAppInst;
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = L"D3DWndClassName";
if (!RegisterClass(&wc))
{
MessageBox(0, L"RegisterClass Failed.", 0, 0);
return false;
}
// Compute window rectangle dimensions based on requested client area dimensions.
RECT R = { 0, 0, m_iClientWidth, m_iClientHeight };
AdjustWindowRect(&R, WS_OVERLAPPEDWINDOW, false);
int width = R.right - R.left;
int height = R.bottom - R.top;
m_hMainWnd = CreateWindow(L"D3DWndClassName", m_sMainWndCaption.c_str(),
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, width, height, 0, 0, m_hAppInst, 0);
if (!m_hMainWnd)
{
MessageBox(0, L"CreateWindow Failed.", 0, 0);
return false;
}
ShowWindow(m_hMainWnd, SW_SHOW);
UpdateWindow(m_hMainWnd);
return true;
}
bool D3DApp::InitDirect3D()
{
HRESULT hr = S_OK;
UINT createDeviceFlags = 0;
#if defined(DEBUG) | defined(_DEBUG)
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
D3D_FEATURE_LEVEL featureLevel;
HR(D3D11CreateDevice(0, m_D3dDriverType, 0, createDeviceFlags, 0, 0, D3D11_SDK_VERSION, &m_pD3dDevice, &featureLevel, &m_pD3dImmediateContext));
if (featureLevel != D3D_FEATURE_LEVEL_11_0)
{
MessageBox(0, L"Direct3D FeatureLevel 11 unsupported.", 0, 0);
return false;
}
HR(m_pD3dDevice->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, 4, &m_ui4xMsaaQuality));
assert(m_ui4xMsaaQuality > 0);
DXGI_SWAP_CHAIN_DESC swapChainDesc;
swapChainDesc.BufferCount = 1;
swapChainDesc.OutputWindow = m_hMainWnd;
swapChainDesc.Windowed = true;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;//用于描述前台缓存在绘制之后D3D应该作何选择
swapChainDesc.Flags = 0;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.BufferDesc.Height = m_iClientHeight;
swapChainDesc.BufferDesc.Width = m_iClientWidth;
swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
swapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
if (m_bEnable4xMsaa)
{
swapChainDesc.SampleDesc.Quality = m_ui4xMsaaQuality - 1;
swapChainDesc.SampleDesc.Count = 4;
}
else
{
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.SampleDesc.Count = 1;
}
IDXGIDevice* dxgiDevice = 0;
HR(m_pD3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice));
IDXGIAdapter* dxgiAdapter = 0;
HR(dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter));
IDXGIFactory* dxgiFatory = 0;
HR(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&dxgiFatory));
//Create SwapChain;
HR(dxgiFatory->CreateSwapChain(m_pD3dDevice, &swapChainDesc, &m_pSwapChain));
ReleaseCom(dxgiDevice);
ReleaseCom(dxgiAdapter);
ReleaseCom(dxgiFatory);
OnResize();
return true;
}
void D3DApp::CalculateFrameStats()
{
static int frameCnt = 0;
static float timeElapsed = 0.0f;
frameCnt++;
// Compute averages over one second period.
if ((m_Timer.TotalTime() - timeElapsed) >= 1.0f)
{
float fps = (float)frameCnt; // fps = frameCnt / 1
float mspf = 1000.0f / fps;
std::wostringstream outs;
outs.precision(6);
outs << m_sMainWndCaption << L" "
<< L"FPS: " << fps << L" "
<< L"Frame Time: " << mspf << L" (ms)";
SetWindowText(m_hMainWnd, outs.str().c_str());
// Reset for next average.
frameCnt = 0;
timeElapsed += 1.0f;
}
}
| [
"[email protected]"
] | |
7c0ccbe9f8955a333c41f08f3ad12824d6a6cbc8 | 528d46e37130ec93a24da2fe41622db8a59592e6 | /src/refinedepth.h | 0446c776c3b751aa6ae54435a43a9f7c1ec43e90 | [] | no_license | DrawZeroPoint/rgbd_recorder_ros | b035ea327577d18aa205c23f84ef1eb35904601c | 8bae3ee23dd8626fb1b910c7bf1b10a4a9045c18 | refs/heads/master | 2021-05-05T14:05:42.390925 | 2017-10-26T13:41:44 | 2017-10-26T13:41:44 | 105,122,256 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 993 | h | #ifndef REFINEDEPTH_H
#define REFINEDEPTH_H
#include <caffe/caffe.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/contrib/contrib.hpp>
#include <iosfwd>
#include <memory>
#include <string>
#include <utility>
#include <iostream>
#include <random>
#include <vector>
#include "global.h"
using namespace std;
using namespace cv;
class RefineDepth
{
public:
RefineDepth(string proto_folder, int gpu_id);
void refineDepth(Mat rgb_in, Mat depth_in, Mat &depth_out);
protected:
boost::shared_ptr<caffe::Net<float> > net_;
private:
void forward(vector<float> depth_in, vector<vector<float> > features_in,
vector<vector<float> > features_out, Mat &depth_out);
void setParams();
void wrapInputLayer(vector<float> depth_in, vector<vector<float> > features_in,
vector<vector<float> > features_out);
void getOutput(cv::Mat &depth_out);
};
#endif // REFINEDEPTH_H
| [
"[email protected]"
] | |
be75c495fdb6c4fa86ce734db3887695b1a6c870 | 8bc92d04be9e68bcca9aba5411caa1572f6aba7d | /Drone/shader.cpp | f419e81902e6a588ee071d24a5f809dd5a9b9136 | [] | no_license | bjarnemoro/Drone | 5f20b6e1cf0794f4f49b09b239a39c15bd0faa95 | e2dfb25099e0dd535479be0a186a99d05a0a12cc | refs/heads/master | 2023-05-26T23:37:11.965036 | 2021-06-02T18:57:34 | 2021-06-02T18:57:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,787 | cpp | #include "shader.h"
Shader::Shader(const char* vertexPath, const char* fragmentPath, const char* geometryPath)
{
std::string vertexCode;
std::string fragmentCode;
std::string geometryCode;
std::ifstream vShaderFile;
std::ifstream fShaderFile;
std::ifstream gShaderFile;
vShaderFile.exceptions(std::ifstream::failbit | std::ifstream::badbit);
fShaderFile.exceptions(std::ifstream::failbit | std::ifstream::badbit);
gShaderFile.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try
{
vShaderFile.open(vertexPath);
fShaderFile.open(fragmentPath);
std::stringstream vShaderStream, fShaderStream;
vShaderStream << vShaderFile.rdbuf();
fShaderStream << fShaderFile.rdbuf();
vShaderFile.close();
fShaderFile.close();
vertexCode = vShaderStream.str();
fragmentCode = fShaderStream.str();
if (geometryPath != nullptr)
{
gShaderFile.open(geometryPath);
std::stringstream gShaderStream;
gShaderStream << gShaderFile.rdbuf();
gShaderFile.close();
geometryCode = gShaderStream.str();
}
}
catch (std::ifstream::failure e)
{
std::cout << "ERROR::SHADER::FILE_NOT::SUCCESFULLY_READ" << std::endl;
}
const char* vShaderCode = vertexCode.c_str();
const char* fShaderCode = fragmentCode.c_str();
unsigned int vertex, fragment;
int success;
char infoLog[512];
vertex = glCreateShader(GL_VERTEX_SHADER);
fragment = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(vertex, 1, &vShaderCode, NULL);
glShaderSource(fragment, 1, &fShaderCode, NULL);
glCompileShader(vertex);
glCompileShader(fragment);
glGetShaderiv(vertex, GL_COMPILE_STATUS, &success);
if (!success)
{
glGetShaderInfoLog(vertex, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl;
}
glGetShaderiv(fragment, GL_COMPILE_STATUS, &success);
if (!success)
{
glGetShaderInfoLog(fragment, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << std::endl;
}
unsigned int geometry;
if (geometryPath != nullptr)
{
const char* gShaderCode = geometryCode.c_str();
geometry = glCreateShader(GL_GEOMETRY_SHADER);
glShaderSource(geometry, 1, &gShaderCode, NULL);
glCompileShader(geometry);
glGetShaderiv(geometry, GL_COMPILE_STATUS, &success);
if (!success)
{
glGetShaderInfoLog(geometry, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::GEOMETRY::COMPILATION_FAILED\n" << infoLog << std::endl;
}
}
ID = glCreateProgram();
glAttachShader(ID, vertex);
glAttachShader(ID, fragment);
if (geometryPath != nullptr)
glAttachShader(ID, geometry);
glLinkProgram(ID);
glGetProgramiv(ID, GL_LINK_STATUS, &success);
if (!success)
{
glGetProgramInfoLog(ID, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << std::endl;
}
glDeleteShader(vertex);
glDeleteShader(fragment);
if (geometryPath != nullptr)
glDeleteShader(geometry);
}
void Shader::use()
{
glUseProgram(ID);
}
void Shader::SetBool(const std::string& name, bool value) const
{
int loc = glGetUniformLocation(ID, name.c_str());
glUniform1i(loc, value);
}
void Shader::SetInt(const std::string& name, int value) const
{
int loc = glGetUniformLocation(ID, name.c_str());
glUniform1i(loc, value);
}
void Shader::SetFloat(const std::string& name, float value) const
{
int loc = glGetUniformLocation(ID, name.c_str());
glUniform1f(loc, value);
}
void Shader::Setu4(const std::string& name, float v1, float v2, float v3, float v4) const
{
int loc = glGetUniformLocation(ID, name.c_str());
glUniform4f(loc, v1, v2, v3, v4);
}
void Shader::SetMat4(const std::string& name, float* value) const
{
unsigned int loc = glGetUniformLocation(ID, name.c_str());
glUniformMatrix4fv(loc, 1, GL_FALSE, value);
}
void Shader::SetMat4(const std::string& name, const glm::mat4& value) const
{
unsigned int loc = glGetUniformLocation(ID, name.c_str());
glUniformMatrix4fv(loc, 1, GL_FALSE, &value[0][0]);
}
void Shader::SetVec3(const std::string& name, const glm::vec3& value) const
{
glUniform3fv(glGetUniformLocation(ID, name.c_str()), 1, &value[0]);
}
void Shader::SetVec3(const std::string& name, float v1, float v2, float v3) const
{
unsigned int loc = glGetUniformLocation(ID, name.c_str());
glUniform3f(loc, v1, v2, v3);
}
void Shader::SetVec4(const std::string& name, const glm::vec4& value) const
{
glUniform4fv(glGetUniformLocation(ID, name.c_str()), 1, &value[0]);
}
void Shader::SetVec4(const std::string& name, float v1, float v2, float v3, float v4) const
{
unsigned int loc = glGetUniformLocation(ID, name.c_str());
glUniform4f(loc, v1, v2, v3, v4);
}
void Shader::SetVec2(const std::string& name, const glm::vec2& value) const
{
glUniform2fv(glGetUniformLocation(ID, name.c_str()), 1, &value[0]);
} | [
"[email protected]"
] | |
d14da23073b1f2178741b56b2f2cdccc6c2c2168 | 1e1d05f8be45005c7fd5c67f5a00f6532729f8c0 | /sr_tengine_c_api/sr_tengine_c_api.cpp | c4bf707ca4fcd53868c431d3dfe4dfadc5ac20b4 | [] | no_license | guoqiangqi/SR_api | c87ec45236f283a6edcbfe3f6d7f6da386c41252 | 7c6f36a1b8e8230d966c250ac384d071ea7af66b | refs/heads/master | 2020-04-05T11:10:03.071443 | 2018-11-09T07:28:14 | 2018-11-09T07:41:22 | 156,825,375 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 27,470 | cpp | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* License); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/*
* Copyright (c) 2017, Open AI Lab
* Author: [email protected]
*/
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <iostream>
#include <string>
#include "tengine_config.hpp"
#include "tengine_plugin.hpp"
#include "static_graph.hpp"
#include "resource_container.hpp"
#include "sr_graph_executor.hpp"
#include "serializer.hpp"
#include "tengine_c_api.h"
#include "share_lib_parser.hpp"
#include "data_type.hpp"
#include "data_layout.hpp"
#include "cpu_device.h"
using namespace TEngine;
struct tensor_handle
{
GraphExecutor * executor;
Tensor * tensor;
};
namespace TEngine {
extern void tengine_init_executor(void);
}
#define TO_BE_IMPLEMENTED XLOG_WARN()<<"TODO: "<<__FUNCTION__<<" to be implemented\n"
static int vload_model(const char * model_name, const char * file_format, const char * fname, va_list ap);
static workspace_t get_default_workspace(void);
static user_context_t get_default_user_context();
/*** Level 0 API implementation */
graph_t create_graph(const char * graph_name, const char * format, const char * fname, ...)
{
va_list argp;
graph_t graph;
int ret;
if(init_tengine_library()<0)
return nullptr;
va_start(argp,fname);
/*the model name is the same as graph name */
ret=vload_model(graph_name,format,fname,argp);
if(ret<0)
return nullptr;
/* use the default workspace to execute the graph */
graph=create_runtime_graph(graph_name,graph_name,NULL);
return graph;
}
int check_graph_valid(graph_t graph)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
if(executor==nullptr)
return 0;
return 1;
}
const char * get_graph_name(graph_t graph)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
return executor->GetGraphName().c_str();
}
const char * get_model_name(graph_t graph)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
return executor->GetModelName().c_str();
}
int set_graph_device(graph_t graph, const char * device_name)
{
GraphExecutor *executor = static_cast<GraphExecutor*>(graph);
std::string device = device_name;
executor->GetGraph()->SetAttr("default_executor", device);
return 0;
}
int run_inference(graph_t graph, void * input_data, int input_size)
{
const char * tensor_name;
const char * node_name;
tensor_t tensor;
int ret;
/* should only one input node */
if(get_input_node_number(graph)!=1)
return -1;
if(prerun_graph(graph)<0)
{
return -1;
}
node_name=get_input_node_name(graph,0);
tensor_name=get_node_output_tensor(graph,node_name,0);
tensor=get_graph_tensor(graph,tensor_name);
if(set_tensor_data(tensor,input_data,input_size)<0)
{
put_graph_tensor(tensor);
return -1;
}
ret=run_graph(graph,1);
put_graph_tensor(tensor);
return ret;
}
int get_graph_output(graph_t graph, void * output_data, int output_size)
{
const char * tensor_name;
const char * node_name;
tensor_t tensor;
if(get_output_node_number(graph)!=1)
return -1;
node_name=get_output_node_name(graph,0);
tensor_name=get_node_output_tensor(graph,node_name,0);
tensor=get_graph_tensor(graph,tensor_name);
int ret=get_tensor_data(tensor,output_data,output_size);
put_graph_tensor(tensor);
return ret;
}
void destroy_graph(graph_t graph)
{
postrun_graph(graph);
const char * model_name=get_model_name(graph);
remove_model(model_name);
destroy_runtime_graph(graph);
release_tengine_library();
}
int get_output_size(graph_t graph)
{
const char * tensor_name;
const char * node_name;
tensor_t tensor;
if(get_output_node_number(graph)!=1)
return -1;
node_name=get_output_node_name(graph,0);
tensor_name=get_node_output_tensor(graph,node_name,0);
tensor=get_graph_tensor(graph,tensor_name);
int ret=get_tensor_buffer_size(tensor);
put_graph_tensor(tensor);
return ret;
}
int set_input_shape(graph_t graph, int dims[], int dim_number)
{
const char * tensor_name;
const char * node_name;
tensor_t tensor;
/* should only one input node */
if(get_input_node_number(graph)!=1)
return -1;
node_name=get_input_node_name(graph,0);
tensor_name=get_node_output_tensor(graph,node_name,0);
tensor=get_graph_tensor(graph,tensor_name);
int ret=set_tensor_shape(tensor,dims,dim_number);
put_graph_tensor(tensor);
return ret;
}
static user_context_t get_default_user_context(void)
{
static user_context_t def_user_context=nullptr;
if(def_user_context==nullptr)
{
def_user_context=create_user_context("default");
}
return def_user_context;
}
static workspace_t create_default_workspace(void)
{
user_context_t user_context=get_default_user_context();
return create_workspace("default",user_context);
}
static workspace_t get_default_workspace(void)
{
static workspace_t default_workspace=nullptr;
if(default_workspace==nullptr)
{
default_workspace=create_default_workspace();
}
return default_workspace;
}
/*** Level 1 API implementation */
void __attribute__((constructor)) first_init(void)
{
NamedData<DataLayout>::InitPredefinedData();
NamedData<DataType>::InitPredefinedData();
}
extern "C" {
void operator_plugin_init(void);
void serializer_plugin_init(void);
void executor_plugin_init(void);
void driver_plugin_init(void);
}
static void InitAllPlugin(void)
{
operator_plugin_init();
serializer_plugin_init();
executor_plugin_init();
driver_plugin_init();
}
static void set_cpu_list(const char * cpu_list_str)
{
char * copy_str=strdup(cpu_list_str);
std::vector<int> cpu_list;
char * p=strtok(copy_str,",");
while(p)
{
int cpu_id=strtoul(p,NULL,10);
cpu_list.push_back(cpu_id);
p=strtok(NULL,",");
}
int * int_buf=cpu_list.data();
set_working_cpu(int_buf,cpu_list.size());
free(copy_str);
}
int init_tengine_library(void)
{
static int initialized=0;
static std::mutex init_mutex;
if(initialized)
return 0;
TEngineLock(init_mutex);
if(initialized)
{
TEngineUnlock(init_mutex);
return 0;
}
initialized=1;
TEngineConfig::Set("exec.engine","generic",true);
//create the default user context
get_default_user_context();
InitAllPlugin();
//create the default context and workspace
get_default_user_context();
get_default_workspace();
TEnginePlugin::InitModule();
//set the default online cpu according to env var
const char * cpu_list_str=std::getenv("TENGINE_CPU_LIST");
if(cpu_list_str)
{
std::cout<<"ENV SET: ["<<cpu_list_str<<"]\n";
set_cpu_list(cpu_list_str);
}
TEngineUnlock(init_mutex);
return 0;
}
void release_tengine_library(void)
{
TEnginePlugin::ReleaseModule();
}
const char * get_tengine_version(void)
{
return TEngineConfig::version.c_str();
}
int request_tengine_version(const char * version)
{
//TODO: the real version compatibility check
// TO_BE_IMPLEMENTED;
return 1;
}
static int vload_model(const char * model_name, const char * file_format, const char * fname, va_list argp)
{
SerializerPtr serializer;
if(!SerializerManager::SafeGet(file_format,serializer))
return -1;
int saved_file_number=serializer->GetFileNum();
std::vector<std::string> file_list;
file_list.push_back(fname);
for(int i=1;i<saved_file_number;i++)
{
const char * file=va_arg(argp,const char *);
file_list.emplace_back(file);
}
va_end(argp);
StaticGraph * static_graph=CreateStaticGraph(model_name);
if(!serializer->LoadModel(file_list,static_graph) ||
!CheckGraphIntegraity(static_graph))
{
delete static_graph;
return -1;
}
if(StaticGraphManager::SafeAdd(std::string(model_name),StaticGraphPtr(static_graph)))
return 0;
return -1;
}
int load_model(const char * model_name, const char * file_format, const char * fname, ...)
{
va_list argp;
va_start(argp,fname);
return vload_model(model_name,file_format,fname,argp);
}
int save_model(graph_t graph, const char * file_format, const char * fname, ...)
{
/* Get the serializer according to file_format */
SerializerPtr serializer;
if(!SerializerManager::SafeGet(file_format, serializer))
return -1;
/* Create file list */
va_list argp;
va_start(argp,fname);
std::vector<std::string> file_list;
file_list.push_back(fname);
for(unsigned int i=1; i < serializer->GetFileNum(); i++)
{
const char *file = va_arg(argp, const char *);
file_list.emplace_back(file);
}
va_end(argp);
/* Get runtime graph pointer */
GraphExecutor *executor = static_cast<GraphExecutor *>(graph);
Graph *g = executor->GetGraph();
/* Save the graph to the files */
if(!serializer->SaveModel(file_list, g))
return -1;
return 0;
}
int remove_model(const char * model_name)
{
if(!StaticGraphManager::Find(model_name))
return -1;
StaticGraphManager::Remove(model_name);
return 0;
}
int dump_model(const char * model_name)
{
StaticGraphPtr graph_ptr;
if(StaticGraphManager::SafeGet(model_name,graph_ptr))
{
DumpStaticGraph(graph_ptr.get());
return 0;
}
return -1;
}
graph_t create_runtime_graph(const char * graph_name, const char * model_name,workspace_t ws)
{
if(ws==nullptr)
ws=get_default_workspace();
RuntimeWorkspace* r_ws=static_cast<RuntimeWorkspace *>(ws);
if(r_ws==nullptr)
{
return nullptr;
}
return r_ws->CreateGraphExecutor(graph_name,model_name);
}
int destroy_runtime_graph(graph_t graph)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
RuntimeWorkspace * r_ws=executor->GetWorkspace();
if(r_ws->DestroyGraphExecutor(executor))
return 0;
return -1;
}
int set_graph_input_node(graph_t graph, const char * input_nodes[], int input_number)
{
std::vector<std::string> inputs;
for(int i=0;i<input_number;i++)
inputs.push_back(input_nodes[i]);
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
if(executor->SetGraphInputNode(inputs))
return 0;
return -1;
}
int set_graph_output_node(graph_t graph, const char * output_nodes[], int output_number)
{
std::vector<std::string> outputs;
for(int i=0;i<output_number;i++)
outputs.push_back(output_nodes[i]);
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
if(executor->SetGraphOutputNode(outputs))
return 0;
return -1;
}
int get_input_node_number(graph_t graph)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
return executor->GetGraphInputNodeNum();
}
const char * get_input_node_name(graph_t graph, int idx)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
return executor->GetGraphInputNodeName(idx).c_str();
}
int get_node_input_number(graph_t graph, const char * node_name)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
return executor->GetNodeInputNum(node_name);
}
const char * get_node_input_tensor(graph_t graph, const char * node_name, int input_idx)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
return executor->GetNodeInputTensor(node_name,input_idx).c_str();
}
int get_output_node_number(graph_t graph)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
return executor->GetGraphOutputNodeNum();
}
const char * get_output_node_name(graph_t graph, int idx)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
return executor->GetGraphOutputNodeName(idx).c_str();
}
int get_node_output_number(graph_t graph, const char * node_name)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
return executor->GetNodeOutputNum(node_name);
}
const char * get_node_output_tensor(graph_t graph, const char * node_name, int output_idx)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
return executor->GetNodeOutputTensor(node_name,output_idx).c_str();
}
tensor_t get_graph_tensor(graph_t graph, const char * tensor_name)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
Tensor * tensor=executor->FindTensor(tensor_name);
if(tensor==nullptr)
return nullptr;
tensor_handle * h=new tensor_handle();
h->executor=executor;
h->tensor=tensor;
return h;
}
tensor_t get_graph_input_tensor(graph_t graph, int input_node_idx, int tensor_idx)
{
int node_number = get_input_node_number(graph);
if(!node_number || input_node_idx >= node_number)
return nullptr;
const char * node_name = get_input_node_name(graph, input_node_idx);
int tensor_number = get_node_output_number(graph, node_name);
if(!tensor_number || tensor_idx >= tensor_number)
return nullptr;
const char * tensor_name = get_node_output_tensor(graph, node_name, tensor_idx);
tensor_t tensor = get_graph_tensor(graph, tensor_name);
return tensor;
}
tensor_t get_graph_output_tensor(graph_t graph, int output_node_idx, int tensor_idx)
{
int node_number = get_output_node_number(graph);
if(!node_number || output_node_idx >= node_number)
return nullptr;
const char * node_name = get_output_node_name(graph, output_node_idx);
int tensor_number = get_node_output_number(graph, node_name);
if(!tensor_number || tensor_idx >= tensor_number)
return nullptr;
const char * tensor_name = get_node_output_tensor(graph, node_name, tensor_idx);
tensor_t tensor = get_graph_tensor(graph, tensor_name);
return tensor;
}
int check_tensor_valid(tensor_t tensor)
{
tensor_handle * t=static_cast<tensor_handle *>(tensor);
if(t==nullptr)
return 0;
return 1;
}
void put_graph_tensor(tensor_t tensor)
{
tensor_handle * h=static_cast<tensor_handle *>(tensor);
delete h;
}
int set_tensor_shape(tensor_t tensor, int dims[], int dim_number)
{
std::vector<int> dim;
for(int i=0;i<dim_number;i++)
dim.push_back(dims[i]);
tensor_handle * h=static_cast<tensor_handle*>(tensor);
Tensor * real_tensor=h->tensor;
TShape& shape=real_tensor->GetShape();
shape.SetDim(dim);
return 0;
}
int get_tensor_shape(tensor_t tensor, int dims[], int dim_number)
{
tensor_handle * h=static_cast<tensor_handle*>(tensor);
Tensor * real_tensor=h->tensor;
TShape& shape=real_tensor->GetShape();
std::vector<int>& dim=shape.GetDim();
int dim_size=dim.size();
if(dim_size>dim_number)
return -1;
for(int i=0;i<dim_size;i++)
dims[i]=dim[i];
return dim_size;
}
int get_tensor_buffer_size(tensor_t tensor)
{
tensor_handle * h=static_cast<tensor_handle*>(tensor);
Tensor * real_tensor=h->tensor;
return real_tensor->GetTotalSize();
}
int set_tensor_buffer_transfer(tensor_t tensor, void * buffer, int buffer_size,tensor_buf_cb_t cb, void * cb_arg)
{
tensor_handle * h=static_cast<tensor_handle*>(tensor);
GraphExecutor * executor=h->executor;
/* TODO: pass the callback to below layers*/
if(executor->SetTensorBuffer(h->tensor,buffer,buffer_size))
return 0;
return -1;
}
int set_tensor_buffer(tensor_t tensor, void * buffer, int buffer_size)
{
tensor_handle * h=static_cast<tensor_handle*>(tensor);
GraphExecutor * executor=h->executor;
if(executor->SetTensorBuffer(h->tensor,buffer,buffer_size))
return 0;
return -1;
}
int set_tensor_data(tensor_t tensor, const void * input_data, int data_size)
{
tensor_handle * h=static_cast<tensor_handle*>(tensor);
GraphExecutor * executor=h->executor;
if(executor->SetTensorData(h->tensor,input_data,data_size))
return 0;
return -1;
}
int get_tensor_data(tensor_t tensor, void * output_data, int data_size)
{
tensor_handle * h=static_cast<tensor_handle*>(tensor);
GraphExecutor * executor=h->executor;
if(executor->GetTensorData(h->tensor,output_data,data_size))
return 0;
return -1;
}
void * get_tensor_buffer(tensor_t tensor)
{
tensor_handle * h=static_cast<tensor_handle*>(tensor);
GraphExecutor * executor=h->executor;
return executor->GetTensorBuffer(h->tensor);
}
const char * get_tensor_name(tensor_t tensor)
{
tensor_handle * h=static_cast<tensor_handle*>(tensor);
Tensor * real_tensor=h->tensor;
return real_tensor->GetName().c_str();
}
void * get_graph_node(graph_t graph, const char * node_name)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
return executor->FindNode(node_name);
}
int set_node_device(node_t node, const char * dev_name)
{
Node* node_ = static_cast<Node*>(node);
std::string dev = dev_name;
node_->SetAttr("dev_id", dev);
return 0;
}
void put_graph_node(void * node)
{
}
int get_node_param_int(node_t node, const char * param_name, int * param_val)
{
return get_node_param_generic(node,param_name,&typeid(int),param_val);
}
int get_node_param_float(node_t node, const char * param_name, float * param_val)
{
return get_node_param_generic(node,param_name,&typeid(float),param_val);
}
/* a temporary solution:
* Define an intermidate function
* NodeGetParamGeneric(): defined in node.cpp
*
*/
namespace TEngine {
extern int NodeGetParamGeneric(void * node, const char * param_name, const void * type_info, void * param_val);
extern int NodeSetParamGeneric(void * node, const char * param_name, const void * type_info, const void * param_val);
}
int get_node_param_generic(node_t node, const char * param_name, const void * type_info, void * param_val)
{
return NodeGetParamGeneric(node,param_name,type_info,param_val);
}
int set_node_param_int(node_t node, const char * param_name, const int * param_val)
{
return set_node_param_generic(node,param_name,&typeid(int),param_val);
}
int set_node_param_float(node_t node, const char * param_name, const float * param_val)
{
return set_node_param_generic(node,param_name,&typeid(float),param_val);
}
int set_node_param_generic(node_t node, const char * param_name, const void * type_info, const void * param_val)
{
return NodeSetParamGeneric(node,param_name,type_info,param_val);
}
int prerun_graph(graph_t graph)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
if(!executor->InferShape())
return -1;
if(executor->Prerun())
return 0;
return -1;
}
int infer_shape(graph_t graph)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
if(!executor->InferShape())
return -1;
return 0;
}
int run_graph(graph_t graph, int block)
{
GraphExecutor * executor=reinterpret_cast<GraphExecutor *>(graph);
if(GetSyncRunMode())
return executor->SyncRun();
else
return executor->Run(block);
}
void dump_graph(graph_t graph)
{
GraphExecutor * executor=static_cast<GraphExecutor *>(graph);
/* first: try to dump optimized graph */
Graph* g=executor->GetOptimizedGraph();
if(g)
{
g->DumpGraph();
return;
}
/* get the origin graph */
g=executor->GetGraph();
g->DumpGraph();
}
int wait_graph(graph_t graph, int try_wait)
{
GraphExecutor * executor=reinterpret_cast<GraphExecutor *>(graph);
return executor->WaitGraph(try_wait);
}
int postrun_graph(graph_t graph)
{
GraphExecutor * executor=reinterpret_cast<GraphExecutor *>(graph);
executor->Postrun();
return 0;
}
int get_graph_exec_status(graph_t graph)
{
TO_BE_IMPLEMENTED;
return 0;
}
int set_graph_event_hook(graph_t graph, int event, graph_callback_t cb_func, void * cb_arg)
{
TO_BE_IMPLEMENTED;
return 0;
}
int get_engine_number(void)
{
TO_BE_IMPLEMENTED;
return 0;
}
const char * get_engine_name(int idx)
{
TO_BE_IMPLEMENTED;
return 0;
}
int set_device_mode(const char * device_name, int mode)
{
TO_BE_IMPLEMENTED;
return 0;
}
int get_device_mode(const char * device_name)
{
TO_BE_IMPLEMENTED;
return 0;
}
int get_device_config(const char * device_name, const char * config_name, void * val, int size)
{
TO_BE_IMPLEMENTED;
return 0;
}
int set_device_config(const char * device_name, const char * config_name, void * val, int size)
{
TO_BE_IMPLEMENTED;
return 0;
}
int del_device_config(const char * device_name, const char * config_name)
{
TO_BE_IMPLEMENTED;
return 0;
}
user_context_t create_user_context(const char * context_name)
{
bool ret;
UserContext * context=new UserContext(context_name);
ret=UserContextManager::SafeAdd(context_name,context);
if(ret)
return context;
delete context;
return nullptr;
}
int check_user_context_valid(user_context_t context)
{
UserContext * user_context=static_cast<UserContext *>(context);
if(user_context==nullptr)
return 0;
return 1;
}
user_context_t get_user_context(const char * context_name)
{
UserContext * user_context;
if(UserContextManager::SafeGet(context_name,user_context))
return user_context;
return nullptr;
}
void destroy_user_context(user_context_t context)
{
UserContext * user_context=static_cast<UserContext *>(context);
if(UserContextManager::SafeRemove(user_context->GetName()))
delete user_context;
XLOG_ERROR()<<"BUG: not managed user context: "<<user_context->GetName()<<"\n";
}
int set_user_context_config(user_context_t context, const char * name, void * val, int size)
{
TO_BE_IMPLEMENTED;
return 0;
}
int get_user_context_config(user_context_t context, const char * name, void * val, int size)
{
TO_BE_IMPLEMENTED;
return 0;
}
int del_user_context_config(user_context_t context, const char * name)
{
TO_BE_IMPLEMENTED;
return 0;
}
workspace_t create_workspace(const char * ws_name, user_context_t context)
{
UserContext *user_context=static_cast<UserContext *>(context);
return user_context->CreateWorkspace(ws_name);
}
int check_workspace_valid(workspace_t ws)
{
RuntimeWorkspace * r_ws=static_cast<RuntimeWorkspace *> (ws);
if(r_ws==nullptr)
return 0;
return 1;
}
workspace_t get_workspace(const char * ws_name,user_context_t context)
{
UserContext *user_context=static_cast<UserContext *>(context);
return user_context->FindWorkspace(ws_name);
}
void destroy_workspace(workspace_t ws)
{
RuntimeWorkspace * r_ws=static_cast<RuntimeWorkspace *> (ws);
UserContext * user_context=r_ws->GetUserContext();
user_context->DestroyWorkspace(r_ws);
}
int set_workspace_config(workspace_t ws, const char * config_name, void * config_val)
{
TO_BE_IMPLEMENTED;
return 0;
}
int get_workspace_config(workspace_t ws, const char * config_name, void * config_val)
{
TO_BE_IMPLEMENTED;
return 0;
}
int del_workspace_config(workspace_t ws, const char * config_name)
{
TO_BE_IMPLEMENTED;
return 0;
}
int set_graph_config(graph_t graph, const char * name, void * val, int size)
{
TO_BE_IMPLEMENTED;
return 0;
}
int get_graph_config(graph_t graph, const char * name, void * val, int size)
{
TO_BE_IMPLEMENTED;
return 0;
}
int del_graph_config(graph_t graph, const char * name)
{
TO_BE_IMPLEMENTED;
return 0;
}
void set_log_level(int level)
{
SET_LOG_LEVEL((LogLevel)level);
}
static std::string tengine_conf_file;
void set_config_file(const char * conf_file)
{
tengine_conf_file=conf_file;
}
const char * get_config_file(void)
{
if(!tengine_conf_file.empty())
return tengine_conf_file.c_str();
const char * env_key="TENGINE_CONFIG_FILE";
const char * conf_env=std::getenv(env_key);
if(conf_env)
return conf_env;
std::fstream test_fs;
/* check if /etc/tengine/config or /usr/local/etc/tengine/config exists */
const char * conf_basename="config";
std::string std_etc_conf("/etc/tengine/");
std_etc_conf=std_etc_conf+conf_basename;
test_fs.open(std_etc_conf);
if(test_fs.is_open())
{
test_fs.close();
tengine_conf_file=std_etc_conf;
return tengine_conf_file.c_str();
}
std::string usr_etc_conf("/usr/local/etc/tengine/");
usr_etc_conf=usr_etc_conf+conf_basename;
test_fs.open(usr_etc_conf);
if(test_fs.is_open())
{
test_fs.close();
tengine_conf_file=usr_etc_conf;
return tengine_conf_file.c_str();
}
#ifndef PATH_MAX
/* check current directory */
#define PATH_MAX 1024
#endif
char file_path[PATH_MAX+128];
if(getcwd(file_path,PATH_MAX))
{
sprintf(file_path+strlen(file_path),"/etc/tengine/config");
test_fs.open(file_path);
if(test_fs.is_open())
{
test_fs.close();
tengine_conf_file=file_path;
return tengine_conf_file.c_str();
}
if(getcwd(file_path,PATH_MAX)==NULL)
return nullptr;
sprintf(file_path+strlen(file_path),"/etc/config");
test_fs.open(file_path);
if(test_fs.is_open())
{
test_fs.close();
tengine_conf_file=file_path;
return tengine_conf_file.c_str();
}
}
/* check the relative path of executable */
/* get the abs path of executable first */
int n=readlink("/proc/self/exe",file_path,PATH_MAX);
if(n==PATH_MAX)
n=PATH_MAX-1;
file_path[n]=0x0;
char * p=strrchr(file_path,'/');
p[1]=0;
sprintf(file_path+strlen(file_path),"../etc/tengine/config");
test_fs.open(file_path);
if(test_fs.is_open())
{
test_fs.close();
tengine_conf_file=file_path;
return tengine_conf_file.c_str();
}
n=readlink("/proc/self/exe",file_path,PATH_MAX);
if(n==PATH_MAX)
n=PATH_MAX-1;
file_path[n]=0x0;
p=strrchr(file_path,'/');
p[1]=0;
sprintf(file_path+strlen(file_path),"../etc/config");
test_fs.open(file_path);
if(test_fs.is_open())
{
test_fs.close();
tengine_conf_file=file_path;
return tengine_conf_file.c_str();
}
return nullptr;
}
| [
"[email protected]"
] | |
596b6601fc29346f6307f1a31aa4510917e37eec | 910c62f88fe2e31e7fba7526af9a7edf24339bc3 | /src/solver/approx_eb.h | 508c5d85964e32e85e4275e054fc7812a477ade8 | [
"MIT"
] | permissive | termi3/aphros | 5d4ef5663fc50e6ed07faf566d6822e992105e10 | a6cd17666fcd150dc835a1c270d644d29863793b | refs/heads/master | 2023-01-24T04:49:18.137356 | 2020-09-22T08:55:05 | 2020-09-22T08:55:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,651 | h | // Created by Petr Karnakov on 11.02.2020
// Copyright 2020 ETH Zurich
#pragma once
#include <array>
#include <memory>
#include <stdexcept>
#include <string>
#include <vector>
#include "cond.h"
#include "embed.h"
#include "geom/mesh.h"
#include "parse/vars.h"
#include "solver.h"
template <class Scal_>
struct ULinear {
static constexpr size_t dim = 3;
using Scal = Scal_;
using Vect = generic::Vect<Scal, dim>;
template <size_t N>
static std::array<Scal, N> Mul(
std::array<Scal, N * N> a, std::array<Scal, N> x) {
using Int = size_t;
std::array<Scal, N> r;
for (Int i = 0; i < N; ++i) {
r[i] = 0;
for (Int j = 0; j < N; ++j) {
r[i] += a[i * N + j] * x[j];
}
}
return r;
}
// Solves linear system a*x=b.
template <size_t N>
static std::array<Scal, N> SolveLinear(
std::array<Scal, N * N> a, std::array<Scal, N> b) {
using Int = size_t;
auto aa = [&a](Int i, Int j) -> Scal& { return a[i * N + j]; };
auto swaprows = [&aa, &b](Int i, Int ip) {
if (i == ip) {
return;
}
for (Int j = 0; j < N; ++j) {
std::swap(aa(i, j), aa(ip, j));
}
std::swap(b[i], b[ip]);
};
auto ipivot = [&aa](const Int j) {
Int imax = j;
for (Int i = j + 1; i < N; ++i) {
if (std::abs(aa(i, j)) > std::abs(aa(imax, j))) {
imax = i;
}
}
return imax;
};
auto addrow = [&aa, &b](Int i, Int ip, Scal ap) {
for (Int j = 0; j < N; ++j) {
aa(i, j) += aa(ip, j) * ap;
}
b[i] += b[ip] * ap;
};
for (Int j = 0; j < N; ++j) {
const Int ip = ipivot(j);
swaprows(ip, j);
for (Int i = j + 1; i < N; ++i) {
addrow(i, j, -aa(i, j) / aa(j, j));
}
}
std::array<Scal, N> x;
for (Int i = N; i > 0;) {
--i;
Scal t = b[i];
for (Int j = i + 1; j < N; ++j) {
t -= aa(i, j) * x[j];
}
x[i] = t / aa(i, i);
}
return x;
}
// Fits linear function to set of points and values
// u = g.dot(x) + u0
// Returns {g, u0}.
static std::pair<Vect, Scal> FitLinear(
const std::vector<Vect>& xx, const std::vector<Scal>& uu);
// Fits linear function to set of points and values
// u = g.dot(x) + u0
// Returns {g, u0}.
static std::pair<generic::Vect<Vect, dim>, Vect> FitLinear(
const std::vector<Vect>& xx, const std::vector<Vect>& uu);
template <class T>
static T EvalLinear(
const std::pair<generic::Vect<T, dim>, T>& p, const Vect& x) {
auto& g = p.first;
auto& u0 = p.second;
return g[0] * x[0] + g[1] * x[1] + g[2] * x[2] + u0;
}
};
template <class EB, class T>
auto FitLinear(IdxCell c, const FieldCell<T>& fcu, const EB& eb) {
using Scal = typename EB::Scal;
using Vect = typename EB::Vect;
auto& m = eb.GetMesh();
std::vector<Vect> xx;
std::vector<T> uu;
for (auto cn : eb.Stencil(c)) {
xx.push_back(m.GetCenter(cn));
uu.push_back(fcu[cn]);
}
return ULinear<Scal>::FitLinear(xx, uu);
}
template <class EB, class T>
T EvalLinearFit(
typename EB::Vect x, IdxCell c, const FieldCell<T>& fcu, const EB& eb) {
auto p = FitLinear(c, fcu, eb);
return ULinear<typename EB::Scal>::EvalLinear(p, x);
}
template <class M_>
struct UEmbed {
using M = M_;
using EB = Embed<M>;
static constexpr size_t dim = M::dim;
using Scal = typename M::Scal;
using Vect = typename M::Vect;
using Type = typename EB::Type;
struct CondEmbed {
enum class Type { value, gradient };
Scal u; // value or normal gradient
};
static FieldNode<Scal> InitEmbed(const M& m, const Vars& var, bool verb);
// feu: field on embedded boundaries [a]
// Returns:
// field on cells [a]
template <class T>
static FieldCell<T> Interpolate(const FieldEmbed<T>& feu, const EB& eb);
// feu: field on embedded boundaries [a]
// Returns:
// gradient on cells [a]
static FieldCell<Vect> GradientGauss(
const FieldEmbed<Scal>& feu, const EB& eb);
// Gradient from linear fit to face centers.
// feu: field on embedded boundaries [a]
// Returns:
// gradient on cells [a]
static FieldCell<Vect> GradientLinearFit(
const FieldEmbed<Scal>& feu, const EB& eb);
template <class T>
static FieldCell<T> AverageCutCells(const FieldCell<T>& fcu, const EB& eb);
template <class T>
static FieldCell<T> RedistributeCutCells(
const FieldCell<T>& fcu, const EB& eb);
template <class T>
static FieldCell<T> RedistributeCutCells(
const FieldCell<T>& fcu, const M& m);
static FieldCell<Scal> RedistributeCutCellsAdvection(
const FieldCell<Scal>& fcs, const FieldFace<Scal>& ffv, Scal cfl, Scal dt,
const M& m);
static FieldCell<Scal> RedistributeCutCellsAdvection(
const FieldCell<Scal>& fcs, const FieldEmbed<Scal>& ffv, Scal cfl,
Scal dt, const EB& eb);
// Updates flux in cut faces using bilinear interpolation from regular faces
// (Schwartz,2006).
// feu: field [a]
// bc: boundary conditions type, 0: value, 1: grad
// bcv: value or normal gradient (grad dot GetNormal)
// Returns:
// grad dot GetNormal on embedded boundaries [s]
template <class T>
static FieldFace<T> InterpolateBilinearFaces(
const FieldFace<T>& ffu, const EB& eb);
template <class T>
static FieldFace<T> InterpolateBilinearFaces(
const FieldFace<T>& ffu, const M& m);
template <class T>
static FieldEmbed<T> Interpolate(
const FieldCell<T>& fcu, const MapEmbed<BCond<T>>& mebc, const EB& eb);
template <class T>
static FieldEmbed<T> Gradient(
const FieldCell<T>& fcu, const MapEmbed<BCond<T>>& mebc, const EB& eb);
static FieldEmbed<Scal> InterpolateUpwind(
const FieldCell<Scal>& fcu, const MapEmbed<BCond<Scal>>& mebc, ConvSc sc,
const FieldCell<Vect>& fcg, const FieldEmbed<Scal>& fev, const EB& eb);
// Bell-Colella-Glaz advection scheme (1989) without limiters
static FieldEmbed<Scal> InterpolateBcg(
const FieldCell<Scal>& fcu, const MapEmbed<BCond<Scal>>& mebc,
const FieldEmbed<Scal>& fev, const FieldCell<Scal>& fc_src, const Scal dt,
const EB& eb);
template <class T>
static FieldFace<T> Interpolate(
const FieldCell<T>& fcu, const MapEmbed<BCond<T>>& mebc, const M& m);
template <class T>
static FieldFace<T> Gradient(
const FieldCell<T>& fcu, const MapEmbed<BCond<T>>& mebc, const M& m);
static FieldFace<Scal> InterpolateUpwind(
const FieldCell<Scal>& fcu, const MapEmbed<BCond<Scal>>& mebc, ConvSc sc,
const FieldCell<Vect>& fcg, const FieldFace<Scal>& ffv, const M& m);
static FieldFace<Scal> InterpolateBcg(
const FieldCell<Scal>& fcu, const MapEmbed<BCond<Scal>>& mebc,
const FieldFace<Scal>& ffv, const FieldCell<Scal>& fc_src, const Scal dt,
const M& m);
using ExprFace = typename M::ExprFace;
using Expr = typename M::Expr;
// Implicit interpolation with deferred correction.
// fcu: field cell from previous iteration [s]
// mebc: boundary conditions
// sc: interpolation scheme
// deferred: deferred correction factor (1: fully deferred)
// fcg: gradient [s]
// ffv: flow direction [i]
// Returns:
// ffe: interpolation expressions [i]
static FieldEmbed<ExprFace> InterpolateUpwindImplicit(
const FieldCell<Scal>& fcu, const MapEmbed<BCond<Scal>>& mebc, ConvSc sc,
Scal deferred, const FieldCell<Vect>& fcg, const FieldEmbed<Scal>& fev,
const EB& eb);
static FieldFace<ExprFace> InterpolateUpwindImplicit(
const FieldCell<Scal>& fcu, const MapEmbed<BCond<Scal>>& mebc, ConvSc sc,
Scal deferred, const FieldCell<Vect>& fcg, const FieldFace<Scal>& ffv,
const M& m);
// Implicit gradient with deferred correction.
// fcu: field cell from previous iteration [s]
// mebc: boundary conditions
// deferred: deferred correction factor (1: fully deferred)
// Returns:
// ffe: interpolation expressions [i]
static FieldEmbed<ExprFace> GradientImplicit(
const FieldCell<Scal>& fcu, const MapEmbed<BCond<Scal>>& mebc,
const EB& eb);
static FieldFace<ExprFace> GradientImplicit(
const FieldCell<Scal>& fcu, const MapEmbed<BCond<Scal>>& mebc,
const M& m);
static FieldCell<Vect> Gradient(const FieldEmbed<Scal>& feu, const EB& eb) {
return GradientLinearFit(feu, eb);
}
static FieldCell<Vect> Gradient(const FieldFace<Scal>& ffu, const M& m);
static FieldCell<Vect> AverageGradient(
const FieldEmbed<Scal>& ffg, const EB& eb);
static FieldCell<Vect> AverageGradient(
const FieldFace<Scal>& ffg, const M& m);
template <class MEB>
static Scal Eval(
const Expr& e, IdxCell c, const FieldCell<Scal>& fcu, const MEB& meb) {
Scal r = e[Expr::dim - 1];
r += fcu[c] * e[0];
for (auto q : meb.Nci(c)) {
r += fcu[meb.GetCell(c, q)] * e[1 + q];
}
return r;
}
template <class MEB>
static Scal Eval(
const ExprFace& e, IdxFace f, const FieldCell<Scal>& fcu,
const MEB& meb) {
const IdxCell cm = meb.GetCell(f, 0);
const IdxCell cp = meb.GetCell(f, 1);
return fcu[cm] * e[0] + fcu[cp] * e[1] + e[2];
}
static Scal Eval(
const ExprFace& e, IdxCell c, const FieldCell<Scal>& fcu, const EB&) {
return fcu[c] * e[0] + e[2];
}
template <class MEB>
static auto InterpolateHarmonic(
const FieldCell<Scal>& fcu, const MapEmbed<BCond<Scal>>& mebc,
const MEB& eb) {
auto inv = fcu;
for (auto c : eb.AllCells()) {
inv[c] = 1 / inv[c];
}
auto ff = Interpolate(inv, mebc, eb);
eb.LoopSuFaces([&](auto cf) { //
ff[cf] = 1 / ff[cf];
});
return ff;
}
};
| [
"[email protected]"
] | |
767f081df4e3affbd6631f449ddf454a1912f7ff | 35719512a1608493103c4c93817bc2a1c2d4fcc6 | /cppEnt/MyForm.h | da5b377d11e3e67b7eb036594fc767300c789d83 | [] | no_license | Jehoshaphatia/cppEnt | 2ac799e1b2908f9a305ec2f22904792d29073e11 | 4d70e19762eefb1637f4118ca86cf57126bd34eb | refs/heads/master | 2021-01-23T08:11:03.461542 | 2017-01-31T15:42:22 | 2017-01-31T15:42:22 | 80,534,217 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,080 | h | #pragma once
#include "MyForm1.h";
namespace cpp {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
MyForm(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(94, 92);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(95, 52);
this->button1->TabIndex = 0;
this->button1->Text = L"button1";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(284, 261);
this->Controls->Add(this->button1);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
MyForm1^ F2 = gcnew MyForm1;
F2->Show();
this->Hide();
}
};
}
| [
"[email protected]"
] | |
4567ed7db3dfef6b72d8bbc93c93b1dc4855b25f | e00f0be7179fdfe87f87475984dfdc55acdab16a | /7zip_4_65/CPP/7zip/Compress/LzxDecoder.cpp | 6109f9755dbf652e0a24be7b33101f61f2f8ea66 | [] | no_license | BIAINC/7Zip | 5ee647c9d3d02e127a6793bc47075848c97fd4be | aecbbd0bc9612fac8676ab8caf521be64575bd62 | refs/heads/master | 2021-01-01T05:51:58.730009 | 2014-09-04T23:40:09 | 2014-09-04T23:40:09 | 9,531,434 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,731 | cpp | // LzxDecoder.cpp
#include "StdAfx.h"
#include "../../Common/Defs.h"
#include "LzxDecoder.h"
namespace NCompress {
namespace NLzx {
const int kLenIdNeedInit = -2;
CDecoder::CDecoder(bool wimMode):
_keepHistory(false),
_skipByte(false),
_wimMode(wimMode)
{
m_x86ConvertOutStreamSpec = new Cx86ConvertOutStream;
m_x86ConvertOutStream = m_x86ConvertOutStreamSpec;
}
void CDecoder::ReleaseStreams()
{
m_OutWindowStream.ReleaseStream();
m_InBitStream.ReleaseStream();
m_x86ConvertOutStreamSpec->ReleaseStream();
}
STDMETHODIMP CDecoder::Flush()
{
RINOK(m_OutWindowStream.Flush());
return m_x86ConvertOutStreamSpec->Flush();
}
UInt32 CDecoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); }
#define RIF(x) { if (!(x)) return false; }
bool CDecoder::ReadTable(Byte *lastLevels, Byte *newLevels, UInt32 numSymbols)
{
Byte levelLevels[kLevelTableSize];
UInt32 i;
for (i = 0; i < kLevelTableSize; i++)
levelLevels[i] = (Byte)ReadBits(kNumBitsForPreTreeLevel);
RIF(m_LevelDecoder.SetCodeLengths(levelLevels));
int num = 0;
Byte symbol = 0;
for (i = 0; i < numSymbols;)
{
if (num != 0)
{
lastLevels[i] = newLevels[i] = symbol;
i++;
num--;
continue;
}
UInt32 number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
if (number == kLevelSymbolZeros)
{
num = kLevelSymbolZerosStartValue + (int)ReadBits(kLevelSymbolZerosNumBits);
symbol = 0;
}
else if (number == kLevelSymbolZerosBig)
{
num = kLevelSymbolZerosBigStartValue + (int)ReadBits(kLevelSymbolZerosBigNumBits);
symbol = 0;
}
else if (number == kLevelSymbolSame || number <= kNumHuffmanBits)
{
if (number <= kNumHuffmanBits)
num = 1;
else
{
num = kLevelSymbolSameStartValue + (int)ReadBits(kLevelSymbolSameNumBits);
number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
if (number > kNumHuffmanBits)
return false;
}
symbol = Byte((17 + lastLevels[i] - number) % (kNumHuffmanBits + 1));
}
else
return false;
}
return true;
}
bool CDecoder::ReadTables(void)
{
Byte newLevels[kMaxTableSize];
{
if (_skipByte)
m_InBitStream.DirectReadByte();
m_InBitStream.Normalize();
int blockType = (int)ReadBits(kNumBlockTypeBits);
if (blockType > kBlockTypeUncompressed)
return false;
if (_wimMode)
if (ReadBits(1) == 1)
m_UnCompressedBlockSize = (1 << 15);
else
m_UnCompressedBlockSize = ReadBits(16);
else
m_UnCompressedBlockSize = m_InBitStream.ReadBitsBig(kUncompressedBlockSizeNumBits);
m_IsUncompressedBlock = (blockType == kBlockTypeUncompressed);
_skipByte = (m_IsUncompressedBlock && ((m_UnCompressedBlockSize & 1) != 0));
if (m_IsUncompressedBlock)
{
ReadBits(16 - m_InBitStream.GetBitPosition());
if (!m_InBitStream.ReadUInt32(m_RepDistances[0]))
return false;
m_RepDistances[0]--;
for (int i = 1; i < kNumRepDistances; i++)
{
UInt32 rep = 0;
for (int j = 0; j < 4; j++)
rep |= (UInt32)m_InBitStream.DirectReadByte() << (8 * j);
m_RepDistances[i] = rep - 1;
}
return true;
}
m_AlignIsUsed = (blockType == kBlockTypeAligned);
if (m_AlignIsUsed)
{
for(int i = 0; i < kAlignTableSize; i++)
newLevels[i] = (Byte)ReadBits(kNumBitsForAlignLevel);
RIF(m_AlignDecoder.SetCodeLengths(newLevels));
}
}
RIF(ReadTable(m_LastMainLevels, newLevels, 256));
RIF(ReadTable(m_LastMainLevels + 256, newLevels + 256, m_NumPosLenSlots));
for (UInt32 i = 256 + m_NumPosLenSlots; i < kMainTableSize; i++)
newLevels[i] = 0;
RIF(m_MainDecoder.SetCodeLengths(newLevels));
RIF(ReadTable(m_LastLenLevels, newLevels, kNumLenSymbols));
return m_LenDecoder.SetCodeLengths(newLevels);
}
class CDecoderFlusher
{
CDecoder *m_Decoder;
public:
bool NeedFlush;
CDecoderFlusher(CDecoder *decoder): m_Decoder(decoder), NeedFlush(true) {}
~CDecoderFlusher()
{
if (NeedFlush)
m_Decoder->Flush();
m_Decoder->ReleaseStreams();
}
};
void CDecoder::ClearPrevLevels()
{
int i;
for (i = 0; i < kMainTableSize; i++)
m_LastMainLevels[i] = 0;
for (i = 0; i < kNumLenSymbols; i++)
m_LastLenLevels[i] = 0;
};
HRESULT CDecoder::CodeSpec(UInt32 curSize)
{
if (_remainLen == kLenIdNeedInit)
{
_remainLen = 0;
m_InBitStream.Init();
if (!_keepHistory || !m_IsUncompressedBlock)
m_InBitStream.Normalize();
if (!_keepHistory)
{
_skipByte = false;
m_UnCompressedBlockSize = 0;
ClearPrevLevels();
UInt32 i86TranslationSize = 12000000;
bool translationMode = true;
if (!_wimMode)
{
translationMode = (ReadBits(1) != 0);
if (translationMode)
{
i86TranslationSize = ReadBits(16) << 16;
i86TranslationSize |= ReadBits(16);
}
}
m_x86ConvertOutStreamSpec->Init(translationMode, i86TranslationSize);
for(int i = 0 ; i < kNumRepDistances; i++)
m_RepDistances[i] = 0;
}
}
while(_remainLen > 0 && curSize > 0)
{
m_OutWindowStream.PutByte(m_OutWindowStream.GetByte(m_RepDistances[0]));
_remainLen--;
curSize--;
}
while(curSize > 0)
{
if (m_UnCompressedBlockSize == 0)
if (!ReadTables())
return S_FALSE;
UInt32 next = (Int32)MyMin(m_UnCompressedBlockSize, curSize);
curSize -= next;
m_UnCompressedBlockSize -= next;
if (m_IsUncompressedBlock)
{
while(next > 0)
{
m_OutWindowStream.PutByte(m_InBitStream.DirectReadByte());
next--;
}
}
else while(next > 0)
{
UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
if (number < 256)
{
m_OutWindowStream.PutByte((Byte)number);
next--;
}
else
{
UInt32 posLenSlot = number - 256;
if (posLenSlot >= m_NumPosLenSlots)
return S_FALSE;
UInt32 posSlot = posLenSlot / kNumLenSlots;
UInt32 lenSlot = posLenSlot % kNumLenSlots;
UInt32 len = kMatchMinLen + lenSlot;
if (lenSlot == kNumLenSlots - 1)
{
UInt32 lenTemp = m_LenDecoder.DecodeSymbol(&m_InBitStream);
if (lenTemp >= kNumLenSymbols)
return S_FALSE;
len += lenTemp;
}
if (posSlot < kNumRepDistances)
{
UInt32 distance = m_RepDistances[posSlot];
m_RepDistances[posSlot] = m_RepDistances[0];
m_RepDistances[0] = distance;
}
else
{
UInt32 distance;
int numDirectBits;
if (posSlot < kNumPowerPosSlots)
{
numDirectBits = (int)(posSlot >> 1) - 1;
distance = ((2 | (posSlot & 1)) << numDirectBits);
}
else
{
numDirectBits = kNumLinearPosSlotBits;
distance = ((posSlot - 0x22) << kNumLinearPosSlotBits);
}
if (m_AlignIsUsed && numDirectBits >= kNumAlignBits)
{
distance += (m_InBitStream.ReadBits(numDirectBits - kNumAlignBits) << kNumAlignBits);
UInt32 alignTemp = m_AlignDecoder.DecodeSymbol(&m_InBitStream);
if (alignTemp >= kAlignTableSize)
return S_FALSE;
distance += alignTemp;
}
else
distance += m_InBitStream.ReadBits(numDirectBits);
m_RepDistances[2] = m_RepDistances[1];
m_RepDistances[1] = m_RepDistances[0];
m_RepDistances[0] = distance - kNumRepDistances;
}
UInt32 locLen = len;
if (locLen > next)
locLen = next;
if (!m_OutWindowStream.CopyBlock(m_RepDistances[0], locLen))
return S_FALSE;
len -= locLen;
next -= locLen;
if (len != 0)
{
_remainLen = (int)len;
return S_OK;
}
}
}
}
return S_OK;
}
HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *, const UInt64 *outSize, ICompressProgressInfo *progress)
{
if (outSize == NULL)
return E_INVALIDARG;
UInt64 size = *outSize;
RINOK(SetInStream(inStream));
m_x86ConvertOutStreamSpec->SetStream(outStream);
m_OutWindowStream.SetStream(m_x86ConvertOutStream);
RINOK(SetOutStreamSize(outSize));
CDecoderFlusher flusher(this);
const UInt64 start = m_OutWindowStream.GetProcessedSize();
for (;;)
{
UInt32 curSize = 1 << 18;
UInt64 rem = size - (m_OutWindowStream.GetProcessedSize() - start);
if (curSize > rem)
curSize = (UInt32)rem;
if (curSize == 0)
break;
RINOK(CodeSpec(curSize));
if (progress != NULL)
{
UInt64 inSize = m_InBitStream.GetProcessedSize();
UInt64 nowPos64 = m_OutWindowStream.GetProcessedSize() - start;
RINOK(progress->SetRatioInfo(&inSize, &nowPos64));
}
}
flusher.NeedFlush = false;
return Flush();
}
HRESULT CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{
try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
catch(const CLzOutWindowException &e) { return e.ErrorCode; }
catch(...) { return S_FALSE; }
}
STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream)
{
m_InBitStream.SetStream(inStream);
return S_OK;
}
STDMETHODIMP CDecoder::ReleaseInStream()
{
m_InBitStream.ReleaseStream();
return S_OK;
}
STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
{
if (outSize == NULL)
return E_FAIL;
_remainLen = kLenIdNeedInit;
m_OutWindowStream.Init(_keepHistory);
return S_OK;
}
HRESULT CDecoder::SetParams(int numDictBits)
{
if (numDictBits < kNumDictionaryBitsMin || numDictBits > kNumDictionaryBitsMax)
return E_INVALIDARG;
UInt32 numPosSlots;
if (numDictBits < 20)
numPosSlots = 30 + (numDictBits - 15) * 2;
else if (numDictBits == 20)
numPosSlots = 42;
else
numPosSlots = 50;
m_NumPosLenSlots = numPosSlots * kNumLenSlots;
if (!m_OutWindowStream.Create(kDictionarySizeMax))
return E_OUTOFMEMORY;
if (!m_InBitStream.Create(1 << 16))
return E_OUTOFMEMORY;
return S_OK;
}
}}
| [
"[email protected]"
] | |
1c81a533b294f87931f15c55d0f3634619e4da03 | bee8a28bfc0e66d4889cf8bd715cd2f16fb7c917 | /windows/selectcontact.cpp | 32e107b368d9c0c696fc61750a9648a61da3b8b8 | [] | no_license | NotMrPotter/mwc-qt-wallet | dd80097d9e092b150cb169668c5f15366fd0b872 | f178744a535d4c0b2e0cbccabf57e53b9cbadf63 | refs/heads/master | 2020-06-09T13:10:42.781473 | 2019-06-23T16:06:23 | 2019-06-23T16:06:23 | 193,442,516 | 1 | 0 | null | 2019-06-24T05:53:52 | 2019-06-24T05:53:52 | null | UTF-8 | C++ | false | false | 1,373 | cpp | #include "windows/selectcontact.h"
#include "ui_selectcontact.h"
#include "../util/stringutils.h"
#include <QListWidgetItem>
#include "../control/messagebox.h"
namespace wnd {
SelectContact::SelectContact(QWidget *parent, const QVector<wallet::WalletContact> & _contacts ) :
QDialog(parent),
ui(new Ui::SelectContact),
contacts(_contacts)
{
ui->setupUi(this);
int idx = 0;
for ( const wallet::WalletContact & cnt : contacts ) {
QListWidgetItem *aitem = new QListWidgetItem(
util::expandStrR(cnt.name, 15) + cnt.address , ui->contactsListWidget );
aitem->setData(Qt::UserRole, idx++);
ui->contactsListWidget->addItem(aitem);
}
}
SelectContact::~SelectContact()
{
delete ui;
}
void SelectContact::on_cancelButton_clicked()
{
reject();
}
void SelectContact::on_selectButton_clicked()
{
QListWidgetItem * itm = ui->contactsListWidget->currentItem();
if (itm==nullptr) {
control::MessageBox::message(this, "Need info", "Please select a contact that you are going to use");
return;
}
int idx = itm->data(Qt::UserRole).toInt();
selectedContact = contacts[idx];
accept();
}
void SelectContact::on_contactsListWidget_itemActivated(QListWidgetItem *item)
{
int idx = item->data(Qt::UserRole).toInt();
selectedContact = contacts[idx];
accept();
}
}
| [
"[email protected]"
] | |
e08d0133196e20c682cb26a70dfd07e9ffe9a551 | 711e5c8b643dd2a93fbcbada982d7ad489fb0169 | /XPSP1/NT/windows/advcore/rcml/xmllib/xml/tokenizer/parser/xmlparser.cxx | f990feafeb4a524b25e957f2c5816189b0888173 | [] | no_license | aurantst/windows-XP-SP1 | 629a7763c082fd04d3b881e0d32a1cfbd523b5ce | d521b6360fcff4294ae6c5651c539f1b9a6cbb49 | refs/heads/master | 2023-03-21T01:08:39.870106 | 2020-09-28T08:10:11 | 2020-09-28T08:10:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 70,512 | cxx | /*
*
* Copyright (c) 1998,1999 Microsoft Corporation. All rights reserved.
* EXEMPT: copyright change only, no build required
*
*/
#include "stdafx.h"
#include <shlwapi.h> // StrCmpNI
#if 0
#include "core.hxx"
#pragma hdrstop
#endif
#include "xmlparser.hxx"
#include "../../xmlstream/xmlstream.hxx"
#include "../../../core/util/chartype.hxx"
#if 0
#include "../net/urlstream.hxx"
#include "datatype.hxx"
#include "chartype.hxx"
// For message formatting...
#include "core/lang/string.hxx"
#include "core/util/resources.hxx"
#include <objbase.h>
#endif
#if _FA
DeclareTag(tagParserCallback, "XML Parser", "callbacks");
DeclareTag(tagParserError, "XML Parser", "errors");
#endif
#define CRITICALSECTIONLOCK CSLock lock(&_cs);
// FA
#define STACK_ENTRY_MODEL(f)
#undef CRITICALSECTIONLOCK
#define CRITICALSECTIONLOCK
#define STACK_ENTRY
#define TraceTag(z) 0?0:0
#define Assert(x)
#define new_ne new
extern HRESULT UrlOpenAllowed(LPCWSTR pwszUrl, LPCWSTR pwszBaseUrl, BOOL fDTD);
#ifdef UNIX
#ifndef POSSIBLY_FOSSIL_CODE
// This was a hack to fix this calling the wrong delete
// REVIEW BUGBUG
void XMLParser::operator delete( void * p )
{
MemFree( p );
}
#endif // FOSSIL_CODE
#endif // UNIX
//extern char* WideToAscii(const WCHAR* string);
// --------------------------------------------------------------------
// A little helper class for setting a boolean flag and clearing it
// on destruction.
class BoolLock
{
bool* _pFlag;
public:
BoolLock(bool* pFlag)
{
_pFlag = pFlag;
*pFlag = true;
}
~BoolLock()
{
*_pFlag = false;
}
};
#define breakhr(a) hr = (a); if (hr != S_OK) break;
extern HINSTANCE g_hInstance;
extern "C"{
#ifndef __IID_DEFINED__
#define __IID_DEFINED__
typedef struct _IID
{
unsigned long x;
unsigned short s1;
unsigned short s2;
unsigned char c[8];
} IID;
#endif // __IID_DEFINED__
};
// Since we cannot use the SHLWAPI wnsprintfA function...
int DecimalToBuffer(long value, char* buffer, int j, long maxdigits)
{
long max = 1;
for (int k = 0; k < maxdigits; k++)
max = max * 10;
if (value > (max*10)-1)
value = (max*10)-1;
max = max/10;
for (int i = 0; i < maxdigits; i++)
{
long digit = (value / max);
value -= (digit * max);
max /= 10;
buffer[i+j] = '0' + (char)digit;
}
buffer[i+j]=0;
return i+j;
}
int StrToBuffer(const WCHAR* str, WCHAR* buffer, int j)
{
while (*str != NULL)
{
buffer[j++] = *str++;
}
return j;
}
/*********
WCHAR* StringAdd(WCHAR* a, WCHAR* b)
{
long len1 = _tcslen(a);
long len2 = _tcslen(b);
WCHAR* result = new_ne WCHAR[len1+len2+1];
if (result != NULL)
{
::memcpy(result, a, len1 * sizeof(WCHAR*));
::memcpy(&result[len1], b, len2 * sizeof(WCHAR*));
result[len1+len2] = 0;
}
return result;
}
************/
#define PUSHNODEINFO(pNodeInfo)\
if (_cNodeInfoAllocated == _cNodeInfoCurrent)\
{\
checkhr2(GrowNodeInfo());\
}\
_paNodeInfo[_cNodeInfoCurrent++] = _pCurrent;
#if 0
/************************ code bloat unacceptable ******************************
// ============ BEGIN HACK
// These are copied from messages.mc. I have to do this because including messages.h
// would clash with <xmlparser.h>
//#define XML_I_LINENUMBER 0x400CE590L
//#define XML_I_LINEPOSITION 0x400CE591L
// ============ END HACK
//==============================================================================
// This function calls FormatMessageA and converts the result to unicode.
// This is so that it works on Win95 !!
// For convenience the va_list of arguments are WCHAR arguments and this function
// converts them to ascii for you.
typedef char* PCHAR;
WCHAR* FormatMessageInternal(
LPCVOID lpSource, // pointer to message source
DWORD dwMessageId, // requested message identifier
WCHAR* arg1, ...) // variable list of args.
{
// Caller assumes the arguments are wide chars, so now we have to convert
// them to ascii.
char* temp = NULL;
DWORD rc = 0;
WCHAR* result = NULL;
PCHAR* args = NULL;
int argcount = 0;
int argsize = 0;
va_list arglist;
DWORD dwFlags = (lpSource == NULL) ? FORMAT_MESSAGE_FROM_SYSTEM : FORMAT_MESSAGE_FROM_HMODULE;
dwFlags |= FORMAT_MESSAGE_ALLOCATE_BUFFER;
// First we count number of args
va_start(arglist, arg1);
for (WCHAR* s = arg1; s; s = va_arg(arglist, WCHAR *))
{
argcount++;
}
va_end(arglist);
va_start(arglist, arg1);
// Then we pack the args into an array and convert them to ascii.
if (argcount > 0)
{
dwFlags |= FORMAT_MESSAGE_ARGUMENT_ARRAY;
args = new_ne PCHAR[argcount+1];
if (args == NULL)
goto CleanUp;
argcount=0;
for (WCHAR* s = arg1; s; s = va_arg(arglist, WCHAR *))
{
args[argcount] = WideToAscii(s);
if (args[argcount] == NULL)
goto CleanUp; // out of memory.
argcount++;
}
args[argcount] = NULL; // NULL terminate the array of args.
}
rc = ::FormatMessageA(dwFlags, lpSource, dwMessageId,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPSTR)&temp, 0, args);
if (rc > 0)
{
int length = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, temp, rc, NULL, 0);
result = new_ne WCHAR[length+1];
if (result == NULL)
goto CleanUp;
rc = ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, temp, rc, result, length);
result[rc] = 0; // NULL terminate
}
CleanUp:
va_end(arglist);
if (temp) ::LocalFree(temp);
// Now delete the array of arguments that we converted to ascii.
while (argcount > 0)
{
delete[] args[--argcount];
}
delete [] args;
return result;
}
**********************/
#endif
const USHORT STACK_INCREMENT=10;
//------------------------------------------------------------------------
XMLParser::XMLParser()
: _pDownloads(1), _pStack(STACK_INCREMENT)
// ,_reThreadModel(MultiThread) // make sure this is thead safe (as it always has been in the past).
{
ctorInit();
}
#ifdef RENTAL_MODEL
XMLParser::XMLParser(RentalEnum re)
: _pDownloads(1), _pStack(STACK_INCREMENT), _reThreadModel(re)
{
ctorInit();
}
#endif
void
XMLParser::ctorInit()
{
InitializeCriticalSection(&_cs);
_pTokenizer = NULL;
_pCurrent = NULL;
_lCurrentElement = 0;
_paNodeInfo = NULL;
_cNodeInfoAllocated = _cNodeInfoCurrent = 0;
_pdc = NULL;
_usFlags = 0;
_fCaseInsensitive = false;
_bstrError = NULL;
// _fTokenizerChanged = false;
_fRunEntryCount = 0;
_pszSecureBaseURL = NULL;
_pszCurrentURL = NULL;
_pszBaseURL = NULL;
_fInLoading = false;
_fInsideRun = false;
_fFoundDTDAttribute = false;
_cAttributes = 0;
_pRoot = NULL;
_fAttemptedURL = NULL;
_fLastError = 0;
_fStopped = false;
_fSuspended = false;
_fStarted = false;
_fWaiting = false;
_fIgnoreEncodingAttr = false;
_dwSafetyOptions = 0;
// ::IncrementComponents();
// rest of initialization done in the init() method.
//EnableTag(tagParserCallback, TRUE);
//EnableTag(tagParserError, TRUE);
}
XMLParser::~XMLParser()
{
{
// CRITICALSECTIONLOCK;
Reset();
// Cleanup tagname buffers in context for good this time...
for (long i = _pStack.size()-1; i>=0; i--)
{
MY_XML_NODE_INFO* pNodeInfo = _pStack[i];
if (pNodeInfo->_pwcTagName != NULL)
{
delete [] pNodeInfo->_pwcTagName;
pNodeInfo->_pwcTagName = NULL;
pNodeInfo->_ulBufLen = 0;
}
// NULL out the node pointer in case it point's to a GC'd object :-)
pNodeInfo->pNode = NULL;
}
delete _pszSecureBaseURL;
delete _pszCurrentURL;
delete[] _paNodeInfo;
// ::DecrementComponents();
}
DeleteCriticalSection(&_cs);
}
HRESULT STDMETHODCALLTYPE
XMLParser::QueryInterface(REFIID riid, void ** ppvObject)
{
#if 0
// STACK_ENTRY;
// Since this one class implements both IXMLNodeSource and
// IXMLParser, we must override QueryInterface since the
// IUnknown template doesn't know about the IXMLNodeSource
// interface.
HRESULT hr = S_OK;
if (riid == IID_IXMLNodeSource || riid == IID_Parser)
{
*ppvObject = static_cast<IXMLNodeSource*>(this);
AddRef();
}
else
{
hr = _unknown<IXMLParser, &IID_IXMLParser>::QueryInterface(riid, ppvObject);
}
return hr;
#endif
return S_OK;
}
ULONG STDMETHODCALLTYPE
XMLParser::AddRef( void)
{
#if 0
STACK_ENTRY;
return _unknown<IXMLParser, &IID_IXMLParser>::AddRef();
#endif
return S_OK;
}
ULONG STDMETHODCALLTYPE
XMLParser::Release( void)
{
#if 0
STACK_ENTRY;
return _unknown<IXMLParser, &IID_IXMLParser>::Release();
#endif
return S_OK;
}
#define checknull(a) if (!(a)) { hr = E_OUTOFMEMORY; goto error; }
HRESULT STDMETHODCALLTYPE
XMLParser::SetURL(
/* [in] */ const WCHAR* pszBaseUrl,
/* [in] */ const WCHAR* pszRelativeUrl,
/* [in] */ BOOL async)
{
// CRITICALSECTIONLOCK;
STACK_ENTRY_MODEL(_reThreadModel);
return PushURL(pszBaseUrl, pszRelativeUrl,
(async == TRUE),// async
true, // new tokenizer
false, // is dtd
false, // is entity
false // is parameter entity
);
}
HRESULT
XMLParser::PushURL(
/* [in] */ const WCHAR* pszBaseUrl,
/* [in] */ const WCHAR* pszRelativeUrl,
/* [in] */ bool async,
/* [in] */ bool tokenizer,
/* [in] */ bool dtd,
/* [in] */ bool fentity,
/* [in] */ bool fpe)
{
#if 0 // FA
HRESULT hr = S_OK;
URL url;
URLStream* stream = NULL;
const WCHAR* pszSecureBaseURL = NULL;
if (NULL == pszRelativeUrl)
{
hr = E_INVALIDARG;
goto cleanup;
}
if (_pDownloads.used() == 0)
init();
if (pszBaseUrl == NULL)
{
pszBaseUrl = _pszBaseURL;
}
stream = new_ne URLStream(this, dtd);
if (stream == NULL)
{
hr = E_OUTOFMEMORY;
goto cleanup;
}
if (tokenizer)
{
checkerr(PushTokenizer(stream));
if (dtd)
{
_pTokenizer->SetDTD(true);
}
}
else
{
checkerr(PushDownload(stream, NULL));
}
_pdc->_fAsync = async;
_pdc->_fDTD = dtd;
_pdc->_fEntity = fentity;
_pdc->_fPEReference = fpe;
checknull(_pdc->_pURLStream);
checkerr(url.set(pszRelativeUrl, _pszCurrentURL, pszBaseUrl));
pszSecureBaseURL = getSecureBaseURL();
if (! pszSecureBaseURL && _dwSafetyOptions)
pszSecureBaseURL = pszBaseUrl;
checkerr(url.setSecureBase( pszSecureBaseURL )); // can be different from pszBaseUrl.
checkerr(SetCurrentURL(url.getResolved()));
_fInLoading = true;
// WARNING: this must be done last because sometimes the callback bounces
// right back immediately and calls Run() on the parser !!
hr = _pdc->_pURLStream->Open(&url, async ? URLStream::ASYNCREAD : URLStream::SYNCREAD);
_fInLoading = false;
if (FAILED(hr))
{
_fAttemptedURL = ::SysAllocString(url.getRelative()); // save this for error info.
goto error;
}
hr = S_OK;
goto cleanup;
error:
PopDownload();
cleanup:
if (stream) stream->Release();
_fLastError = hr;
return hr;
#endif // FA
return S_OK;
}
HRESULT STDMETHODCALLTYPE
XMLParser::Load(
/* [in] */ BOOL fFullyAvailable,
/* [in] */ IMoniker __RPC_FAR *pimkName,
/* [in] */ LPBC pibc,
/* [in] */ DWORD grfMode)
{
#if 0 //FA
STACK_ENTRY_MODEL(_reThreadModel);
CRITICALSECTIONLOCK;
HRESULT hr = S_OK;
URL url;
URLStream* stream = NULL;
if (NULL == pimkName)
{
hr = E_INVALIDARG;
goto cleanup;
}
if (_pDownloads.used()== 0)
init();
// In this case we register a special call back to pump
// the parser during download. Typically in this case the
// caller also has a registered callback in order to monitor
// the download progress.
stream = new_ne URLStream(this);
if (stream == NULL)
{
hr = E_OUTOFMEMORY;
goto cleanup;
}
checkerr(PushTokenizer(stream));
checknull(_pdc->_pURLStream);
checkerr(ExtractURL(pimkName, pibc, &url));
_fInLoading = true;
_pdc->_fAsync = true;
// WARNING: this must be done last because sometimes the callback bounces
// right back immediately and calls Run() on the parser !!
hr = _pdc->_pURLStream->Open(pimkName, pibc, &url, URLStream::ASYNCREAD);
_fInLoading = false;
if (FAILED(hr))
{
_fAttemptedURL = ::SysAllocString(url.getRelative()); // save this for error info.
goto error;
}
goto cleanup;
error:
PopDownload();
cleanup:
if (stream) stream->Release();
return hr;
#endif // FA
return S_OK;
}
HRESULT STDMETHODCALLTYPE
XMLParser::LoadDTD(
/* [in] */ const WCHAR* pszBaseUrl,
/* [in] */ const WCHAR* pszRelativeUrl)
{
HRESULT hr;
STACK_ENTRY_MODEL(_reThreadModel);
CRITICALSECTIONLOCK;
BOOL async = FALSE;
// If previous download is async, then make this one async too.
if (_pdc && _pdc->_fAsync)
async = TRUE;
//
// Have to do this first because PushURL may invoke another downloading and calls back to the parser immediately
//
_cDTD++;
hr = _pFactory->NotifyEvent( this, XMLNF_STARTDTD);
if (SUCCEEDED(hr))
{
hr = PushURL(pszBaseUrl, pszRelativeUrl,
(async == TRUE),// async
true, // new tokenizer
true, // is dtd
false, // is entity
false // is parameter entity
);
_fTokenizerChanged = false;
}
return hr;
}
HRESULT STDMETHODCALLTYPE
XMLParser::SetInput(
/* [in] */ IUnknown __RPC_FAR *pStm)
{
if (pStm == NULL)
return E_INVALIDARG;
STACK_ENTRY_MODEL(_reThreadModel);
CRITICALSECTIONLOCK;
if (_pDownloads.used() == 0)
init();
HRESULT hr = S_OK;
checkhr2(PushTokenizer(NULL));
// Get the url path
// Continue even if we cannot get it
STATSTG stat;
IStream * pStream = NULL;
memset(&stat, 0, sizeof(stat));
hr = pStm->QueryInterface(IID_IStream, (void**)&pStream);
if (SUCCEEDED(hr))
{
hr = pStream->Stat(&stat, 0);
if (SUCCEEDED(hr) && stat.pwcsName != NULL)
{
SetCurrentURL(stat.pwcsName);
#if 0 // FA URL
WCHAR* pszSecureBaseURL = getSecureBaseURL();
if (*stat.pwcsName != 0 && pszSecureBaseURL != NULL && *pszSecureBaseURL != 0)
{
// Then we can apply security to IStream also - but first we have
// to turn the pwcsName into a valid URL.
// BUGBUG - If we can't make a valid URL then we can't verify security.
URL url;
url.set(stat.pwcsName,NULL,NULL);
hr = UrlOpenAllowed(url.getResolved(), pszSecureBaseURL, FALSE);
}
CoTaskMemFree(stat.pwcsName);
#endif // FA URL
}
else
{
hr = S_OK; // we don't care if stat fails.
}
if (SUCCEEDED(hr))
{
hr = PushStream(pStream, false);
}
pStream->Release();
}
return hr;
}
HRESULT STDMETHODCALLTYPE
XMLParser::PushData(
#ifdef UNIX
//
// The IDL compiler under Unix is outputting a
// /* [in] */ const unsigned char *pData,
// instead of
// /* [in] */ const char *pData,
// See also xmlparser.hxx
//
/* [in] */ const unsigned char *pData,
#else
/* [in] */ const char __RPC_FAR *pData,
#endif
/* [in] */ ULONG ulChars,
/* [in] */ BOOL fLastBuffer)
{
STACK_ENTRY_MODEL(_reThreadModel);
CRITICALSECTIONLOCK;
HRESULT hr=S_OK;
if (NULL == pData && (ulChars != 0))
{
return E_INVALIDARG;
}
if (_pTokenizer == NULL)
{
init();
checkhr2(PushTokenizer(NULL));
}
return _pTokenizer->AppendData((const BYTE*)pData, ulChars, fLastBuffer);
}
HRESULT STDMETHODCALLTYPE
XMLParser::LoadEntity(
/* [in] */ const WCHAR* pszBaseUrl,
/* [in] */ const WCHAR* pszRelativeUrl,
/* [in] */ BOOL fpe)
{
STACK_ENTRY_MODEL(_reThreadModel);
CRITICALSECTIONLOCK;
HRESULT hr;
BOOL async = FALSE;
// If previous download is async, then make this one async too.
if (_pdc && _pdc->_fAsync)
async = TRUE;
// then text is just a string that needs to be parsed.
hr = PushURL(pszBaseUrl, pszRelativeUrl,
(async == TRUE),// async
(fpe != TRUE), // new tokenizer
(fpe == TRUE), // is dtd
true, // is entity
(fpe == TRUE) // is parameter entity
);
if (hr == S_OK)
{
hr = _pFactory->NotifyEvent(this, XMLNF_STARTENTITY);
}
return hr;
}
HRESULT STDMETHODCALLTYPE
XMLParser::ParseEntity(
/* [in] */ const WCHAR* pwcText,
/* [in] */ ULONG ulLen,
/* [in] */ BOOL fpe)
{
STACK_ENTRY_MODEL(_reThreadModel);
CRITICALSECTIONLOCK;
HRESULT hr;
if (!fpe)
{
// Then we need a new tokenizer to parse it.
checkhr2(PushTokenizer(NULL));
_pdc->_fEntity = true;
_pdc->_fPEReference = (fpe == TRUE);
checkhr2(_pTokenizer->AppendData((const BYTE*)s_ByteOrderMark, sizeof(s_ByteOrderMark), FALSE));
hr = _pTokenizer->AppendData((const BYTE*)pwcText, ulLen * sizeof(WCHAR), TRUE);
}
else
{
hr = _pTokenizer->InsertData((const WCHAR *)pwcText, ulLen, true);
}
if (hr == S_OK)
{
hr = _pFactory->NotifyEvent(this, XMLNF_STARTENTITY);
}
return hr;
}
HRESULT STDMETHODCALLTYPE
XMLParser::ExpandEntity(
/* [in] */ const WCHAR* pwcText,
/* [in] */ ULONG ulLen)
{
STACK_ENTRY_MODEL(_reThreadModel);
CRITICALSECTIONLOCK;
return _pTokenizer->InsertData((const WCHAR *)pwcText, ulLen, false);
}
HRESULT STDMETHODCALLTYPE
XMLParser::SetRoot(
/* [in] */ PVOID pRoot)
{
STACK_ENTRY;
CRITICALSECTIONLOCK;
_pRoot = pRoot;
_pNode = pRoot;
return S_OK;
}
HRESULT STDMETHODCALLTYPE
XMLParser::GetRoot(
/* [in] */ PVOID __RPC_FAR * ppRoot)
{
STACK_ENTRY;
CRITICALSECTIONLOCK;
if (ppRoot == NULL) return E_INVALIDARG;
*ppRoot = _pRoot;
return S_OK;
}
HRESULT STDMETHODCALLTYPE
XMLParser::SetFactory(
/* [in] */ IXMLNodeFactory __RPC_FAR *pNodeFactory)
{
STACK_ENTRY;
CRITICALSECTIONLOCK;
_pFactory = pNodeFactory;
return S_OK;
}
HRESULT STDMETHODCALLTYPE
XMLParser::GetFactory(
/* [out] */ IXMLNodeFactory** ppNodeFactory)
{
if (ppNodeFactory == NULL) return E_INVALIDARG;
if (_pFactory)
{
*ppNodeFactory = _pFactory;
(*ppNodeFactory)->AddRef();
}
else
{
*ppNodeFactory = NULL;
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE
XMLParser::Run(
/* [in] */ long lChars)
{
STACK_ENTRY_MODEL(_reThreadModel);
CRITICALSECTIONLOCK;
XML_NODE_INFO info;
XML_NODE_INFO* aNodeInfo[1];
HRESULT hr = 0;
USHORT numRecs;
bool fIsAttribute = false;
WCHAR wc;
bool stop;
if (_fSuspended)
_fSuspended = FALSE; // caller must want to resume.
if (_pFactory == NULL)
{
return E_FAIL;
}
if (_fStopped)
{
return XML_E_STOPPED;
}
if (_pTokenizer == NULL)
{
if (_fLastError != S_OK)
return _fLastError;
else
// must be _fStarted == false
return XMLPARSER_IDLE;
}
// Check for recurrsive entry and whether caller actually
// wants anything parsed.
if (_fInsideRun || lChars == 0)
return E_PENDING;
BoolLock flock(&_fInsideRun);
if (_fLastError != 0)
{
// one more chance to cleanup the parser stack.
hr = _fLastError;
goto cleanup_stack;
}
if (! _fStarted)
{
_fStarted = true;
hr = _pFactory->NotifyEvent(this, XMLNF_STARTDOCUMENT);
if (_fStopped) // watch for onReadyStateChange handlers
return S_OK; // fussing with the parser state.
}
_fWaiting = false;
if (_fPendingBeginChildren)
{
_fPendingBeginChildren = false;
hr = _pFactory->BeginChildren(this, (XML_NODE_INFO*)_pCurrent);
}
if (_fPendingEndChildren)
{
_fPendingEndChildren = false;
hr = _pFactory->EndChildren(this, TRUE, (XML_NODE_INFO*)_pCurrent);
if (!hr)
hr = pop(); // no match needed
}
info.dwSize = sizeof(XML_NODE_INFO);
info.dwType = XMLStream::XML_PENDING;
info.dwSubType = 0;
info.pwcText = NULL;
info.ulLen = 0;
info.ulNsPrefixLen = 0;
info.pNode = NULL;
info.pReserved = NULL;
aNodeInfo[0] = &info;
more:
_fRunEntryCount++; // count of callers inside this loop...
while (hr == 0 && ! _fSuspended)
{
info.dwSubType = 0;
// The XMLStream error codes have been aligned with the
// XMLParser error code so no mapping is necessary.
hr = _pTokenizer->GetNextToken(&info.dwType, (const WCHAR **)&info.pwcText, (long*)&info.ulLen, (long*)&info.ulNsPrefixLen);
if (hr == E_PENDING)
{
_fWaiting = true;
break;
}
if (! _fFoundNonWS &&
info.dwType != XMLStream::XML_PENDING &&
info.dwType != XML_WHITESPACE &&
info.dwType != XML_XMLDECL)
{
_fFoundNonWS = true;
}
// Now the NodeType is the same as the XMLToken value. We set
// this up by aligning the two enums.
switch (info.dwType)
{
case 0:
if (hr == XML_E_INVALIDSWITCH && _fIgnoreEncodingAttr)
{
hr = 0; // ignore it and continue on.
}
break;
// --------- Container Nodes -------------------
case XML_XMLDECL:
if (_fFoundNonWS && ! _fIE4Mode) // IE4 allowed this...
{
hr = XML_E_BADXMLDECL;
break;
}
// _fFoundNonWS = true;
goto containers;
case XML_XMLSPACE:
case XML_XMLLANG:
info.dwSubType = info.dwType; // pass this as a subtype.
info.dwType = XML_ATTRIBUTE;
// fall through
case XML_ATTRIBUTE:
fIsAttribute = true;
goto containers;
case XML_VERSION:
info.dwSubType = info.dwType;
info.dwType = XML_ATTRIBUTE;
_fGotVersion = true;
fIsAttribute = true;
goto containers;
case XML_STANDALONE:
case XML_ENCODING:
if (! _fGotVersion && _pDownloads.used() == 1)
{
hr = XML_E_EXPECTING_VERSION;
break;
}
if (info.dwType == XML_STANDALONE)
{
if (_pDownloads.used() > 1)
{
hr = XML_E_UNEXPECTED_STANDALONE;
break;
}
}
info.dwSubType = info.dwType;
info.dwType = XML_ATTRIBUTE;
fIsAttribute = true;
goto containers;
case XML_NS:
info.dwSubType = info.dwType;
info.dwType = XML_ATTRIBUTE;
fIsAttribute = true;
{
MY_XML_NODE_INFO* ptr = _pStack[_lCurrentElement];// tell namespacenodefactory
ptr->pReserved = (void*)0x1; // that we found an XML_NS attribute.
}
goto containers;
case XML_ELEMENT:
case XML_PI:
containers:
if (_fRootLevel)
{
// Special rules apply for root level tags.
if (info.dwType == XML_ELEMENT)
{
// This is a root level element.
if (! _fFoundRoot)
{
_fFoundRoot = true;
}
else
{
hr = XML_E_MULTIPLEROOTS;
break;
}
}
else if (info.dwType != XML_PI &&
info.dwType != XML_XMLDECL &&
info.dwType != XML_DOCTYPE)
{
hr = XML_E_INVALIDATROOTLEVEL;
break;
}
}
info.fTerminal = FALSE;
if (fIsAttribute)
{
breakhr( pushAttribute(info));
fIsAttribute = false;
}
else
{
breakhr( push(info));
}
break;
// --------- DTD Container Nodes -------------------
case XML_DOCTYPE:
if (_fSeenDocType)
{
hr = (HRESULT)XML_E_DUPLICATEDOCTYPE;
break;
}
_fSeenDocType = true;
if (_cDTD)
{
hr = XML_E_DOCTYPE_IN_DTD;
break;
}
else if (_fFoundRoot)
{
hr = XML_E_DOCTYPE_OUTSIDE_PROLOG;
break;
}
goto dtdcontainers;
case XML_SYSTEM:
case XML_PUBLIC:
case XML_NDATA:
info.dwSubType = info.dwType;
info.dwType = XML_DTDATTRIBUTE;
fIsAttribute = true;
goto dtdcontainers;
// Put all DTD related container nodes here...
case XML_PENTITYDECL:
info.dwSubType = info.dwType; // make this a subtype of
info.dwType = XML_ENTITYDECL; // XML_ENTITYDECL
// fall through
case XML_ENTITYDECL:
case XML_ELEMENTDECL:
case XML_ATTLISTDECL:
case XML_NOTATION:
case XML_GROUP:
case XML_INCLUDESECT:
if (_cDTD == 0)
{
hr = (HRESULT)XML_E_DTDELEMENT_OUTSIDE_DTD;
break;
}
dtdcontainers:
// Cannot buffer attributes for DTD declarations because of PARAMETER
// ENTITIES
if (_fFoundDTDAttribute)
{
breakhr(popDTDAttribute());
}
info.fTerminal = FALSE;
if (fIsAttribute)
{
fIsAttribute = false;
// NOTE - this code is setup in a way to make it possible for the
// node factory to return E_PENDING to force the Run to return
// but then be able to call Run() later on and pick up where it
// left off. This means all the state info needed to re-enter Run
// must be saved away.
hr = _pFactory->CreateNode(this, _pNode, 1, aNodeInfo);
HRESULT hr2 = pushDTDAttribute(info);
if (FAILED(hr2)) hr = hr2; // this is more serious that E_PENDING.
_pNode = info.pNode;
info.pNode = NULL;
}
else
{
hr = _pFactory->CreateNode(this, _pNode, 1, aNodeInfo);
HRESULT hr2 = push(info);
if (FAILED(hr2)) hr = hr2; // this is more serious than E_PENDING.
_pNode = info.pNode;
info.pNode = NULL;
}
break;
// --------- Terminal Nodes -------------------
case XML_AT_CDATA:
case XML_AT_ID:
case XML_AT_IDREF:
case XML_AT_IDREFS:
case XML_AT_ENTITY:
case XML_AT_ENTITIES:
case XML_AT_NMTOKEN:
case XML_AT_NMTOKENS:
case XML_AT_NOTATION:
// Make these subtypes of XML_ATTTYPE.
info.dwSubType = info.dwType;
info.dwType = XML_ATTTYPE;
goto dtdterminals;
case XML_AT_REQUIRED:
case XML_AT_IMPLIED:
case XML_AT_FIXED:
// Make these subtypes of XML_ATTPRESENCE.
info.dwSubType = info.dwType;
info.dwType = XML_ATTPRESENCE;
goto dtdterminals;
case XML_EMPTY:
case XML_ANY:
case XML_MIXED:
case XML_SEQUENCE:
case XML_CHOICE:
case XML_STAR:
case XML_PLUS:
case XML_QUESTIONMARK:
info.dwSubType = info.dwType; // make these subtypes of XML_MODEL
info.dwType = XML_MODEL;
goto dtdterminals;
// Put all DTD terminal nodes here...
case XML_IGNORESECT:
case XML_PEREF:
case XML_ATTDEF:
dtdterminals:
if (_cDTD == 0)
{
hr = (HRESULT)XML_E_DTDELEMENT_OUTSIDE_DTD;
break;
}
// goto terminals;
// fall through
case XML_PCDATA:
case XML_CDATA:
terminals:
// Special rules apply for root level tags.
if (_fRootLevel)
{
hr = XML_E_INVALIDATROOTLEVEL;
break;
}
// fall through
case XML_COMMENT:
case XML_WHITESPACE:
tcreatenode:
info.fTerminal = TRUE;
if (_cAttributes != 0)
{
// We are inside the attribute list, so we need to push this.
hr = pushAttributeValue(info);
break;
}
hr = _pFactory->CreateNode(this, _pNode, 1, aNodeInfo);
info.pNode = NULL;
break;
case XML_NAME:
case XML_NMTOKEN:
case XML_STRING:
case XML_DTDSUBSET:
info.fTerminal = TRUE;
hr = _pFactory->CreateNode(this, _pNode, 1, aNodeInfo);
info.pNode = NULL;
if (info.dwType == XML_DTDSUBSET)
{
_cDTD--;
breakhr(_pFactory->NotifyEvent(this, XMLNF_ENDDTDSUBSET));
}
break;
case XML_ENTITYREF:
if (_fRootLevel)
{
hr = XML_E_INVALIDATROOTLEVEL;
break;
}
// We handle builtin entities and char entities in xmlstream
// so these must be user defined entity, so treat it like a regular terminal node.
goto terminals;
break;
case XMLStream::XML_BUILTINENTITYREF:
case XMLStream::XML_HEXENTITYREF:
case XMLStream::XML_NUMENTITYREF:
// pass real entityref type as subtype so we can publish these
// subtypes eventually.
info.dwSubType = info.dwType; // XML_ENTITYREF;
info.dwType = XML_PCDATA;
if (_cAttributes == 0)
{
goto tcreatenode;
}
// We are inside the attribute list, so we need to push this.
info.fTerminal = TRUE;
hr = pushAttributeValue(info);
if (SUCCEEDED(hr))
{
hr = CopyText(_pCurrent);
}
break;
case XMLStream::XML_TAGEND:
numRecs = 1+_cAttributes;
if (_cAttributes != 0) // this is safe because _rawstack does NOT reclaim
{ // the popped stack entries.
popAttributes();
}
hr = _pFactory->CreateNode(this, _pNode, numRecs, (XML_NODE_INFO **)&_paNodeInfo[_lCurrentElement]);
_pNode = _pCurrent->pNode;
if (FAILED(hr))
{
_fPendingBeginChildren = true;
break;
}
breakhr( _pFactory->BeginChildren(this, (XML_NODE_INFO*)_pCurrent));
break;
// The ENDXMLDECL is like EMPTYENDTAGs since we've been
// buffering up their attributes, and we have still got to call CreateNode.
case XMLStream::XML_ENDXMLDECL:
_fGotVersion = false; // reset back to initial state.
// fall through.
case XMLStream::XML_EMPTYTAGEND:
numRecs = 1+_cAttributes;
if (_cAttributes != 0)
{
popAttributes();
}
hr = _pFactory->CreateNode(this, _pNode, numRecs, (XML_NODE_INFO **)&_paNodeInfo[_lCurrentElement]);
if (FAILED(hr))
{
_fPendingEndChildren = true;
break;
}
breakhr(_pFactory->EndChildren(this, TRUE, (XML_NODE_INFO*)_pCurrent));
breakhr(pop()); // no match needed
break;
case XMLStream::XML_ENDDECL:
if (_fFoundDTDAttribute)
{
breakhr(popDTDAttribute());
}
breakhr(_pFactory->EndChildren(this, TRUE, (XML_NODE_INFO*)_pCurrent));
breakhr(pop()); // no match needed
break;
// ---------------- end of a container -----------------
case XMLStream::XML_ENDPI:
info.dwType = XML_CDATA;
info.dwSubType = XML_PI;
info.fTerminal = TRUE;
breakhr(pushAttribute(info));
hr = _pFactory->CreateNode(this, _pNode, 2, (XML_NODE_INFO **)&_paNodeInfo[_cNodeInfoCurrent-2]);
popAttribute(); // pop the PCDATA node.
if (FAILED(hr))
{
_fPendingEndChildren = true;
break;
}
breakhr(_pFactory->EndChildren(this, FALSE, (XML_NODE_INFO*)_pCurrent));
breakhr(pop()); // pop the XML_PI node.
break;
case XMLStream::XML_CLOSEPAREN:
case XMLStream::XML_ENDCONDSECT:
breakhr(_pFactory->EndChildren(this, FALSE, (XML_NODE_INFO*)_pCurrent));
hr = pop(); // no tagname to match.
break;
case XMLStream::XML_ENDTAG:
if (_pStack.used() == 0)
{
hr = XML_E_UNEXPECTEDENDTAG;
}
else
{
XML_NODE_INFO* pCurrent = (XML_NODE_INFO*)_pCurrent; // save current record
breakhr(pop(info.pwcText, info.ulLen)); // check tag/match
breakhr(_pFactory->EndChildren(this, FALSE, (XML_NODE_INFO*)pCurrent));
}
break;
case XMLStream::XML_STARTDTDSUBSET:
_cDTD++;
if (_fFoundDTDAttribute)
{
popDTDAttribute();
}
breakhr( _pFactory->NotifyEvent(this, XMLNF_STARTDTDSUBSET));
break;
case XMLStream::XML_ENDPROLOG:
// For top level document only, (not for DTD's or
// entities), call EndProlog on the node factory.
if (_fRootLevel &&
! _pdc->_fEntity && ! _pdc->_fDTD)
breakhr( _pFactory->NotifyEvent(this, XMLNF_ENDPROLOG));
break;
default:
hr = E_FAIL;
break;
}
}
_fRunEntryCount--;
stop = false;
if (hr == XML_E_ENDOFINPUT)
{
hr = S_OK;
bool inDTD = _pdc->_fDTD;
bool inEntity = _pdc->_fEntity;
bool inPEReference = _pdc->_fPEReference;
if (inEntity && _pdc->_fDepth != _pStack.used())
{
// Entity itself was unbalanced.
hr = ReportUnclosedTags(_pdc->_fDepth);
}
else if (PopDownload() == S_OK)
{
// then we must have just finished a DTD and we still have more to do
// BUGBUG -- need to check that entity is well formed, i.e. no tags
// left open.
if (!inPEReference)
{
if (inEntity)
{
hr = _pFactory->NotifyEvent(this, XMLNF_ENDENTITY);
}
else if (inDTD)
{
hr = _pFactory->NotifyEvent(this, XMLNF_ENDDTD);
_cDTD--;
}
}
if (FAILED(hr))
{
goto cleanup_stack;
}
// In a synchronous DTD download, there is another parser
// parser Run() call on the stack above us, so let's return
// back to that Run method so we don't complete the parsing
// out from under it.
if (_fRunEntryCount > 0)
return S_OK;
if (_fStopped)
return S_OK;
goto more;
}
else
{
if (_pStack.used() > 0)
{
hr = ReportUnclosedTags(0);
}
else if (! _fFoundRoot)
{
hr = XML_E_MISSINGROOT;
}
stop = true;
}
}
cleanup_stack:
if (hr != S_OK && hr != E_PENDING)
{
stop = true;
_fLastError = hr;
// Pass all the XML_NODE_INFO structs to the Error function so the client
// gets a chance to cleanup the PVOID pNode fields.
HRESULT edr = _pFactory->Error(this, hr,
(USHORT)(_paNodeInfo ? _lCurrentElement+1 : 0), (XML_NODE_INFO**)_paNodeInfo);
if (edr != 0)
_fLastError = hr;
}
if (stop && ! _fStopped)
{
TraceTag((tagParserError, "Parser stopping with hr %x", hr));
_fLastError = hr;
_fStopped = true;
_fStarted = false;
HRESULT edr;
edr = _pFactory->NotifyEvent(this, XMLNF_ENDDOCUMENT);
if (edr != 0)
{
hr = edr; // allow factory to change error code (except to S_OK)
if (S_OK == _fLastError)
{
// Make sure the node factory always finds out about errors.
edr = _pFactory->Error(this, hr, 0, NULL);
if (edr != 0)
hr = edr;
}
_fLastError = hr;
}
}
return hr;
}
HRESULT
XMLParser::popAttributes()
{
// Now I pop all the attributes that were pushed for this tag.
// I know we have at least one attribute.
HRESULT hr;
while (_cAttributes > 0)
{
popAttribute(); // no match needed
}
Assert(_pStack.used() == _lCurrentElement+1);
return S_OK;
}
HRESULT STDMETHODCALLTYPE
XMLParser::GetParserState( void)
{
CRITICALSECTIONLOCK;
if (_fLastError != 0)
return XMLPARSER_ERROR;
if (_fStopped)
return XMLPARSER_STOPPED;
if (_fSuspended)
return XMLPARSER_SUSPENDED;
if (! _fStarted)
return XMLPARSER_IDLE;
if (_fWaiting)
return XMLPARSER_WAITING;
return XMLPARSER_BUSY;
}
HRESULT STDMETHODCALLTYPE
XMLParser::Abort(
/* [in] */ BSTR bstrErrorInfo)
{
#if 0 // FA URL
int i;
STACK_ENTRY_MODEL(_reThreadModel);
// Have to set these before Critical Section to notify Run()
_fStopped = true;
_fSuspended = true; // force Run to terminate...
CRITICALSECTIONLOCK;
TraceTag((tagParserError, "Parser aborted - %ls", bstrErrorInfo));
//BUGBUG: may need to check bstrErrorInfo is NULL or not
// and the returned result so that we can report
// E_OUTOFMEMORY error
if (_bstrError) ::SysFreeString(_bstrError);
_bstrError = ::SysAllocString(bstrErrorInfo);
// abort all downloads
for (i=_pDownloads.used()-1; i>=0; --i)
{
URLStream* stm = _pDownloads[i]->_pURLStream;
if (stm)
stm->Abort();
}
#endif // FA URL
return S_OK;
}
HRESULT STDMETHODCALLTYPE
XMLParser::Suspend( void)
{
_fSuspended = true; // force Run to suspend
return S_OK;
}
HRESULT STDMETHODCALLTYPE
XMLParser::Reset( void)
{
STACK_ENTRY;
CRITICALSECTIONLOCK;
init();
delete _pszCurrentURL;
_pszCurrentURL = NULL;
delete _pszBaseURL;
_pszBaseURL = NULL;
_pRoot = NULL;
_pFactory = NULL;
_pNode = NULL;
#if 0
if (_bstrError != NULL) ::SysFreeString(_bstrError);
_bstrError = NULL;
if (_fAttemptedURL != NULL) ::SysFreeString(_fAttemptedURL);
_fAttemptedURL = NULL;
#endif
return S_OK;
}
ULONG STDMETHODCALLTYPE
XMLParser::GetLineNumber( void)
{
CRITICALSECTIONLOCK;
if (_pTokenizer) return _pTokenizer->GetLine();
else return 0;
}
ULONG STDMETHODCALLTYPE
XMLParser::GetLinePosition( void)
{
CRITICALSECTIONLOCK;
if (_pTokenizer) return _pTokenizer->GetLinePosition();
else return 0;
}
ULONG STDMETHODCALLTYPE
XMLParser::GetAbsolutePosition( void)
{
CRITICALSECTIONLOCK;
if (_pTokenizer) return _pTokenizer->GetInputPosition();
else return 0;
}
HRESULT STDMETHODCALLTYPE
XMLParser::GetLineBuffer(
/* [out] */ const WCHAR __RPC_FAR *__RPC_FAR *ppwcBuf,
/* [out] */ ULONG __RPC_FAR *pulLen,
/* [out] */ ULONG __RPC_FAR *pulStartPos)
{
if (pulLen == NULL || pulStartPos == NULL) return E_INVALIDARG;
STACK_ENTRY;
CRITICALSECTIONLOCK;
if (_pTokenizer)
{
return _pTokenizer->GetLineBuffer(ppwcBuf, pulLen, pulStartPos);
}
*ppwcBuf = NULL;
*pulLen = 0;
return S_OK;
}
HRESULT STDMETHODCALLTYPE
XMLParser::GetLastError( void)
{
return _fLastError;
}
HRESULT STDMETHODCALLTYPE
XMLParser::GetErrorInfo(
/* [out] */ BSTR __RPC_FAR *pbstrErrorInfo)
{
#if 0 // FA error
HRESULT hr = S_OK;
WCHAR* buffer = NULL;
STACK_ENTRY_MODEL(_reThreadModel);
CRITICALSECTIONLOCK;
*pbstrErrorInfo = NULL;
HRESULT errorid = GetLastError();
if (_bstrError)
{
*pbstrErrorInfo = ::SysAllocString(_bstrError);
if(*pbstrErrorInfo == NULL)
{
hr = E_OUTOFMEMORY;
}
goto DONE;
}
else if ((ULONG)errorid <= 0xC00CEFFF && (ULONG)errorid >= 0xC00CE000)
{
// MSXML error msg.
TRY
{
String* s = Resources::FormatMessage(errorid, NULL);
*pbstrErrorInfo = s->getBSTR();
if(*pbstrErrorInfo == NULL)
{
hr = E_OUTOFMEMORY;
}
goto DONE;
// buffer = ::FormatMessageInternal(g_hInstance, errorid, NULL);
}
CATCH
{
hr = ERESULT;
goto DONE;
}
ENDTRY
}
else
{
// MSXML error msg.
// System error
#if 0
/**************
buffer = ::FormatMessageInternal(NULL, errorid, NULL);
if (buffer == NULL && HRESULT_FACILITY(errorid) == FACILITY_INTERNET)
{
// maybe it's URLMON...
HINSTANCE h = ::GetModuleHandleA("URLMON.DLL");
buffer = ::FormatMessageInternal(h, errorid, NULL);
if (_fAttemptedURL)
{
WCHAR* buf2 = ::FormatMessageInternal(g_hInstance, XML_E_RESOURCE,
_fAttemptedURL, NULL);
if (buffer == NULL)
{
buffer = buf2;
}
else
{
WCHAR* buf3 = StringAdd(buffer, buf2);
delete[] buf2;
if (buf3 != NULL)
{
delete [] buffer;
buffer = buf3;
}
}
}
}
**************/
#endif
TRY
{
String* s = Resources::FormatSystemMessage(errorid);
if (_fAttemptedURL)
{
String* rs = Resources::FormatMessage(XML_E_RESOURCE,
String::newString(_fAttemptedURL), NULL);
s = String::add(s,rs,null);
}
*pbstrErrorInfo = s->getBSTR();
if(*pbstrErrorInfo == NULL)
{
hr = E_OUTOFMEMORY;
}
goto DONE;
}
CATCH
{
hr = ERESULT;
goto DONE;
}
ENDTRY
}
if (buffer == NULL)
{
*pbstrErrorInfo = NULL;
hr = S_FALSE;
goto DONE;
}
*pbstrErrorInfo = ::SysAllocString(buffer);
delete[] buffer;
if(*pbstrErrorInfo == NULL)
{
hr = E_OUTOFMEMORY;
}
DONE:
return hr;
#endif // FA error
return S_OK;
}
HRESULT STDMETHODCALLTYPE
XMLParser::SetFlags(
/* [in] */ ULONG lFlags)
{
_usFlags = (unsigned short)lFlags;
_fCaseInsensitive = (lFlags & XMLFLAG_CASEINSENSITIVE) != 0;
_fIE4Mode = (_usFlags & XMLFLAG_IE4QUIRKS) != 0;
if (_pTokenizer != NULL)
_pTokenizer->SetFlags(_usFlags);
return S_OK;
}
ULONG STDMETHODCALLTYPE
XMLParser::GetFlags( )
{
return _usFlags;
}
HRESULT STDMETHODCALLTYPE
XMLParser::GetURL(
/* [out] */ const WCHAR __RPC_FAR *__RPC_FAR *ppwcBuf)
{
#if 0 // FA URL
if (ppwcBuf == NULL)
return E_INVALIDARG;
URL* url;
//BUGBUG: should CoTaskAlloc ??
if (_pszCurrentURL != NULL)
{
*ppwcBuf = _pszCurrentURL;
}
else if (_pdc != NULL && _pdc->_pURLStream && ((url = _pdc->_pURLStream->GetURL()) != NULL))
{
*ppwcBuf = url->getResolved();
}
else
{
*ppwcBuf = NULL;
}
#endif
return S_OK;
}
HRESULT STDMETHODCALLTYPE
XMLParser::SetSecureBaseURL(
/* [in] */ const WCHAR* pszBaseUrl)
{
#if 0
WCHAR* newBaseUrl = NULL;
if (pszBaseUrl != NULL)
{
newBaseUrl = ::StringDup(pszBaseUrl);
if (newBaseUrl == NULL)
return E_OUTOFMEMORY;
}
delete _pszSecureBaseURL;
_pszSecureBaseURL = newBaseUrl;
#endif
return S_OK;
}
HRESULT STDMETHODCALLTYPE
XMLParser::GetSecureBaseURL(
/* [out] */ const WCHAR __RPC_FAR *__RPC_FAR *ppwcBuf)
{
*ppwcBuf = _pszSecureBaseURL;
return S_OK;
}
HRESULT
XMLParser::SetCurrentURL(
/* [in] */ const WCHAR* pszCurrentUrl)
{
#if 0 // FA
WCHAR* newCurrentUrl = NULL;
if (pszCurrentUrl != NULL)
{
newCurrentUrl = ::StringDup(pszCurrentUrl);
if (newCurrentUrl == NULL)
return E_OUTOFMEMORY;
}
delete _pszCurrentURL;
_pszCurrentURL = newCurrentUrl;
#endif
return S_OK;
}
HRESULT
XMLParser::SetBaseURL(
/* [in] */ const WCHAR* pszBaseUrl)
{
#if 0 // FA URL
WCHAR* newBaseUrl = NULL;
if (pszBaseUrl != NULL)
{
newBaseUrl = ::StringDup(pszBaseUrl);
if (newBaseUrl == NULL)
return E_OUTOFMEMORY;
}
delete _pszBaseURL;
_pszBaseURL = newBaseUrl;
#endif
return S_OK;
}
#if 0 // FA URL
HRESULT
XMLParser::HandleData(URLStream* pStm, bool last)
{
HRESULT hr = S_OK;
// According to email with danpoz on 1/19/99 There is a limit of 2 keep-alive
// connections per process and you cannot tell URLMON to NOT use keep-alive.
// You can find the current keep-alive limit using :
// InternetQueryOption(INTERNET_OPTION_MAX_CONNS_PER_SERVER).
// So we have to continue pumping downloads - even if the parser is suspended.
// For example, if we download an XML document that in turn loads a DTD and the
// DTD loads an external entity - WININET will hang waiting for an available
// connection if the main XML document download or DTD download never completes.
// Even worse, is in the synchronous case we have to download ALL the data before
// parsing otherwise we attempt multiple downloads on the same thread which will
// always hang because there's no way to pump the prior downloads - since we're
// doing all this on the one thread.
// Also if this bounces back synchronously then this is a local file !
// in which case we do NOT need to do this expensive buffering.
if (! _fInLoading || 0 != (_usFlags & XMLFLAG_RUNBUFFERONLY))
{
Download* download = FindDownload(pStm);
if (download && download->_pEncodingStream)
{
hr = download->_pEncodingStream->BufferData();
if (FAILED(hr) && E_PENDING != hr)
{
// must tell the encoding stream to pass the error onto the bufferedstream then.
download->_pEncodingStream->setReadStream(true);
}
}
// If this download failed, then we need to call Run() in order to notify
// the Document that it failed.
if ((S_OK != hr || last || _pdc->_fAsync) && // can parse if this is the last buffer or it's async
! _fSuspended && // and not if this parser is actually suspended
download && // and only if the download has officially been Pushed.
_pdc == download) // and only if the "current" download matches the one for this HandleData
{
AddRef(); // stabilize
hr = Run(-1);
TraceTag((tagParserCallback, "HandleData got hr %x from Run", hr));
if (hr != S_OK && hr != E_PENDING && hr != XML_E_STOPPED && hr != XML_E_SUSPENDED)
{
_fLastError = hr;
hr = E_ABORT;
}
Release();
}
}
Cleanup:
return hr;
}
XMLParser::Download*
XMLParser::FindDownload(URLStream* pStream)
{
// Find the EncodingStream that wraps this URLStream and tell it
// to buffer up the data so that we do not BLOCK the sockets. If we
// do not do this then we will eventually hang in WININET while waiting
// for a socket to free up. WININET enforces a limit to the number of
// concurrent downloads allowed to ensure we are a good internet citizen.
for (long i = _pDownloads.used()-1; i >= 0; i--)
{
Download* download = _pDownloads[i];
if (download->_pURLStream == pStream)
{
return download;
}
}
return null;
}
#endif // FA URL
//------------ PRIVATE METHODS --------------------------------------------------
HRESULT
XMLParser::PushTokenizer(
URLStream* stream)
{
_pTokenizer = new_ne XMLStream(this);
if (_pTokenizer == NULL)
return E_OUTOFMEMORY;
_pTokenizer->SetFlags(_usFlags);
// _fTokenizerChanged = true;
HRESULT hr= PushDownload(stream, _pTokenizer);
if (FAILED(hr))
{
delete _pTokenizer;
_pTokenizer = NULL;
return hr;
}
return S_OK;
}
HRESULT
XMLParser::PushDownload(URLStream* stream, XMLStream* tokenizer)
{
// NOTE: tokenizer can be null, in the case of a parameter entity download.
_pdc = _pDownloads.push();
if (_pdc == NULL)
{
return E_OUTOFMEMORY;
}
if (_pDownloads.used() > 1)
_fRootLevel = false;
_pdc->_pTokenizer = tokenizer;
_pdc->_fDTD = false;
_pdc->_fEntity = false;
_pdc->_fAsync = false;
_pdc->_fFoundNonWS = _fFoundNonWS;
_pdc->_fFoundRoot = _fFoundRoot;
_pdc->_fSeenDocType = _fSeenDocType;
_pdc->_fRootLevel = _fRootLevel;
_pdc->_fDepth = _pStack.used();
_fFoundNonWS = false;
_fFoundRoot = false;
_fRootLevel = (_pStack.used() == 0 && _pDownloads.used() == 1);
HRESULT hr = S_OK;
if (stream != NULL)
{
_pdc->_pURLStream = stream;
hr = PushStream(stream,
tokenizer == NULL); // this is a parameter entity stream if "tokenizer" is NULL.
}
return hr;
}
HRESULT
XMLParser::PushStream(IStream* pStm, bool fpe)
{
EncodingStream* stream = (EncodingStream*)EncodingStream::newEncodingStream(pStm); // refcount = 1
if (stream == NULL)
return E_OUTOFMEMORY;
// FA
// if (_usFlags & XMLFLAG_RUNBUFFERONLY)
// stream->setReadStream(false);
_pdc->_pEncodingStream = stream;
stream->Release(); // Smart pointer is holding a ref
HRESULT hr = _pTokenizer->PushStream(stream, fpe);
if (hr == E_PENDING)
{
_fWaiting = true;
}
return hr;
}
HRESULT
XMLParser::PopDownload()
{
// NOTE: tokenizer can be null, in the case of a parameter entity download.
HRESULT hr = S_OK;
if (_pdc != NULL)
{
if (_pdc->_pTokenizer)
{
_pdc->_pTokenizer->Reset();
delete _pdc->_pTokenizer;
_pdc->_pTokenizer = NULL;
}
_pdc->_pEncodingStream = NULL;
#if 0 // FA URL
if (_pdc->_pURLStream)
_pdc->_pURLStream->Reset();
#endif
_pdc->_pURLStream = NULL;
// restore saved value of foundnonws.
_fFoundNonWS = _pdc->_fFoundNonWS;
_pdc = _pDownloads.pop();
}
if (_pdc != NULL)
{
if (_pdc->_pTokenizer != NULL)
{
_pTokenizer = _pdc->_pTokenizer;
}
#if 0 // FA URL
if (_pdc->_pURLStream != NULL)
{
hr = SetCurrentURL(_pdc->_pURLStream->GetURL()->getResolved());
}
#endif
}
else
{
_pTokenizer = NULL;
hr = S_FALSE;
}
if (_pStack.used() == 0 && _pDownloads.used() == 1)
_fRootLevel = true;
return hr;
}
HRESULT
XMLParser::GrowNodeInfo()
{
USHORT newsize = _cNodeInfoAllocated + STACK_INCREMENT;
MY_XML_NODE_INFO** pNewArray = new_ne PMY_XML_NODE_INFO[newsize];
if (pNewArray == NULL)
return E_OUTOFMEMORY;
// Now since STACK_INCREMENT is the same for _pStack then _pStack
// has also re-allocated. Therefore we need to re-initialize all
// the pointers in this array - since they point into the _pStack's memory.
for (int i = _pStack.used() - 1; i >= 0; i--)
{
pNewArray[i] = _pStack[i];
}
delete[] _paNodeInfo;
_paNodeInfo = pNewArray;
_cNodeInfoAllocated = newsize;
return S_OK;
}
HRESULT
XMLParser::GrowBuffer(PMY_XML_NODE_INFO pNodeInfo, long newlen)
{
delete [] pNodeInfo->_pwcTagName;
pNodeInfo->_pwcTagName = NULL;
// add 50 characters to avoid too many reallocations.
pNodeInfo->_pwcTagName = new_ne WCHAR[ newlen ];
if (pNodeInfo->_pwcTagName == NULL)
return E_OUTOFMEMORY;
pNodeInfo->_ulBufLen = newlen;
return S_OK;
}
HRESULT
XMLParser::push(XML_NODE_INFO& info)
{
HRESULT hr;
_lCurrentElement = _pStack.used();
_pCurrent = _pStack.push();
if (_pCurrent == NULL)
return E_OUTOFMEMORY;
*((XML_NODE_INFO*)_pCurrent) = info;
PUSHNODEINFO(_pCurrent);
_fRootLevel = false;
// Save the tag name into the private buffer so it sticks around until the
// close tag </foo> which could be anywhere down the road after the
// BufferedStream been overwritten
// THIS CODE IS OPTIMIZED FOR PERFORMANCE WHICH IS WHY IT IS NOT
// CALLING THE CopyText METHOD.
if (_pCurrent->_ulBufLen < info.ulLen+1)
{
checkhr2(GrowBuffer(_pCurrent, info.ulLen + 50));
}
Assert(info.ulLen >= 0);
::memcpy(_pCurrent->_pwcTagName, info.pwcText, info.ulLen*sizeof(WCHAR));
_pCurrent->_pwcTagName[info.ulLen] = L'\0';
// And make the XML_NODE_INFO point to private buffer.
_pCurrent->pwcText = _pCurrent->_pwcTagName;
return S_OK;
}
HRESULT
XMLParser::pushAttribute(XML_NODE_INFO& info)
{
HRESULT hr;
if (_cAttributes != 0)
{
// Attributes are special in that they are supposed to be unique.
// So here we actually check this.
for (long i = _pStack.used()-1; i > _lCurrentElement; i--)
{
XML_NODE_INFO* ptr = _pStack[i];
if (ptr->dwType != XML_ATTRIBUTE)
continue; // ignore attribute values.
if (ptr->ulLen != info.ulLen)
{
continue; // we're ok with this one
}
// Optimized for the normal case where there is no match
if (::memcmp(ptr->pwcText, info.pwcText, info.ulLen*sizeof(TCHAR)) == 0)
{
if (! _fCaseInsensitive)
{
return XML_E_DUPLICATEATTRIBUTE;
}
else if (StrCmpNI(ptr->pwcText, info.pwcText, info.ulLen) == 0)
{
// Duplicate attributes are allowed in IE4 mode!!
// But only the latest one shows up
// So we have to delete the previous duplication
if (_fIE4Mode)
{
// This is some code, so we comment it out for now
#ifdef NEVER
long j = i + 1;
int k;
// Find the next attribute
while (j < _pStack.used())
{
XML_NODE_INFO * pInfo = _pStack[j];
if (pInfo->dwType == XML_ATTRIBUTE)
break;
else
j++;
}
// move the stack content
for (k = 0; k < _pStack.used() - j; k++)
{
*((XML_NODE_INFO*)_pStack[k + i]) = *((XML_NODE_INFO*)_pStack[k + j]);
}
// pop
for (k = j - i; k > 0; k --)
_pCurrent = _pStack.pop();
_cNodeInfoCurrent -= j - i;
_cAttributes -= j - i;
#endif
break;
}
else
{
return XML_E_DUPLICATEATTRIBUTE;
}
}
}
}
}
_cAttributes++;
_pCurrent = _pStack.push();
if (_pCurrent == NULL)
return E_OUTOFMEMORY;
*((XML_NODE_INFO*)_pCurrent) = info;
PUSHNODEINFO(_pCurrent);
return S_OK;
}
HRESULT
XMLParser::pushAttributeValue(XML_NODE_INFO& info)
{
HRESULT hr;
// Attributes are saved in the BufferedStream so we can point to the
// real text in the buffered stream instead of copying it !!
_pCurrent = _pStack.push();
if (_pCurrent == NULL)
return E_OUTOFMEMORY;
// store attribute value quote character in the pReserved field.
info.pReserved = (PVOID)_pTokenizer->getAttrValueQuoteChar();
*((XML_NODE_INFO*)_pCurrent) = info;
PUSHNODEINFO(_pCurrent);
// this is really the count of nodes on the stack, not just attributes.
_cAttributes++;
return S_OK;
}
HRESULT
XMLParser::pushDTDAttribute(XML_NODE_INFO& info)
{
HRESULT hr;
_pCurrent = _pStack.push();
if (_pCurrent == NULL)
return E_OUTOFMEMORY;
*((XML_NODE_INFO*)_pCurrent) = info;
PUSHNODEINFO(_pCurrent);
_fFoundDTDAttribute = true;
return S_OK;
}
HRESULT
XMLParser::pop(const WCHAR* tag, ULONG len)
{
HRESULT hr = S_OK;
if (_pCurrent == NULL || _pStack.used() == 0)
{
hr = XML_E_UNEXPECTEDENDTAG;
goto Cleanup;
}
if (len != 0)
{
if (_pCurrent->ulLen != len)
{
hr = XML_E_ENDTAGMISMATCH;
}
// Optimized for the normal case where there is no match
else if (::memcmp(_pCurrent->pwcText, tag, len*sizeof(TCHAR)) != 0)
{
if (! _fCaseInsensitive)
{
hr = XML_E_ENDTAGMISMATCH;
}
else if (::StrCmpNI(_pCurrent->pwcText, tag, len) != 0)
{
hr = XML_E_ENDTAGMISMATCH;
}
}
if (hr)
{
#if 0 // FA String
TRY
{
String* s = Resources::FormatMessage(hr, String::newString(_pCurrent->pwcText, 0, _pCurrent->ulLen),
String::newString(tag, 0, len), NULL);
_bstrError = s->getBSTR();
}
CATCH
{
hr = ERESULT;
}
ENDTRY
#endif // FA String
goto Cleanup;
}
}
// We don't delete the fTagName because we're going to reuse this field
// later to avoid lots of memory allocations.
_pCurrent = _pStack.pop();
_cNodeInfoCurrent--;
if (_pCurrent == 0)
{
_pNode = _pRoot;
if (_pDownloads.used() == 1)
_fRootLevel = true;
}
else
{
_pNode = _pCurrent->pNode;
}
Cleanup:
return hr;
}
HRESULT XMLParser::pop()
{
// We don't delete the fTagName because we're going to reuse this field
// later to avoid lots of memory allocations.
_pCurrent = _pStack.pop();
_cNodeInfoCurrent--;
if (_pCurrent == 0)
{
_pNode = _pRoot;
if (_pDownloads.used() == 1)
_fRootLevel = true;
}
else
{
_pNode = _pCurrent->pNode;
}
return S_OK;
}
void XMLParser::popAttribute()
{
Assert(_pStack.used() > 0);
_pCurrent = _pStack.pop();
_cNodeInfoCurrent--;
Assert(_pCurrent != 0);
_cAttributes--;
}
HRESULT
XMLParser::popDTDAttribute()
{
HRESULT hr;
Assert(_pStack.used() > 0);
hr = _pFactory->EndChildren(this, TRUE, (XML_NODE_INFO*)_pCurrent);
_fFoundDTDAttribute = false;
_pCurrent = _pStack.pop();
_cNodeInfoCurrent--;
Assert(_pCurrent != 0);
_pNode = _pCurrent->pNode;
return hr;
}
HRESULT
XMLParser::CopyText(PMY_XML_NODE_INFO pNodeInfo)
{
HRESULT hr = S_OK;
if (pNodeInfo->_pwcTagName != pNodeInfo->pwcText)
{
ULONG len = pNodeInfo->ulLen;
// Copy the current text into the buffer.
if (pNodeInfo->_ulBufLen < len+1)
{
checkhr2(GrowBuffer(pNodeInfo, len + 50));
}
if (len > 0)
{
::memcpy(pNodeInfo->_pwcTagName, pNodeInfo->pwcText, len*sizeof(WCHAR));
}
pNodeInfo->_pwcTagName[len] = L'\0';
// And make the XML_NODE_INFO point to private buffer.
pNodeInfo->pwcText = pNodeInfo->_pwcTagName;
}
return S_OK;
}
HRESULT
XMLParser::CopyContext()
{
// For performance reasons we try not to copy the data for attributes
// and their values when we push them on the stack. We can do this
// because the tokenizer tries to freeze the internal buffers while
// parsing attributes and thereby guarentee that the pointers stay
// good. But occasionally the BufferedStream has to reallocate when
// the attributes are right at the end of the buffer.
long last = _pStack.used();
for (long i = _cAttributes; i > 0 ; i--)
{
long index = last - i;
MY_XML_NODE_INFO* ptr = _pStack[index];
CopyText(ptr);
}
return S_OK;
}
HRESULT XMLParser::ReportUnclosedTags(int start)
{
HRESULT hr = XML_E_UNCLOSEDTAG;
// Build a string containing the list of unclosed tags and format an error
// message containing this text.
int tags = _pStack.used();
WCHAR* buffer = NULL;
WCHAR* msgbuf = NULL;
unsigned long size = 0;
unsigned long used = 0;
for (long i = start; i < tags; i++)
{
XML_NODE_INFO* ptr = _pStack[i];
if (ptr->dwType == XML_ATTRIBUTE)
break;
if (used + ptr->ulLen + 3 > size) // +3 for '<','>' and '\0'
{
long newsize = used + ptr->ulLen + 500;
WCHAR* newbuf = new_ne WCHAR[newsize];
if (newbuf == NULL)
{
goto nomem;
}
if (buffer != NULL)
{
::memcpy(newbuf, buffer, used);
delete[] buffer;
}
size = newsize;
buffer = newbuf;
}
if (i > start)
{
buffer[used++] = ',';
buffer[used++] = ' ';
}
::memcpy(&buffer[used], ptr->pwcText, sizeof(WCHAR) * ptr->ulLen);
used += ptr->ulLen;
buffer[used] = '\0';
}
// msgbuf = ::FormatMessageInternal(g_hInstance, XML_E_UNCLOSEDTAG, buffer, NULL);
#if 0 // FA String
TRY
{
String* s = Resources::FormatMessage(XML_E_UNCLOSEDTAG,
String::newString(buffer), NULL);
_bstrError = s->getBSTR();
goto cleanup;
}
CATCH
{
hr = ERESULT;
goto done;
}
ENDTRY
#endif // FA String
if (msgbuf == NULL)
goto nomem;
#if 0 // FA BSTR sllocs
if (_bstrError) ::SysFreeString(_bstrError);
_bstrError = ::SysAllocString(msgbuf);
if (_bstrError == NULL)
goto nomem;
#endif
goto cleanup;
nomem:
hr = E_OUTOFMEMORY;
cleanup:
delete [] buffer;
delete [] msgbuf;
done:
return hr;
}
HRESULT XMLParser::init()
{
CRITICALSECTIONLOCK;
_fLastError = 0;
_fStopped = false;
_fSuspended = false;
_pNode = _pRoot;
_fStarted = false;
_fStopped = false;
_fWaiting = false;
_fFoundRoot = false;
_fFoundNonWS = false;
_pTokenizer = NULL;
_fGotVersion = false;
_cDTD = 0;
_fSeenDocType = false;
_fRootLevel = true;
_cAttributes = 0;
_fFoundDTDAttribute = false;
_fPendingBeginChildren = false;
_fPendingEndChildren = false;
while (_pCurrent != NULL)
{
_pCurrent = _pStack.pop();
}
_cNodeInfoCurrent = 0;
_lCurrentElement = 0;
// cleanup downloads
while (_pdc != NULL)
{
PopDownload();
}
_pCurrent = NULL;
return S_OK;
}
#if 0 // FA URL
/**
*Gets the URL from the specified IMoniker and binding context
*/
HRESULT XMLParser::ExtractURL(IMoniker* pmk, LPBC pbc, URL* pURL)
{
LPOLESTR pOleStr = NULL;
HRESULT hr = S_OK;
long len = 0;
checkerr(pmk->GetDisplayName(pbc, pmk, &pOleStr));
len = ::StrLen(pOleStr);
// Fix bugs in what GetDisplayName returns...
if (len > 4 && ::StrNCmpI(pOleStr, _T("file"), 4) == 0)
{
TCHAR* buf = new_ne TCHAR[ len + 10 ];
::StrCpy(buf, _T("file:///"));
LPOLESTR ptr = &pOleStr[4];
if (*ptr == L':') ptr++;
while (*ptr != NULL && *ptr == L'/') ptr++;
TCHAR* temp = &buf[7];
while (*ptr != NULL)
{
if (*ptr == L'\\')
*temp = L'/';
else
*temp = *ptr;
ptr++;
temp++;
}
*temp = '\0'; // NULL terminate it !!
hr = pURL->set(buf, NULL);
delete[] buf;
}
else
hr = pURL->set(pOleStr, NULL);
error:
if (pOleStr)
CoTaskMemFree(pOleStr);
return hr;
}
void
XMLParser::SetMimeType(URLStream* pStm, const WCHAR * pwszMimeType, int length)
{
Download* download = FindDownload(pStm);
if (download && download->_pEncodingStream)
{
download->_pEncodingStream->SetMimeType(pwszMimeType, length);
}
}
void
XMLParser::SetCharset(URLStream* pStm, const WCHAR * pwszCharset, int length)
{
Download* download = FindDownload(pStm);
if (download && download->_pEncodingStream)
{
download->_pEncodingStream->SetCharset(pwszCharset, length);
}
}
#endif
HRESULT
XMLParser::ErrorCallback(HRESULT hr)
{
Assert(hr == XMLStream::XML_DATAAVAILABLE ||
hr == XMLStream::XML_DATAREALLOCATE);
if (hr == XMLStream::XML_DATAREALLOCATE)
{
// This is more serious. We have to actually save away the
// context because the buffers are about to be reallocated.
checkhr2(CopyContext());
}
checkhr2(_pFactory->NotifyEvent(this, XMLNF_DATAAVAILABLE));
return hr;
}
| [
"[email protected]"
] | |
cc565a25d5ae55c8348ba5ece6218ac98d44d66e | bd1fea86d862456a2ec9f56d57f8948456d55ee6 | /000/113/753/CWE762_Mismatched_Memory_Management_Routines__delete_array_long_malloc_54a.cpp | 0dc5069ce04ae1267814bfdf16a6cfb0b00628df | [] | no_license | CU-0xff/juliet-cpp | d62b8485104d8a9160f29213368324c946f38274 | d8586a217bc94cbcfeeec5d39b12d02e9c6045a2 | refs/heads/master | 2021-03-07T15:44:19.446957 | 2020-03-10T12:45:40 | 2020-03-10T12:45:40 | 246,275,244 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,670 | cpp | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE762_Mismatched_Memory_Management_Routines__delete_array_long_malloc_54a.cpp
Label Definition File: CWE762_Mismatched_Memory_Management_Routines__delete_array.label.xml
Template File: sources-sinks-54a.tmpl.cpp
*/
/*
* @description
* CWE: 762 Mismatched Memory Management Routines
* BadSource: malloc Allocate data using malloc()
* GoodSource: Allocate data using new []
* Sinks:
* GoodSink: Deallocate data using free()
* BadSink : Deallocate data using delete []
* Flow Variant: 54 Data flow: data passed as an argument from one function through three others to a fifth; all five functions are in different source files
*
* */
#include "std_testcase.h"
namespace CWE762_Mismatched_Memory_Management_Routines__delete_array_long_malloc_54
{
#ifndef OMITBAD
/* bad function declaration */
void badSink_b(long * data);
void bad()
{
long * data;
/* Initialize data*/
data = NULL;
/* POTENTIAL FLAW: Allocate memory with a function that requires free() to free the memory */
data = (long *)malloc(100*sizeof(long));
badSink_b(data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void goodG2BSink_b(long * data);
static void goodG2B()
{
long * data;
/* Initialize data*/
data = NULL;
/* FIX: Allocate memory using new [] */
data = new long[100];
goodG2BSink_b(data);
}
/* goodB2G uses the BadSource with the GoodSink */
void goodB2GSink_b(long * data);
static void goodB2G()
{
long * data;
/* Initialize data*/
data = NULL;
/* POTENTIAL FLAW: Allocate memory with a function that requires free() to free the memory */
data = (long *)malloc(100*sizeof(long));
goodB2GSink_b(data);
}
void good()
{
goodG2B();
goodB2G();
}
#endif /* OMITGOOD */
} /* close namespace */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
using namespace CWE762_Mismatched_Memory_Management_Routines__delete_array_long_malloc_54; /* so that we can use good and bad easily */
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
| [
"[email protected]"
] | |
cc16d0adf2680215089a0b08b232d7f09214f55b | 96f822b56f71f9ee767a3261f28bf48db29a59ed | /Source/Loader.cpp | 982bf1a80ac7a64b4d3e9cd4b2e52178ff0d371e | [
"Apache-2.0"
] | permissive | LarryTheKing/VGS | 31e3ff93f287f22414ddac50a8d73e7f02bb7996 | ddfc9f6bceaac565d95f8887c9c2cf7488be59c3 | refs/heads/master | 2021-01-20T07:00:00.568918 | 2015-11-01T05:33:51 | 2015-11-01T05:33:51 | 27,315,374 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,049 | cpp | #include <fstream>
#include <string>
#include <cstdlib>
#include <iostream>
#include "Loader.h"
#include "Compiler\ELF.h"
namespace VGS
{
using namespace Compiler;
char * VerifyELF(const char * const pFile)
{
std::ifstream fin(pFile, std::ios::in | std::ios::binary | std::ios::ate);
if (!fin.is_open())
{
std::cout << "ERROR : Unable to open file " << pFile << std::endl;
return nullptr;
}
// Verify that this could be an ELF file
size_t fileSize = static_cast<size_t>(fin.tellg());
if (fileSize < sizeof(Elf32_Ehdr))
{
std::cout << "ERROR : Not an ELF object" << std::endl;
return nullptr;
}
// Load and check header
Elf32_Ehdr e_hdr;
fin.seekg(0, std::ios_base::beg);
fin.read(reinterpret_cast<char*>(&e_hdr), sizeof(Elf32_Ehdr));
// Check magic number
if (e_hdr.e_ident[EI_MAG0] != ELFMAG0 ||
e_hdr.e_ident[EI_MAG1] != ELFMAG1 ||
e_hdr.e_ident[EI_MAG2] != ELFMAG2 ||
e_hdr.e_ident[EI_MAG3] != ELFMAG3)
{
std::cout << "ERROR : Not an ELF object" << std::endl;
return nullptr;
}
// Check encoding
if (e_hdr.e_ident[EI_CLASS] != 1 ||
e_hdr.e_ident[EI_DATA] != 1 ||
e_hdr.e_ident[EI_VERSION] != 1)
{
std::cout << "ERROR : Unrecognized encoding" << std::endl;
return nullptr;
}
// Check type
if (e_hdr.e_type != ET_EXEC ||
e_hdr.e_machine != EM_MIPS ||
e_hdr.e_flags != EF_MIPS_NOREORDER)
{
std::cout << "ERROR : Incompatible type" << std::endl;
return nullptr;
}
// Okay, this file checks out. Load it!
char * pData = reinterpret_cast<char*>(malloc(fileSize));
fin.seekg(0, std::ios_base::beg);
fin.read(pData, fileSize);
fin.close();
std::cout << ">> Is compatible ELF file" << std::endl;
// Return pointer to loaded content
return pData;
}
Elf32_Shdr * GetShdrByIndex(char * const pData, unsigned __int32 const index)
{
// Finds where the section headers are stored, returns the index'th one
return reinterpret_cast<Elf32_Shdr * const>(reinterpret_cast<Elf32_Ehdr * const>(pData)->e_shoff + pData) + index;
}
Elf32_Shdr * GetShdrByName(char * const pData, char const * const pName)
{
// Find the section header that describes where section names are stored
Elf32_Shdr * pShdr = GetShdrByIndex(pData, reinterpret_cast<const Elf32_Ehdr*>(pData)->e_shstrndx);
// Find these section names
const char * const pStr = pData + pShdr->sh_offset;
// Check for a matching section name
const unsigned __int32 Shnum = reinterpret_cast<Elf32_Ehdr*>(pData)->e_shnum;
for (unsigned __int32 i = 0; i < Shnum; i++)
{
// Get the section at index i
pShdr = GetShdrByIndex(pData, i);
// Compare section name and pName
if (strcmp(pStr + pShdr->sh_name, pName) == 0)
return pShdr; // We found a match, return the section
}
return nullptr;
}
bool Loader::LoadELF(System * const pSys, char const * const pFile)
{
std::cout << std::endl << "Loading ELF file \"" << pFile << "\"" << std::endl;
char * const pData = VerifyELF(pFile);
if (!pData)
{
std::cout << "ERROR : Unable to verify " << pFile << std::endl;
return false;
}
Elf32_Shdr * pShdrText = GetShdrByName(pData, ".text");
Elf32_Shdr * pShdrData = GetShdrByName(pData, ".data");
if (!pShdrText || !pShdrText->sh_size){
std::cout << "ERROR : No ROM found " << std::endl;
}
else {
// Clear old ROM and copy in new ROM
pSys->vROM.~MEM();
new (&pSys->vROM)MEM(pShdrText->sh_size);
memcpy(pSys->vROM.pData, pData + pShdrText->sh_offset, pShdrText->sh_size);
std::cout << ">> Found " << pShdrText->sh_size << " bytes of ROM" << std::endl;
}
if (pShdrData)
{
if (pShdrData->sh_size > pSys->vRAM.size)
{
std::cout << "ERROR : Not enough RAM, requires " << pShdrData->sh_size << "bytes" << std::endl;
return false;
}
memcpy(pSys->vRAM.pData, pData + pShdrData->sh_offset, pShdrData->sh_size);
std::cout << ">> Found " << pShdrData->sh_size << " bytes of RAM" << std::endl;
}
std::cout << std::endl << "Load successful!" << std::endl;
return true;
}
} | [
"[email protected]"
] | |
a2acc51a7bb431b9fcc1bea0efadc29de6151994 | d19463e41a8003c097db8ba3f3924a81aade044e | /GIRLSNBS.cpp | 5bddf37bded15a7a3dc65d7c57c90bccb4defc6f | [] | no_license | Justme21/Spoj_Programs | 4d6cbc6afe7c3222476d85c58d60689e5ec7697d | 69b59c2b8412c5dad00a77818bdfc2b883145fcd | refs/heads/master | 2020-12-02T06:16:55.660703 | 2017-07-10T18:48:30 | 2017-07-10T18:48:30 | 96,810,426 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 298 | cpp | #include <iostream>
using namespace std;
int main(){
int max,min,temp;
while(cin>>max>>min){
if(max==-1||min==-1){break;}
if(min>max){
temp=max;
max=min;
min=temp;
}
cout<<(max/(min+1))+int(max%(min+1)!=0)<<endl;
}
}
| [
"[email protected]"
] | |
1dbe35f11448b31b2cc2a7649bcd42746a797e90 | 150b768328db3ad1f785f5d6b0d70e4c20a588d4 | /AtomGraphics/thread/AtomicTimer.h | d8425d99fb4da1a97ee5071f3ccaae553745fa57 | [] | no_license | Polepoint/AtomGraphics | 2fda9e8e32a56954efbc6656ad5bc867b3f58dcc | 6e0e73119afa4c27ccd65d3d14de682f852ac3dc | refs/heads/master | 2022-08-14T13:31:07.012604 | 2022-07-08T01:13:47 | 2022-07-08T01:13:47 | 127,279,667 | 7 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 689 | h | //
// Created by Amazing on 2018-12-21.
//
#ifndef PODS_ATOMICTIMER_H
#define PODS_ATOMICTIMER_H
#include <mutex>
#include "Timer.h"
namespace AtomGraphics {
class AtomicTimer final : public Timer {
public:
template<typename TimerFiredClass, typename TimerFiredBaseClass>
AtomicTimer(TaskRunner *taskRunner, TimerFiredClass &object, void (TimerFiredBaseClass::*function)())
: Timer(taskRunner, object, function) {}
AtomicTimer(TaskRunner *taskRunner, std::function<void()> function)
: Timer(taskRunner, function) {}
bool isActive() override;
void fired() override;
private:
std::mutex m_lock;
};
}
#endif //PODS_ATOMICTIMER_H
| [
"[email protected]"
] | |
1edaedcace0805d8cd2493afe9f16af308626215 | ae33af0fbde5e84ea65562de5828f5cab9e6dbc1 | /GeneratedFiles/Debug/moc_AppQt.cpp | 762b8d1c18ef7e1783aca8049382ba0a94f778a5 | [] | no_license | Conan1991/Test_unigine | 5e57405429f38f939472e7133de15c5392d15e85 | 022ce550bc4bbb5d40b695f72650e5319c17841a | refs/heads/master | 2020-03-11T15:45:47.216743 | 2018-05-04T14:26:37 | 2018-05-04T14:26:37 | 130,095,214 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,865 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'AppQt.h'
**
** Created by: The Qt Meta Object Compiler version 63 (Qt 4.8.6)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../../AppQt.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'AppQt.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 63
#error "This file was generated using the moc from 4.8.6. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_AppQt[] = {
// content:
6, // revision
0, // classname
0, 0, // classinfo
1, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
1, // signalCount
// signals: signature, parameters, type, tag, flags
7, 6, 6, 6, 0x05,
0 // eod
};
static const char qt_meta_stringdata_AppQt[] = {
"AppQt\0\0closed()\0"
};
void AppQt::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
Q_ASSERT(staticMetaObject.cast(_o));
AppQt *_t = static_cast<AppQt *>(_o);
switch (_id) {
case 0: _t->closed(); break;
default: ;
}
}
Q_UNUSED(_a);
}
const QMetaObjectExtraData AppQt::staticMetaObjectExtraData = {
0, qt_static_metacall
};
const QMetaObject AppQt::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_AppQt,
qt_meta_data_AppQt, &staticMetaObjectExtraData }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &AppQt::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *AppQt::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *AppQt::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_AppQt))
return static_cast<void*>(const_cast< AppQt*>(this));
if (!strcmp(_clname, "Unigine::App"))
return static_cast< Unigine::App*>(const_cast< AppQt*>(this));
return QWidget::qt_metacast(_clname);
}
int AppQt::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 1)
qt_static_metacall(this, _c, _id, _a);
_id -= 1;
}
return _id;
}
// SIGNAL 0
void AppQt::closed()
{
QMetaObject::activate(this, &staticMetaObject, 0, 0);
}
QT_END_MOC_NAMESPACE
| [
"[email protected]"
] | |
6d3317ca85ffcea6749f2b71279e121cdb243a71 | 58f46a28fc1b58f9cd4904c591b415c29ab2842f | /chromium-32.0.1700.107/chrome/browser/ui/views/color_chooser_aura.cc | a92acc1603b40f335bc201c6380c060c2ba9830f | [
"BSD-3-Clause"
] | permissive | bbmjja8123/chromium-1 | e739ef69d176c636d461e44d54ec66d11ed48f96 | 2a46d8855c48acd51dafc475be7a56420a716477 | refs/heads/master | 2021-01-16T17:50:45.184775 | 2015-03-20T18:38:11 | 2015-03-20T18:42:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,530 | cc | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/color_chooser_aura.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "ui/views/color_chooser/color_chooser_view.h"
#include "ui/views/widget/widget.h"
ColorChooserAura* ColorChooserAura::current_color_chooser_ = NULL;
ColorChooserAura::ColorChooserAura(content::WebContents* web_contents,
SkColor initial_color)
: web_contents_(web_contents) {
view_ = new views::ColorChooserView(this, initial_color);
Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
widget_ = views::Widget::CreateWindowWithParent(
view_, browser->window()->GetNativeWindow());
widget_->Show();
}
void ColorChooserAura::OnColorChosen(SkColor color) {
if (web_contents_)
web_contents_->DidChooseColorInColorChooser(color);
}
void ColorChooserAura::OnColorChooserDialogClosed() {
view_ = NULL;
widget_ = NULL;
DidEndColorChooser();
}
void ColorChooserAura::End() {
if (widget_ && widget_->IsVisible()) {
view_->set_listener(NULL);
widget_->Close();
view_ = NULL;
widget_ = NULL;
// DidEndColorChooser will invoke Browser::DidEndColorChooser, which deletes
// this. Take care of the call order.
DidEndColorChooser();
}
}
void ColorChooserAura::DidEndColorChooser() {
DCHECK(current_color_chooser_ == this);
current_color_chooser_ = NULL;
if (web_contents_)
web_contents_->DidEndColorChooser();
}
void ColorChooserAura::SetSelectedColor(SkColor color) {
if (view_)
view_->OnColorChanged(color);
}
// static
ColorChooserAura* ColorChooserAura::Open(
content::WebContents* web_contents, SkColor initial_color) {
if (current_color_chooser_)
current_color_chooser_->End();
DCHECK(!current_color_chooser_);
current_color_chooser_ = new ColorChooserAura(web_contents, initial_color);
return current_color_chooser_;
}
#if !defined(OS_WIN)
namespace chrome {
content::ColorChooser* ShowColorChooser(content::WebContents* web_contents,
SkColor initial_color) {
return ColorChooserAura::Open(web_contents, initial_color);
}
} // namespace chrome
#endif // OS_WIN
| [
"[email protected]"
] | |
c9d5b74054afce836f859eeb1815099f6fc35d29 | e92edf2c40b256e2e7fd29908264a19e65f80289 | /tests/Qt_dispatch_mainqueue_lambda.cpp | a1c9e9de307434f4a7a8a1034e293dc630070709 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"LicenseRef-scancode-bsd-unmodified",
"ISC",
"BSD-2-Clause"
] | permissive | bmanGH/xdispatch | 7c84336722616813a0a81c5100765ed39615e1b8 | 06d31d4bd299952078f0bc067e207b1b8af411b3 | refs/heads/master | 2021-01-22T07:27:46.998071 | 2013-11-21T15:33:54 | 2013-11-21T15:33:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,081 | cpp | /*
* Qt_dispatch_mainqueue_lambda.cpp
*
* Copyright (c) 2008-2009 Apple Inc.
* Copyright (c) 2011-2013 MLBA-Team.
* All rights reserved.
*
* @LICENSE_HEADER_START@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* @LICENSE_HEADER_END@
*/
#include <QtCore/QTime>
#include <QtDispatch/QtDispatch>
#include "Qt_tests.h"
#define RUN_TIMES 2000
class MainWorker : public QRunnable {
public:
MainWorker(unsigned int* work) : worker(work) {}
void run(){
if(*worker < RUN_TIMES) {
(*worker)++;
//MU_MESSAGE("Running worker %u", *worker);
QDispatch::mainQueue().async(new MainWorker(worker));
} else {
MU_ASSERT_EQUAL(RUN_TIMES, *worker);
delete worker;
//MU_MESSAGE("Deleted worker");
MU_MESSAGE("System usage should be zero");
QDispatch::mainQueue().after(
QTime::currentTime().addSecs(5),
[=]{
MU_PASS("");
}
);
}
}
private:
unsigned int* worker;
};
/*
Little tests mainly checking the correct mapping of the Qt api
to the underlying C Api
*/
extern "C" void Qt_dispatch_mainqueue_lambda(){
char* argv = QString("test").toAscii().data();
int argc = 1;
QDispatchApplication app(argc,&argv);
MU_BEGIN_TEST(Qt_dispatch_mainqueue_lambda);
unsigned int* worker = new unsigned int;
*worker = 0;
QDispatchQueue q = QDispatch::mainQueue();
MU_ASSERT_NOT_NULL(q.native());
q.async(new MainWorker(worker));
app.exec();
MU_END_TEST;
}
| [
"marius@9e4c620c-c391-4b63-a7fb-4924991ea895"
] | marius@9e4c620c-c391-4b63-a7fb-4924991ea895 |
e6badd549ba4b6ce83b51ab38a00fd948ca7da21 | 014676b729173af18b82765acec3e15751a9ce69 | /link/librtp/iceplayer/input/logger.h | c9c4c919aa40bf486e4e57cdbdcca2e432ebc460 | [] | no_license | chenhy2018/dev-guchengpeng | cdca5b2d1bd763b6c87bcb138e722c3ceb5883d4 | e8e51da96e1cba8573be15baa7f2985fd1512f05 | refs/heads/master | 2020-04-11T01:48:00.662378 | 2018-12-12T08:33:05 | 2018-12-12T08:33:05 | 161,290,193 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,878 | h | #include "spdlog/spdlog.h"
#include <stdarg.h>
extern std::shared_ptr<spdlog::logger> spdlogger;
#define _s_l_(x) #x
#define _str_line_(x) _s_l_(x)
#define __STR_LINE__ _str_line_(__LINE__)
#ifdef WIN32
#define logtrace(fmt,...) \
if(spdlogger.get() != nullptr) spdlogger->trace(THIS_FILE ":" __STR_LINE__ ": " fmt, __VA_ARGS__)
#define logdebug(fmt,...) \
if(spdlogger.get() != nullptr) spdlogger->debug(THIS_FILE ":" __STR_LINE__ ": " fmt, __VA_ARGS__)
#define loginfo(fmt,...) \
if(spdlogger.get() != nullptr) spdlogger->info(THIS_FILE ":" __STR_LINE__ ": " fmt, __VA_ARGS__)
#define logwarn(fmt,...) \
if(spdlogger.get() != nullptr) spdlogger->warn(THIS_FILE ":" __STR_LINE__ ": " fmt, __VA_ARGS__)
#define logerror(fmt,...) \
if(spdlogger.get() != nullptr) spdlogger->error(THIS_FILE ":" __STR_LINE__ ": " fmt, __VA_ARGS__)
#else
#define logtrace(fmt,...) \
if(spdlogger.get() != nullptr) spdlogger->trace(THIS_FILE ":" __STR_LINE__ ": " fmt, ##__VA_ARGS__)
#define logdebug(fmt,...) \
if(spdlogger.get() != nullptr) spdlogger->debug(THIS_FILE ":" __STR_LINE__ ": " fmt, ##__VA_ARGS__)
#define loginfo(fmt,...) \
if(spdlogger.get() != nullptr) spdlogger->info(THIS_FILE ":" __STR_LINE__ ": " fmt, ##__VA_ARGS__)
#define logwarn(fmt,...) \
if(spdlogger.get() != nullptr) spdlogger->warn(THIS_FILE ":" __STR_LINE__ ": " fmt, ##__VA_ARGS__)
#define logerror(fmt,...) \
if(spdlogger.get() != nullptr) spdlogger->error(THIS_FILE ":" __STR_LINE__ ": " fmt, ##__VA_ARGS__)
#endif
#define BOALOG_LEN 5
static inline int loghex(char * buffer, char * data, int data_len)
{
int i, j = 0, buf_len, logline_len = 69 + 2 * BOALOG_LEN;
char s[100], temp[BOALOG_LEN + 1], format_l[10] = { 0 }, format_r[10] = {
0};
char *buf_tmp;
buf_tmp = buffer ;
sprintf(format_l, "%%0%dd:", BOALOG_LEN);
sprintf(format_r, ":%%0%dd", BOALOG_LEN);
memset(s, 0, sizeof(s));
memset(s, '-', logline_len);
sprintf(buf_tmp, "%s\n", s);
buf_len = logline_len + 1;
for (i = 0; i < data_len; i++) {
if (j == 0) {
memset(s, ' ', logline_len);
sprintf(s, format_l, i);
sprintf(&s[69 + BOALOG_LEN - 1], format_r, i + 16);
}
sprintf(temp, "%02X ", (unsigned char) data[i]);
memcpy(&s[j * 3 + BOALOG_LEN + 1 + (j > 7)], temp, 3);
if (isprint((unsigned char) data[i])) {
s[j + 51 + BOALOG_LEN + (j > 7)] = data[i];
} else {
if (data[i] != 0)
s[j + 51 + BOALOG_LEN + (j > 7)] = '.';
}
j++;
if (j == 16) {
s[logline_len] = 0;
sprintf(buf_tmp + buf_len, "%s\n", s);
buf_len += logline_len + 1;
j = 0;
}
}
if (j) {
s[logline_len] = 0;
sprintf(buf_tmp + buf_len, "%s\n", s);
buf_len += logline_len + 1;
}
memset(s, 0, sizeof(s));
/*memset(s, '-', logline_len); */
memset(s, '=', logline_len); /*为了perl好分析,改为=== */
sprintf(buf_tmp + buf_len, "%s\n", s);
buf_len += logline_len + 1;
//printf("return len:%d\n", buf_len);
return buf_len;
}
extern "C" void logger_init_file_output(const char * path);
extern "C" void logger_set_level_trace();
extern "C" void logger_set_level_debug();
extern "C" void logger_set_level_info();
extern "C" void logger_set_level_warn();
extern "C" void logger_set_level_error();
extern "C" void logger_flush();
extern "C" spdlog::level::level_enum logger_get_level();
| [
"[email protected]"
] | |
7a6bca2935618815383b288ab9babf8e84096e52 | d0fb46aecc3b69983e7f6244331a81dff42d9595 | /resourcemanager/src/model/DeregisterDelegatedAdministratorResult.cc | b6888e5e1096122f8645186d8c5675882922c26b | [
"Apache-2.0"
] | permissive | aliyun/aliyun-openapi-cpp-sdk | 3d8d051d44ad00753a429817dd03957614c0c66a | e862bd03c844bcb7ccaa90571bceaa2802c7f135 | refs/heads/master | 2023-08-29T11:54:00.525102 | 2023-08-29T03:32:48 | 2023-08-29T03:32:48 | 115,379,460 | 104 | 82 | NOASSERTION | 2023-09-14T06:13:33 | 2017-12-26T02:53:27 | C++ | UTF-8 | C++ | false | false | 1,383 | cc | /*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/resourcemanager/model/DeregisterDelegatedAdministratorResult.h>
#include <json/json.h>
using namespace AlibabaCloud::ResourceManager;
using namespace AlibabaCloud::ResourceManager::Model;
DeregisterDelegatedAdministratorResult::DeregisterDelegatedAdministratorResult() :
ServiceResult()
{}
DeregisterDelegatedAdministratorResult::DeregisterDelegatedAdministratorResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
DeregisterDelegatedAdministratorResult::~DeregisterDelegatedAdministratorResult()
{}
void DeregisterDelegatedAdministratorResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
}
| [
"[email protected]"
] | |
a7130479357a5f2ec2ccfd4549d0ce8004d1b05b | 02fec111191ecede92d844422125ac8482171bde | /Contests/565div3/c.cpp | 05a4b1cf899220c5c462b261368b532462c9d125 | [] | no_license | Lucas3H/Maratona | 475825b249659e376a1f63a6b3b6a1e15c0d4287 | 97a2e2a91fb60243124fc2ffb4193e1b72924c3c | refs/heads/master | 2020-11-24T18:35:24.456960 | 2020-11-06T14:00:56 | 2020-11-06T14:00:56 | 228,292,025 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,119 | cpp | #include<bits/stdc++.h>
using namespace std;
#define fr(i, n) for(int i = 0; i < n; i++)
#define frr(i, n) for(int i = 1; i <= n; i++)
#define frm(i, n) for(int i = n-1; i >= 0; i--)
#define pb push_back
typedef pair<int,int> pii;
typedef pair<int, int> ponto;
#define mem(v, k) memset(v, k, sizeof(v));
#define mp make_pair
#define pq priority_queue
#define mx(a, b) a = max(a, b);
#define ll long long
#define MAXN 500010
int main(){
ios::sync_with_stdio(false);
int n;
cin >> n;
int a[MAXN];
fr(i, n) cin >> a[i];
vector<int> v[6];
int rem = 0;
fr(i, n){
if(a[i] == 4) v[0].pb(i);
else if(a[i] == 8) v[1].pb(i);
else if(a[i] == 15) v[2].pb(i);
else if(a[i] == 16) v[3].pb(i);
else if(a[i] == 23) v[4].pb(i);
else if(a[i] == 42) v[5].pb(i);
}
frr(k, 5){
int j = 0, i = 0;
for(i = 0; i<v[k].size() && j < v[k-1].size(); i++){
if(v[k][i] < v[k-1][j]){
rem++;
v[k].erase(v[k].begin() + i, v[k].begin()+i+1);
}
else j++;
}
rem += v[k].size() - i;
}
cout << rem << endl;
}
| [
"[email protected]"
] | |
7d1bc6f93d7bbfaa45eb23bfb5247fffdb06ae87 | 95acba541ae3b60ebe5ab209fcaecff6936d5f79 | /UIObject.h | 58ae1cdd1b6396f7c2b1a92b1563a8111e2c6dc5 | [] | no_license | AlanWills/SpinOut_Source | 3397e3a5e4b418493e4606c02b8c2a0b6fc9b87b | d264046c1b37f8201942c2eaa0ee7d092301431c | refs/heads/master | 2021-01-13T00:46:26.713831 | 2016-01-25T20:30:14 | 2016-01-25T20:30:14 | 49,532,214 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,122 | h | #pragma once
#include "BaseObject.h"
class UIObject : public BaseObject
{
public:
enum UIType
{
kScreen,
kInGame,
kUnSet
};
UIObject(const std::string& dataAsset, LoadType loadType = LoadType::kTexture, BaseObject* parent = nullptr, float lifeTime = FLT_MAX);
UIObject(const Vector2& localPosition, const std::string& dataAsset, LoadType loadType = LoadType::kTexture, BaseObject* parent = nullptr, float lifeTime = FLT_MAX);
UIObject(const Vector2& size, const Vector2& localPosition, const std::string& dataAsset, LoadType loadType = LoadType::kTexture, BaseObject* parent = nullptr, float lifeTime = FLT_MAX);
virtual ~UIObject();
void Update(float elapsedSeconds) override;
void SetStoredObject(void* storedObject) { m_storedObject = storedObject; }
template <typename T>
T GetStoredObjectAs() const { return static_cast<T>(m_storedObject); }
void SetType(UIType type) { m_type = type; }
UIType GetType() const { return m_type; }
protected:
void CheckVisible() override;
private:
float m_lifeTime;
float m_currentLifeTime;
void* m_storedObject;
UIType m_type;
};
| [
"[email protected]"
] | |
8c78a182a078955c641f5b16866dba045a353173 | 2c8595b6cbf30615d8a6638787ddc25816c05ea3 | /src/core/SquareWaveChannel.cpp | d4a3e4aa3ed0b02d76a443cbada086fee0ca6406 | [] | no_license | zlisinski/zlgb | 2452377886af528148e1d0d461b5496cece3ae8b | 7ca423b3b84ee75c90a6bbd5e70fb444c566e4b8 | refs/heads/master | 2020-04-09T01:39:21.567860 | 2020-02-14T00:02:52 | 2020-02-14T00:02:52 | 159,912,382 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,740 | cpp | #include "gbemu.h"
#include "Logger.h"
#include "SquareWaveChannel.h"
const int8_t WAVEFORM[4][8] = {
{-1, -1, -1, -1, -1, -1, -1, 1},
{ 1, -1, -1, -1, -1, -1, -1, 1},
{ 1, -1, -1, -1, -1, 1, 1, 1},
{-1, 1, 1, 1, 1, 1, 1, -1}
};
SquareWaveChannel::SquareWaveChannel(const char *name) :
name(name),
active(false),
counter(0),
frequency(0),
frequencyCounter(0),
continuous(false),
lengthCounter(0),
dutyCycle(eDutyCycle50),
dutySequence(0),
masterVolume(0),
volume(0),
envelopeUp(false),
envelopeLength(0),
envelopeCounter(0),
sweepTime(0),
sweepUp(false),
sweepShift(0),
sweepCounter(0)
{
}
SquareWaveChannel::~SquareWaveChannel()
{
}
void SquareWaveChannel::Tick(uint value)
{
if (active == false)
return;
for (uint i = 0; i < value; i += CLOCKS_PER_CYCLE)
{
counter += CLOCKS_PER_CYCLE;
// Every 256Hz check the length counter and deactivate channel if it reaches zero.
if ((counter & 0x3FFF) == 0 && continuous == false && lengthCounter != 0)
{
lengthCounter--;
if (lengthCounter == 0)
{
// This is supposed to also clear NR52 Channel X On bit.
LogAudio("Channel %s disabled", name);
active = false;
}
}
// Every 64Hz perform envelope amplification/attenuation.
if ((counter & 0xFFFF) == 0 && envelopeLength != 0)
{
envelopeCounter--;
if (envelopeCounter == 0)
{
if (envelopeUp && volume < 15)
{
volume++;
if (volume >= 15)
envelopeLength = 0;
}
else if (!envelopeUp && volume > 0)
{
volume--;
if (volume == 0)
envelopeLength = 0;
}
ReloadEnvelopeCounter();
}
}
// Every 128Hz shift the frequency if sweep is enabled.
if ((counter & 0x7FFF) == 0 && sweepTime != 0 && sweepShift != 0)
{
sweepCounter--;
if (sweepCounter == 0)
{
if (sweepUp)
{
uint newFreq = frequency + (frequency >> sweepShift);
if (newFreq > 0x7FF)
{
// This is supposed to also clear NR52 Channel 1 On bit.
active = false;
frequency = 0x7FF;
}
else
frequency = newFreq;
}
else
{
int newFreq = frequency - (frequency >> sweepShift);
if (newFreq >= 0)
frequency = newFreq;
}
ReloadSweepCounter();
}
}
// Every frequency period, advance the duty sequence.
frequencyCounter--;
if (frequencyCounter == 0)
{
dutySequence = (dutySequence + 1) & 0x07;
ReloadFrequencyCounter();
}
}
}
int8_t SquareWaveChannel::GetSample()
{
if (!active)
return 0;
return WAVEFORM[dutyCycle][dutySequence] * volume;
}
void SquareWaveChannel::SetInitialize(bool init)
{
if (init)
{
dutySequence = 0;
ReloadFrequencyCounter();
ReloadLengthCounter();
ReloadEnvelopeCounter();
ReloadSweepCounter();
volume = masterVolume;
// Channel is disabled if the volume is 0, and the envelope is not set to amplify.
if (volume == 0 && envelopeUp == false)
{
LogAudio("Init of channel %s, but volume is 0", name);
return;
}
if (active == true)
LogAudio("Channel %s enabled while already enabled %uHz counter=%u", name, GetFrequency(), lengthCounter);
else
LogAudio("Channel %s enabled %uHz", name, GetFrequency());
active = true;
}
else
{
active = false;
}
}
void SquareWaveChannel::SetContinuous(bool cont)
{
continuous = cont;
//LogAudio("Channel %s continuous=%d", name, cont);
}
void SquareWaveChannel::SetFrequency(uint16_t freq)
{
frequency = freq;
ReloadFrequencyCounter();
}
void SquareWaveChannel::SetDutyCycle(DutyCycle duty)
{
dutyCycle = duty;
}
void SquareWaveChannel::SetSoundLength(uint8_t length)
{
soundLength = 64 - length;
lengthCounter = soundLength;
//LogAudio("Channel %s length=%u", name, lengthCounter);
}
void SquareWaveChannel::SetVolume(uint8_t vol)
{
masterVolume = vol;
volume = vol;
}
void SquareWaveChannel::SetEnvelopeUp(bool up)
{
envelopeUp = up;
}
void SquareWaveChannel::SetEnvelopeLength(uint8_t length)
{
envelopeLength = length;
ReloadEnvelopeCounter();
}
void SquareWaveChannel::SetSweepTime(uint8_t time)
{
sweepTime = time;
ReloadSweepCounter();
}
void SquareWaveChannel::SetSweepUp(bool up)
{
sweepUp = up;
}
void SquareWaveChannel::SetSweepShift(uint8_t shift)
{
sweepShift = shift;
}
void SquareWaveChannel::ReloadFrequencyCounter()
{
frequencyCounter = 2048 - frequency;
}
void SquareWaveChannel::ReloadLengthCounter()
{
lengthCounter = soundLength;
}
void SquareWaveChannel::ReloadEnvelopeCounter()
{
envelopeCounter = envelopeLength;
}
void SquareWaveChannel::ReloadSweepCounter()
{
sweepCounter = sweepTime;
}
uint32_t SquareWaveChannel::GetFrequency() const
{
return CLOCKS_PER_SECOND / (8 * (2048 - frequency));
} | [
"[email protected]"
] | |
8ae3e7a8375740d136e7d4207c65df768326c43c | 88ae8695987ada722184307301e221e1ba3cc2fa | /chrome/browser/profiles/profile_avatar_downloader.cc | 7043e2f5266704e0e12e270402cfe0a1d7ac07bb | [
"BSD-3-Clause"
] | permissive | iridium-browser/iridium-browser | 71d9c5ff76e014e6900b825f67389ab0ccd01329 | 5ee297f53dc7f8e70183031cff62f37b0f19d25f | refs/heads/master | 2023-08-03T16:44:16.844552 | 2023-07-20T15:17:00 | 2023-07-23T16:09:30 | 220,016,632 | 341 | 40 | BSD-3-Clause | 2021-08-13T13:54:45 | 2019-11-06T14:32:31 | null | UTF-8 | C++ | false | false | 3,504 | cc | // Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/profiles/profile_avatar_downloader.h"
#include <memory>
#include <string>
#include "base/files/file_path.h"
#include "base/functional/callback.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "net/base/load_flags.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/url_request/referrer_policy.h"
#include "ui/gfx/image/image.h"
namespace {
const char kHighResAvatarDownloadUrlPrefix[] =
"trk:271:https://www.gstatic.com/chrome/profile_avatars/";
}
ProfileAvatarDownloader::ProfileAvatarDownloader(size_t icon_index,
FetchCompleteCallback callback)
: icon_index_(icon_index), callback_(std::move(callback)) {
DCHECK(!callback_.is_null());
GURL url(std::string(kHighResAvatarDownloadUrlPrefix) +
profiles::GetDefaultAvatarIconFileNameAtIndex(icon_index));
net::NetworkTrafficAnnotationTag traffic_annotation =
net::DefineNetworkTrafficAnnotation("profile_avatar", R"(
semantics {
sender: "Profile Avatar Downloader"
description:
"The Chromium binary comes with a bundle of low-resolution "
"versions of avatar images. When the user selects an avatar in "
"chrome://settings, Chromium will download a high-resolution "
"version from Google's static content servers for use in the "
"people manager UI."
trigger:
"User selects a new avatar in chrome://settings for their profile"
data: "None, only the filename of the png to download."
destination: GOOGLE_OWNED_SERVICE
}
policy {
cookies_allowed: NO
setting: "This feature cannot be disabled in settings."
policy_exception_justification:
"No content is being uploaded or saved; this request merely "
"downloads a publicly available PNG file."
})");
fetcher_ = std::make_unique<BitmapFetcher>(url, this, traffic_annotation);
}
ProfileAvatarDownloader::~ProfileAvatarDownloader() = default;
void ProfileAvatarDownloader::Start() {
SystemNetworkContextManager* system_network_context_manager =
g_browser_process->system_network_context_manager();
// In unit tests, the browser process can return a NULL context manager
if (!system_network_context_manager)
return;
network::mojom::URLLoaderFactory* loader_factory =
system_network_context_manager->GetURLLoaderFactory();
if (loader_factory) {
fetcher_->Init(
net::ReferrerPolicy::REDUCE_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN,
network::mojom::CredentialsMode::kOmit);
fetcher_->Start(loader_factory);
}
}
// BitmapFetcherDelegate overrides.
void ProfileAvatarDownloader::OnFetchComplete(const GURL& url,
const SkBitmap* bitmap) {
if (!bitmap)
return;
// Decode the downloaded bitmap. Ownership of the image is taken by |cache_|.
std::move(callback_).Run(
gfx::Image::CreateFrom1xBitmap(*bitmap),
profiles::GetDefaultAvatarIconFileNameAtIndex(icon_index_),
profiles::GetPathOfHighResAvatarAtIndex(icon_index_));
}
| [
"[email protected]"
] | |
e048c4343413702c7aa669d0b790da09a0a2cb34 | 83b3a323b6f7402a60eab2d33a35605374c8bcc9 | /SignalListener.h | 068b7ebb47d9c66b44eb3a9d4dcc2ab550946f32 | [
"Apache-2.0"
] | permissive | hagleitn/hepalicious | cc20e289d762307c07d4e66849a127859938c5b3 | cc3996e3ef33cf696d6a71afaca3430f386182ee | refs/heads/master | 2021-01-13T03:34:12.928508 | 2016-12-25T05:27:43 | 2016-12-25T05:27:43 | 77,310,092 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 165 | h | #ifndef SIGNAL_LISTENER_H
#define SIGNAL_LISTENER_H
#include "Arduino.h"
class SignalListener {
public:
virtual void update(double x, long time) = 0;
};
#endif
| [
"[email protected]"
] | |
e4b8f2782e7246956637c063014fffbd942e883b | 4f07dffbbc1dcf3c06c33219296eb72d99b08ab0 | /chrome/browser/chromeos/policy/active_directory_policy_manager.h | 07fb5a7109d32181cba5c40c1c7b99725e0db009 | [
"BSD-3-Clause"
] | permissive | zeyiwu/chromium | 4815e89f8a9acd0e9e6957dc2be6e6d6f4995a52 | 2969192f368b295477a3348584160a854fd3316b | refs/heads/master | 2023-02-21T20:39:29.821478 | 2018-05-22T02:04:26 | 2018-05-22T02:04:26 | 134,348,434 | 1 | 0 | null | 2018-05-22T02:16:57 | 2018-05-22T02:16:57 | null | UTF-8 | C++ | false | false | 6,982 | h | // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_
#define CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_
#include <memory>
#include "base/bind.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "components/account_id/account_id.h"
#include "components/policy/core/common/cloud/cloud_policy_store.h"
#include "components/policy/core/common/configuration_policy_provider.h"
#include "components/policy/core/common/policy_scheduler.h"
namespace policy {
class CloudExternalDataManager;
// ConfigurationPolicyProvider for policy from Active Directory.
// Derived classes implement specializations for user and device policy.
// Data flow: Triggered by DoPolicyFetch(), policy is fetched by authpolicyd and
// stored in session manager with completion indicated by OnPolicyFetched().
// From there policy load from session manager is triggered, completion of which
// is notified via OnStoreLoaded()/OnStoreError().
class ActiveDirectoryPolicyManager : public ConfigurationPolicyProvider,
public CloudPolicyStore::Observer {
public:
~ActiveDirectoryPolicyManager() override;
// ConfigurationPolicyProvider:
void Init(SchemaRegistry* registry) override;
void Shutdown() override;
bool IsInitializationComplete(PolicyDomain domain) const override;
void RefreshPolicies() override;
// CloudPolicyStore::Observer:
void OnStoreLoaded(CloudPolicyStore* cloud_policy_store) override;
void OnStoreError(CloudPolicyStore* cloud_policy_store) override;
CloudPolicyStore* store() const { return store_.get(); }
CloudExternalDataManager* external_data_manager() const {
return external_data_manager_.get();
}
PolicyScheduler* scheduler() { return scheduler_.get(); }
protected:
ActiveDirectoryPolicyManager(
std::unique_ptr<CloudPolicyStore> store,
std::unique_ptr<CloudExternalDataManager> external_data_manager);
// Publish the policy that's currently cached in the store.
void PublishPolicy();
// Calls into authpolicyd to fetch policy. Reports success or failure via
// |callback|.
virtual void DoPolicyFetch(PolicyScheduler::TaskCallback callback) = 0;
// Allows derived classes to cancel waiting for the initial policy fetch/load
// and to flag the ConfigurationPolicyProvider ready (assuming all other
// initialization tasks have completed) or to exit the session in case the
// requirements to continue have not been met. |success| denotes whether the
// policy fetch was successful.
virtual void CancelWaitForInitialPolicy(bool success) {}
private:
// Called by scheduler with result of policy fetch. This covers policy
// download, parsing and storing into session manager. (To access and publish
// the policy, the store needs to be reloaded from session manager.)
void OnPolicyFetched(bool success);
// Called right before policy is published. Expands e.g. ${machine_name} for
// a selected set of policies.
void ExpandVariables(PolicyMap* policy_map);
// Whether policy fetch has ever been reported as completed by authpolicyd.
bool fetch_ever_completed_ = false;
// Whether policy fetch has ever been reported as successful by authpolicyd.
bool fetch_ever_succeeded_ = false;
// Store used to serialize policy, usually sends data to Session Manager.
std::unique_ptr<CloudPolicyStore> store_;
// Manages external data referenced by policies.
std::unique_ptr<CloudExternalDataManager> external_data_manager_;
std::unique_ptr<PolicyScheduler> scheduler_;
// Must be last member.
base::WeakPtrFactory<ActiveDirectoryPolicyManager> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ActiveDirectoryPolicyManager);
};
// Manages user policy for Active Directory managed devices.
class UserActiveDirectoryPolicyManager : public ActiveDirectoryPolicyManager {
public:
// If |initial_policy_fetch_timeout| is non-zero, IsInitializationComplete()
// is forced to false until either there has been a successful policy fetch
// from the server and a subsequent successful load from session manager or
// |initial_policy_fetch_timeout| has expired and there has been a successful
// load from session manager. The timeout may be set to TimeDelta::Max() to
// enforce successful policy fetch. In case the conditions for signaling
// initialization complete are not met, the user session is aborted by calling
// |exit_session|.
UserActiveDirectoryPolicyManager(
const AccountId& account_id,
base::TimeDelta initial_policy_fetch_timeout,
base::OnceClosure exit_session,
std::unique_ptr<CloudPolicyStore> store,
std::unique_ptr<CloudExternalDataManager> external_data_manager);
~UserActiveDirectoryPolicyManager() override;
// ConfigurationPolicyProvider:
bool IsInitializationComplete(PolicyDomain domain) const override;
// Helper function to force a policy fetch timeout.
void ForceTimeoutForTesting();
protected:
// ActiveDirectoryPolicyManager:
void DoPolicyFetch(PolicyScheduler::TaskCallback callback) override;
void CancelWaitForInitialPolicy(bool success) override;
private:
// Called when |initial_policy_timeout_| times out, to cancel the blocking
// wait for the initial policy fetch.
void OnBlockingFetchTimeout();
// The user's account id.
AccountId account_id_;
// Whether we're waiting for a policy fetch to complete before reporting
// IsInitializationComplete().
bool waiting_for_initial_policy_fetch_ = false;
// Whether the user session is continued in case of failure of initial policy
// fetch.
bool initial_policy_fetch_may_fail_ = false;
// A timer that puts a hard limit on the maximum time to wait for the initial
// policy fetch/load.
base::Timer initial_policy_timeout_{false /* retain_user_task */,
false /* is_repeating */};
// Callback to exit the session.
base::OnceClosure exit_session_;
// Must be last member.
base::WeakPtrFactory<UserActiveDirectoryPolicyManager> weak_ptr_factory_{
this};
DISALLOW_COPY_AND_ASSIGN(UserActiveDirectoryPolicyManager);
};
// Manages device policy for Active Directory managed devices.
class DeviceActiveDirectoryPolicyManager : public ActiveDirectoryPolicyManager {
public:
explicit DeviceActiveDirectoryPolicyManager(
std::unique_ptr<CloudPolicyStore> store);
~DeviceActiveDirectoryPolicyManager() override;
protected:
// ActiveDirectoryPolicyManager:
void DoPolicyFetch(PolicyScheduler::TaskCallback callback) override;
private:
DISALLOW_COPY_AND_ASSIGN(DeviceActiveDirectoryPolicyManager);
};
} // namespace policy
#endif // CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_
| [
"[email protected]"
] | |
a8cec766dff8b63fd26af985d747db1c095ab8f4 | 0b45aa221f069d9cd781dafa14bc2099b20fb03e | /tags/2.28.2/sdk/tests/test_feature/source/test_module.cpp | 36d4927430ea8223af970455ca2977245f7e3c5f | [] | no_license | svn2github/angelscript | f2d16c2f32d89a364823904d6ca3048222951f8d | 6af5956795e67f8b41c6a23d20e369fe2c5ee554 | refs/heads/master | 2023-09-03T07:42:01.087488 | 2015-01-12T00:00:30 | 2015-01-12T00:00:30 | 19,475,268 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 10,652 | cpp | #include "utils.h"
namespace TestModule
{
bool Test()
{
bool fail = false;
int r;
CBufferedOutStream bout;
COutStream out;
asIScriptContext *ctx;
asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
engine->SetMessageCallback(asMETHOD(CBufferedOutStream,Callback), &bout, asCALL_THISCALL);
engine->RegisterGlobalFunction("void assert(bool)", asFUNCTION(Assert), asCALL_GENERIC);
ctx = engine->CreateContext();
asIScriptModule *mod = engine->GetModule(0, asGM_ALWAYS_CREATE);
// Compile a single function
asIScriptFunction *func = 0;
r = mod->CompileFunction("My func", "void func() {}", 0, 0, &func);
if( r < 0 )
TEST_FAILED;
// Execute the function
r = ctx->Prepare(func);
if( r < 0 )
TEST_FAILED;
r = ctx->Execute();
if( r != asEXECUTION_FINISHED )
TEST_FAILED;
// The function's section name should be correct
if( std::string(func->GetScriptSectionName()) != "My func" )
TEST_FAILED;
// We must release the function afterwards
if( func )
{
func->Release();
func = 0;
}
// It must not be allowed to include more than one function in the code
bout.buffer = "";
r = mod->CompileFunction("two funcs", "void func() {} void func2() {}", 0, 0, 0);
if( r >= 0 )
TEST_FAILED;
r = mod->CompileFunction("no code", "", 0, 0, 0);
if( r >= 0 )
TEST_FAILED;
r = mod->CompileFunction("var", "int a;", 0, 0, 0);
if( r >= 0 )
TEST_FAILED;
if( bout.buffer != "two funcs (0, 0) : Error : The code must contain one and only one function\n"
"no code (1, 1) : Warning : The script section is empty\n"
"no code (0, 0) : Error : The code must contain one and only one function\n"
"var (0, 0) : Error : The code must contain one and only one function\n" )
{
printf("%s", bout.buffer.c_str());
TEST_FAILED;
}
// Compiling without giving the function pointer shouldn't leak memory
r = mod->CompileFunction(0, "void func() {}", 0, 0, 0);
if( r < 0 )
TEST_FAILED;
// If the code is not provided, a proper error should be given
r = mod->CompileFunction(0,0,0,0,0);
if( r != asINVALID_ARG )
TEST_FAILED;
// Don't permit recursive calls, unless the function is added to the module scope
// TODO: It may be possible to compile a recursive function even without adding
// it to the scope, but the application needs to explicitly allows it
bout.buffer = "";
r = mod->CompileFunction(0, "void func() {\n func(); \n}", -1, 0, 0);
if( r >= 0 )
TEST_FAILED;
if( bout.buffer != " (1, 2) : Error : No matching signatures to 'func()'\n" )
{
printf("%s", bout.buffer.c_str());
TEST_FAILED;
}
// It should be possible to add the compiled function to the scope of the module
if( mod->GetFunctionCount() > 0 )
TEST_FAILED;
r = mod->CompileFunction(0, "void func() {}", 0, asCOMP_ADD_TO_MODULE, 0);
if( r < 0 )
TEST_FAILED;
if( mod->GetFunctionCount() != 1 )
TEST_FAILED;
// It should be possible to remove a function from the scope of the module
r = mod->RemoveFunction(mod->GetFunctionByIndex(0));
if( r < 0 )
TEST_FAILED;
if( mod->GetFunctionCount() != 0 )
TEST_FAILED;
// Compiling recursive functions that are added to the module is OK
r = mod->CompileFunction(0, "void func() {\n func(); \n}", -1, asCOMP_ADD_TO_MODULE, 0);
if( r < 0 )
TEST_FAILED;
// It should be possible to remove global variables from the scope of the module
mod->AddScriptSection(0, "int g_var; void func() { g_var = 1; }");
r = mod->Build();
if( r < 0 )
TEST_FAILED;
if( mod->GetGlobalVarCount() != 1 )
TEST_FAILED;
r = mod->RemoveGlobalVar(0);
if( r < 0 )
TEST_FAILED;
if( mod->GetGlobalVarCount() != 0 )
TEST_FAILED;
r = ExecuteString(engine, "func()", mod);
if( r != asEXECUTION_FINISHED )
TEST_FAILED;
// It should be possible to add new variables
r = mod->CompileGlobalVar(0, "int g_var;", 0);
if( r < 0 )
TEST_FAILED;
r = mod->CompileGlobalVar(0, "int g_var2 = g_var;", 0);
if( r < 0 )
TEST_FAILED;
if( mod->GetGlobalVarCount() != 2 )
TEST_FAILED;
// Shouldn't be possible to add function with the same name as a global variable
bout.buffer = "";
r = mod->CompileFunction(0, "void g_var() {}", 0, asCOMP_ADD_TO_MODULE, 0);
if( r >= 0 )
TEST_FAILED;
if( bout.buffer != " (1, 1) : Error : Name conflict. 'g_var' is a global property.\n" )
{
printf("%s", bout.buffer.c_str());
TEST_FAILED;
}
if( ctx )
ctx->Release();
engine->Release();
// TODO: Removing a function from the scope of the module shouldn't free it
// immediately if it is still used by another function. This is working.
// I just need a formal test for regression testing.
// TODO: Make sure cyclic references between functions are resolved so we don't get memory leaks
// This is working. I just need a formal test for regression testing.
// TODO: Do not allow adding functions that already exist in the module
// TODO: Maybe we can allow replacing an existing function
// TODO: It should be possible to serialize these dynamic functions
// TODO: The dynamic functions should also be JIT compiled
// TODO: What should happen if a function in the module scope references another function that has
// been removed from the scope but is still alive, and then the byte code for the module is saved?
// Make sure a circular reference between global variable, class, and class method is properly released
engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
engine->SetMessageCallback(asMETHOD(CBufferedOutStream,Callback), &bout, asCALL_THISCALL);
mod = engine->GetModule("script", asGM_ALWAYS_CREATE);
const char *script = "obj o; class obj { void d() { o.val = 1; } int val; }";
mod->AddScriptSection("script", script);
bout.buffer = "";
r = mod->Build();
if( r != 0 )
TEST_FAILED;
if( bout.buffer != "" )
{
printf("%s", bout.buffer.c_str());
TEST_FAILED;
}
engine->Release();
// GetObjectTypeById must not crash even though the object type has already been removed
{
engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
engine->SetMessageCallback(asMETHOD(COutStream, Callback), &out, asCALL_THISCALL);
RegisterScriptArray(engine, false);
asIScriptModule *mod = engine->GetModule("mod", asGM_ALWAYS_CREATE);
mod->AddScriptSection("test", "class A {}");
r = mod->Build();
if( r < 0 )
TEST_FAILED;
int typeId = mod->GetTypeIdByDecl("array<A@>");
if( typeId < 0 )
TEST_FAILED;
asIObjectType *type = engine->GetObjectTypeById(typeId);
if( type == 0 || std::string(type->GetName()) != "array" )
TEST_FAILED;
mod->Discard();
engine->GarbageCollect();
type = engine->GetObjectTypeById(typeId);
if( type != 0 )
TEST_FAILED;
engine->Release();
}
// Recompiling the same module over and over again without
// discarding shouldn't increase memory consumption
{
engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &bout, asCALL_THISCALL);
const char *script =
"int global = 0; \n"
"void func() {} \n"
"class Cls { void mthd() {} } \n"
"shared class SCls { void mthd() {} } \n"
"interface Int { void mthd(); } \n";
const char *scriptWithError =
"void func2() { rterte } \n";
int memSize[5] = {0};
for( int n = 0; n < 5; n++ )
{
// Try with a module that is reused without first discarding it
bout.buffer = "";
asIScriptModule *mod1 = engine->GetModule("script1", asGM_CREATE_IF_NOT_EXISTS);
r = mod1->AddScriptSection("name", script);
r = mod1->Build();
if( r < 0 )
TEST_FAILED;
if( bout.buffer != "" )
{
printf("%s", bout.buffer.c_str());
TEST_FAILED;
}
// Try with a module that is compiled with error
bout.buffer = "";
asIScriptModule *mod2 = engine->GetModule("script2", asGM_CREATE_IF_NOT_EXISTS);
r = mod2->AddScriptSection("name", script);
r = mod2->AddScriptSection("error", scriptWithError);
r = mod2->Build();
if( r >= 0 )
TEST_FAILED;
if( bout.buffer != "error (1, 1) : Info : Compiling void func2()\n"
"error (1, 23) : Error : Expected ';'\n"
"error (1, 23) : Error : Instead found '}'\n" )
{
printf("%s", bout.buffer.c_str());
TEST_FAILED;
}
memSize[n] = GetAllocedMem();
}
if( engine->GetModuleCount() != 2 )
TEST_FAILED;
engine->Release();
// The first iteration uses slightly less memory due to internal buffers
// holding larger capacity after the second build, but afterwards the
// size should be constant
if( memSize[1] != memSize[3] || memSize[3] != memSize[4] )
TEST_FAILED;
}
// Recompiling the same module over and over again shouldn't increase memory consumption
// Another test, this time with derived classes
{
engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &bout, asCALL_THISCALL);
const char *script =
"class ssBlock \n"
"{ \n"
" ssNode@ GetNode() { return ssCreateNode(); } \n"
"}; \n"
"class ssNode \n"
"{ \n"
" ssBlock GetBlock() { return ssBlock(); } \n"
"}; \n"
"class ssNode_Float : ssNode \n"
"{ \n"
"} \n"
"ssNode@ ssCreateNode() \n"
"{ \n"
" ssNode_Float FloatNode(); \n"
" return FloatNode; \n"
"} \n"
;
int memSize[5] = {0};
for( int n = 0; n < 5; n++ )
{
// Try with a module that is reused without first discarding it
bout.buffer = "";
asIScriptModule *mod1 = engine->GetModule("script1", asGM_ALWAYS_CREATE);
// There shouldn't be anything left in the GC
asUINT gcSize;
engine->GetGCStatistics(&gcSize);
if( gcSize != 0 )
TEST_FAILED;
/* for( asUINT i = 0; i < gcSize; i++ )
{
void *obj = 0;
asIObjectType *type = 0;
engine->GetObjectInGC(i, 0, &obj, &type);
if( strcmp(type->GetName(), "_builtin_function_") == 0 )
{
asIScriptFunction *func = (asIScriptFunction*)obj;
printf("func: %s\n", func->GetDeclaration());
}
else
{
asIObjectType *ot = (asIObjectType*)obj;
printf("type: %s\n", ot->GetName());
}
}*/
r = mod1->AddScriptSection("name", script);
r = mod1->Build();
if( r < 0 )
TEST_FAILED;
if( bout.buffer != "" )
{
printf("%s", bout.buffer.c_str());
TEST_FAILED;
}
memSize[n] = GetAllocedMem();
}
engine->Release();
// The first iteration uses slightly less memory due to internal buffers
// holding larger capacity after the second build, but afterwards the
// size should be constant
if( memSize[1] != memSize[3] || memSize[3] != memSize[4] )
TEST_FAILED;
}
// Success
return fail;
}
} // namespace
| [
"angelcode@404ce1b2-830e-0410-a2e2-b09542c77caf"
] | angelcode@404ce1b2-830e-0410-a2e2-b09542c77caf |
6b0f3c0af993a9ecd386251e30f56dd5c7d3c12b | 91a63b14f22c70b0f67cc93a3f227d71d3d8f74a | /FeedParser.cpp | 862b7128c1cbb6fceefd435a52755d2a60f8e95c | [] | no_license | welllima88/fish_client | b6c7191779ab416c3f9ae1820981b3c63e2d3489 | 899404f7b6a66f06335b28842763c2a642b25016 | refs/heads/master | 2020-12-29T00:12:52.430040 | 2016-06-18T02:23:53 | 2016-06-18T02:23:53 | 66,525,134 | 0 | 2 | null | 2016-08-25T04:38:14 | 2016-08-25T04:38:14 | null | UHC | C++ | false | false | 20,547 | cpp | // FeedParser.cpp: implementation of the CFeedParser class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "FISH.h"
#include "FeedParser.h"
#include "DateParser.h"
#include "XML/EzXMLParser.h"
#include "fish_common.h"
#include "fish_def.h"
#include "fish_struct.h"
#include <map>
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
using namespace std;
//#define LOOP_ALLPARSER
//////////////////////////////////////////////////////////////////////
// RSS 2.0 parsing
//////////////////////////////////////////////////////////////////////
// xpath
#define XML_DPXPATH_RSS _T("//rss")
#define XML_DPXPATH_CHANNEL _T("//channel")
#define XML_DPXPATH_CHANNEL2 _T("//*[name()='channel']")
#define XML_DPXPATH_ITEM _T("//item")
#define XML_DPXPATH_ITEM2 _T("//*[name()='item']")
#define XML_DPXPATH_RDF _T("//rdf:RDF")
#define XML_DPXPATH_FEED_F _T("//*[name()='feed']")
// item name
#define XML_LASTBUILDDATE _T("lastBuildDate")
#define XML_VERSION _T("version")
#define XML_XMLNS _T("xmlns")
#define RSS10_XPATH XML_DPXPATH_RDF
#define RSS10_TYPE XML_XMLNS
#define RSS10_DATA _T("http://purl.org/rss/1.0/")
#define RSS20_XPATH XML_DPXPATH_RSS
#define RSS20_TYPE XML_VERSION
#define RSS20_DATA _T("2.0")
#define RSS091_XPATH XML_DPXPATH_RSS
#define RSS091_TYPE XML_VERSION
#define RSS091_DATA _T("0.91")
#define RSS092_XPATH XML_DPXPATH_RSS
#define RSS092_TYPE XML_VERSION
#define RSS092_DATA _T("0.92")
#define RSS093_XPATH XML_DPXPATH_RSS
#define RSS093_TYPE XML_VERSION
#define RSS093_DATA _T("0.93")
#define RSS094_XPATH XML_DPXPATH_RSS
#define RSS094_TYPE XML_VERSION
#define RSS094_DATA _T("0.94")
#define ATOM_XPATH XML_DPXPATH_FEED_F
#define ATOM03_TYPE XML_VERSION
#define ATOM03_DATA _T("0.3")
#define ATOM10_TYPE XML_XMLNS
#define ATOM10_DATA _T("http://purl.org/atom/ns#")
#define RV_RSS093 _T("rss0.93")
#define RV_RSS094 _T("rss0.94")
struct PARSER
{
RSSParser rp;
LPCTSTR v;
LPCTSTR xpath;
LPCTSTR stype;
LPCTSTR data;
};
BOOL DefaultParser(CEzXMLParser* pparser, POST_LIST* plist, int channelid, COleDateTime& lasttime);
BOOL DefaultRSS20Parser(CEzXMLParser* pparser, POST_LIST* plist, int channelid, COleDateTime& lasttime);
BOOL DefaultRSS10Parser(CEzXMLParser* pparser, POST_LIST* plist, int channelid, COleDateTime& lasttime);
BOOL AtomParser(CEzXMLParser* pparser, POST_LIST* plist, int channelid, COleDateTime& lasttime);
RSSParser GetDefaultParser(CEzXMLParser* pparser, CString& v);
BOOL RemoveAllTag(CString& html); // htmlmaker에... 정의됨...
struct PARSER defaultparser[] =
{
{DefaultRSS20Parser, RV_RSS20, RSS20_XPATH, RSS20_TYPE, RSS20_DATA}
, {DefaultRSS20Parser, RV_RSS091, RSS091_XPATH, RSS091_TYPE, RSS091_DATA}
, {DefaultRSS20Parser, RV_RSS092, RSS092_XPATH, RSS092_TYPE, RSS092_DATA}
, {DefaultRSS20Parser, RV_RSS093, RSS093_XPATH, RSS093_TYPE, RSS093_DATA}
, {DefaultRSS20Parser, RV_RSS094, RSS094_XPATH, RSS094_TYPE, RSS094_DATA}
, {DefaultRSS10Parser, RV_RSS10, RSS10_XPATH, RSS10_TYPE, NULL}
, {AtomParser, RV_ATOM03, ATOM_XPATH, ATOM03_TYPE, ATOM03_DATA }
, {AtomParser, RV_ATOM10, ATOM_XPATH, ATOM10_TYPE, ATOM10_DATA }
, {0}
}; // 0.91버전... 2.0파서에서 지원 되도록 데이터 추가.... by aquarelle 2006/02/02
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CFeedParser::CFeedParser()
{
}
CFeedParser::~CFeedParser()
{
m_mapParser.clear();
}
/**************************************************************************
* written by moonknit
*
* @history
* created 2005-11-11
*
* @Description
* XML을 파싱을 위한 dll을 읽어온다.
**************************************************************************/
int CFeedParser::LoadParser()
{
int cnt = 0;
m_mapParser.clear();
return cnt;
}
/**************************************************************************
* written by moonknit
*
* @history
* created 2005-11-11
*
* @Description
* XML을 파싱하여 POST_LIST를 채운다.
**************************************************************************/
BOOL CFeedParser::Parsing(CEzXMLParser* pparser, POST_LIST* plist, int channelid, COleDateTime& lasttime, CString& v)
{
if(pparser == NULL || plist == NULL) return FALSE;
BOOL result = FALSE;
// 이곳에선 dll의 parsing 함수를 사용한다.
// TO DO
try
{
// result = DLLParser(pparser, plist, lasttime);
if(result) return TRUE;
}
catch (...)
{
}
#ifdef LOOP_ALLPARSER
RSSParser parser;
for(int i = 0; defaultparser[i].rp != 0; ++i)
{
parser = defaultparser[i].rp;
if((*parser) (pparser, plist, lasttime))
{
return TRUE;
}
}
return FALSE;
#else
RSSParser parser = GetDefaultParser(pparser, v);
if(parser)
{
return (*parser) (pparser, plist, channelid, lasttime);
}
return result;
#endif
}
/**************************************************************************
* written by moonknit
*
* @history
* created 2005-11-11
*
* @Description
* 어떤 파서를 써야할지 검사한다.
**************************************************************************/
RSSParser GetDefaultParser(CEzXMLParser* pparser, CString& v)
{
IXMLDOMNodeListPtr listptr = NULL;
CString rssinfodata, rsstmp;
TRACE(_T("version : %s\n"), v);
if(!v.IsEmpty())
{
for(int i = 0; defaultparser[i].rp != 0; ++i)
{
rsstmp = defaultparser[i].v;
if(rsstmp == v)
{
TRACE(_T("\nParser Version : %s\n"), defaultparser[i].v);
return defaultparser[i].rp;
}
}
return NULL;
}
for(int i = 0; defaultparser[i].rp != 0; ++i)
{
pparser->SearchNodes((LPTSTR) defaultparser[i].xpath);
if(listptr != NULL && listptr->length > 0)
{
rssinfodata = GetNamedNodeText(defaultparser[i].stype, pparser, listptr->item[0]);
if(!defaultparser[i].data)
{
TRACE(_T("Parser Version : %s"), defaultparser[i].v);
return defaultparser[i].rp;
}
rsstmp = defaultparser[i].data;
if(rssinfodata == rsstmp)
{
TRACE(_T("Parser Version : %s"), defaultparser[i].v);
return defaultparser[i].rp;
}
break;
}
}
return NULL;
}
/**************************************************************************
* written by moonknit, aquarelle
*
* @history
* created 2005-11-11
* updated 2005-12-15 :: last update 정보가 없는 경우의 처리 by moonknit
* updated 2006-01-27 :: 제목이 없는 경우 본분 내용에서 일부 발췌 by aquarelle
* updated 2006-02-02 :: pubdate가 없는 Feed 처리 추가 by aquarelle
* updated 2006-02-06 :: Date Parsing 실패시 처리 추가 by aquarelle
*
* @Description
* RSS 2.0 파서
* RSS 0.91 버전파싱 호환(?) by aquarelle 2006/02/02
**************************************************************************/
BOOL DefaultRSS20Parser(CEzXMLParser* pparser, POST_LIST* plist, int channelid, COleDateTime& lasttime)
{
IXMLDOMNodeListPtr listptr = NULL;
listptr = pparser->SearchNodes(XML_DPXPATH_CHANNEL);
if(listptr == NULL || listptr->length == 0)
{
return FALSE;
}
CString lastBuildDate = GetNamedNodeText(XML_LASTBUILDDATE, pparser, listptr->item[0], 1);
if(lastBuildDate.GetLength() == 0)
lastBuildDate = GetNamedNodeText(XML_PUBDATE_2, pparser, listptr->item[0], 1);
COleDateTime lbd;
BOOL bHaveLastbuild = FALSE;
if(lastBuildDate.GetLength() > 0)
{
if(CDateParser::getDate(lastBuildDate, lbd) && lbd.m_dt != 0)
{
bHaveLastbuild = TRUE;
// 파싱할 필요가 없다.
if(lbd <= lasttime)
return TRUE;
}
else
lbd.SetTime(0, 0, 0);
}
listptr = pparser->SearchNodes(XML_DPXPATH_ITEM);
IXMLDOMNodePtr nodeptr;
BOOL read = FALSE
, readon = FALSE
, xmlupdate = FALSE
, bDateError = FALSE;
CString author
, category
, description
, enclosure
, guid
, url
, subject
, strPubDate
, encoded
, comments
, commentRss;
COleDateTime pubdate;
COleDateTime currentTime = COleDateTime::GetCurrentTime();
for(int i=0; listptr->item[i] != NULL ; i++)
{
nodeptr = listptr->item[i];
// pubDate
strPubDate = GetNamedNodeText(XML_PUBDATE_2, pparser, nodeptr, 1);
if(strPubDate.IsEmpty())
{
strPubDate = GetNamedNodeText(XML_DC_DATE, pparser, nodeptr, 1);
}
//TRACE(_T("String Date : %s\n"), strPubDate);
if(!strPubDate.IsEmpty())
{
if(!bDateError)
bDateError = !(CDateParser::getDate(strPubDate, pubdate));
if(bDateError) // Date Parsing 실패시.. 현재시기간 기준으로 시간 설정..
{
COleDateTimeSpan span(0, 0, 0, listptr->Getlength() - i);
pubdate = currentTime + span;
//return FALSE;
}
}
else// pubdate 미지원 Feed 처리...
{ // 파싱시간 기준으로 pubdate 입력. 신규post 추가시 guid 비교하므로 문제 안됨(?)
COleDateTimeSpan span(0, 0, 0, listptr->Getlength() - i);
pubdate = currentTime + span;
}
if(pubdate <= lasttime)
break;
if(!bHaveLastbuild && pubdate > lbd) lbd = pubdate;
// Subject
subject = GetNamedNodeText(XML_TITLE, pparser, nodeptr, 1);
// Author
author = GetNamedNodeText(XML_AUTHOR, pparser, nodeptr, 1);
if(author.IsEmpty())
{
author = GetNamedNodeText(XML_DC_CREATOR, pparser, nodeptr, 1);
}
// Category
category = GetNamedNodeText(XML_CATEGORY, pparser, nodeptr, 1);
if(category.IsEmpty())
{
category = GetNamedNodeText(XML_DC_SUBJECT, pparser, nodeptr, 1);
}
// Decription
description = GetNamedNodeText(XML_DESCRIPTION, pparser, nodeptr, 1);
if(subject.IsEmpty() && !description.IsEmpty()) // 제목이 비었을경우 본문내용에서.. 발췌
{
subject = description;
RemoveAllTag(subject);
subject = subject.Left(20);
subject += _T("...");
}
// URL
url = GetNamedNodeText(XML_LINK, pparser, nodeptr, 1);
if(url.IsEmpty())
{
url = GetNamedNodeText(XML_URL, pparser, nodeptr, 1);
}
// guid
guid = GetNamedNodeText(XML_GUID, pparser, nodeptr, 1);
if(url.IsEmpty() && guid.IsEmpty())
{
return FALSE;
}
if(url.IsEmpty())
url = guid;
if(guid.IsEmpty())
guid = url;
// enclosure
enclosure = GetNamedNodeText(XML_ENCLOSURE, pparser, nodeptr, 1);
// content : 아직 item에 포함 안됨
encoded = GetNamedNodeText(XML_CONTENT_ENCODED, pparser, nodeptr, 1);
if(description.IsEmpty())
description = encoded;
// comments : 아직 item에 포함 안됨
comments = GetNamedNodeText(XML_COMMENTS, pparser, nodeptr, 1);
// commentsRss : 아직 item에 포함 안됨
commentRss = GetNamedNodeText(XML_WFW_COMMENTRSS, pparser, nodeptr, 1);
//if(guid.GetLength() == 0) guid = url;
// POSTITEM Insert
plist->insert(plist->begin(),
POSTITEM(1, channelid, read, readon, xmlupdate, url, guid, author,
category, subject, description, enclosure, pubdate,
encoded, comments, commentRss));
}
lasttime = lbd;
return TRUE;
}
/**************************************************************************
* written by moonknit, aquarelle
*
* @history
* created 2005-11-11
* updated 2005-12-15 :: last update 정보가 없는 경우의 처리 by moonknit
* updated 2006-01-27 :: 제목이 없는 경우 본분 내용에서 일부 발췌 by aquarelle
* updated 2006-02-02 :: pubdate가 없는 Feed 처리 추가 by aquarelle
* updated 2006-02-06 :: Date Parsing 실패시 처리 추가 by aquarelle
*
* @Description
* RSS 1.0 파서
**************************************************************************/
BOOL DefaultRSS10Parser(CEzXMLParser* pparser, POST_LIST* plist, int channelid, COleDateTime& lasttime)
{
IXMLDOMNodeListPtr listptr = NULL;
listptr = pparser->SearchNodes(XML_DPXPATH_CHANNEL2);
if(listptr == NULL || listptr->length == 0)
{
return FALSE;
}
CString lastBuildDate = GetNamedNodeText(XML_DC_DATE, pparser, listptr->item[0], 1);
COleDateTime lbd;
BOOL bHaveLastbuild = FALSE;
if(lastBuildDate.GetLength() > 0)
{
if(CDateParser::getDate(lastBuildDate, lbd))
{
bHaveLastbuild = TRUE;
// 파싱할 필요가 없다.
if(lbd <= lasttime)
return TRUE;
}
else
lbd.SetTime(0, 0, 0);
}
listptr = pparser->SearchNodes(XML_DPXPATH_ITEM2);
IXMLDOMNodePtr nodeptr;
BOOL read = FALSE
, readon = FALSE
, xmlupdate = FALSE
, bDateError = FALSE;
CString author
, category
, description
, enclosure
, guid
, url
, subject
, strPubDate
, encoded
, commentRss;
COleDateTime pubdate;
COleDateTime currentTime = COleDateTime::GetCurrentTime();
for(int i=0; listptr->item[i] != NULL ; i++)
{
nodeptr = listptr->item[i];
// pubDate
strPubDate = GetNamedNodeText(XML_DC_DATE, pparser, nodeptr, 1);
if(!strPubDate.IsEmpty())
{
if(!bDateError)
bDateError = !(CDateParser::getDate(strPubDate, pubdate));
if(bDateError) // Date Parsing 실패시.. 현재시기간 기준으로 시간 설정..
{
COleDateTimeSpan span(0, 0, 0, listptr->Getlength() - i);
pubdate = currentTime + span;
//return FALSE;
}
}
else // pubdate 미지원 Feed 처리...
{ // 파싱시간 기준으로 pubdate 입력. 신규post 추가시 guid 비교하므로 문제 안됨(?)
COleDateTimeSpan span(0, 0, 0, listptr->Getlength() - i);
pubdate = currentTime + span;
}
if(pubdate <= lasttime)
break;
if(!bHaveLastbuild && pubdate > lbd) lbd = pubdate;
// Subject
subject = GetNamedNodeText(XML_TITLE_F, pparser, nodeptr, 1);
// Author
author = GetNamedNodeText(XML_DC_CREATOR, pparser, nodeptr, 1);
// Category
category = GetNamedNodeText(XML_DC_SUBJECT, pparser, nodeptr, 1);
// Decription
description = GetNamedNodeText(XML_DESCRIPTION_F, pparser, nodeptr, 1);
if(description.IsEmpty())
{
description = GetNamedNodeText(XML_DC_DESCRIPTION, pparser, nodeptr, 1);
}
if(subject.IsEmpty() && !description.IsEmpty()) // 제목이 비었을경우 본문내용에서.. 발췌
{
subject = description;
RemoveAllTag(subject);
subject = subject.Left(20);
subject += _T("...");
}
// URL
url = GetNamedNodeText(XML_LINK_F, pparser, nodeptr, 1);
// guid
guid = GetNamedNodeText(XML_GUID_F, pparser, nodeptr, 1);
if(url.IsEmpty() && guid.IsEmpty())
{
return FALSE;
}
if(guid.IsEmpty())
guid = url;
if(url.IsEmpty())
url = guid;
// enclosure
enclosure = GetNamedNodeText(XML_ENCLOSURE_F, pparser, nodeptr, 1);
// encoded : 추가 안함.
encoded = GetNamedNodeText(XML_CONTENT_ENCODED, pparser, nodeptr, 1);
if(description.IsEmpty())
description = encoded;
// commentsRss : 추가 안함.
commentRss = GetNamedNodeText(XML_WFW_COMMENTRSS, pparser, nodeptr, 1);
// POSTITEM Insert
plist->insert(plist->begin(),
POSTITEM(1, channelid, read, readon, xmlupdate, url, guid, author,
category, subject, description, enclosure, pubdate,
encoded, _T(""), commentRss));
}
lasttime = lbd;
return TRUE;
}
/**************************************************************************
* written by aquarelle
*
* @history
* created 2005-12-22
* updated 2006-01-27 :: 제목이 없는 경우 본분 내용에서 일부 발췌 by aquarelle
* updated 2006-02-02 :: pubdate가 없는 Feed 처리 추가 by aquarelle
* updated 2006-02-06 :: Date Parsing 실패시 처리 추가 by aquarelle
*
* @Description
* Atom 파서 : 0.3, 1.0 공용
**************************************************************************/
BOOL AtomParser(CEzXMLParser* pparser, POST_LIST* plist, int channelid, COleDateTime& lasttime)
{
IXMLDOMNodeListPtr listptr = NULL;
listptr = pparser->SearchNodes(XML_DPXPATH_FEED_F);
if(listptr == NULL || listptr->length == 0)
{
return FALSE;
}
CString lastBuildDate = GetNamedNodeText(XML_MODIFIED_F, pparser, listptr->item[0], 1);
if(lastBuildDate.GetLength() == 0)
{
lastBuildDate = GetNamedNodeText(XML_UPDATED_F, pparser, listptr->item[0], 1);
}
COleDateTime lbd;
BOOL bHaveLastbuild = FALSE;
if(lastBuildDate.GetLength() > 0)
{
if(CDateParser::getDate(lastBuildDate, lbd))
{
bHaveLastbuild = TRUE;
// 파싱할 필요가 없다.
if(lbd <= lasttime)
return TRUE;
}
else
lbd.SetTime(0, 0, 0);
}
listptr = pparser->SearchNodes(XML_XPATH_ENTRY_F);
int cnt = listptr->length;
IXMLDOMNodePtr nodeptr, in_nodeptr;
IXMLDOMNodeListPtr in_nodelistptr;
BOOL read = FALSE
, readon = FALSE
, xmlupdate = FALSE
, bDateError = FALSE;
CString author
, category
, description
, enclosure
, guid
, url
, subject
, strPubDate
, encoded
, commentRss;
COleDateTime pubdate;
COleDateTime currentTime = COleDateTime::GetCurrentTime();
for(int i=0; listptr->item[i] != NULL ; i++)
{
nodeptr = listptr->item[i];
// pubDate
strPubDate = GetNamedNodeText(XML_MODIFIED_F, pparser, nodeptr, 1);
if(strPubDate.IsEmpty())
{
strPubDate = GetNamedNodeText(XML_UPDATED_F, pparser, nodeptr, 1);
}
if(strPubDate.IsEmpty())
{
strPubDate = GetNamedNodeText(XML_ISSUED_F, pparser, nodeptr, 1);
}
if(strPubDate.IsEmpty())
{
strPubDate = GetNamedNodeText(XML_CREATED_F, pparser, nodeptr, 1);
}
if(!strPubDate.IsEmpty())
{
if(!bDateError)
bDateError = !(CDateParser::getDate(strPubDate, pubdate));
if(bDateError) // Date Parsing 실패시.. 현재시기간 기준으로 시간 설정..
{
COleDateTimeSpan span(0, 0, 0, listptr->Getlength() - i);
pubdate = currentTime + span;
//return FALSE;
}
}
else // pubdate 미지원 Feed 처리...
{ // 파싱시간 기준으로 pubdate 입력. 신규post 추가시 guid 비교하므로 문제 안됨(?)
COleDateTimeSpan span(0, 0, 0, listptr->Getlength() - i);
pubdate = currentTime + span;
}
if(pubdate <= lasttime)
break;
if(!bHaveLastbuild && pubdate > lbd) lbd = pubdate;
// Subject
subject = GetNamedNodeText(XML_TITLE_F, pparser, nodeptr, 1);
// Author
author = GetNamedNodeText(XML_XPATH_AUTHOR_NAME_F, pparser, nodeptr, 1);
// Category
category = GetNamedNodeText(XML_CATEGORY_F, pparser, nodeptr, 1);
if(category.GetLength() == 0)
{
category = GetNamedNodeText(XML_DC_SUBJECT_F, pparser, nodeptr, 1);
}
// Decription
in_nodelistptr = pparser->SearchNodes(nodeptr, XML_CONTENT_F);
if(in_nodelistptr->length == 0)
in_nodelistptr = pparser->SearchNodes(nodeptr, XML_SUMMARY_F);
in_nodeptr = in_nodelistptr->item[0];
if(in_nodeptr != NULL)
{
if(GetNamedNodeText(XML_TYPE, pparser, in_nodeptr, 0) == _T("application/xhtml+xml"))
{
in_nodeptr = in_nodeptr->firstChild;
description = _T("");
while(in_nodeptr != NULL)
{
description += (LPTSTR) in_nodeptr->xml;
description.TrimLeft();
description += _T("\r\n");
in_nodeptr = in_nodeptr->nextSibling;
}
description.TrimRight();
}
else
{
description = (LPTSTR) in_nodeptr->text;
}
}
if(subject.IsEmpty() && !description.IsEmpty()) // 제목이 비었을경우 본문내용에서.. 발췌
{
subject = description;
RemoveAllTag(subject);
subject = subject.Left(20);
subject += _T("...");
}
// URL, enclosure
in_nodelistptr = pparser->SearchNodes(nodeptr, XML_LINK_F);
for(int i = 0; in_nodelistptr->item[i] != NULL; i++)
{
in_nodeptr = in_nodelistptr->item[i];
// URL
if(GetNamedNodeText(XML_REL, pparser, in_nodeptr, 0) == XML_TYPE_ALTERNATE)
{
url = GetNamedNodeText(_T("href"), pparser, in_nodeptr, 0);
}
// enclosure
else if(GetNamedNodeText(XML_REL, pparser, in_nodeptr, 0) == XML_TYPE_ENCLOSURE)
{
enclosure = GetNamedNodeText(XML_HREF,pparser, in_nodeptr, 0);
}
}
// guid
guid = GetNamedNodeText(XML_ID_F, pparser, nodeptr, 1);
if(url.IsEmpty() && guid.IsEmpty())
{
return FALSE;
}
if(url.IsEmpty())
url = guid;
if(guid.IsEmpty())
guid = url;
// encoded : 추가 안함.
//encoded = GetNamedNodeText(XML_CONTENT_ENCODED, pparser, nodeptr, 1);
// commentsRss : 추가 안함.
//commentRss = GetNamedNodeText(XML_WFW_COMMENTRSS, pparser, nodeptr, 1);
// POSTITEM Insert
plist->insert(plist->begin(),
POSTITEM(1, channelid, read, readon, xmlupdate, url, guid, author,
category, subject, description, enclosure, pubdate));
}
lasttime = lbd;
return TRUE;
} | [
"[email protected]"
] | |
3b00357ab1c65b19595cabe5e8d1e3a2b42bb506 | 89277ec1edab18707d30cf3527ccb74662ade7e3 | /src/tcp/Source.cpp | bd15bfa15545fb1c846ac7206c19b8de93596075 | [] | no_license | Arenoros/usb-relay-hid-service | 86cc46743658b54516f29ca82a915848f78e7f53 | a2f0494416db290d8243ea83511e3c16693fa6fe | refs/heads/master | 2021-05-23T13:37:47.137759 | 2020-04-26T12:58:46 | 2020-04-26T12:58:46 | 253,315,359 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 739 | cpp | #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stddef.h>
#include <vector>
#include <thread>
#include <map>
#include <regex>
#include "platform_conf.h"
#include <cassert>
#include "sha1.h"
#include "ws_server.h"
bool test_Accept() {
std::string Key = "dGhlIHNhbXBsZSBub25jZQ==258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
uint8_t data[20];
mplc::SHA1::make(Key, data);
Key = mplc::to_base64(data);
return Key == "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=";
}
void on_error(SOCKET sock) {
printf("Error: %d\n", WSAGetLastError());
closesocket(sock);
}
int main() {
mplc::InitializeSockets();
assert(test_Accept());
mplc::WSServer server(4444);
server.Start();
WSACleanup();
return 0;
}
| [
"[email protected]"
] | |
51d4854d9f93b13baab811f30e1aa854d5f72390 | b2d821ef8fe21d02b63b0f5f65175912b61aa44c | /examples/example2.cpp | 2c98474ae77a1b99831a4c8bb6be551be199f1f3 | [
"MIT"
] | permissive | chewi/ttvfs | 2445fb8d54780e6adae14fb55c0b64cc10b66d8f | 471f69762cbba1b0c16d17c825ff6a906393be55 | refs/heads/master | 2021-01-17T22:07:51.893650 | 2013-07-31T18:47:04 | 2013-07-31T18:47:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,826 | cpp |
/* ttvfs example #2 - init, mounting and basic tree operations */
#include <iostream>
#include <VFS.h>
ttvfs::VFSHelper vfs;
static void PrintFile(const char *fn)
{
ttvfs::VFSFile *vf = vfs.GetFile(fn);
std::cout << "Open file " << fn << ": ";
if(vf)
{
vf->open("r"); // force text mode
std::cout << (const char*)vf->getBuf() << std::endl;
vf->dropBuf(true); // no longer needed
vf->close();
}
else
{
std::cout << "FILE OPEN ERROR!" << std::endl;
}
}
static void FileCallback(ttvfs::VFSFile *vf, void *user)
{
std::cout << "File: " << vf->name() << " --> " << vf->fullname() << std::endl;
// Known to be an int ptr.
unsigned int *c = (unsigned int*)user;
++(*c);
}
int main(int argc, char *argv[])
{
// this should be checked, especially in larger projects
if(!ttvfs::checkCompat())
{
std::cout << "HUH? ttvfs was compiled with different options than this file!" << std::endl;
return 1;
}
// Note: Here, it is really important that all files & subdirs are loaded recursively.
// In the merge step below, only those files that already exist in the tree will be
// accessible in their new location.
vfs.LoadFileSysRoot(true);
vfs.Prepare();
PrintFile("myfile.txt"); // this is the default file
PrintFile("patches/myfile.txt"); // this is the patch file
std::cout << "-- Mounting 'patches' -> ''" << std::endl;
// merge "patches" into root dir
//vfs.MountExternalPath("patches"); // this works, but recreates parts of the tree
// that are already existing - possibly error prone!
vfs.Mount("patches", ""); // <-- this is the better way.
// all files and subdirs that were in "patches" are now mirrored in "" as well.
PrintFile("myfile.txt"); // Access the file as before -> it got replaced.
std::cout << "-- Before mounting 'more/even_more/deep' -> 'far' (should error)" << std::endl;
PrintFile("far/file.txt"); // not found!
// remount a directory under a different name
vfs.Mount("more/even_more/deep", "far");
std::cout << "-- After mounting 'more/even_more/deep' -> 'far'" << std::endl;
PrintFile("far/file.txt"); // ... and access this file normally
// mount an external directory (this could be ~/.MyApp or anything)
vfs.MountExternalPath("../ttvfs", "ext");
ttvfs::VFSDir *ext = vfs.GetDir("ext");
if(ext)
{
//VFS_GUARD(ext); // in case this would be called from multiple threads, lock this directory.
std::cout << "Listing files in 'ext' subdir ..." << std::endl;
unsigned int c = 0;
ext->forEachFile(FileCallback, &c);
std::cout << c << " files in total!" << std::endl;
}
return 0;
}
| [
"[email protected]"
] | |
77d45870b685a2d53b23f3c91baff420e02887fe | 7435c4218f847c1145f2d8e60468fcb8abca1979 | /Vaango/src/Core/Tracker/TrackerServer.cc | d9655e063644b5844ff86e324d98623dcb221f7e | [] | no_license | markguozhiming/ParSim | bb0d7162803279e499daf58dc8404440b50de38d | 6afe2608edd85ed25eafff6085adad553e9739bc | refs/heads/master | 2020-05-16T19:04:09.700317 | 2019-02-12T02:30:45 | 2019-02-12T02:30:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,868 | cc | /*
* The MIT License
*
* Copyright (c) 2013-2014 Callaghan Innovation, New Zealand
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
/*
* The MIT License
*
* Copyright (c) 1997-2012 The University of Utah
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include <Core/Tracker/TrackerServer.h>
#include <Core/Containers/StringUtil.h>
#include <Core/Exceptions/InternalError.h>
#include <Core/Thread/Thread.h>
#include <iostream>
using namespace std;
using namespace Uintah;
using namespace Uintah;
TrackerServer * TrackerServer::trackerServer_ = NULL;
void
TrackerServer::startTracking( unsigned int numClients )
{
if( trackerServer_ != NULL ) {
// ERROR, already intialized...
cout << "ERROR: TrackerServer is already started... continuing, but something is probabl wrong...\n";
return;
}
trackerServer_ = new TrackerServer( numClients );
while( !trackerServer_->shutdown_ ) {
string result;
int size = trackerServer_->sockets_[0]->read( result );
if( size <= 0 ) {
break;
}
cout << "from: " << trackerServer_->sockets_[0]->getSocketInfo() << "\n";
cout << "just received: " << result;
}
}
TrackerServer::TrackerServer( unsigned int numClients ) :
shutdown_( false )
{
Socket socket;
socket.create();
cout << "created\n";
socket.bind( TRACKER_PORT );
cout << "bound\n";
socket.listen();
cout << "listened\n";
for( unsigned int pos = 0; pos < numClients; pos++ ) {
sockets_.push_back( new Socket() );
cout << "accepting\n";
socket.accept( *sockets_[pos] );
cout << "accepted\n";
}
}
TrackerServer::~TrackerServer()
{
// Clean up.
for( unsigned int pos = 0; pos < sockets_.size(); pos++ ) {
delete sockets_[ pos ];
}
}
void
TrackerServer::quit()
{
trackerServer_->shutdown_ = true;
}
| [
"[email protected]"
] | |
470238f4a594176673d1d2ea1a0aa985b4427e8d | 772d932a0e5f6849227a38cf4b154fdc21741c6b | /CPP_Joc_Windows_Android/SH_Client_Win_Cpp_Cmake/App/src/base/physics3D/config/shape/PhysicsShapeConfigCylinder.h | 000602a743c6ba54578c0fdc3a1508e93eb359e6 | [] | no_license | AdrianNostromo/CodeSamples | 1a7b30fb6874f2059b7d03951dfe529f2464a3c0 | a0307a4b896ba722dd520f49d74c0f08c0e0042c | refs/heads/main | 2023-02-16T04:18:32.176006 | 2021-01-11T17:47:45 | 2021-01-11T17:47:45 | 328,739,437 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 534 | h | #pragma once
#include <base/gh.h>
#include "PhysicsShapeConfig.h"
#include <base/math/Vector3.h>
namespace physics3D {
class PhysicsShapeConfigCylinder : public PhysicsShapeConfig {priv typedef PhysicsShapeConfig super;pub dCtor(PhysicsShapeConfigCylinder);
pub static int TYPE;
pub float collisionMargin;
pub Vector3 mainAxis;
pub Vector3 halfExtents;
pub explicit PhysicsShapeConfigCylinder(
float collisionMargin,
Vector3& mainAxis,
Vector3 halfExtents);
pub ~PhysicsShapeConfigCylinder() override;
};
};
| [
"[email protected]"
] | |
77437fc206e8ceace62075b131ed89a7978de9b4 | f0423e2dcdd63478b4e08a352e58b6029dcf7b02 | /src/Authoring/Common/Code/Multicaster.h | 0601e0e2dfcb4f6848cd42fb1951d34359b82d9e | [
"BSL-1.0"
] | permissive | flyhex/qt3dstudio | 074a4f45f6997b8376c01cd3a5567687237fe60d | 27247ff41708c3de59aa532691adb1fd8de48902 | refs/heads/master | 2022-04-11T01:14:01.517889 | 2020-02-27T13:01:46 | 2020-02-28T12:02:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,076 | h | /****************************************************************************
**
** Copyright (C) 2002 NVIDIA Corporation.
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt 3D Studio.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef INCLUDE_MULTICASTER_H
#define INCLUDE_MULTICASTER_H 1
#pragma once
//==============================================================================
// Includes
//==============================================================================
#include "SafeArray.h"
//==============================================================================
/**
* Template class for maintaining a list of listeners and fire events off to them.
*/
template <class TObject>
class CMulticaster
{
typedef CSafeArray<TObject> TList;
public:
CMulticaster() {}
virtual ~CMulticaster() {}
//==============================================================================
/**
* Adds a listener to the internally maintained list. First removes any
* previous instances of the listener before adding a new one.
*
* @param inListener The listener to be registered.
*/
void AddListener(TObject inListener)
{
this->RemoveListener(inListener);
m_List.Add(inListener);
}
//==============================================================================
/**
* Removes all instances of the specified listener from the registration list.
*
* @param inListener The listener to be unregistered
*/
void RemoveListener(TObject inListener)
{
typename TList::CIterator thePos = m_List.Begin();
for (; thePos.HasNext(); ++thePos) {
if (inListener == (*thePos)) {
m_List.Remove(thePos);
break;
}
}
}
//==============================================================================
/**
* Template methods for firing events with arbitrary numbers of params to
* listeners. If a source is specfied, then the source will not receive
* notifications that it kicked off itself.
*/
template <typename TMethodType>
void FireEvent(TMethodType inMethod)
{
this->FireEventSource(inMethod, NULL);
}
template <typename TMethodType>
void FireEventSource(TMethodType inMethod, void *inSource)
{
typename TList::CIterator thePos = m_List.Begin();
for (; thePos.HasNext(); ++thePos) {
if (*thePos != inSource) {
((*thePos)->*inMethod)();
}
}
}
template <typename TMethodType, typename TFirstArg>
void FireEvent(TMethodType inMethod, TFirstArg inFirstArg)
{
this->FireEventSource(inMethod, inFirstArg, NULL);
}
template <typename TMethodType, typename TFirstArg>
void FireEventSource(TMethodType inMethod, TFirstArg inFirstArg, void *inSource)
{
typename TList::CIterator thePos = m_List.Begin();
for (; thePos.HasNext(); ++thePos) {
if (*thePos != inSource) {
((*thePos)->*inMethod)(inFirstArg);
}
}
}
template <typename TMethodType, typename TFirstArg, typename TSecondArg>
void FireEvent(TMethodType inMethod, TFirstArg inFirstArg, TSecondArg inSecondArg)
{
this->FireEventSource(inMethod, inFirstArg, inSecondArg, NULL);
}
template <typename TMethodType, typename TFirstArg, typename TSecondArg>
void FireEventSource(TMethodType inMethod, TFirstArg inFirstArg, TSecondArg inSecondArg,
void *inSource)
{
typename TList::CIterator thePos = m_List.Begin();
for (; thePos.HasNext(); ++thePos) {
if (*thePos != inSource) {
((*thePos)->*inMethod)(inFirstArg, inSecondArg);
}
}
}
template <typename TMethodType, typename TFirstArg, typename TSecondArg, typename TThirdArg>
void FireEvent(TMethodType inMethod, TFirstArg inFirstArg, TSecondArg inSecondArg,
TThirdArg inThirdArg)
{
this->FireEventSource(inMethod, inFirstArg, inSecondArg, inThirdArg, NULL);
}
template <typename TMethodType, typename TFirstArg, typename TSecondArg, typename TThirdArg>
void FireEventSource(TMethodType inMethod, TFirstArg inFirstArg, TSecondArg inSecondArg,
TThirdArg inThirdArg, void *inSource)
{
typename TList::CIterator thePos = m_List.Begin();
for (; thePos.HasNext(); ++thePos) {
if (*thePos != inSource) {
((*thePos)->*inMethod)(inFirstArg, inSecondArg, inThirdArg);
}
}
}
template <typename TMethodType, typename TFirstArg, typename TSecondArg, typename TThirdArg,
typename TFourthArg>
void FireEvent(TMethodType inMethod, TFirstArg inFirstArg, TSecondArg inSecondArg,
TThirdArg inThirdArg, TFourthArg inFourthArg)
{
this->FireEventSource(inMethod, inFirstArg, inSecondArg, inThirdArg, inFourthArg, NULL);
}
template <typename TMethodType, typename TFirstArg, typename TSecondArg, typename TThirdArg,
typename TFourthArg>
void FireEventSource(TMethodType inMethod, TFirstArg inFirstArg, TSecondArg inSecondArg,
TThirdArg inThirdArg, TFourthArg inFourthArg, void *inSource)
{
typename TList::CIterator thePos = m_List.Begin();
for (; thePos.HasNext(); ++thePos) {
if (*thePos != inSource) {
((*thePos)->*inMethod)(inFirstArg, inSecondArg, inThirdArg, inFourthArg);
}
}
}
//=========================================================================
/**
* Get the number of listeners in this multicaster.
* @return the number of listeners in this multicaster.
*/
long GetCount() { return m_List.GetCount(); }
protected:
TList m_List; ///< List of objects to fire events to
};
#endif // INCLUDE_MULTICASTER_H
| [
"[email protected]"
] | |
fed6c1f527a018f1b68c64c343442722fe3533f5 | c13cd1901223e22cc0711c85c20abd15770c0812 | /src/appleseed/renderer/modeling/aov/aov.h | f50c783940b542a056d4733451abbb293fb30a46 | [
"MIT"
] | permissive | istemi-bahceci/appleseed | c0e7e42e77a8e403157c793865a56902ccacd547 | 2db1041acb04bad4742cf7826ce019f0e623fe35 | refs/heads/master | 2021-01-18T15:57:00.618077 | 2017-03-28T12:52:54 | 2017-03-28T12:52:54 | 86,699,496 | 1 | 0 | null | 2017-03-30T12:22:41 | 2017-03-30T12:22:41 | null | UTF-8 | C++ | false | false | 2,872 | h |
//
// This source file is part of appleseed.
// Visit http://appleseedhq.net/ for additional information and resources.
//
// This software is released under the MIT license.
//
// Copyright (c) 2017 Esteban Tovagliari, The appleseedhq Organization
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#ifndef APPLESEED_RENDERER_MODELING_AOV_AOV_H
#define APPLESEED_RENDERER_MODELING_AOV_AOV_H
// appleseed.renderer headers.
#include "renderer/modeling/entity/entity.h"
// appleseed.foundation headers.
#include "foundation/platform/compiler.h"
#include "foundation/utility/autoreleaseptr.h"
#include "foundation/utility/uid.h"
// appleseed.main headers.
#include "main/dllsymbol.h"
// Standard headers.
#include <cstddef>
// Forward declarations.
namespace renderer { class AOVAccumulator; }
namespace renderer { class ParamArray; }
namespace renderer
{
class APPLESEED_DLLSYMBOL AOV
: public Entity
{
public:
// Return the unique ID of this class of entities.
static foundation::UniqueID get_class_uid();
// Constructor.
AOV(const char* name, const ParamArray& params);
// Delete this instance.
virtual void release() APPLESEED_OVERRIDE;
// Return a string identifying the model of this entity.
virtual const char* get_model() const = 0;
// Return the number of channels of this AOV.
virtual size_t get_channel_count() const = 0;
// Return the ith channel name.
virtual const char* get_channel_name(const size_t i) const = 0;
// Return true if this AOV contains color data.
virtual bool has_color_data() const = 0;
// Create an accumulator for this AOV.
virtual foundation::auto_release_ptr<AOVAccumulator> create_accumulator(
const size_t index) const = 0;
};
} // namespace renderer
#endif // !APPLESEED_RENDERER_MODELING_AOV_AOV_H
| [
"[email protected]"
] | |
e9f2c7293471251614efb048e0cbdddb522f204e | 3cc352b29b8042b4a9746796b851d8469ff9ff62 | /src/util/FastbPrint.cc | d14c792cfd626142abacb64b922babbc1c267807 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | CompRD/BroadCRD | 1412faf3d1ffd9d1f9907a496cc22d59ea5ad185 | 303800297b32e993abd479d71bc4378f598314c5 | refs/heads/master | 2020-12-24T13:53:09.985406 | 2019-02-06T21:38:45 | 2019-02-06T21:38:45 | 34,069,434 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,095 | cc | ///////////////////////////////////////////////////////////////////////////////
// SOFTWARE COPYRIGHT NOTICE AGREEMENT //
// This software and its documentation are copyright (2009) by the //
// Broad Institute. All rights are reserved. This software is supplied //
// without any warranty or guaranteed support whatsoever. The Broad //
// Institute is not responsible for its use, misuse, or functionality. //
///////////////////////////////////////////////////////////////////////////////
#include "CoreTools.h"
#include "MainTools.h"
#include "Basevector.h"
#include "Qualvector.h"
inline String ANSI256RGBColorID(int red, int green, int blue)
{ return "8;5;" + ToString(16 + blue + 6 * (green + 6 * red)); }
inline String ANSISetBackground(String color) { return "\x1b[4" + color + "m"; }
inline String ANSISetForeground(String color) { return "\x1b[3" + color + "m"; }
inline String ANSISetDefault() { return "\x1b[0m"; }
void print_base_vec(const BaseVecVec & bvv,
const QualVecVec & qvv,
const size_t ibv,
const size_t ib0,
const size_t ib1,
const int COLOR,
const bool RC,
const bool QUALS)
{
const BaseVec & bv = bvv[ibv];
for (size_t ib = ib0; ib < ib1; ib++) {
char base = as_base((RC) ? 3 - bv[ib1 - (ib - ib0) - 1] : bv[ib]);
String color_str;
if (QUALS) {
const QualVec & qv = qvv[ibv];
if (COLOR == 1) {
color_str = ((qv[ib] >= 20) ? "2" : // green
((qv[ib] >= 10) ? "3" : // yellow
"1")); // red
}
else {
// Color scheme for 256-color case: Red progressing to green
int color = Min(qv[ib] / 8, 5);
color_str = ANSI256RGBColorID(5 - color, color, 0);
}
}
else {
if (base == 'A') color_str = ANSI256RGBColorID(5, 0, 0);
if (base == 'C') color_str = ANSI256RGBColorID(2, 5, 0);
if (base == 'G') color_str = ANSI256RGBColorID(3, 0, 5);
if (base == 'T') color_str = ANSI256RGBColorID(0, 5, 5);
}
if (COLOR == 3) {
if (base == 'A') base = '^';
if (base == 'C') base = '(';
if (base == 'G') base = '-';
if (base == 'T') base = '.';
}
cout << ANSISetForeground(color_str) + base;
}
cout << ANSISetDefault();
}
/*
* PrintBases
*
* Print the given bases from the specifed entry in a fastb file.
*/
int main(int argc, char *argv[])
{
RunTime();
BeginCommandArguments;
CommandArgument_String(HEAD);
CommandArgument_IntSet(READ_IDS);
CommandArgument_UnsignedInt_OrDefault(BEGIN, 0);
CommandArgument_UnsignedInt_OrDefault(END, (INT_MAX));
CommandArgument_Bool_OrDefault(QUALS, False);
CommandArgument_Bool_OrDefault(RC, False);
CommandArgument_Bool_OrDefault(FULL, False);
CommandArgument_UnsignedInt_OrDefault(COLOR, 3);
EndCommandArguments;
ForceAssertGt(END, BEGIN);
const size_t nb_max = 100;
BaseVecVec bvv;
bvv.SparseRead(HEAD + ".fastb", READ_IDS, 0);
size_t nibv = READ_IDS.size();
QualVecVec qvv;
if (QUALS)
qvv.SparseRead(HEAD + ".qualb", READ_IDS, 0);
for (size_t iibv = 0; iibv != nibv; iibv++) {
const size_t ibv = READ_IDS[iibv];
const BaseVec & bv = bvv[ibv];
const size_t ib0 = BEGIN;
const size_t ib1 = (END > bv.size() ? bv.size() : END);
ForceAssertGt(ib1, ib0);
cout << "read ID = " << ibv << endl;
cout << "read size = " << bv.size() << endl;
if (!FULL && ib1 - ib0 > 2 * nb_max) {
if (RC) {
print_base_vec(bvv, qvv, ibv, ib0, ib0 + nb_max, COLOR, RC, QUALS);
cout << " ...(" << (ib1 - ib0 - 2 * nb_max) << " bases)... ";
print_base_vec(bvv, qvv, ibv, ib1 - nb_max, ib1, COLOR, RC, QUALS);
}
else {
print_base_vec(bvv, qvv, ibv, ib1 - nb_max, ib1, COLOR, RC, QUALS);
cout << " ...(" << (ib1 - ib0 - 2 * nb_max) << " bases)... ";
print_base_vec(bvv, qvv, ibv, ib0, ib0 + nb_max, COLOR, RC, QUALS);
}
}
else {
print_base_vec(bvv, qvv, ibv, ib0, ib1, COLOR, RC, QUALS);
}
cout << endl << endl;
}
cout << endl;
}
| [
"[email protected]"
] | |
46fa9d05643a4344acac62a66decd4f7c846647f | 69be3ee422b056b34f1c606d415f3f6736c9cc8f | /duckhunt/hmm.cpp | a78460f99b63f5caebe9d63dba1722c8783fce93 | [] | no_license | rsanchez15/ai14 | f00f9c9f6f818324d73d5ea4cc3b54457b1cf863 | 116b28d31b8a5a2ba5be1d277dc2166d9c61dbe5 | refs/heads/master | 2020-04-20T07:26:28.895621 | 2014-10-12T05:55:05 | 2014-10-12T05:55:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16 | cpp | ../hmm/4/hmm.cpp | [
"[email protected]"
] | |
e913ff9e2c1e323bc00e09b778e0d2a43937ea38 | e624afc84b3a1088463b1244fd9095194d706a65 | /SpaceFuckery/KeyListener.h | 73f97cede24e2a591fa1992a00a863d107750328 | [] | no_license | sn-archi/SpaceFuckery | 1be1a4b74ac05f4498f3d97ef2ed63c799341d89 | 20fc2bb9fdd12cfbc09c0aa9d180a742613e550f | refs/heads/master | 2021-03-24T09:07:47.420252 | 2016-05-03T10:06:38 | 2016-05-03T10:06:38 | 48,547,074 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 752 | h | #ifndef KEYLISTENER_H_INCLUDED
#define KEYLISTENER_H_INCLUDED
/*************************************************
* *
* Project: SpaceFuckery *
* *
* Copyright 2015 - 2016 - Marc-Olivier Barre *
* All rights reserved *
* *
**************************************************/
#include "OISInputManager.h"
namespace SpaceFuckery
{
class KeyListener:
public OIS::KeyListener
{
private:
virtual bool keyPressed (const OIS::KeyEvent &arg);
virtual bool keyReleased (const OIS::KeyEvent &arg);
};
}
#endif // KEYLISTENER_H_INCLUDED
| [
"[email protected]"
] | |
08802fdc48270d95e73f977dbf9decc2be0c889c | d0dd5fa9b6f7b3824a98a775a512fc2cde9a5410 | /src/lib/p2engine/p2engine/http/http_connection_base.hpp | 5caf6e590ba25e5917627dce08bc861541d6263f | [] | no_license | guangzhuwu/p2streaming | b57948bb3537b15c7d75f6533c446bb901492ad3 | a600b8bba41914f73267848e96885c74f3a9bb46 | refs/heads/master | 2021-12-25T01:59:22.079699 | 2021-12-23T03:27:43 | 2021-12-23T03:27:43 | 54,152,152 | 33 | 20 | null | null | null | null | UTF-8 | C++ | false | false | 3,042 | hpp | #ifndef P2ENGINE_HTTP_CONNECTION_BASE_HPP
#define P2ENGINE_HTTP_CONNECTION_BASE_HPP
#include "p2engine/push_warning_option.hpp"
#include "p2engine/config.hpp"
#include <boost/algorithm/string.hpp>
#include <boost/date_time.hpp>
#include <string>
#include "p2engine/pop_warning_option.hpp"
#include "p2engine/time.hpp"
#include "p2engine/contrib.hpp"
//#include "p2engine/fssignal.hpp"
#include "p2engine/variant_endpoint.hpp"
#include "p2engine/basic_dispatcher.hpp"
#include "p2engine/basic_engine_object.hpp"
#include "p2engine/http/response.hpp"
#include "p2engine/http/request.hpp"
#include "p2engine/http/basic_http_dispatcher.hpp"
namespace p2engine {
namespace http {
namespace detail{
class basic_http_connection_base
{
typedef basic_http_connection_base this_type;
SHARED_ACCESS_DECLARE;
public:
typedef this_type connection_base_type;
typedef tcp::socket::lowest_layer_type lowest_layer_type;
protected:
basic_http_connection_base(bool enable_ssl, bool isPassive)
:b_passive_(isPassive), enable_ssl_(enable_ssl)
{}
virtual ~basic_http_connection_base(){};
public:
virtual error_code open(const endpoint& local_edp, error_code& ec,
const time_duration& life_time = boost::date_time::pos_infin,
const proxy_settings& ps = proxy_settings()
) = 0;
template<typename Option>
void set_option(const Option& option, error_code& ec)
{
this->lowest_layer().set_option(option, ec);
}
virtual void async_connect(const std::string& remote_host, int port,
const time_duration& time_out = boost::date_time::pos_infin
) = 0;
virtual void async_connect(const endpoint& peer_endpoint,
const time_duration& time_out = boost::date_time::pos_infin
) = 0;
//reliable send
virtual void async_send(const safe_buffer& buf) = 0;
virtual void keep_async_receiving() = 0;
virtual void block_async_receiving() = 0;
virtual lowest_layer_type& lowest_layer() = 0;
virtual void close(bool greaceful = true) = 0;
virtual bool is_open() const = 0;
virtual bool is_connected()const = 0;
virtual endpoint local_endpoint(error_code& ec)const = 0;
virtual endpoint remote_endpoint(error_code& ec)const = 0;
bool is_passive()const { return b_passive_; }
bool enable_ssl()const { return enable_ssl_; }
virtual size_t overstocked_send_size()const = 0;
protected:
bool b_passive_;
bool enable_ssl_;
};
}
class http_connection_base
:public basic_engine_object
, public detail::basic_http_connection_base
, public http_connection_dispatcher
{
typedef http_connection_base this_type;
SHARED_ACCESS_DECLARE;
public:
typedef this_type connection_base_type;
protected:
http_connection_base(io_service& ios, bool enable_ssl, bool isPassive)
:basic_engine_object(ios)
, detail::basic_http_connection_base(enable_ssl, isPassive)
{}
};
} // namespace http
} // namespace p2engine
#endif // P2ENGINE_HTTP_CONNECTION_BASE_HPP
| [
"[email protected]"
] | |
00a7d35ef532d26e1d6e06bf30cc77cbb29ba9bc | 0e06ce00206b72a0b36e66eb6e2ccfcc9a1a3d28 | /include/cpgf/private/gtween_p.h | a23bd9890c10ed232f51f42f0e8e5c91758c9f78 | [
"Apache-2.0"
] | permissive | Happy-Ferret/cpgf | e0845c4a9646b59bb7927647f9cbcb95ca63b607 | 077485bc7f16ca90bd28cca0405f917ac2833a68 | refs/heads/master | 2020-03-19T11:02:58.666786 | 2017-03-25T13:38:17 | 2017-03-25T13:38:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,251 | h | #ifndef CPGF_GTWEEN_P_H
#define CPGF_GTWEEN_P_H
#include "cpgf/gflags.h"
namespace cpgf {
namespace tween_internal {
struct GTweenItemVirtual
{
void (*deleteSelf)(void * self);
void (*tick)(void * self, GTweenEaseParam * param, const GTweenEaseType & ease);
void (*init)(void * self);
const void * (*getInstance)(void * self);
};
class GTweenItem
{
public:
void deleteSelf();
void tick(GTweenEaseParam * param, const GTweenEaseType & ease);
void init();
const void * getInstance();
protected:
GTweenItemVirtual * virtualFunctions;
};
enum GTweenTargetItemFlag
{
ttifRelative = 1 << 0,
ttifHasFrom = 1 << 1
};
template <typename AccessorType>
class GTweenTargetItem : public GTweenItem
{
private:
typedef GTweenItem super;
typedef typename AccessorType::ValueType ValueType;
typedef GTweenTargetItem<AccessorType> ThisType;
private:
static void virtualDeleteSelf(void * self) {
delete static_cast<ThisType *>(self);
}
static void virtualTick(void * self, GTweenEaseParam * param, const GTweenEaseType & ease) {
static_cast<ThisType *>(self)->doTick(param, ease);
}
static void virtualInit(void * self) {
static_cast<ThisType *>(self)->doInit();
}
static const void * virtualGetInstance(void * self) {
return static_cast<ThisType *>(self)->doGetInstance();
}
public:
GTweenTargetItem(const AccessorType & accessor, const ValueType & from, const ValueType & to, const cpgf::GFlags<GTweenTargetItemFlag> & flags)
: super(), accessor(accessor), from(from), to(to), change(to), flags(flags)
{
static GTweenItemVirtual thisFunctions = {
&virtualDeleteSelf,
&virtualTick,
&virtualInit,
&virtualGetInstance
};
this->virtualFunctions = &thisFunctions;
}
protected:
void doTick(GTweenEaseParam * param, const GTweenEaseType & ease) {
GTweenNumber ratio = ease(param);
ValueType value = (ValueType)(this->from + (this->change * ratio));
this->accessor(value);
}
void doInit() {
if(this->accessor.canRead()) {
if(! this->flags.has(ttifHasFrom)) {
this->from = this->accessor();
}
}
if(! this->flags.has(ttifRelative)) {
this->change = this->to - this->from;
}
}
const void * doGetInstance() {
return this->accessor.getInstance();
}
private:
AccessorType accessor;
ValueType from;
ValueType to;
ValueType change;
cpgf::GFlags<GTweenTargetItemFlag> flags;
};
template <typename AccessorType, typename TargetGetterType>
class GTweenFollowItem : public GTweenItem
{
private:
typedef GTweenItem super;
typedef typename AccessorType::ValueType ValueType;
typedef typename TargetGetterType::ValueType TargetValueType;
typedef GTweenFollowItem<AccessorType, TargetGetterType> ThisType;
private:
static void virtualDeleteSelf(void * self) {
delete static_cast<ThisType *>(self);
}
static void virtualTick(void * self, GTweenEaseParam * param, const GTweenEaseType & ease) {
static_cast<ThisType *>(self)->doTick(param, ease);
}
static void virtualInit(void * self) {
static_cast<ThisType *>(self)->doInit();
}
static const void * virtualGetInstance(void * self) {
return static_cast<ThisType *>(self)->doGetInstance();
}
public:
GTweenFollowItem(const AccessorType & accessor, const ValueType & from, const TargetGetterType & TargetGetter)
: super(), accessor(accessor), from(from), TargetGetter(TargetGetter)
{
static GTweenItemVirtual thisFunctions = {
&virtualDeleteSelf,
&virtualTick,
&virtualInit,
&virtualGetInstance
};
this->virtualFunctions = &thisFunctions;
}
protected:
void doTick(GTweenEaseParam * param, const GTweenEaseType & ease) {
GTweenNumber ratio = ease(param);
ValueType value = (ValueType)(this->from + (((ValueType)(this->TargetGetter()) - this->from) * ratio));
this->accessor(value);
}
void doInit() {
if(this->accessor.canRead()) {
this->from = this->accessor();
}
}
const void * doGetInstance() {
return this->accessor.getInstance();
}
private:
AccessorType accessor;
ValueType from;
TargetGetterType TargetGetter;
};
} // namespace tween_internal
} //namespace cpgf
#endif
| [
"[email protected]"
] | |
f53fb06b4de66d3bb3c0280ee18348318f23aafb | 55f31e411e083ad06f3eb4e50df144695fe28de5 | /crf_src/inc/crf_cuda.h | ce2a76fb2598e2c38073afec269e3ae98dd8b508 | [] | no_license | limacv/crf-cuda | 132a34afd0e76d0c9d34123b81ba723fae001b18 | 7e30733823aebcbd479ee219ca1845bb5b1adacd | refs/heads/master | 2021-11-27T14:45:42.773895 | 2011-05-06T01:18:52 | 2011-05-06T01:18:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 612 | h | /*
* crf_cuda.h
*
* Created on: Mar 4, 2011
* Author: PNTX43
*/
#ifndef CRF_CUDA_H_
#define CRF_CUDA_H_
struct cuPath;
struct cuNode {
unsigned int x;
unsigned int y;
double alpha; //This will be casted to float by the GPU
double beta;
double cost;
double bestCost;
cuNode *prev;
int *fvector;
std::vector<cuPath *> lpath;
std::vector<cuPath *> rpath;
};
struct cuPath {
cuNode *rnode;
cuNode *lnode;
int *fvector;
double cost;
};
/* need to add macros to initialize path and node */
#endif /* CRF_CUDA_H_ */
| [
"pntx43@localhost"
] | pntx43@localhost |
d37fb1781a43d1142ae513449ff841427cf43b55 | 06b0de6f0dc0c3f3105934fa11556f34cd500005 | /Source/UnrealCPPVR/UnrealCPPVRGameModeBase.h | 27c12c9597deb38ad278453cfa33be375b811f65 | [] | no_license | Urb0rg/VRDev | 3f8e4b704e1c424a2dec8901cc49fe5bddf190ca | d8291038067c0f7d6984cc1747280291ca16e513 | refs/heads/master | 2020-04-10T13:55:56.057575 | 2019-01-13T14:13:56 | 2019-01-13T14:13:56 | 161,062,851 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 323 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "UnrealCPPVRGameModeBase.generated.h"
/**
*
*/
UCLASS()
class UNREALCPPVR_API AUnrealCPPVRGameModeBase : public AGameModeBase
{
GENERATED_BODY()
};
| [
"[email protected]"
] | |
1c152052ecb6f32d99c1979634578d290cd7d20b | ad92be9086fb61900a25573a11bc66e4ac1132dd | /src/ACESclipReader.cpp | 29a5950d9d75b4f39167a31852c75458a69f73a5 | [
"BSD-2-Clause-Views"
] | permissive | ggarra13/libACESclip | 6524500f26dd69233e7ddede2a9d75f36f0e8e04 | 522d562ecb8b5c7695850acb7f4072304d83bbdb | refs/heads/master | 2016-09-05T12:32:23.601510 | 2015-03-19T17:07:06 | 2015-03-19T17:07:06 | 30,095,302 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,184 | cpp | /*
Copyright (c) 2015, Gonzalo Garramuño
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <locale.h>
#include <iostream>
#ifdef _WIN32
#define strtod_l _strtod_l
#endif
#include "ACESclipReader.h"
namespace ACES {
using namespace tinyxml2;
/**
* Set status of a transform
*
* @param s kPreview or kApplied
*/
ACESclipReader::BitDepth ACESclipReader::get_bit_depth( const std::string& d )
{
if ( d == "10i" ) return k10i;
if ( d == "12i" ) return k12i;
if ( d == "16i" ) return k16i;
if ( d == "16f" ) return k16f;
if ( d == "32f" ) return k32f;
return kLastBitDepth;
}
/**
* Set status of a transform
*
* @param s kPreview or kApplied
*/
std::string ACESclipReader::date_time( const char* i )
{
if (!i) return "";
std::string s = i;
size_t e = s.find('T');
std::string r = s.substr(0, e );
r += " Time: ";
r += s.substr( e+1, s.size() );
return r;
}
/**
* Set status of a transform
*
* @param s kPreview or kApplied
*/
TransformStatus ACESclipReader::get_status( const std::string& s )
{
if ( s == "applied" ) return kApplied;
else return kPreview;
}
/**
* Parse a vector of 3 float numbers
*
* @param s 3 float numbers as a string separated by spaces
* @param out the 3 float numbers
*/
void ACESclipReader::parse_V3( const char* v3, float out[3] )
{
const char* s = v3;
char* e;
out[0] = strtod_l( s, &e, loc ); s = e;
out[1] = strtod_l( s, &e, loc ); s = e;
out[2] = strtod_l( s, &e, loc );
}
/**
* Constructor
*
*/
ACESclipReader::ACESclipReader()
{
#ifdef _WIN32
// The following line should in theory work, but it doesn't
// _loc = _create_locale( LC_ALL, "en-US" );
// We instead use a full name
loc = _create_locale( LC_ALL, "C" );
#else
locale_t empty;
memset( &empty, 0, sizeof(locale_t) );
loc = newlocale( LC_ALL, "en_US.UTF-8", empty );
#endif
}
ACESclipReader::~ACESclipReader()
{
#ifdef _WIN32
_free_locale( loc );
#else
freelocale( loc );
#endif
}
/**
* Standard header.
*
* @return XML_NO_ERROR on success, XML_ERROR_FILE_READ_ERROR on failure
*/
ACESclipReader::ACESError ACESclipReader::header()
{
root = doc.FirstChildElement("aces:ACESmetadata");
if ( !root ) return kNotAnAcesFile;
element = root->FirstChildElement( "ContainerFormatVersion" );
if ( !element ) return kErrorParsingElement;
float version = atof( element->GetText() );
if ( version > 1.0f )
return kErrorVersion;
return kAllOK;
}
ACESclipReader::ACESError ACESclipReader::info()
{
root2 = root->FirstChildElement( "aces:Info" );
if (!root2)
return kNoAcesInfo;
element = root2->FirstChildElement( "Application" );
if ( element )
{
const char* tmp = element->GetText();
if ( tmp ) application = tmp;
tmp = element->Attribute("version");
if ( tmp ) version = tmp;
}
element = root2->FirstChildElement( "Comment" );
if ( element )
{
const char* tmp = element->GetText();
if ( tmp ) comment = tmp;
}
return kAllOK;
}
ACESclipReader::ACESError ACESclipReader::clip_id()
{
root2 = root->FirstChildElement( "aces:ClipID" );
if ( !root2 ) return kNoClipID;
element = root2->FirstChildElement( "ClipName" );
if ( element )
{
const char* tmp = element->GetText();
if ( tmp ) clip_name = tmp;
}
element = root2->FirstChildElement( "Source_MediaID" );
if ( element )
{
const char* tmp = element->GetText();
if ( tmp ) media_id = tmp;
}
element = root2->FirstChildElement( "ClipDate" );
if ( element )
{
const char* tmp = element->GetText();
if ( tmp ) clip_date = date_time( tmp );
}
return kAllOK;
}
ACESclipReader::ACESError ACESclipReader::config()
{
root2 = root->FirstChildElement( "aces:Config" );
if ( !root2 ) return kNoConfig;
element = root2->FirstChildElement( "ACESrelease_Version" );
if ( element )
{
const char* tmp = element->GetText();
if ( tmp )
{
double version = atof( tmp );
if ( version > 1.0 )
{
return kErrorVersion;
}
}
}
element = root2->FirstChildElement( "ClipDate" );
if ( element )
{
const char* tmp = element->GetText();
if ( tmp ) timestamp = tmp;
}
return kAllOK;
}
ACESclipReader::ACESError ACESclipReader::GradeRef()
{
element = root3->FirstChildElement( "aces:GradeRef" );
if ( !element ) return kAllOK;
graderef_status = kPreview;
const char* tmp = element->Attribute( "status" );
if ( tmp ) graderef_status = get_status( tmp );
root4 = element;
element = root4->FirstChildElement( "Convert_to_WorkSpace" );
if ( !element ) return kMissingSpaceConversion;
tmp = element->Attribute( "TransformID" );
if ( ! tmp ) return kMissingSpaceConversion;
convert_to = tmp;
XMLNode* root5 = root4->FirstChildElement( "ColorDecisionList" );
if ( !root5 ) return kAllOK;
element = root5->FirstChildElement( "ASC_CDL" );
if ( !element ) return kAllOK;
XMLNode* root6 = element;
tmp = element->Attribute( "inBitDepth" );
if ( tmp )
{
std::string depth = tmp;
in_bit_depth = get_bit_depth( depth );
}
tmp = element->Attribute( "outBitDepth" );
if ( tmp )
{
std::string depth = tmp;
out_bit_depth = get_bit_depth( depth );
}
XMLNode* root7 = root6->FirstChildElement( "SOPNode" );
if ( root7 )
{
grade_refs.push_back( "SOPNode" );
float out[3];
element = root7->FirstChildElement( "Slope" );
if ( element )
{
const char* tmp = element->GetText();
if ( tmp )
{
parse_V3( tmp, out );
sops.slope( out[0], out[1], out[2] );
}
}
element = root7->FirstChildElement( "Offset" );
if ( element )
{
const char* tmp = element->GetText();
if ( tmp )
{
parse_V3( tmp, out );
sops.offset( out[0], out[1], out[2] );
}
}
element = root7->FirstChildElement( "Power" );
if ( element )
{
const char* tmp = element->GetText();
if ( tmp )
{
parse_V3( tmp, out );
sops.power( out[0], out[1], out[2] );
}
}
}
root7 = root6->FirstChildElement( "SatNode" );
if ( root7 )
{
element = root7->FirstChildElement( "Saturation" );
if ( element )
{
grade_refs.push_back( "SatNode" );
const char* s = element->GetText();
if ( s )
{
char* e = (char*) s + strlen(s) - 1;
sops.saturation( (float) strtod_l( s, &e, loc ) );
}
}
}
element = root4->FirstChildElement( "Convert_from_WorkSpace" );
if ( !element ) return kMissingSpaceConversion;
tmp = element->Attribute( "TransformID" );
if ( ! tmp ) return kMissingSpaceConversion;
convert_from = tmp;
return kAllOK;
}
ACESclipReader::ACESError ACESclipReader::ITL()
{
root3 = root2->FirstChildElement( "aces:InputTransformList" );
if ( !root3 ) {
root3 = root2->FirstChildElement( "InputTransformList" );
if ( !root3 ) return kNoInputTransformList;
}
std::string name, link_transform;
TransformStatus status = kPreview;
element = root3->FirstChildElement( "aces:IDTref" );
if ( element )
{
root4 = element;
const char* tmp = element->Attribute( "TransformID" );
if ( tmp ) name = tmp;
else
{
// For backwards compatibility
tmp = element->Attribute( "name" );
if ( tmp ) name = tmp;
}
tmp = element->Attribute( "status" );
if ( tmp ) status = get_status( tmp );
element = root4->FirstChildElement( "LinkTransform" );
if ( element )
{
const char* tmp = element->GetText();
if ( tmp ) link_transform = tmp;
}
}
IDT.name = name;
IDT.link_transform = link_transform;
IDT.status = status;
ACESclipReader::ACESError err = GradeRef();
if ( err != kAllOK )
return err;
element = root3->FirstChildElement( "LinkInputTransformList" );
if ( element )
{
const char* tmp = element->GetText();
if ( tmp ) link_ITL = tmp;
}
return kAllOK;
}
ACESclipReader::ACESError ACESclipReader::PTL()
{
root3 = root2->FirstChildElement( "aces:PreviewTransformList" );
if ( !root3 ) {
root3 = root2->FirstChildElement( "PreviewTransformList" );
if ( !root3 ) return kNoPreviewTransformList;
}
element = root3->FirstChildElement( "aces:LMTref" );
while( element )
{
std::string name, link_transform;
TransformStatus status = kPreview;
if ( element )
{
const char* tmp = element->Attribute( "TransformID" );
if ( tmp ) name = tmp;
else
{
// For backwards compatibility
tmp = element->Attribute( "name" );
if ( tmp ) name = tmp;
}
tmp = element->Attribute( "status" );
if ( tmp ) status = get_status( tmp );
root4 = element;
XMLElement* elem = root4->FirstChildElement( "LinkTransform" );
if ( elem )
{
const char* tmp = elem->GetText();
if ( tmp ) link_transform = tmp;
}
LMT.push_back( Transform( name, link_transform, status ) );
element = element->NextSiblingElement( "aces:LMTref" );
}
}
std::string name;
TransformStatus status = kPreview;
element = root3->FirstChildElement( "aces:RRTODTref" );
if ( element )
{
const char* tmp = element->Attribute( "TransformID" );
if ( tmp ) name = tmp;
tmp = element->Attribute( "status" );
if ( tmp ) status = get_status( tmp );
RRTODT.name = name;
RRTODT.status = status;
}
else
{
std::string name;
TransformStatus status = kPreview;
element = root3->FirstChildElement( "aces:RRTref" );
if ( element )
{
root4 = element;
const char* tmp = element->Attribute( "TransformID" );
if ( tmp ) name = tmp;
else
{
// For backwards compatibility
tmp = element->Attribute( "name" );
if ( tmp ) name = tmp;
}
tmp = element->Attribute( "status" );
if ( tmp ) status = get_status( tmp );
}
RRT.name = name;
RRT.status = status;
}
{
std::string name, link_transform;
TransformStatus status = kPreview;
element = root3->FirstChildElement( "aces:ODTref" );
if ( element )
{
root4 = element;
const char* tmp = element->Attribute( "TransformID" );
if ( tmp ) name = tmp;
else
{
// For backwards compatibility
tmp = element->Attribute( "name" );
if ( tmp ) name = tmp;
}
tmp = element->Attribute( "status" );
if ( tmp ) status = get_status( tmp );
element = root4->FirstChildElement( "LinkTransform" );
if ( element )
{
const char* tmp = element->GetText();
if ( tmp ) link_transform = tmp;
}
}
ODT.name = name;
ODT.link_transform = link_transform;
ODT.status = status;
}
element = root3->FirstChildElement( "LinkPreviewTransformList" );
if ( element )
{
const char* tmp = element->GetText();
if ( tmp ) link_PTL = tmp;
}
return kAllOK;
}
const char* ACESclipReader::error_name( ACESclipReader::ACESError err ) const
{
switch( err )
{
case kAllOK:
return "ALL OK";
case kFileError:
return "File Error";
case kNotAnAcesFile:
return "Not an ACES clip file";
case kErrorParsingElement:
return "Error Parsing Element";
case kErrorVersion:
return "Not a supported version";
case kNoAcesInfo:
return "No aces:Info";
case kNoClipID:
return "No aces:clipID";
case kNoConfig:
return "No aces:Config";
case kMissingSpaceConversion:
return "Missing color space conversion";
case kNoInputTransformList:
return "No InputTransformList";
case kNoPreviewTransformList:
return "No PreviewTransformList";
case kLastError:
default:
return "Unknown Error";
};
}
/**
* First Step. Load the XML file.
*
* @param filename file to load the XML file from.
*
* @return true on success, false on failure
*/
ACESclipReader::ACESError ACESclipReader::load( const char* filename )
{
XMLError e = doc.LoadFile( filename );
if ( e != XML_NO_ERROR ) return kFileError;
ACESError err = header();
if ( err != kAllOK ) return err;
err = info();
if ( err != kAllOK ) return err;
err = clip_id();
if ( err != kAllOK ) return err;
err = config();
if ( err != kAllOK ) return err;
err = ITL();
if ( err != kAllOK ) return err;
err = PTL();
if ( err != kAllOK ) return err;
return kAllOK;
}
} // namespace ACES
| [
"[email protected]"
] | |
eddf434e5b29e7f7c7a196625d9bb9c1196b3fa4 | 9e0f4cfafb4127a30380ff6549ddb47c190ee043 | /06-海康相机Ubuntu1404Node/CH_HCNetSDK_V5.3.5.2_build20171124_Linux64/QtDemo/src/ParaConfig/configure_params/RemoteParams/cremoteparams.h | 52f73cfbe27d1c3de1546d6a8c008fa459fc4c5a | [] | no_license | robot-samuel/robot_src | 73f936542da9ec012a90386cb301081f0c113cbf | 82938d8fd3dc9d862e7efd767ed56874fcdd5a27 | refs/heads/master | 2020-03-26T06:00:42.382350 | 2018-10-20T06:41:43 | 2018-10-20T06:41:43 | 144,585,360 | 2 | 1 | null | null | null | null | GB18030 | C++ | false | false | 2,602 | h | #ifndef CREMOTEPARAMS_H
#define CREMOTEPARAMS_H
#include <QtGui/QWidget>
#include <QLineEdit>
#ifndef HPR_OK
#define HPR_OK 0
#endif
#ifndef HPR_ERROR
#define HPR_ERROR -1
#endif
#ifndef INT_LEN
#define INT_LEN 10 //the length of the string of 32 bit int
#endif
#include "cadvancednetparams.h"
#include "ui_cremoteparams.h"
#include "cnfsparams.h"
#include "czonedst.h"
#include "crtspparams.h"
#include "ccompressaudio.h"
#include "cchannelparams.h"
#include "cuserparams.h"
#include "catmparams.h"
#include "exceptionparams.h"
#include "cserialparams.h"
#include "calarmparamsdlg.h"
#include "devicedata.h"
class CRemoteParams : public QWidget {
Q_OBJECT
public:
CRemoteParams(QWidget *parent = 0);
~CRemoteParams();
//kit function
int editToInt(const QLineEdit *pEdit, int *pNum);
int intToEdit(QLineEdit *pEdit, int iNum);
int checkIP(char * ip); //check ip
int editToStr(const QLineEdit *pEdit, BYTE *pStr, int iLen);
int editToIP(const QLineEdit *pEditIP, BYTE *pIP, int iLen);
//***SDK function***//
int setUserID(long lUserID);
int getDeviceInfo();//get device params
int setDeviceInfo();//change device params
int getNetInfo();//Get net params;
int setNetInfo();//Set net params;
//视频缩放
int getScaleInfo();
int setScaleInfo();
public slots:
void refreshParams(); //Update all params.
void saveParams(); //Save all params.
//combox
void clickDHCP(); //CheckboDHCP is clicked.
//button
void clickAdvancedNet(); //The btnAdvancednet is clicked.
void clickNFS(); //NFS
void clickZoneDst(); // zone and dfs
void clickRtsp(); //rtsp
void clickCompressAudio(); //audio
//click table pages
void clickTabPage(int iTabIndex);
protected:
void changeEvent(QEvent *e);
private:
Ui::CRemoteParamsClass *m_ui;
long m_lUserID;
long m_lChannel;
//Net Parameters
CAdvancedNetParams *m_pAdvancedNet;
CNfsParams *m_pNfs; //net file system
CZoneDst *m_pZoneDst; //zone time
CRtspParams *m_pRtsp; //Rtsp
CCompressAudio *m_pCompressAudio; // Audio
//Channel Parameters
int m_iTabIndex; //the index of pages
CChannelParams *m_pChannelParams; // the pointer of ChannelParams table page
CUserParams *m_pUserParams; //用户参数窗口指针
ExceptionParams *m_pExceptionParams;
CSerialParams *m_pSerialParams;
CAlarmParamsDlg *m_pAlarmParams;
CATMParams *m_pATMParams;
//event
void showEvent ( QShowEvent * event );
};
#endif // CREMOTEPARAMS_H
| [
"[email protected]"
] | |
459b6abebbb0d387b1fd0015b0566f73b71b98c3 | a0f52ffb5d603f30860dacc178b2d4908e708ed8 | /src/control/joints.h | 1ccb0c304d10a96badf633b950ea1dbb241de76b | [] | no_license | ehuang3/drchubo | bdc8fea999e24f18311de326de55c03f1185d574 | 1164327389c286527fd65b2c7f717298d1d05630 | refs/heads/master | 2020-04-10T19:51:20.317281 | 2013-06-19T22:01:53 | 2013-06-19T22:01:53 | 10,016,324 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,292 | h | #pragma once
#include "control.h"
namespace control {
class control_t;
class control_data_t;
//############################################################
//### Leg: Analytical IK
//############################################################
class JOINT_T : public control_t {
public:
JOINT_T(std::string name) : control_t(name), joint_index(0), joint_changed(true) {}
~JOINT_T() {}
virtual bool run(robot::robot_state_t& target, control_data_t* data);
virtual bool change_mode(int ch, robot::robot_state_t& target);
int joint_index;
bool joint_changed;
};
class GRASP_T : public control_t {
public:
GRASP_T(std::string name) : control_t(name) {}
~GRASP_T() {}
virtual bool run(robot::robot_state_t& target, control_data_t* data);
};
class TORSO_T : public control_t {
public:
TORSO_T(std::string name) : control_t(name) {}
~TORSO_T() {}
virtual bool run(robot::robot_state_t& target, control_data_t* data);
};
class FLOATING_T : public control_t {
public:
FLOATING_T(std::string name) : control_t(name) {}
~FLOATING_T() {}
virtual bool run(robot::robot_state_t& target, control_data_t* data);
};
}
| [
"[email protected]"
] | |
4f6eb924c3054bc722e32eca3c59010962238f20 | 7a8a363e51f826edd32db6e2564500b10527c3ae | /project1/week 2/bus_stop3.cpp | 53b0549ebe58408873e3947e41f8545711ff76b5 | [] | no_license | alialele11/white_belt_cpp | 6b81ee5b28238219fb3feac6cd58c25fc5c0be9b | f1fdc122da14c543370a78719b7ad7aa882a91b2 | refs/heads/master | 2022-12-03T22:54:16.757910 | 2020-08-16T14:26:24 | 2020-08-16T14:26:24 | 287,953,779 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 708 | cpp | #include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
using namespace std;
int main() {
int number = 1;
map<set<string>, int> stop_number;
int Q;
cin >> Q;
for (int i = 0; i < Q; ++i) {
int N;
cin >> N;
set<string> stops;
for (int i = 0; i < N; ++i) {
string s;
cin >> s;
stops.insert(s);
}
if (stop_number.count(stops) == 0) {
stop_number[stops] = number;
cout << "New bus " << number << endl;
++number;
}
else {
cout << "Already exists for " << stop_number[stops] << endl;
}
}
return 0;
} | [
"[email protected]"
] | |
4052fc16a3a5810756398a5c604472044e430e8e | bba6aebbc1a0c0f1a013c048f546028121e22722 | /third_party/usd/include/pxr/imaging/hdSt/basisCurves.h | 1d0373b8e9048b3530ce8bf60c1edeb4a766862b | [] | no_license | michal1000w/GPUSmoke | d061c33bbab817803707984334091c14846e6808 | a5d17ae75871112ff82d39073bf96ea0e96e8fe3 | refs/heads/master | 2023-05-21T13:03:41.573055 | 2021-06-10T14:13:52 | 2021-06-10T14:13:52 | 262,777,366 | 125 | 16 | null | 2021-06-10T14:13:53 | 2020-05-10T12:00:26 | C++ | UTF-8 | C++ | false | false | 6,679 | h | //
// Copyright 2016 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#ifndef PXR_IMAGING_HD_ST_BASIS_CURVES_H
#define PXR_IMAGING_HD_ST_BASIS_CURVES_H
#include "pxr/pxr.h"
#include "pxr/imaging/hdSt/api.h"
#include "pxr/imaging/hd/version.h"
#include "pxr/imaging/hd/basisCurves.h"
#include "pxr/imaging/hd/drawingCoord.h"
#include "pxr/imaging/hd/enums.h"
#include "pxr/imaging/hd/perfLog.h"
#include "pxr/usd/sdf/path.h"
#include "pxr/base/vt/array.h"
#include <memory>
PXR_NAMESPACE_OPEN_SCOPE
class HdStDrawItem;
using HdSt_BasisCurvesTopologySharedPtr =
std::shared_ptr<class HdSt_BasisCurvesTopology>;
/// \class HdStBasisCurves
///
/// A collection of curves using a particular basis.
///
/// Render mode is dependent on both the HdBasisCurvesGeomStyle, refinement
/// level, and the authored primvars.
///
/// If style is set to HdBasisCurvesGeomStyleWire, the curves will always draw
/// as infinitely thin wires. Cubic curves will be refined if complexity is
/// above 0, otherwise they draw the unrefined control points. (This may
/// provide a misleading representation for Catmull-Rom and Bspline curves.)
///
/// If style is set to HdBasisCurvesGeomStylePatch, the curves will draw as
/// patches ONLY if refinement level is above 0. Otherwise, they draw
/// as the unrefined control points (see notes on HdBasisCurvesGeomStyleWire).
///
/// Curves rendered as patches may be rendered as ribbons or halftubes.
/// Curves with primvar authored normals will always render as ribbons.
/// Curves without primvar authored normals are assumed to be round and may be
/// rendered in one of three styles:
/// * if complexity is 1, a camera facing normal is used
/// * if complexity is 2, a fake "bumped" round normal is used
/// * if complexity is 3 or above, the patch is displaced into a half tube
/// We plan for future checkins will remove the need for the camera facing normal
/// mode, using the fake "bumped" round normal instead.
class HdStBasisCurves final: public HdBasisCurves {
public:
HF_MALLOC_TAG_NEW("new HdStBasisCurves");
HDST_API
HdStBasisCurves(SdfPath const& id);
HDST_API
virtual ~HdStBasisCurves();
HDST_API
virtual void Sync(HdSceneDelegate *delegate,
HdRenderParam *renderParam,
HdDirtyBits *dirtyBits,
TfToken const &reprToken) override;
HDST_API
virtual HdDirtyBits GetInitialDirtyBitsMask() const override;
protected:
HDST_API
virtual void _InitRepr(TfToken const &reprToken,
HdDirtyBits *dirtyBits) override;
HDST_API
virtual HdDirtyBits _PropagateDirtyBits(HdDirtyBits bits) const override;
void _UpdateRepr(HdSceneDelegate *sceneDelegate,
TfToken const &reprToken,
HdDirtyBits *dirtyBitsState);
void _PopulateTopology(HdSceneDelegate *sceneDelegate,
HdStDrawItem *drawItem,
HdDirtyBits *dirtyBits,
const HdBasisCurvesReprDesc &desc);
void _PopulateVertexPrimvars(HdSceneDelegate *sceneDelegate,
HdStDrawItem *drawItem,
HdDirtyBits *dirtyBits);
void _PopulateVaryingPrimvars(HdSceneDelegate *sceneDelegate,
HdStDrawItem *drawItem,
HdDirtyBits *dirtyBits);
void _PopulateElementPrimvars(HdSceneDelegate *sceneDelegate,
HdStDrawItem *drawItem,
HdDirtyBits *dirtyBits);
private:
enum DrawingCoord {
HullTopology = HdDrawingCoord::CustomSlotsBegin,
PointsTopology,
InstancePrimvar // has to be at the very end
};
enum DirtyBits : HdDirtyBits {
DirtyIndices = HdChangeTracker::CustomBitsBegin,
DirtyHullIndices = (DirtyIndices << 1),
DirtyPointsIndices = (DirtyHullIndices << 1)
};
// When processing primvars, these will get set to if we determine that
// we should do cubic basis interpolation on the normals and widths.
// NOTE: I worry that it may be possible for these to get out of sync.
// The right long term fix is likely to maintain proper separation between
// varying and vertex primvars throughout the HdSt rendering pipeline.
bool _basisWidthInterpolation = false;
bool _basisNormalInterpolation = false;
bool _SupportsRefinement(int refineLevel);
bool _SupportsUserWidths(HdStDrawItem* drawItem);
bool _SupportsUserNormals(HdStDrawItem* drawItem);
const TfToken& _GetMaterialTag(const HdRenderIndex &renderIndex) const;
void _UpdateDrawItem(HdSceneDelegate *sceneDelegate,
HdStDrawItem *drawItem,
HdDirtyBits *dirtyBits,
const HdBasisCurvesReprDesc &desc);
void _UpdateDrawItemGeometricShader(HdSceneDelegate *sceneDelegate,
HdStDrawItem *drawItem,
const HdBasisCurvesReprDesc &desc);
void _UpdateShadersForAllReprs(HdSceneDelegate *sceneDelegate,
bool updateMaterialShader,
bool updateGeometricShader);
HdSt_BasisCurvesTopologySharedPtr _topology;
HdTopology::ID _topologyId;
HdDirtyBits _customDirtyBitsInUse;
int _refineLevel; // XXX: could be moved into HdBasisCurveTopology.
bool _displayOpacity;
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif // PXR_IMAGING_HD_ST_BASIS_CURVES_H
| [
"[email protected]"
] | |
f449c51ea76730da1a6dfa72d78626344061801e | 660d76367f347e4086bb9922ad35a9f3762dc9b9 | /core/logs.hpp | bd6563292cf13451768e02cd8d2a3ff6af22027a | [
"MIT"
] | permissive | kkw1206/lemon | 211da4c35e7aae35bcd8f35444afb63ec1199cd4 | 44b4a19b19e1825d65ac260b5e1636d27da5c1f4 | refs/heads/master | 2023-04-09T17:27:55.660939 | 2021-04-09T21:44:48 | 2021-04-10T19:21:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 97 | hpp | #pragma once
class Options;
namespace logs
{
void preinit();
void init(const Options& opt);
} | [
"[email protected]"
] | |
8cbc5d542a85aff8758f5f80705aae47896c631a | 328aa43cffe647ed2d971cbf8a4f864d54635643 | /113. Path Sum II/solution1.cpp | 977be9a3f3842e6e5fc51c6375cc0d05f6ebd872 | [] | no_license | diwujiahao/leetcode | 24fa5990af640fcab6c8ca2f20e61db8058e7968 | 58f49db3fd532eee4630c86f62786d36fcb1f9d2 | refs/heads/master | 2021-05-08T22:31:20.014373 | 2019-06-17T15:27:28 | 2019-06-17T15:27:28 | 119,675,284 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 972 | cpp | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
vector<vector<int>> result;
int target;
void recursion(TreeNode* node, vector<int> temp, int temp_sum){
// 空节点返回
if (!node){
return;
}
// 加入当前节点值
temp.push_back(node->val);
temp_sum += node->val;
// 判断当前路径是否满足条件
if (temp_sum == target && !node->left && !node->right){
result.push_back(temp);
}
// 遍历左右子树
recursion(node->left, temp, temp_sum);
recursion(node->right, temp, temp_sum);
}
public:
vector<vector<int>> pathSum(TreeNode* root, int sum) {
target = sum;
recursion(root, vector<int>(), 0);
return result;
}
}; | [
""
] | |
b5a2f23f0a2285da9cc346635489e4d8be16cf7d | 8afb5afd38548c631f6f9536846039ef6cb297b9 | /_ORGS/NPM/node/deps/v8/src/torque/declaration-visitor.cc | 71cde509635cc7eeb59f328c52a126a5efd2fb93 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"SunPro"
] | permissive | bgoonz/UsefulResourceRepo2.0 | d87588ffd668bb498f7787b896cc7b20d83ce0ad | 2cb4b45dd14a230aa0e800042e893f8dfb23beda | refs/heads/master | 2023-03-17T01:22:05.254751 | 2022-08-11T03:18:22 | 2022-08-11T03:18:22 | 382,628,698 | 10 | 12 | MIT | 2022-10-10T14:13:54 | 2021-07-03T13:58:52 | null | UTF-8 | C++ | false | false | 15,534 | cc | // Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/torque/declaration-visitor.h"
#include "src/torque/ast.h"
#include "src/torque/server-data.h"
#include "src/torque/type-inference.h"
#include "src/torque/type-visitor.h"
namespace v8 {
namespace internal {
namespace torque {
Namespace* GetOrCreateNamespace(const std::string& name) {
std::vector<Namespace*> existing_namespaces = FilterDeclarables<Namespace>(
Declarations::TryLookupShallow(QualifiedName(name)));
if (existing_namespaces.empty()) {
return Declarations::DeclareNamespace(name);
}
DCHECK_EQ(1, existing_namespaces.size());
return existing_namespaces.front();
}
void PredeclarationVisitor::Predeclare(Declaration* decl) {
CurrentSourcePosition::Scope scope(decl->pos);
switch (decl->kind) {
#define ENUM_ITEM(name) \
case AstNode::Kind::k##name: \
return Predeclare(name::cast(decl));
AST_TYPE_DECLARATION_NODE_KIND_LIST(ENUM_ITEM)
#undef ENUM_ITEM
case AstNode::Kind::kNamespaceDeclaration:
return Predeclare(NamespaceDeclaration::cast(decl));
case AstNode::Kind::kGenericCallableDeclaration:
return Predeclare(GenericCallableDeclaration::cast(decl));
case AstNode::Kind::kGenericTypeDeclaration:
return Predeclare(GenericTypeDeclaration::cast(decl));
default:
// Only processes type declaration nodes, namespaces and generics.
break;
}
}
void DeclarationVisitor::Visit(Declaration* decl) {
CurrentSourcePosition::Scope scope(decl->pos);
switch (decl->kind) {
#define ENUM_ITEM(name) \
case AstNode::Kind::k##name: \
return Visit(name::cast(decl));
AST_DECLARATION_NODE_KIND_LIST(ENUM_ITEM)
#undef ENUM_ITEM
default:
UNIMPLEMENTED();
}
}
Builtin* DeclarationVisitor::CreateBuiltin(BuiltinDeclaration* decl,
std::string external_name,
std::string readable_name,
Signature signature,
base::Optional<Statement*> body) {
const bool javascript = decl->javascript_linkage;
const bool varargs = decl->parameters.has_varargs;
Builtin::Kind kind = !javascript ? Builtin::kStub
: varargs ? Builtin::kVarArgsJavaScript
: Builtin::kFixedArgsJavaScript;
if (varargs && !javascript) {
Error("Rest parameters require ", decl->name,
" to be a JavaScript builtin");
}
if (javascript) {
if (!signature.return_type->IsSubtypeOf(TypeOracle::GetJSAnyType())) {
Error("Return type of JavaScript-linkage builtins has to be JSAny.")
.Position(decl->return_type->pos);
}
for (size_t i = signature.implicit_count;
i < signature.parameter_types.types.size(); ++i) {
const Type* parameter_type = signature.parameter_types.types[i];
if (!TypeOracle::GetJSAnyType()->IsSubtypeOf(parameter_type)) {
Error(
"Parameters of JavaScript-linkage builtins have to be a supertype "
"of JSAny.")
.Position(decl->parameters.types[i]->pos);
}
}
}
for (size_t i = 0; i < signature.types().size(); ++i) {
if (signature.types()[i]->StructSupertype()) {
Error("Builtin do not support structs as arguments, but argument ",
signature.parameter_names[i], " has type ", *signature.types()[i],
".");
}
}
if (signature.return_type->StructSupertype() && javascript) {
Error(
"Builtins with JS linkage cannot return structs, but the return type "
"is ",
*signature.return_type, ".");
}
if (signature.return_type == TypeOracle::GetVoidType()) {
Error("Builtins cannot have return type void.");
}
return Declarations::CreateBuiltin(std::move(external_name),
std::move(readable_name), kind,
std::move(signature), body);
}
void DeclarationVisitor::Visit(ExternalBuiltinDeclaration* decl) {
Declarations::Declare(
decl->name->value,
CreateBuiltin(decl, decl->name->value, decl->name->value,
TypeVisitor::MakeSignature(decl), base::nullopt));
}
void DeclarationVisitor::Visit(ExternalRuntimeDeclaration* decl) {
Signature signature = TypeVisitor::MakeSignature(decl);
if (signature.parameter_types.types.size() == 0) {
ReportError(
"Missing parameters for runtime function, at least the context "
"parameter is required.");
}
if (!(signature.parameter_types.types[0] == TypeOracle::GetContextType() ||
signature.parameter_types.types[0] == TypeOracle::GetNoContextType())) {
ReportError(
"first parameter to runtime functions has to be the context and have "
"type Context or NoContext, but found type ",
*signature.parameter_types.types[0]);
}
if (!(signature.return_type->IsSubtypeOf(TypeOracle::GetStrongTaggedType()) ||
signature.return_type == TypeOracle::GetVoidType() ||
signature.return_type == TypeOracle::GetNeverType())) {
ReportError(
"runtime functions can only return strong tagged values, but "
"found type ",
*signature.return_type);
}
for (const Type* parameter_type : signature.parameter_types.types) {
if (!parameter_type->IsSubtypeOf(TypeOracle::GetStrongTaggedType())) {
ReportError(
"runtime functions can only take strong tagged parameters, but "
"found type ",
*parameter_type);
}
}
Declarations::DeclareRuntimeFunction(decl->name->value, signature);
}
void DeclarationVisitor::Visit(ExternalMacroDeclaration* decl) {
Declarations::DeclareMacro(
decl->name->value, true, decl->external_assembler_name,
TypeVisitor::MakeSignature(decl), base::nullopt, decl->op);
}
void DeclarationVisitor::Visit(TorqueBuiltinDeclaration* decl) {
Declarations::Declare(
decl->name->value,
CreateBuiltin(decl, decl->name->value, decl->name->value,
TypeVisitor::MakeSignature(decl), decl->body));
}
void DeclarationVisitor::Visit(TorqueMacroDeclaration* decl) {
Macro* macro = Declarations::DeclareMacro(
decl->name->value, decl->export_to_csa, base::nullopt,
TypeVisitor::MakeSignature(decl), decl->body, decl->op);
// TODO(szuend): Set identifier_position to decl->name->pos once all callable
// names are changed from std::string to Identifier*.
macro->SetPosition(decl->pos);
}
void DeclarationVisitor::Visit(IntrinsicDeclaration* decl) {
Declarations::DeclareIntrinsic(decl->name->value,
TypeVisitor::MakeSignature(decl));
}
void DeclarationVisitor::Visit(ConstDeclaration* decl) {
Declarations::DeclareNamespaceConstant(
decl->name, TypeVisitor::ComputeType(decl->type), decl->expression);
}
void DeclarationVisitor::Visit(SpecializationDeclaration* decl) {
std::vector<GenericCallable*> generic_list =
Declarations::LookupGeneric(decl->name->value);
// Find the matching generic specialization based on the concrete parameter
// list.
GenericCallable* matching_generic = nullptr;
Signature signature_with_types = TypeVisitor::MakeSignature(decl);
for (GenericCallable* generic : generic_list) {
// This argument inference is just to trigger constraint checking on the
// generic arguments.
TypeArgumentInference inference = generic->InferSpecializationTypes(
TypeVisitor::ComputeTypeVector(decl->generic_parameters), {});
if (inference.HasFailed()) {
continue;
}
Signature generic_signature_with_types =
MakeSpecializedSignature(SpecializationKey<GenericCallable>{
generic, TypeVisitor::ComputeTypeVector(decl->generic_parameters)});
if (signature_with_types.HasSameTypesAs(generic_signature_with_types,
ParameterMode::kIgnoreImplicit)) {
if (matching_generic != nullptr) {
std::stringstream stream;
stream << "specialization of " << decl->name
<< " is ambigous, it matches more than one generic declaration ("
<< *matching_generic << " and " << *generic << ")";
ReportError(stream.str());
}
matching_generic = generic;
}
}
if (matching_generic == nullptr) {
std::stringstream stream;
if (generic_list.size() == 0) {
stream << "no generic defined with the name " << decl->name;
ReportError(stream.str());
}
stream << "specialization of " << decl->name
<< " doesn't match any generic declaration\n";
stream << "specialization signature:";
stream << "\n " << signature_with_types;
stream << "\ncandidates are:";
for (GenericCallable* generic : generic_list) {
stream << "\n "
<< MakeSpecializedSignature(SpecializationKey<GenericCallable>{
generic,
TypeVisitor::ComputeTypeVector(decl->generic_parameters)});
}
ReportError(stream.str());
}
if (GlobalContext::collect_language_server_data()) {
LanguageServerData::AddDefinition(decl->name->pos,
matching_generic->IdentifierPosition());
}
CallableDeclaration* generic_declaration = matching_generic->declaration();
Specialize(SpecializationKey<GenericCallable>{matching_generic,
TypeVisitor::ComputeTypeVector(
decl->generic_parameters)},
generic_declaration, decl, decl->body, decl->pos);
}
void DeclarationVisitor::Visit(ExternConstDeclaration* decl) {
const Type* type = TypeVisitor::ComputeType(decl->type);
if (!type->IsConstexpr()) {
std::stringstream stream;
stream << "extern constants must have constexpr type, but found: \""
<< *type << "\"\n";
ReportError(stream.str());
}
Declarations::DeclareExternConstant(decl->name, type, decl->literal);
}
void DeclarationVisitor::Visit(CppIncludeDeclaration* decl) {
GlobalContext::AddCppInclude(decl->include_path);
}
void DeclarationVisitor::DeclareSpecializedTypes(
const SpecializationKey<GenericCallable>& key) {
size_t i = 0;
const std::size_t generic_parameter_count =
key.generic->generic_parameters().size();
if (generic_parameter_count != key.specialized_types.size()) {
std::stringstream stream;
stream << "Wrong generic argument count for specialization of \""
<< key.generic->name() << "\", expected: " << generic_parameter_count
<< ", actual: " << key.specialized_types.size();
ReportError(stream.str());
}
for (auto type : key.specialized_types) {
Identifier* generic_type_name = key.generic->generic_parameters()[i++].name;
TypeAlias* alias = Declarations::DeclareType(generic_type_name, type);
alias->SetIsUserDefined(false);
}
}
Signature DeclarationVisitor::MakeSpecializedSignature(
const SpecializationKey<GenericCallable>& key) {
CurrentScope::Scope generic_scope(key.generic->ParentScope());
// Create a temporary fake-namespace just to temporarily declare the
// specialization aliases for the generic types to create a signature.
Namespace tmp_namespace("_tmp");
CurrentScope::Scope tmp_namespace_scope(&tmp_namespace);
DeclareSpecializedTypes(key);
return TypeVisitor::MakeSignature(key.generic->declaration());
}
Callable* DeclarationVisitor::SpecializeImplicit(
const SpecializationKey<GenericCallable>& key) {
base::Optional<Statement*> body = key.generic->CallableBody();
if (!body && IntrinsicDeclaration::DynamicCast(key.generic->declaration()) ==
nullptr) {
ReportError("missing specialization of ", key.generic->name(),
" with types <", key.specialized_types, "> declared at ",
key.generic->Position());
}
SpecializationRequester requester{CurrentSourcePosition::Get(),
CurrentScope::Get(), ""};
CurrentScope::Scope generic_scope(key.generic->ParentScope());
Callable* result = Specialize(key, key.generic->declaration(), base::nullopt,
body, CurrentSourcePosition::Get());
result->SetIsUserDefined(false);
requester.name = result->ReadableName();
result->SetSpecializationRequester(requester);
CurrentScope::Scope callable_scope(result);
DeclareSpecializedTypes(key);
return result;
}
Callable* DeclarationVisitor::Specialize(
const SpecializationKey<GenericCallable>& key,
CallableDeclaration* declaration,
base::Optional<const SpecializationDeclaration*> explicit_specialization,
base::Optional<Statement*> body, SourcePosition position) {
CurrentSourcePosition::Scope pos_scope(position);
size_t generic_parameter_count = key.generic->generic_parameters().size();
if (generic_parameter_count != key.specialized_types.size()) {
std::stringstream stream;
stream << "number of template parameters ("
<< std::to_string(key.specialized_types.size())
<< ") to intantiation of generic " << declaration->name
<< " doesnt match the generic's declaration ("
<< std::to_string(generic_parameter_count) << ")";
ReportError(stream.str());
}
if (key.generic->GetSpecialization(key.specialized_types)) {
ReportError("cannot redeclare specialization of ", key.generic->name(),
" with types <", key.specialized_types, ">");
}
Signature type_signature =
explicit_specialization
? TypeVisitor::MakeSignature(*explicit_specialization)
: MakeSpecializedSignature(key);
std::string generated_name = Declarations::GetGeneratedCallableName(
declaration->name->value, key.specialized_types);
std::stringstream readable_name;
readable_name << declaration->name->value << "<";
bool first = true;
for (const Type* t : key.specialized_types) {
if (!first) readable_name << ", ";
readable_name << *t;
first = false;
}
readable_name << ">";
Callable* callable;
if (MacroDeclaration::DynamicCast(declaration) != nullptr) {
callable =
Declarations::CreateTorqueMacro(generated_name, readable_name.str(),
false, type_signature, *body, true);
} else if (IntrinsicDeclaration::DynamicCast(declaration) != nullptr) {
callable =
Declarations::CreateIntrinsic(declaration->name->value, type_signature);
} else {
BuiltinDeclaration* builtin = BuiltinDeclaration::cast(declaration);
callable =
CreateBuiltin(builtin, GlobalContext::MakeUniqueName(generated_name),
readable_name.str(), type_signature, *body);
}
key.generic->AddSpecialization(key.specialized_types, callable);
return callable;
}
void PredeclarationVisitor::ResolvePredeclarations() {
const auto& all_declarables = GlobalContext::AllDeclarables();
for (size_t i = 0; i < all_declarables.size(); ++i) {
Declarable* declarable = all_declarables[i].get();
if (const TypeAlias* alias = TypeAlias::DynamicCast(declarable)) {
CurrentScope::Scope scope_activator(alias->ParentScope());
CurrentSourcePosition::Scope position_activator(alias->Position());
alias->Resolve();
}
}
}
} // namespace torque
} // namespace internal
} // namespace v8
| [
"[email protected]"
] | |
4213af2e3d3ee6bef3e094ed8e2ae84588d61b71 | fcfb9503f43d7da0e35a04a77e443ff3d5815d8b | /src/futz/platforms/FutzSDL2.cpp | 6f88e33ab913465f729cf9c22732921f6ba027c2 | [
"MIT"
] | permissive | zibas/futz | c264490d10159cfe6fe2161f4cd1ebf2789ff89f | 83fc0e1a7489940bb55e2db6ccc8ca7d1ac0719f | refs/heads/master | 2021-10-12T17:18:23.164331 | 2021-10-09T16:08:06 | 2021-10-09T16:08:06 | 162,630,385 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,189 | cpp | /*
* FutzSDL.cpp
*
* Created on: August 31, 2014
* Author: ziba
*/
#if FUTZ_PLATFORM_SDL2
#include "../Futz.h"
#include "FutzSDL2.h"
//#include "SDL/SDL.h"
void checkSDLError(int line = -1)
{
const char *error = SDL_GetError();
if (*error != '\0')
{
printf("SDL Error: %s\n", error);
if (line != -1)
printf(" + line: %i\n", line);
SDL_ClearError();
}
}
void FutzSDL2::Initialize(int argc, char** argv){
Futz* futz = Futz::Instance();
screen = NULL;
if (SDL_Init(SDL_INIT_EVERYTHING) < 0){
futz->Log("Error: Unable to initialize SDL2");
}
//SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
//SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
/* Turn on double buffering with a 24bit Z buffer.
* You may need to change this to 16 or 32 for your system */
//SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32);
displayWindow = SDL_CreateWindow("Futz - SDL", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, futz->platform->width, futz->platform->height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
if (!displayWindow){
futz->Log("Error: Unable to initialize SDL2 display window");
}
checkSDLError(__LINE__);
context = SDL_GL_CreateContext(displayWindow);
checkSDLError(__LINE__);
/* This makes our buffer swap syncronized with the monitor's vertical refresh */
//SDL_GL_SetSwapInterval(1);
Futz::Instance()->camera.SetViewport(futz->platform->width, futz->platform->height);
Futz::Instance()->renderer->Initialize(futz->platform->width, futz->platform->height);
Resize(futz->platform->width, futz->platform->height);
futz->Log("Initialized SDL2");
futz->gameObject->Start();
MainLoop();
}
void FutzSDL2::Resize(int width, int height){
if (height == 0){
height = 1;
}
Futz::Instance()->camera.SetViewport(width, height);
Futz::Instance()->renderer->Resize(width, height);
}
char FutzSDL2::EventToChar(SDL_Event event){
char key = '\0';
if (event.key.keysym.sym == SDLK_a){ key = 'a'; }
else if (event.key.keysym.sym == SDLK_b){ key = 'b'; }
else if (event.key.keysym.sym == SDLK_c){ key = 'c'; }
else if (event.key.keysym.sym == SDLK_d){ key = 'd'; }
else if (event.key.keysym.sym == SDLK_e){ key = 'e'; }
else if (event.key.keysym.sym == SDLK_f){ key = 'f'; }
else if (event.key.keysym.sym == SDLK_g){ key = 'g'; }
else if (event.key.keysym.sym == SDLK_h){ key = 'h'; }
else if (event.key.keysym.sym == SDLK_i){ key = 'i'; }
else if (event.key.keysym.sym == SDLK_n){ key = 'n'; }
else if (event.key.keysym.sym == SDLK_o){ key = 'o'; }
else if (event.key.keysym.sym == SDLK_p){ key = 'p'; }
else if (event.key.keysym.sym == SDLK_q){ key = 'q'; }
else if (event.key.keysym.sym == SDLK_r){ key = 'r'; }
else if (event.key.keysym.sym == SDLK_s){ key = 's'; }
else if (event.key.keysym.sym == SDLK_v){ key = 'v'; }
else if (event.key.keysym.sym == SDLK_w){ key = 'w'; }
else if (event.key.keysym.sym == SDLK_0){ key = '0'; }
else if (event.key.keysym.sym == SDLK_1){ key = '1'; }
else if (event.key.keysym.sym == SDLK_2){ key = '2'; }
else if (event.key.keysym.sym == SDLK_3){ key = '3'; }
else if (event.key.keysym.sym == SDLK_4){ key = '4'; }
else if (event.key.keysym.sym == SDLK_5){ key = '5'; }
else if (event.key.keysym.sym == SDLK_6){ key = '6'; }
else if (event.key.keysym.sym == SDLK_7){ key = '7'; }
else if (event.key.keysym.sym == SDLK_8){ key = '8'; }
else if (event.key.keysym.sym == SDLK_9){ key = '9'; }
else if (event.key.keysym.sym == SDLK_ESCAPE){ key = 27; }
return key;
}
void FutzSDL2::MainLoop(){
Futz* futz = Futz::Instance();
SDL_Event event;
//SDL_StartTextInput();
while (1){
//While there are events to handle
//SDL_EnableUNICODE(SDL_ENABLE);
while (SDL_PollEvent(&event)) {
char ch;
//Handle user quit
switch (event.type) {
case SDL_MOUSEMOTION:
futz->input.SetMouse(event.motion.x, event.motion.y);
break;
case SDL_TEXTINPUT:
break;
case SDL_KEYDOWN:
futz->input.SetDown(this->EventToChar(event));
break;
case SDL_KEYUP:
futz->input.SetUp(this->EventToChar(event));
break;
}
}
futz->Update();
futz->Render();
futz->gameObject->RenderLoop();
//Update screen
SDL_GL_SwapWindow(displayWindow);
//Cap the frame rate
//if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND )
//{ SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() ); }
}
}
void FutzSDL2::ToggleFullscreen(){
Futz* futz = Futz::Instance();
if (!futz->platform->isFullscreen){
SDL_DisplayMode displayMode;
SDL_SetWindowFullscreen(displayWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
int should_be_zero = SDL_GetCurrentDisplayMode(0, &displayMode);
Resize(displayMode.w, displayMode.h);
}
else {
SDL_SetWindowFullscreen(displayWindow, 0);
Resize(futz->platform->width, futz->platform->height);
}
futz->platform->isFullscreen = !futz->platform->isFullscreen;
}
FutzSDL2::~FutzSDL2() {
SDL_GL_DeleteContext(context);
SDL_DestroyWindow(displayWindow);
SDL_Quit();
}
#endif
| [
"[email protected]"
] | |
48cc940f403b368b352dd2bf7a9884fe1c2581b5 | 17cc399543bf9906053252b3197af901f4a2918a | /Jelly/JellyPoint.h | ad3ef94aeedab628f98811361f7259ef931c8763 | [] | no_license | gitzuka/Jelly | c1e75bf0802c6719a24c919b55d119f42a16f0d3 | 126a0af52a4dddc2c1ab189674981d48462429bb | refs/heads/master | 2021-10-25T06:42:01.860341 | 2019-04-02T13:28:42 | 2019-04-02T13:28:42 | 114,768,208 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 690 | h | #pragma once
#include <Qvector3D>
class JellyPoint
{
public:
JellyPoint(const QVector3D &position, float mass, QVector3D velocity);
JellyPoint(const QVector3D &position);
~JellyPoint();
void updatePosition(const QVector3D &position);
void setPosition(const QVector3D &position);
void setMass(float mass);
void setVelocity(QVector3D velocity);
void addForce(const QVector3D &force);
void addVeloctiy(const QVector3D &velocity);
void resetForce();
const QVector3D& getPosition() const;
float getMass() const;
const QVector3D& getVelocity() const;
const QVector3D& getForce() const;
private:
QVector3D m_position;
float m_mass;
QVector3D m_velocity;
QVector3D m_force;
};
| [
"[email protected]"
] | |
db29ec0ac9226448ea55839504ea9e285a0bb608 | cf3c63cc6daf5d4f1a96a86ca05629883e69bedf | /cp/Codeforces/1454Bpost.cpp | f3a2b87c6cd6ce7d2060217995299a0b347e3361 | [] | no_license | soobeenpark/scratchwork | dd2c513349889375de8ef63df8602cf300e79726 | cd3705cd0ede3751a88d68806b52c10633e57caf | refs/heads/master | 2023-04-18T04:29:56.250861 | 2021-04-28T13:39:22 | 2021-04-28T13:39:22 | 293,812,462 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 748 | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
vector<int> idx(n + 1, 0);
vector<int> count(n + 1, 0);
for (int i = 0; i < n; i++) {
int ai;
cin >> ai;
idx[ai] =
i +
1; // Don't care if we overwrite idx at previous same ai value
++count[ai];
}
bool found = false;
for (int i = 1; !found && i <= n; i++) {
if (count[i] == 1) {
cout << idx[i] << endl;
found = true;
break;
}
}
if (!found) {
cout << -1 << endl;
}
}
}
| [
"[email protected]"
] | |
94f7e1499c814d2d8f6eab65c748db2e5e88e9b9 | c5c0269650dae21b591548fe4584acce175b42bb | /open_gl /circle2/circle2/circle2.cpp | 59de0f43c6bfd930bb46e1ea165e2969310c26fb | [] | no_license | sarage/programming_technology | b40ca8eb4737d5cea5cc184ee8186417c0b23fee | 62d8c219f5afe2faf4a673880b9b2031a92ed11c | refs/heads/master | 2021-01-21T17:23:21.537239 | 2017-03-17T10:28:31 | 2017-03-17T10:28:31 | 85,270,729 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,507 | cpp | #include <windows.h>
#include <iostream>
int InputInteger(const char * str, int min, int max){
int x;
std::cout << str;
bool ErrorFlag;
do{
std::cin.clear();
std::cin.ignore(std::cin.rdbuf()->in_avail());
std::cin >> x;
ErrorFlag = !std::cin.good() || x< min || x>max;
if (ErrorFlag){
std::cout << "Error. " << str;
}
} while (ErrorFlag);
std::cin.ignore(std::cin.rdbuf()->in_avail());
return x;
}
COLORREF GetPenColor(){
int r, g, b;
std::cout << "Enter color:\n";
r = InputInteger("Enter R value[0,255]:", 0, 255);
g = InputInteger("Enter G value[0,255]:", 0, 255);
b = InputInteger("Enter B value[0,255]:", 0, 255);
return RGB(r, g, b);
}
int main(){
HWND hWnd = GetConsoleWindow();
HDC hDC = GetDC(hWnd);
RECT temp;
GetClientRect(hWnd, &temp);
HDC hBufferDC = CreateCompatibleDC(hDC);
HBITMAP hBufferBmp = CreateBitmap(temp.right, temp.bottom, 1, 32, NULL);
HBITMAP hBufferBmpOld = (HBITMAP)SelectObject(hBufferDC, hBufferBmp);
FillRect(hBufferDC, &temp, (HBRUSH)GetStockObject(WHITE_BRUSH));
system("cls");
HBRUSH hBrush = (HBRUSH)GetStockObject(NULL_BRUSH);
HPEN hPen = CreatePen(PS_SOLID, 1, GetPenColor());
HBRUSH hOldBrush = (HBRUSH)SelectObject(hBufferDC, hBrush);
HPEN hOldPen = (HPEN)SelectObject(hBufferDC, hPen);
RECT circle = { 0, 0, 100, 100 };
size_t step_h = 3, step_v = 3;
while (!GetAsyncKeyState(VK_ESCAPE)){
FillRect(hBufferDC, &circle, (HBRUSH)GetStockObject(WHITE_BRUSH));
if (GetAsyncKeyState(VK_SPACE)){
system("cls");
InvalidateRect(hWnd, &temp, true);
HPEN hNewPen = CreatePen(PS_SOLID, 1, GetPenColor());
SelectObject(hBufferDC, hNewPen);
DeleteObject(hPen);
hPen = hNewPen;
}
if (GetAsyncKeyState(VK_LEFT)){
circle.left -= step_h;
circle.right -= step_h;
}
if (GetAsyncKeyState(VK_RIGHT)){
circle.left += step_h;
circle.right += step_h;
}
if (GetAsyncKeyState(VK_DOWN)){
circle.top += step_v;
circle.bottom += step_v;
}
if (GetAsyncKeyState(VK_UP)){
circle.top -= step_v;
circle.bottom -= step_v;
}
Ellipse(hBufferDC, circle.left, circle.top, circle.right, circle.bottom);
BitBlt(hDC, 0, 0, temp.right, temp.bottom, hBufferDC, 0, 0, SRCCOPY);
Sleep(10);
}
SelectObject(hBufferDC, hOldBrush);
SelectObject(hBufferDC, hOldPen);
SelectObject(hBufferDC, hBufferBmpOld);
DeleteObject(hPen);
DeleteObject(hBufferBmp);
DeleteDC(hBufferDC);
ReleaseDC(hWnd, hDC);
return 0;
} | [
"[email protected]"
] | |
bbc4fae1035af1f6a89ee812a68a61d6acc8ad63 | cabc5060dddc4c91c7e5d1a3c2748795881872fa | /gtaRenderHook/D3D1XDefaultPipeline.h | c1187bc83af6da17615923692fdb708741fa953a | [] | no_license | wgwjifeng/gtaRenderHook | bb670f24dd56c3c1771f6c1218cabcc204a9ac6f | 517d91df8efcc9cb2c3edffbb5209539cbe27581 | refs/heads/master | 2020-04-06T18:36:40.775939 | 2016-08-25T01:08:27 | 2016-08-25T01:08:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 563 | h | #ifndef D3D1XDefaultPipeline_h__
#define D3D1XDefaultPipeline_h__
#include "D3D1XPipeline.h"
class CD3D1XDefaultPipeline: public CD3D1XPipeline
{
public:
CD3D1XDefaultPipeline(CD3DRenderer* pRenderer);
~CD3D1XDefaultPipeline();
bool Instance (void *object, RxD3D9ResEntryHeader *resEntryHeader, RwBool reinstance);
void Render (RwResEntry *repEntry, void *object, RwUInt8 type, RwUInt32 flags);
private:
ID3D11Buffer* m_pMaterialDataBuffer = nullptr;
CD3D1XShader* m_pHS = nullptr;
CD3D1XShader* m_pDS = nullptr;
};
#endif // D3D1XDefaultPipeline_h__
| [
"[email protected]"
] | |
def8db7fb0c00c4dc545945cafe9510af613dad5 | 318ca14be2b86001f2b6721684f29d8a42a3264c | /src/test/test_bitcoin.cpp | d80fd781080b17c357770ae005917a84544f4ee0 | [
"MIT"
] | permissive | raskul/CROWN | 6ab6fc011c62723b088467953af5897396664156 | 1935b1da72f3db3d7dd472fd52ae176e10526f52 | refs/heads/master | 2020-07-03T16:51:29.644673 | 2014-07-09T21:45:44 | 2014-07-09T21:45:44 | 21,670,068 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,747 | cpp | #define BOOST_TEST_MODULE Crown Test Suite
#include <boost/test/unit_test.hpp>
#include <boost/filesystem.hpp>
#include "db.h"
#include "txdb.h"
#include "main.h"
#include "wallet.h"
#include "util.h"
CWallet* pwalletMain;
CClientUIInterface uiInterface;
extern bool fPrintToConsole;
extern void noui_connect();
struct TestingSetup {
CCoinsViewDB *pcoinsdbview;
boost::filesystem::path pathTemp;
boost::thread_group threadGroup;
TestingSetup() {
fPrintToDebugger = true; // don't want to write to debug.log file
noui_connect();
bitdb.MakeMock();
pathTemp = GetTempPath() / strprintf("test_Crown_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
boost::filesystem::create_directories(pathTemp);
mapArgs["-datadir"] = pathTemp.string();
pblocktree = new CBlockTreeDB(1 << 20, true);
pcoinsdbview = new CCoinsViewDB(1 << 23, true);
pcoinsTip = new CCoinsViewCache(*pcoinsdbview);
InitBlockIndex();
bool fFirstRun;
pwalletMain = new CWallet("wallet.dat");
pwalletMain->LoadWallet(fFirstRun);
RegisterWallet(pwalletMain);
nScriptCheckThreads = 3;
for (int i=0; i < nScriptCheckThreads-1; i++)
threadGroup.create_thread(&ThreadScriptCheck);
}
~TestingSetup()
{
threadGroup.interrupt_all();
threadGroup.join_all();
delete pwalletMain;
pwalletMain = NULL;
delete pcoinsTip;
delete pcoinsdbview;
delete pblocktree;
bitdb.Flush(true);
boost::filesystem::remove_all(pathTemp);
}
};
BOOST_GLOBAL_FIXTURE(TestingSetup);
void Shutdown(void* parg)
{
exit(0);
}
void StartShutdown()
{
exit(0);
}
| [
"[email protected]"
] | |
bcbacd4cb2533bacf4728e8c90cdefaccf24c220 | 39f11f3d1315f213d99dcc2f074b686037cb5815 | /archive/partiel/All_in_all.cpp | 934eca89ca8039cb20bf5695f0e18cf561f125bb | [] | no_license | jdumas/acm | 84985c127a4edb72c4315ab0ca95b95038024e06 | 127d5497cd07574a84c1b56ecbe064daed5da059 | refs/heads/master | 2020-05-30T04:14:28.645335 | 2011-06-09T17:15:03 | 2011-06-09T17:15:03 | 1,560,744 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 330 | cpp | #include <iostream>
#include <string>
using namespace std;
bool is_sub(string & s, string & t) {
unsigned i=0,j;
for (j = 0; i < s.size() && j < t.size(); ++j)
if (s[i] == t[j]) ++i;
return (i >= s.size());
}
int main(void) {
string s,t;
while (cin >> s >> t)
cout << (is_sub(s,t) ? "Yes" : "No") << endl;
return 0;
}
| [
"[email protected]"
] | |
b08a3a3ba1d94c477416f6d0baad3a1926fa190e | 1634d4f09e2db354cf9befa24e5340ff092fd9db | /Wonderland/Wonderland/Editor/Old -ignored-/Plug/FluxPlugBase.h | e238815f9cfd632c8b72008f5eff6865aca8842c | [
"MIT"
] | permissive | RodrigoHolztrattner/Wonderland | cd5a977bec96fda1851119a8de47b40b74bd85b7 | ffb71d47c1725e7cd537e2d1380962b5dfdc3d75 | refs/heads/master | 2021-01-10T15:29:21.940124 | 2017-10-01T17:12:57 | 2017-10-01T17:12:57 | 84,469,251 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,682 | h | ////////////////////////////////////////////////////////////////////////////////
// Filename: FluxPlugBase.h
////////////////////////////////////////////////////////////////////////////////
#pragma once
//////////////
// INCLUDES //
//////////////
#include <string>
#include "..\Variable\FluxVariable.h"
///////////////
// NAMESPACE //
///////////////
/////////////
// DEFINES //
/////////////
//
class LinkObject;
////////////
// GLOBAL //
////////////
////////////////////////////////////////////////////////////////////////////////
// Class name: FluxPlugBase
////////////////////////////////////////////////////////////////////////////////
class FluxPlugBase
{
/////////////
// DEFINES //
public: /////
// The exec link type
struct ExecLinkPlug
{
// The link object (where to continue the execution)
LinkObject* link;
};
// The variable plug type
struct VariablePlug
{
// The variable itself
FluxVariable* variable;
};
// The type of plug
enum class PlugType
{
Undefined,
ExecLink,
Variable
};
//////////////////
// CONSTRUCTORS //
public: //////////
// Constructor / destructor
FluxPlugBase();
FluxPlugBase(const FluxPlugBase& _other);
~FluxPlugBase();
//////////////////
// MAIN METHODS //
public: //////////
// Set the plug name
void SetPlugName(std::string _name);
// Get the plug name
std::string GetPlugName();
// Set the plug type
void SetPlugType(PlugType _type);
// Return the plug type
PlugType GetPlugType();
// Compare 2 variables (type)
bool IsFromType(PlugType _type);
///////////////
// VARIABLES //
private: //////
// The plug type
PlugType m_PlugType;
// The plug name
std::string m_PlugName;
};
| [
"[email protected]"
] | |
5347d5bed4337945e35a79739d22318433948399 | f7452fa005516ebf5189e99a571ea48eaf013762 | /CoinFlip/debug/moc_mypushbutton.cpp | 30a4a67717bc7e80d1ca0b33f666c74404e39728 | [] | no_license | YehongHuinb/MFC-library | 3d39d78bf8f86fc253d171ee79c6f21efd94e330 | 33875914167d076ef99c53c55ac198c88ff8a7ea | refs/heads/master | 2020-12-08T19:11:08.064850 | 2020-04-15T13:09:19 | 2020-04-15T13:09:19 | 233,069,252 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,654 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'mypushbutton.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.9.9)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../mypushbutton.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'mypushbutton.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.9.9. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_MyPushButton_t {
QByteArrayData data[1];
char stringdata0[13];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_MyPushButton_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_MyPushButton_t qt_meta_stringdata_MyPushButton = {
{
QT_MOC_LITERAL(0, 0, 12) // "MyPushButton"
},
"MyPushButton"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_MyPushButton[] = {
// content:
7, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
0 // eod
};
void MyPushButton::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
Q_UNUSED(_o);
Q_UNUSED(_id);
Q_UNUSED(_c);
Q_UNUSED(_a);
}
const QMetaObject MyPushButton::staticMetaObject = {
{ &QPushButton::staticMetaObject, qt_meta_stringdata_MyPushButton.data,
qt_meta_data_MyPushButton, qt_static_metacall, nullptr, nullptr}
};
const QMetaObject *MyPushButton::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *MyPushButton::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
if (!strcmp(_clname, qt_meta_stringdata_MyPushButton.stringdata0))
return static_cast<void*>(this);
return QPushButton::qt_metacast(_clname);
}
int MyPushButton::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QPushButton::qt_metacall(_c, _id, _a);
return _id;
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE
| [
"[email protected]"
] | |
33945be9ad10793d7bc17525c72fd6044e8f7546 | 2485744b38ff8a3cd59d4da4e26648c5bfae78fe | /wcd.cpp | 7a35889729e71a0fc107e6ff8aac1cd72902e396 | [] | no_license | rammendozaa/Intermedios | a47dc527e39190046c8d87f0df5c519d658508d7 | 0c98ca8c293e8a4a9f995cd37d261e19189bd3df | refs/heads/master | 2020-04-06T12:48:17.868890 | 2018-11-24T06:03:17 | 2018-11-24T06:03:17 | 148,851,273 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,740 | cpp | #include <iostream>
#include <utility>
#include <vector>
#include <cmath>
using namespace std;
vector <long long int> sacarPrimos(long long int a)
{
long long int raiz = sqrt(a);
vector <long long int> primos;
for(int i = 2 ; i <= raiz ; i++)
{
while(a % i == 0)
{
primos.push_back(i);
a /= i;
}
}
if(a > 1)
primos.push_back(a);
return primos;
}
int main(void)
{
int numeros;
cin >> numeros;
vector <pair <long long int, long long int> > valores;
long long int auxA, auxB;
while(numeros--)
{
cin >> auxA >> auxB;
valores.push_back(make_pair(auxA, auxB));
}
vector <long long int> fpA = sacarPrimos(valores[0].first);
vector <long long int> fpB = sacarPrimos(valores[0].second);
long long int factorA, factorB;
vector <long long int> posibles;
for(auto b : fpA)
{
for(auto a : valores)
{
if(a.first % b == 0 || a.second % b == 0)
factorA = b;
else
{
factorA = -1;
break;
}
}
if(factorA != -1)
posibles.push_back(factorA);
}
for(auto b : fpB)
{
for(auto a : valores)
{
if(a.first % b == 0 || a.second % b == 0)
factorB = b;
else
{
factorB = -1;
break;
}
}
if(factorB != -1)
posibles.push_back(factorB);
}
(posibles.size() == 0) ? cout << "-1\n" : cout << posibles[0] << "\n";
return 0;
}
| [
"[email protected]"
] | |
9d394346be19a11b5002b5bf45063cd6f216188f | d49689f78c4b5d6958b1a61a43c0b85ace3dcf4e | /practice/2020/9-2.cpp | 4f767bd73b7033187fd61d7c63b6b3b0977e05e5 | [] | no_license | sp3arm4n/CPP-Programming | f6c164075a5d9645533f4d321afc4a1655068fc3 | 8f37e234268d49a55e2ecaf9b8c98bf9e8369b89 | refs/heads/main | 2023-06-11T22:07:49.711653 | 2021-07-09T15:51:31 | 2021-07-09T15:51:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 712 | cpp | #include <iostream>
using namespace std;
class point {
private:
int x, y;
public:
point(int p1, int p2) { x = p1; y = p2; }
float two_distance(point p2);
friend float distance2(point p1, point p2); // point 클래스의 프렌드
};
float point::two_distance(point p2) {
float a = (x - p2.x) * (x - p2.x);
float b = (y - p2.y) * (y - p2.y);
return sqrt(a + b);
}
float distance2(point p1, point p2) {
float a = (p1.x - p2.x) * (p1.x - p2.x);
float b = (p1.y - p2.y) * (p1.y - p2.y);
return sqrt(a + b);
}
int main() {
point p1(3, 4), p2(-1, -5);
cout << "p1과 p2 거리 = " << p1.two_distance(p2) << endl;
cout << "p1과 p2 거리 = " << distance2(p1,p2)<< endl;
}
| [
"[email protected]"
] | |
43a480f2c0a860704ec02481e944526f0d893913 | d7de2814fa9f482e025e0e126b397587dfbfe2f0 | /common/src/imgui/cximgui.cpp | 630c4c8b216a2a6b2a000184678b5f01f257792f | [] | no_license | pieceman/YZXY | 2dcca96356a61ffad2c84f091438b024cfb021eb | f30649a6b0dfe6d91efe1bc9c60da8e9b92bdb3e | refs/heads/master | 2021-02-13T14:38:08.771283 | 2020-02-29T03:21:27 | 2020-02-29T03:21:27 | 244,704,970 | 1 | 0 | null | 2020-03-03T17:57:30 | 2020-03-03T17:57:29 | null | UTF-8 | C++ | false | false | 139,084 | cpp | #include "cximgui.h"
#include <imgui.h>
#include <string.h>
//ImGuiContext* CreateContext(ImFontAtlas* shared_font_atlas);
//UnSupported CreateContext
//void DestroyContext(ImGuiContext* ctx);
//UnSupported DestroyContext
//ImGuiContext* GetCurrentContext();
int cximgui_GetCurrentContext(lua_State* L) {
ImGuiContext* __ret__ = ImGui::GetCurrentContext();
return 0;
};
//void SetCurrentContext(ImGuiContext* ctx);
//UnSupported SetCurrentContext
//bool DebugCheckVersionAndDataLayout(const char* version_str,size_t sz_io,size_t sz_style,size_t sz_vec2,size_t sz_vec4,size_t sz_drawvert);
int cximgui_DebugCheckVersionAndDataLayout_6_siiiii(lua_State* L) {
int __argi__ = 1;
const char* version_str = lua_tostring(L, __argi__++);
size_t sz_io = (size_t)lua_tointeger(L, __argi__++);
size_t sz_style = (size_t)lua_tointeger(L, __argi__++);
size_t sz_vec2 = (size_t)lua_tointeger(L, __argi__++);
size_t sz_vec4 = (size_t)lua_tointeger(L, __argi__++);
size_t sz_drawvert = (size_t)lua_tointeger(L, __argi__++);
bool __ret__ = ImGui::DebugCheckVersionAndDataLayout(version_str, sz_io, sz_style, sz_vec2, sz_vec4, sz_drawvert);
lua_pushboolean(L, __ret__);
return 1;
};
//ImGuiIO& GetIO();
int cximgui_GetIO(lua_State* L) {
ImGuiIO& __ret__ = ImGui::GetIO();
return 0;
};
//ImGuiStyle& GetStyle();
int cximgui_GetStyle(lua_State* L) {
ImGuiStyle& __ret__ = ImGui::GetStyle();
return 0;
};
//void NewFrame();
int cximgui_NewFrame(lua_State* L) {
ImGui::NewFrame();
return 0;
};
//void EndFrame();
int cximgui_EndFrame(lua_State* L) {
ImGui::EndFrame();
return 0;
};
//void Render();
int cximgui_Render(lua_State* L) {
ImGui::Render();
return 0;
};
//ImDrawData* GetDrawData();
int cximgui_GetDrawData(lua_State* L) {
ImDrawData* __ret__ = ImGui::GetDrawData();
return 0;
};
//void ShowDemoWindow(bool* p_open);
int cximgui_ShowDemoWindow_1_bp(lua_State* L) {
int __argi__ = 1;
bool p_open = lua_toboolean(L, __argi__++);
ImGui::ShowDemoWindow(&p_open);
lua_pushboolean(L, p_open);
return 1;
};
//void ShowMetricsWindow(bool* p_open);
int cximgui_ShowMetricsWindow_1_bp(lua_State* L) {
int __argi__ = 1;
bool p_open = lua_toboolean(L, __argi__++);
ImGui::ShowMetricsWindow(&p_open);
lua_pushboolean(L, p_open);
return 1;
};
//void ShowStyleEditor(ImGuiStyle* ref);
//UnSupported ShowStyleEditor
//bool ShowStyleSelector(const char* label);
int cximgui_ShowStyleSelector_1_s(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
bool __ret__ = ImGui::ShowStyleSelector(label);
lua_pushboolean(L, __ret__);
return 1;
};
//void ShowFontSelector(const char* label);
int cximgui_ShowFontSelector_1_s(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
ImGui::ShowFontSelector(label);
return 0;
};
//void ShowUserGuide();
int cximgui_ShowUserGuide(lua_State* L) {
ImGui::ShowUserGuide();
return 0;
};
//const char* GetVersion();
int cximgui_GetVersion(lua_State* L) {
const char* __ret__ = ImGui::GetVersion();
lua_pushstring(L, __ret__);
return 1;
};
//void StyleColorsDark(ImGuiStyle* dst);
//UnSupported StyleColorsDark
//void StyleColorsClassic(ImGuiStyle* dst);
//UnSupported StyleColorsClassic
//void StyleColorsLight(ImGuiStyle* dst);
//UnSupported StyleColorsLight
//bool Begin(const char* name,bool* p_open,ImGuiWindowFlags flags);
int cximgui_Begin_3_sbpi(lua_State* L) {
int __argi__ = 1;
const char* name = lua_tostring(L, __argi__++);
bool p_open = lua_toboolean(L, __argi__++);
ImGuiWindowFlags flags = (ImGuiWindowFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::Begin(name, &p_open, flags);
lua_pushboolean(L, __ret__);
lua_pushboolean(L, p_open);
return 2;
};
//void End();
int cximgui_End(lua_State* L) {
ImGui::End();
return 0;
};
//bool BeginChild(const char* str_id,const ImVec2& size,bool border,ImGuiWindowFlags flags);
int cximgui_BeginChild_4_sv2bi(lua_State* L) {
int __argi__ = 1;
const char* str_id = lua_tostring(L, __argi__++);
ImVec2 size_def = ImVec2(0, 0);
ImVec2 size;
size.x = (float)luaL_optnumber(L, __argi__, size_def.x);
size.y = (float)luaL_optnumber(L, __argi__ + 1, size_def.y);
if (size.x != size_def.x || size.y != size_def.y) __argi__ += 2;
bool border = lua_toboolean(L, __argi__++);
ImGuiWindowFlags flags = (ImGuiWindowFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::BeginChild(str_id, size, border, flags);
lua_pushboolean(L, __ret__);
return 1;
};
//bool BeginChild(ImGuiID id,const ImVec2& size,bool border,ImGuiWindowFlags flags);
int cximgui_BeginChild_4_iv2bi(lua_State* L) {
int __argi__ = 1;
ImGuiID id = (ImGuiID)lua_tointeger(L, __argi__++);
ImVec2 size_def = ImVec2(0, 0);
ImVec2 size;
size.x = (float)luaL_optnumber(L, __argi__, size_def.x);
size.y = (float)luaL_optnumber(L, __argi__ + 1, size_def.y);
if (size.x != size_def.x || size.y != size_def.y) __argi__ += 2;
bool border = lua_toboolean(L, __argi__++);
ImGuiWindowFlags flags = (ImGuiWindowFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::BeginChild(id, size, border, flags);
lua_pushboolean(L, __ret__);
return 1;
};
//void EndChild();
int cximgui_EndChild(lua_State* L) {
ImGui::EndChild();
return 0;
};
//bool IsWindowAppearing();
int cximgui_IsWindowAppearing(lua_State* L) {
bool __ret__ = ImGui::IsWindowAppearing();
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsWindowCollapsed();
int cximgui_IsWindowCollapsed(lua_State* L) {
bool __ret__ = ImGui::IsWindowCollapsed();
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsWindowFocused(ImGuiFocusedFlags flags);
int cximgui_IsWindowFocused_1_i(lua_State* L) {
int __argi__ = 1;
ImGuiFocusedFlags flags = (ImGuiFocusedFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::IsWindowFocused(flags);
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsWindowHovered(ImGuiHoveredFlags flags);
int cximgui_IsWindowHovered_1_i(lua_State* L) {
int __argi__ = 1;
ImGuiHoveredFlags flags = (ImGuiHoveredFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::IsWindowHovered(flags);
lua_pushboolean(L, __ret__);
return 1;
};
//ImDrawList* GetWindowDrawList();
int cximgui_GetWindowDrawList(lua_State* L) {
ImDrawList* __ret__ = ImGui::GetWindowDrawList();
return 0;
};
//float GetWindowDpiScale();
int cximgui_GetWindowDpiScale(lua_State* L) {
float __ret__ = ImGui::GetWindowDpiScale();
lua_pushnumber(L, __ret__);
return 1;
};
//ImGuiViewport* GetWindowViewport();
int cximgui_GetWindowViewport(lua_State* L) {
ImGuiViewport* __ret__ = ImGui::GetWindowViewport();
return 0;
};
//ImVec2 GetWindowPos();
int cximgui_GetWindowPos(lua_State* L) {
ImVec2 __ret__ = ImGui::GetWindowPos();
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//ImVec2 GetWindowSize();
int cximgui_GetWindowSize(lua_State* L) {
ImVec2 __ret__ = ImGui::GetWindowSize();
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//float GetWindowWidth();
int cximgui_GetWindowWidth(lua_State* L) {
float __ret__ = ImGui::GetWindowWidth();
lua_pushnumber(L, __ret__);
return 1;
};
//float GetWindowHeight();
int cximgui_GetWindowHeight(lua_State* L) {
float __ret__ = ImGui::GetWindowHeight();
lua_pushnumber(L, __ret__);
return 1;
};
//ImVec2 GetContentRegionMax();
int cximgui_GetContentRegionMax(lua_State* L) {
ImVec2 __ret__ = ImGui::GetContentRegionMax();
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//ImVec2 GetContentRegionAvail();
int cximgui_GetContentRegionAvail(lua_State* L) {
ImVec2 __ret__ = ImGui::GetContentRegionAvail();
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//float GetContentRegionAvailWidth();
int cximgui_GetContentRegionAvailWidth(lua_State* L) {
float __ret__ = ImGui::GetContentRegionAvailWidth();
lua_pushnumber(L, __ret__);
return 1;
};
//ImVec2 GetWindowContentRegionMin();
int cximgui_GetWindowContentRegionMin(lua_State* L) {
ImVec2 __ret__ = ImGui::GetWindowContentRegionMin();
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//ImVec2 GetWindowContentRegionMax();
int cximgui_GetWindowContentRegionMax(lua_State* L) {
ImVec2 __ret__ = ImGui::GetWindowContentRegionMax();
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//float GetWindowContentRegionWidth();
int cximgui_GetWindowContentRegionWidth(lua_State* L) {
float __ret__ = ImGui::GetWindowContentRegionWidth();
lua_pushnumber(L, __ret__);
return 1;
};
//void SetNextWindowPos(const ImVec2& pos,ImGuiCond cond,const ImVec2& pivot);
int cximgui_SetNextWindowPos_3_v2iv2(lua_State* L) {
int __argi__ = 1;
ImVec2 pos;
pos.x = (float)lua_tonumber(L, __argi__++);
pos.y = (float)lua_tonumber(L, __argi__++);
ImGuiCond cond = (ImGuiCond)luaL_optinteger(L, __argi__++, 0);
ImVec2 pivot_def = ImVec2(0, 0);
ImVec2 pivot;
pivot.x = (float)luaL_optnumber(L, __argi__, pivot_def.x);
pivot.y = (float)luaL_optnumber(L, __argi__ + 1, pivot_def.y);
if (pivot.x != pivot_def.x || pivot.y != pivot_def.y) __argi__ += 2;
ImGui::SetNextWindowPos(pos, cond, pivot);
return 0;
};
//void SetNextWindowSize(const ImVec2& size,ImGuiCond cond);
int cximgui_SetNextWindowSize_2_v2i(lua_State* L) {
int __argi__ = 1;
ImVec2 size;
size.x = (float)lua_tonumber(L, __argi__++);
size.y = (float)lua_tonumber(L, __argi__++);
ImGuiCond cond = (ImGuiCond)luaL_optinteger(L, __argi__++, 0);
ImGui::SetNextWindowSize(size, cond);
return 0;
};
//void SetNextWindowSizeConstraints(const ImVec2& size_min,const ImVec2& size_max,ImGuiSizeCallback custom_callback,void* custom_callback_data);
//UnSupported SetNextWindowSizeConstraints
//void SetNextWindowContentSize(const ImVec2& size);
int cximgui_SetNextWindowContentSize_1_v2(lua_State* L) {
int __argi__ = 1;
ImVec2 size;
size.x = (float)lua_tonumber(L, __argi__++);
size.y = (float)lua_tonumber(L, __argi__++);
ImGui::SetNextWindowContentSize(size);
return 0;
};
//void SetNextWindowCollapsed(bool collapsed,ImGuiCond cond);
int cximgui_SetNextWindowCollapsed_2_bi(lua_State* L) {
int __argi__ = 1;
bool collapsed = lua_toboolean(L, __argi__++);
ImGuiCond cond = (ImGuiCond)luaL_optinteger(L, __argi__++, 0);
ImGui::SetNextWindowCollapsed(collapsed, cond);
return 0;
};
//void SetNextWindowFocus();
int cximgui_SetNextWindowFocus(lua_State* L) {
ImGui::SetNextWindowFocus();
return 0;
};
//void SetNextWindowBgAlpha(float alpha);
int cximgui_SetNextWindowBgAlpha_1_n(lua_State* L) {
int __argi__ = 1;
float alpha = (float)lua_tonumber(L, __argi__++);
ImGui::SetNextWindowBgAlpha(alpha);
return 0;
};
//void SetNextWindowViewport(ImGuiID viewport_id);
int cximgui_SetNextWindowViewport_1_i(lua_State* L) {
int __argi__ = 1;
ImGuiID viewport_id = (ImGuiID)lua_tointeger(L, __argi__++);
ImGui::SetNextWindowViewport(viewport_id);
return 0;
};
//void SetWindowPos(const ImVec2& pos,ImGuiCond cond);
int cximgui_SetWindowPos_2_v2i(lua_State* L) {
int __argi__ = 1;
ImVec2 pos;
pos.x = (float)lua_tonumber(L, __argi__++);
pos.y = (float)lua_tonumber(L, __argi__++);
ImGuiCond cond = (ImGuiCond)luaL_optinteger(L, __argi__++, 0);
ImGui::SetWindowPos(pos, cond);
return 0;
};
//void SetWindowSize(const ImVec2& size,ImGuiCond cond);
int cximgui_SetWindowSize_2_v2i(lua_State* L) {
int __argi__ = 1;
ImVec2 size;
size.x = (float)lua_tonumber(L, __argi__++);
size.y = (float)lua_tonumber(L, __argi__++);
ImGuiCond cond = (ImGuiCond)luaL_optinteger(L, __argi__++, 0);
ImGui::SetWindowSize(size, cond);
return 0;
};
//void SetWindowCollapsed(bool collapsed,ImGuiCond cond);
int cximgui_SetWindowCollapsed_2_bi(lua_State* L) {
int __argi__ = 1;
bool collapsed = lua_toboolean(L, __argi__++);
ImGuiCond cond = (ImGuiCond)luaL_optinteger(L, __argi__++, 0);
ImGui::SetWindowCollapsed(collapsed, cond);
return 0;
};
//void SetWindowFocus();
int cximgui_SetWindowFocus(lua_State* L) {
ImGui::SetWindowFocus();
return 0;
};
//void SetWindowFontScale(float scale);
int cximgui_SetWindowFontScale_1_n(lua_State* L) {
int __argi__ = 1;
float scale = (float)lua_tonumber(L, __argi__++);
ImGui::SetWindowFontScale(scale);
return 0;
};
//void SetWindowPos(const char* name,const ImVec2& pos,ImGuiCond cond);
int cximgui_SetWindowPos_3_sv2i(lua_State* L) {
int __argi__ = 1;
const char* name = lua_tostring(L, __argi__++);
ImVec2 pos;
pos.x = (float)lua_tonumber(L, __argi__++);
pos.y = (float)lua_tonumber(L, __argi__++);
ImGuiCond cond = (ImGuiCond)luaL_optinteger(L, __argi__++, 0);
ImGui::SetWindowPos(name, pos, cond);
return 0;
};
//void SetWindowSize(const char* name,const ImVec2& size,ImGuiCond cond);
int cximgui_SetWindowSize_3_sv2i(lua_State* L) {
int __argi__ = 1;
const char* name = lua_tostring(L, __argi__++);
ImVec2 size;
size.x = (float)lua_tonumber(L, __argi__++);
size.y = (float)lua_tonumber(L, __argi__++);
ImGuiCond cond = (ImGuiCond)luaL_optinteger(L, __argi__++, 0);
ImGui::SetWindowSize(name, size, cond);
return 0;
};
//void SetWindowCollapsed(const char* name,bool collapsed,ImGuiCond cond);
int cximgui_SetWindowCollapsed_3_sbi(lua_State* L) {
int __argi__ = 1;
const char* name = lua_tostring(L, __argi__++);
bool collapsed = lua_toboolean(L, __argi__++);
ImGuiCond cond = (ImGuiCond)luaL_optinteger(L, __argi__++, 0);
ImGui::SetWindowCollapsed(name, collapsed, cond);
return 0;
};
//void SetWindowFocus(const char* name);
int cximgui_SetWindowFocus_1_s(lua_State* L) {
int __argi__ = 1;
const char* name = lua_tostring(L, __argi__++);
ImGui::SetWindowFocus(name);
return 0;
};
//float GetScrollX();
int cximgui_GetScrollX(lua_State* L) {
float __ret__ = ImGui::GetScrollX();
lua_pushnumber(L, __ret__);
return 1;
};
//float GetScrollY();
int cximgui_GetScrollY(lua_State* L) {
float __ret__ = ImGui::GetScrollY();
lua_pushnumber(L, __ret__);
return 1;
};
//float GetScrollMaxX();
int cximgui_GetScrollMaxX(lua_State* L) {
float __ret__ = ImGui::GetScrollMaxX();
lua_pushnumber(L, __ret__);
return 1;
};
//float GetScrollMaxY();
int cximgui_GetScrollMaxY(lua_State* L) {
float __ret__ = ImGui::GetScrollMaxY();
lua_pushnumber(L, __ret__);
return 1;
};
//void SetScrollX(float scroll_x);
int cximgui_SetScrollX_1_n(lua_State* L) {
int __argi__ = 1;
float scroll_x = (float)lua_tonumber(L, __argi__++);
ImGui::SetScrollX(scroll_x);
return 0;
};
//void SetScrollY(float scroll_y);
int cximgui_SetScrollY_1_n(lua_State* L) {
int __argi__ = 1;
float scroll_y = (float)lua_tonumber(L, __argi__++);
ImGui::SetScrollY(scroll_y);
return 0;
};
//void SetScrollHereY(float center_y_ratio);
int cximgui_SetScrollHereY_1_n(lua_State* L) {
int __argi__ = 1;
float center_y_ratio = (float)luaL_optnumber(L, __argi__++, 0.5f);
ImGui::SetScrollHereY(center_y_ratio);
return 0;
};
//void SetScrollFromPosY(float pos_y,float center_y_ratio);
int cximgui_SetScrollFromPosY_2_nn(lua_State* L) {
int __argi__ = 1;
float pos_y = (float)lua_tonumber(L, __argi__++);
float center_y_ratio = (float)luaL_optnumber(L, __argi__++, 0.5f);
ImGui::SetScrollFromPosY(pos_y, center_y_ratio);
return 0;
};
//void PushFont(ImFont* font);
//UnSupported PushFont
//void PopFont();
int cximgui_PopFont(lua_State* L) {
ImGui::PopFont();
return 0;
};
//void PushStyleColor(ImGuiCol idx,ImU32 col);
int cximgui_PushStyleColor_2_ii(lua_State* L) {
int __argi__ = 1;
ImGuiCol idx = (ImGuiCol)lua_tointeger(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
ImGui::PushStyleColor(idx, col);
return 0;
};
//void PushStyleColor(ImGuiCol idx,const ImVec4& col);
int cximgui_PushStyleColor_2_iv4(lua_State* L) {
int __argi__ = 1;
ImGuiCol idx = (ImGuiCol)lua_tointeger(L, __argi__++);
ImVec4 col;
col.x = (float)lua_tonumber(L, __argi__++);
col.y = (float)lua_tonumber(L, __argi__++);
col.z = (float)lua_tonumber(L, __argi__++);
col.w = (float)lua_tonumber(L, __argi__++);
ImGui::PushStyleColor(idx, col);
return 0;
};
//void PopStyleColor(int count);
int cximgui_PopStyleColor_1_i(lua_State* L) {
int __argi__ = 1;
int count = (int)luaL_optinteger(L, __argi__++, 1);
ImGui::PopStyleColor(count);
return 0;
};
//void PushStyleVar(ImGuiStyleVar idx,float val);
int cximgui_PushStyleVar_2_in(lua_State* L) {
int __argi__ = 1;
ImGuiStyleVar idx = (ImGuiStyleVar)lua_tointeger(L, __argi__++);
float val = (float)lua_tonumber(L, __argi__++);
ImGui::PushStyleVar(idx, val);
return 0;
};
//void PushStyleVar(ImGuiStyleVar idx,const ImVec2& val);
int cximgui_PushStyleVar_2_iv2(lua_State* L) {
int __argi__ = 1;
ImGuiStyleVar idx = (ImGuiStyleVar)lua_tointeger(L, __argi__++);
ImVec2 val;
val.x = (float)lua_tonumber(L, __argi__++);
val.y = (float)lua_tonumber(L, __argi__++);
ImGui::PushStyleVar(idx, val);
return 0;
};
//void PopStyleVar(int count);
int cximgui_PopStyleVar_1_i(lua_State* L) {
int __argi__ = 1;
int count = (int)luaL_optinteger(L, __argi__++, 1);
ImGui::PopStyleVar(count);
return 0;
};
//const ImVec4& GetStyleColorVec4(ImGuiCol idx);
int cximgui_GetStyleColorVec4_1_i(lua_State* L) {
int __argi__ = 1;
ImGuiCol idx = (ImGuiCol)lua_tointeger(L, __argi__++);
const ImVec4& __ret__ = ImGui::GetStyleColorVec4(idx);
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
lua_pushnumber(L, __ret__.z);
lua_pushnumber(L, __ret__.w);
return 4;
};
//ImFont* GetFont();
int cximgui_GetFont(lua_State* L) {
ImFont* __ret__ = ImGui::GetFont();
return 0;
};
//float GetFontSize();
int cximgui_GetFontSize(lua_State* L) {
float __ret__ = ImGui::GetFontSize();
lua_pushnumber(L, __ret__);
return 1;
};
//ImVec2 GetFontTexUvWhitePixel();
int cximgui_GetFontTexUvWhitePixel(lua_State* L) {
ImVec2 __ret__ = ImGui::GetFontTexUvWhitePixel();
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//ImU32 GetColorU32(ImGuiCol idx,float alpha_mul);
int cximgui_GetColorU32_2_in(lua_State* L) {
int __argi__ = 1;
ImGuiCol idx = (ImGuiCol)lua_tointeger(L, __argi__++);
float alpha_mul = (float)luaL_optnumber(L, __argi__++, 1.0f);
ImU32 __ret__ = ImGui::GetColorU32(idx, alpha_mul);
lua_pushinteger(L, __ret__);
return 1;
};
//ImU32 GetColorU32(const ImVec4& col);
int cximgui_GetColorU32_1_v4(lua_State* L) {
int __argi__ = 1;
ImVec4 col;
col.x = (float)lua_tonumber(L, __argi__++);
col.y = (float)lua_tonumber(L, __argi__++);
col.z = (float)lua_tonumber(L, __argi__++);
col.w = (float)lua_tonumber(L, __argi__++);
ImU32 __ret__ = ImGui::GetColorU32(col);
lua_pushinteger(L, __ret__);
return 1;
};
//ImU32 GetColorU32(ImU32 col);
int cximgui_GetColorU32_1_i(lua_State* L) {
int __argi__ = 1;
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
ImU32 __ret__ = ImGui::GetColorU32(col);
lua_pushinteger(L, __ret__);
return 1;
};
//void PushItemWidth(float item_width);
int cximgui_PushItemWidth_1_n(lua_State* L) {
int __argi__ = 1;
float item_width = (float)lua_tonumber(L, __argi__++);
ImGui::PushItemWidth(item_width);
return 0;
};
//void PopItemWidth();
int cximgui_PopItemWidth(lua_State* L) {
ImGui::PopItemWidth();
return 0;
};
//float CalcItemWidth();
int cximgui_CalcItemWidth(lua_State* L) {
float __ret__ = ImGui::CalcItemWidth();
lua_pushnumber(L, __ret__);
return 1;
};
//void PushTextWrapPos(float wrap_pos_x);
int cximgui_PushTextWrapPos_1_n(lua_State* L) {
int __argi__ = 1;
float wrap_pos_x = (float)luaL_optnumber(L, __argi__++, 0.0f);
ImGui::PushTextWrapPos(wrap_pos_x);
return 0;
};
//void PopTextWrapPos();
int cximgui_PopTextWrapPos(lua_State* L) {
ImGui::PopTextWrapPos();
return 0;
};
//void PushAllowKeyboardFocus(bool allow_keyboard_focus);
int cximgui_PushAllowKeyboardFocus_1_b(lua_State* L) {
int __argi__ = 1;
bool allow_keyboard_focus = lua_toboolean(L, __argi__++);
ImGui::PushAllowKeyboardFocus(allow_keyboard_focus);
return 0;
};
//void PopAllowKeyboardFocus();
int cximgui_PopAllowKeyboardFocus(lua_State* L) {
ImGui::PopAllowKeyboardFocus();
return 0;
};
//void PushButtonRepeat(bool repeat);
int cximgui_PushButtonRepeat_1_b(lua_State* L) {
int __argi__ = 1;
bool repeat = lua_toboolean(L, __argi__++);
ImGui::PushButtonRepeat(repeat);
return 0;
};
//void PopButtonRepeat();
int cximgui_PopButtonRepeat(lua_State* L) {
ImGui::PopButtonRepeat();
return 0;
};
//void Separator();
int cximgui_Separator(lua_State* L) {
ImGui::Separator();
return 0;
};
//void SameLine(float pos_x,float spacing_w);
int cximgui_SameLine_2_nn(lua_State* L) {
int __argi__ = 1;
float pos_x = (float)luaL_optnumber(L, __argi__++, 0.0f);
float spacing_w = (float)luaL_optnumber(L, __argi__++, -1.0f);
ImGui::SameLine(pos_x, spacing_w);
return 0;
};
//void NewLine();
int cximgui_NewLine(lua_State* L) {
ImGui::NewLine();
return 0;
};
//void Spacing();
int cximgui_Spacing(lua_State* L) {
ImGui::Spacing();
return 0;
};
//void Dummy(const ImVec2& size);
int cximgui_Dummy_1_v2(lua_State* L) {
int __argi__ = 1;
ImVec2 size;
size.x = (float)lua_tonumber(L, __argi__++);
size.y = (float)lua_tonumber(L, __argi__++);
ImGui::Dummy(size);
return 0;
};
//void Indent(float indent_w);
int cximgui_Indent_1_n(lua_State* L) {
int __argi__ = 1;
float indent_w = (float)luaL_optnumber(L, __argi__++, 0.0f);
ImGui::Indent(indent_w);
return 0;
};
//void Unindent(float indent_w);
int cximgui_Unindent_1_n(lua_State* L) {
int __argi__ = 1;
float indent_w = (float)luaL_optnumber(L, __argi__++, 0.0f);
ImGui::Unindent(indent_w);
return 0;
};
//void BeginGroup();
int cximgui_BeginGroup(lua_State* L) {
ImGui::BeginGroup();
return 0;
};
//void EndGroup();
int cximgui_EndGroup(lua_State* L) {
ImGui::EndGroup();
return 0;
};
//ImVec2 GetCursorPos();
int cximgui_GetCursorPos(lua_State* L) {
ImVec2 __ret__ = ImGui::GetCursorPos();
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//float GetCursorPosX();
int cximgui_GetCursorPosX(lua_State* L) {
float __ret__ = ImGui::GetCursorPosX();
lua_pushnumber(L, __ret__);
return 1;
};
//float GetCursorPosY();
int cximgui_GetCursorPosY(lua_State* L) {
float __ret__ = ImGui::GetCursorPosY();
lua_pushnumber(L, __ret__);
return 1;
};
//void SetCursorPos(const ImVec2& local_pos);
int cximgui_SetCursorPos_1_v2(lua_State* L) {
int __argi__ = 1;
ImVec2 local_pos;
local_pos.x = (float)lua_tonumber(L, __argi__++);
local_pos.y = (float)lua_tonumber(L, __argi__++);
ImGui::SetCursorPos(local_pos);
return 0;
};
//void SetCursorPosX(float x);
int cximgui_SetCursorPosX_1_n(lua_State* L) {
int __argi__ = 1;
float x = (float)lua_tonumber(L, __argi__++);
ImGui::SetCursorPosX(x);
return 0;
};
//void SetCursorPosY(float y);
int cximgui_SetCursorPosY_1_n(lua_State* L) {
int __argi__ = 1;
float y = (float)lua_tonumber(L, __argi__++);
ImGui::SetCursorPosY(y);
return 0;
};
//ImVec2 GetCursorStartPos();
int cximgui_GetCursorStartPos(lua_State* L) {
ImVec2 __ret__ = ImGui::GetCursorStartPos();
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//ImVec2 GetCursorScreenPos();
int cximgui_GetCursorScreenPos(lua_State* L) {
ImVec2 __ret__ = ImGui::GetCursorScreenPos();
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//void SetCursorScreenPos(const ImVec2& pos);
int cximgui_SetCursorScreenPos_1_v2(lua_State* L) {
int __argi__ = 1;
ImVec2 pos;
pos.x = (float)lua_tonumber(L, __argi__++);
pos.y = (float)lua_tonumber(L, __argi__++);
ImGui::SetCursorScreenPos(pos);
return 0;
};
//void AlignTextToFramePadding();
int cximgui_AlignTextToFramePadding(lua_State* L) {
ImGui::AlignTextToFramePadding();
return 0;
};
//float GetTextLineHeight();
int cximgui_GetTextLineHeight(lua_State* L) {
float __ret__ = ImGui::GetTextLineHeight();
lua_pushnumber(L, __ret__);
return 1;
};
//float GetTextLineHeightWithSpacing();
int cximgui_GetTextLineHeightWithSpacing(lua_State* L) {
float __ret__ = ImGui::GetTextLineHeightWithSpacing();
lua_pushnumber(L, __ret__);
return 1;
};
//float GetFrameHeight();
int cximgui_GetFrameHeight(lua_State* L) {
float __ret__ = ImGui::GetFrameHeight();
lua_pushnumber(L, __ret__);
return 1;
};
//float GetFrameHeightWithSpacing();
int cximgui_GetFrameHeightWithSpacing(lua_State* L) {
float __ret__ = ImGui::GetFrameHeightWithSpacing();
lua_pushnumber(L, __ret__);
return 1;
};
//void PushID(const char* str_id);
int cximgui_PushID_1_s(lua_State* L) {
int __argi__ = 1;
const char* str_id = lua_tostring(L, __argi__++);
ImGui::PushID(str_id);
return 0;
};
//void PushID(const char* str_id_begin,const char* str_id_end);
int cximgui_PushID_2_ss(lua_State* L) {
int __argi__ = 1;
const char* str_id_begin = lua_tostring(L, __argi__++);
const char* str_id_end = lua_tostring(L, __argi__++);
ImGui::PushID(str_id_begin, str_id_end);
return 0;
};
//void PushID(const void* ptr_id);
//UnSupported PushID
//void PushID(int int_id);
int cximgui_PushID_1_i(lua_State* L) {
int __argi__ = 1;
int int_id = (int)lua_tointeger(L, __argi__++);
ImGui::PushID(int_id);
return 0;
};
//void PopID();
int cximgui_PopID(lua_State* L) {
ImGui::PopID();
return 0;
};
//ImGuiID GetID(const char* str_id);
int cximgui_GetID_1_s(lua_State* L) {
int __argi__ = 1;
const char* str_id = lua_tostring(L, __argi__++);
ImGuiID __ret__ = ImGui::GetID(str_id);
lua_pushinteger(L, __ret__);
return 1;
};
//ImGuiID GetID(const char* str_id_begin,const char* str_id_end);
int cximgui_GetID_2_ss(lua_State* L) {
int __argi__ = 1;
const char* str_id_begin = lua_tostring(L, __argi__++);
const char* str_id_end = lua_tostring(L, __argi__++);
ImGuiID __ret__ = ImGui::GetID(str_id_begin, str_id_end);
lua_pushinteger(L, __ret__);
return 1;
};
//ImGuiID GetID(const void* ptr_id);
//UnSupported GetID
//void TextUnformatted(const char* text,const char* text_end);
int cximgui_TextUnformatted_2_ss(lua_State* L) {
int __argi__ = 1;
const char* text = lua_tostring(L, __argi__++);
const char* text_end = luaL_optstring(L, __argi__++, NULL);
ImGui::TextUnformatted(text, text_end);
return 0;
};
//void Text(const char* fmt,... );
//UnSupported Text
//void TextV(const char* fmt,va_list args);
//UnSupported TextV
//void TextColored(const ImVec4& col,const char* fmt,... );
//UnSupported TextColored
//void TextColoredV(const ImVec4& col,const char* fmt,va_list args);
//UnSupported TextColoredV
//void TextDisabled(const char* fmt,... );
//UnSupported TextDisabled
//void TextDisabledV(const char* fmt,va_list args);
//UnSupported TextDisabledV
//void TextWrapped(const char* fmt,... );
//UnSupported TextWrapped
//void TextWrappedV(const char* fmt,va_list args);
//UnSupported TextWrappedV
//void LabelText(const char* label,const char* fmt,... );
//UnSupported LabelText
//void LabelTextV(const char* label,const char* fmt,va_list args);
//UnSupported LabelTextV
//void BulletText(const char* fmt,... );
//UnSupported BulletText
//void BulletTextV(const char* fmt,va_list args);
//UnSupported BulletTextV
//bool Button(const char* label,const ImVec2& size);
int cximgui_Button_2_sv2(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
ImVec2 size_def = ImVec2(0, 0);
ImVec2 size;
size.x = (float)luaL_optnumber(L, __argi__, size_def.x);
size.y = (float)luaL_optnumber(L, __argi__ + 1, size_def.y);
if (size.x != size_def.x || size.y != size_def.y) __argi__ += 2;
bool __ret__ = ImGui::Button(label, size);
lua_pushboolean(L, __ret__);
return 1;
};
//bool SmallButton(const char* label);
int cximgui_SmallButton_1_s(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
bool __ret__ = ImGui::SmallButton(label);
lua_pushboolean(L, __ret__);
return 1;
};
//bool InvisibleButton(const char* str_id,const ImVec2& size);
int cximgui_InvisibleButton_2_sv2(lua_State* L) {
int __argi__ = 1;
const char* str_id = lua_tostring(L, __argi__++);
ImVec2 size;
size.x = (float)lua_tonumber(L, __argi__++);
size.y = (float)lua_tonumber(L, __argi__++);
bool __ret__ = ImGui::InvisibleButton(str_id, size);
lua_pushboolean(L, __ret__);
return 1;
};
//bool ArrowButton(const char* str_id,ImGuiDir dir);
int cximgui_ArrowButton_2_si(lua_State* L) {
int __argi__ = 1;
const char* str_id = lua_tostring(L, __argi__++);
ImGuiDir dir = (ImGuiDir)lua_tointeger(L, __argi__++);
bool __ret__ = ImGui::ArrowButton(str_id, dir);
lua_pushboolean(L, __ret__);
return 1;
};
//void Image(ImTextureID user_texture_id,const ImVec2& size,const ImVec2& uv0,const ImVec2& uv1,const ImVec4& tint_col,const ImVec4& border_col);
//UnSupported Image
//bool ImageButton(ImTextureID user_texture_id,const ImVec2& size,const ImVec2& uv0,const ImVec2& uv1,int frame_padding,const ImVec4& bg_col,const ImVec4& tint_col);
//UnSupported ImageButton
//bool Checkbox(const char* label,bool* v);
int cximgui_Checkbox_2_sbp(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
bool v = lua_toboolean(L, __argi__++);
bool __ret__ = ImGui::Checkbox(label, &v);
lua_pushboolean(L, __ret__);
lua_pushboolean(L, v);
return 2;
};
//bool CheckboxFlags(const char* label,unsigned int* flags,unsigned int flags_value);
int cximgui_CheckboxFlags_3_sIpI(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
unsigned int flags = (unsigned int)lua_tointeger(L, __argi__++);
unsigned int flags_value = (unsigned int)lua_tointeger(L, __argi__++);
bool __ret__ = ImGui::CheckboxFlags(label, &flags, flags_value);
lua_pushboolean(L, __ret__);
return 1;
};
//bool RadioButton(const char* label,bool active);
int cximgui_RadioButton_2_sb(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
bool active = lua_toboolean(L, __argi__++);
bool __ret__ = ImGui::RadioButton(label, active);
lua_pushboolean(L, __ret__);
return 1;
};
//bool RadioButton(const char* label,int* v,int v_button);
int cximgui_RadioButton_3_sipi(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int v = (int)lua_tointeger(L, __argi__++);
int v_button = (int)lua_tointeger(L, __argi__++);
bool __ret__ = ImGui::RadioButton(label, &v, v_button);
lua_pushboolean(L, __ret__);
lua_pushinteger(L, v);
return 2;
};
//void ProgressBar(float fraction,const ImVec2& size_arg,const char* overlay);
int cximgui_ProgressBar_3_nv2s(lua_State* L) {
int __argi__ = 1;
float fraction = (float)lua_tonumber(L, __argi__++);
ImVec2 size_arg_def = ImVec2(-1, 0);
ImVec2 size_arg;
size_arg.x = (float)luaL_optnumber(L, __argi__, size_arg_def.x);
size_arg.y = (float)luaL_optnumber(L, __argi__ + 1, size_arg_def.y);
if (size_arg.x != size_arg_def.x || size_arg.y != size_arg_def.y) __argi__ += 2;
const char* overlay = luaL_optstring(L, __argi__++, NULL);
ImGui::ProgressBar(fraction, size_arg, overlay);
return 0;
};
//void Bullet();
int cximgui_Bullet(lua_State* L) {
ImGui::Bullet();
return 0;
};
//bool BeginCombo(const char* label,const char* preview_value,ImGuiComboFlags flags);
int cximgui_BeginCombo_3_ssi(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
const char* preview_value = lua_tostring(L, __argi__++);
ImGuiComboFlags flags = (ImGuiComboFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::BeginCombo(label, preview_value, flags);
lua_pushboolean(L, __ret__);
return 1;
};
//void EndCombo();
int cximgui_EndCombo(lua_State* L) {
ImGui::EndCombo();
return 0;
};
//bool Combo(const char* label,int* current_item,const char* const[],int items_count,int popup_max_height_in_items);
//UnSupported Combo
//bool Combo(const char* label,int* current_item,const char* items_separated_by_zeros,int popup_max_height_in_items);
int cximgui_Combo_4_sipsi(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int current_item = (int)lua_tointeger(L, __argi__++);
const char* items_separated_by_zeros = lua_tostring(L, __argi__++);
int popup_max_height_in_items = (int)luaL_optinteger(L, __argi__++, -1);
bool __ret__ = ImGui::Combo(label, ¤t_item, items_separated_by_zeros, popup_max_height_in_items);
lua_pushboolean(L, __ret__);
lua_pushinteger(L, current_item);
return 2;
};
//bool Combo(const char* label,int* current_item,bool @1@2,void* data,int items_count,int popup_max_height_in_items);
//UnSupported Combo
//bool DragFloat(const char* label,float* v,float v_speed,float v_min,float v_max,const char* format,float power);
int cximgui_DragFloat_7_snpnnnsn(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float v = (float)lua_tonumber(L, __argi__++);
float v_speed = (float)luaL_optnumber(L, __argi__++, 1.0f);
float v_min = (float)luaL_optnumber(L, __argi__++, 0.0f);
float v_max = (float)luaL_optnumber(L, __argi__++, 0.0f);
const char* format = luaL_optstring(L, __argi__++, "%.3f");
float power = (float)luaL_optnumber(L, __argi__++, 1.0f);
bool __ret__ = ImGui::DragFloat(label, &v, v_speed, v_min, v_max, format, power);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, v);
return 2;
};
//bool DragFloat2(const char* label,float v[2],float v_speed,float v_min,float v_max,const char* format,float power);
int cximgui_DragFloat2_7_snnnnsn(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float v[2];
v[0] = (float)lua_tonumber(L, __argi__++);
v[1] = (float)lua_tonumber(L, __argi__++);
float v_speed = (float)luaL_optnumber(L, __argi__++, 1.0f);
float v_min = (float)luaL_optnumber(L, __argi__++, 0.0f);
float v_max = (float)luaL_optnumber(L, __argi__++, 0.0f);
const char* format = luaL_optstring(L, __argi__++, "%.3f");
float power = (float)luaL_optnumber(L, __argi__++, 1.0f);
bool __ret__ = ImGui::DragFloat2(label, v, v_speed, v_min, v_max, format, power);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, v[0]);
lua_pushnumber(L, v[1]);
return 3;
};
//bool DragFloat3(const char* label,float v[3],float v_speed,float v_min,float v_max,const char* format,float power);
int cximgui_DragFloat3_7_snnnnsn(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float v[3];
v[0] = (float)lua_tonumber(L, __argi__++);
v[1] = (float)lua_tonumber(L, __argi__++);
v[2] = (float)lua_tonumber(L, __argi__++);
float v_speed = (float)luaL_optnumber(L, __argi__++, 1.0f);
float v_min = (float)luaL_optnumber(L, __argi__++, 0.0f);
float v_max = (float)luaL_optnumber(L, __argi__++, 0.0f);
const char* format = luaL_optstring(L, __argi__++, "%.3f");
float power = (float)luaL_optnumber(L, __argi__++, 1.0f);
bool __ret__ = ImGui::DragFloat3(label, v, v_speed, v_min, v_max, format, power);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, v[0]);
lua_pushnumber(L, v[1]);
lua_pushnumber(L, v[2]);
return 4;
};
//bool DragFloat4(const char* label,float v[4],float v_speed,float v_min,float v_max,const char* format,float power);
int cximgui_DragFloat4_7_snnnnsn(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float v[4];
v[0] = (float)lua_tonumber(L, __argi__++);
v[1] = (float)lua_tonumber(L, __argi__++);
v[2] = (float)lua_tonumber(L, __argi__++);
v[3] = (float)lua_tonumber(L, __argi__++);
float v_speed = (float)luaL_optnumber(L, __argi__++, 1.0f);
float v_min = (float)luaL_optnumber(L, __argi__++, 0.0f);
float v_max = (float)luaL_optnumber(L, __argi__++, 0.0f);
const char* format = luaL_optstring(L, __argi__++, "%.3f");
float power = (float)luaL_optnumber(L, __argi__++, 1.0f);
bool __ret__ = ImGui::DragFloat4(label, v, v_speed, v_min, v_max, format, power);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, v[0]);
lua_pushnumber(L, v[1]);
lua_pushnumber(L, v[2]);
lua_pushnumber(L, v[3]);
return 5;
};
//bool DragFloatRange2(const char* label,float* v_current_min,float* v_current_max,float v_speed,float v_min,float v_max,const char* format,const char* format_max,float power);
int cximgui_DragFloatRange2_9_snpnpnnnssn(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float v_current_min = (float)lua_tonumber(L, __argi__++);
float v_current_max = (float)lua_tonumber(L, __argi__++);
float v_speed = (float)luaL_optnumber(L, __argi__++, 1.0f);
float v_min = (float)luaL_optnumber(L, __argi__++, 0.0f);
float v_max = (float)luaL_optnumber(L, __argi__++, 0.0f);
const char* format = luaL_optstring(L, __argi__++, "%.3f");
const char* format_max = luaL_optstring(L, __argi__++, NULL);
float power = (float)luaL_optnumber(L, __argi__++, 1.0f);
bool __ret__ = ImGui::DragFloatRange2(label, &v_current_min, &v_current_max, v_speed, v_min, v_max, format, format_max, power);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, v_current_min);
lua_pushnumber(L, v_current_max);
return 3;
};
//bool DragInt(const char* label,int* v,float v_speed,int v_min,int v_max,const char* format);
int cximgui_DragInt_6_sipniis(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int v = (int)lua_tointeger(L, __argi__++);
float v_speed = (float)luaL_optnumber(L, __argi__++, 1.0f);
int v_min = (int)luaL_optinteger(L, __argi__++, 0);
int v_max = (int)luaL_optinteger(L, __argi__++, 0);
const char* format = luaL_optstring(L, __argi__++, "%d");
bool __ret__ = ImGui::DragInt(label, &v, v_speed, v_min, v_max, format);
lua_pushboolean(L, __ret__);
lua_pushinteger(L, v);
return 2;
};
//bool DragInt2(const char* label,int v[2],float v_speed,int v_min,int v_max,const char* format);
int cximgui_DragInt2_6_siniis(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int v[2];
v[0] = (int)lua_tointeger(L, __argi__++);
v[1] = (int)lua_tointeger(L, __argi__++);
float v_speed = (float)luaL_optnumber(L, __argi__++, 1.0f);
int v_min = (int)luaL_optinteger(L, __argi__++, 0);
int v_max = (int)luaL_optinteger(L, __argi__++, 0);
const char* format = luaL_optstring(L, __argi__++, "%d");
bool __ret__ = ImGui::DragInt2(label, v, v_speed, v_min, v_max, format);
lua_pushboolean(L, __ret__);
lua_pushinteger(L, v[0]);
lua_pushinteger(L, v[1]);
return 3;
};
//bool DragInt3(const char* label,int v[3],float v_speed,int v_min,int v_max,const char* format);
int cximgui_DragInt3_6_siniis(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int v[3];
v[0] = (int)lua_tointeger(L, __argi__++);
v[1] = (int)lua_tointeger(L, __argi__++);
v[2] = (int)lua_tointeger(L, __argi__++);
float v_speed = (float)luaL_optnumber(L, __argi__++, 1.0f);
int v_min = (int)luaL_optinteger(L, __argi__++, 0);
int v_max = (int)luaL_optinteger(L, __argi__++, 0);
const char* format = luaL_optstring(L, __argi__++, "%d");
bool __ret__ = ImGui::DragInt3(label, v, v_speed, v_min, v_max, format);
lua_pushboolean(L, __ret__);
lua_pushinteger(L, v[0]);
lua_pushinteger(L, v[1]);
lua_pushinteger(L, v[2]);
return 4;
};
//bool DragInt4(const char* label,int v[4],float v_speed,int v_min,int v_max,const char* format);
int cximgui_DragInt4_6_siniis(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int v[4];
v[0] = (int)lua_tointeger(L, __argi__++);
v[1] = (int)lua_tointeger(L, __argi__++);
v[2] = (int)lua_tointeger(L, __argi__++);
v[3] = (int)lua_tointeger(L, __argi__++);
float v_speed = (float)luaL_optnumber(L, __argi__++, 1.0f);
int v_min = (int)luaL_optinteger(L, __argi__++, 0);
int v_max = (int)luaL_optinteger(L, __argi__++, 0);
const char* format = luaL_optstring(L, __argi__++, "%d");
bool __ret__ = ImGui::DragInt4(label, v, v_speed, v_min, v_max, format);
lua_pushboolean(L, __ret__);
lua_pushinteger(L, v[0]);
lua_pushinteger(L, v[1]);
lua_pushinteger(L, v[2]);
lua_pushinteger(L, v[3]);
return 5;
};
//bool DragIntRange2(const char* label,int* v_current_min,int* v_current_max,float v_speed,int v_min,int v_max,const char* format,const char* format_max);
int cximgui_DragIntRange2_8_sipipniiss(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int v_current_min = (int)lua_tointeger(L, __argi__++);
int v_current_max = (int)lua_tointeger(L, __argi__++);
float v_speed = (float)luaL_optnumber(L, __argi__++, 1.0f);
int v_min = (int)luaL_optinteger(L, __argi__++, 0);
int v_max = (int)luaL_optinteger(L, __argi__++, 0);
const char* format = luaL_optstring(L, __argi__++, "%d");
const char* format_max = luaL_optstring(L, __argi__++, NULL);
bool __ret__ = ImGui::DragIntRange2(label, &v_current_min, &v_current_max, v_speed, v_min, v_max, format, format_max);
lua_pushboolean(L, __ret__);
lua_pushinteger(L, v_current_min);
lua_pushinteger(L, v_current_max);
return 3;
};
//bool DragScalar(const char* label,ImGuiDataType data_type,void* v,float v_speed,const void* v_min,const void* v_max,const char* format,float power);
//UnSupported DragScalar
//bool DragScalarN(const char* label,ImGuiDataType data_type,void* v,int components,float v_speed,const void* v_min,const void* v_max,const char* format,float power);
//UnSupported DragScalarN
//bool SliderFloat(const char* label,float* v,float v_min,float v_max,const char* format,float power);
int cximgui_SliderFloat_6_snpnnsn(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float v = (float)lua_tonumber(L, __argi__++);
float v_min = (float)lua_tonumber(L, __argi__++);
float v_max = (float)lua_tonumber(L, __argi__++);
const char* format = luaL_optstring(L, __argi__++, "%.3f");
float power = (float)luaL_optnumber(L, __argi__++, 1.0f);
bool __ret__ = ImGui::SliderFloat(label, &v, v_min, v_max, format, power);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, v);
return 2;
};
//bool SliderFloat2(const char* label,float v[2],float v_min,float v_max,const char* format,float power);
int cximgui_SliderFloat2_6_snnnsn(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float v[2];
v[0] = (float)lua_tonumber(L, __argi__++);
v[1] = (float)lua_tonumber(L, __argi__++);
float v_min = (float)lua_tonumber(L, __argi__++);
float v_max = (float)lua_tonumber(L, __argi__++);
const char* format = luaL_optstring(L, __argi__++, "%.3f");
float power = (float)luaL_optnumber(L, __argi__++, 1.0f);
bool __ret__ = ImGui::SliderFloat2(label, v, v_min, v_max, format, power);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, v[0]);
lua_pushnumber(L, v[1]);
return 3;
};
//bool SliderFloat3(const char* label,float v[3],float v_min,float v_max,const char* format,float power);
int cximgui_SliderFloat3_6_snnnsn(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float v[3];
v[0] = (float)lua_tonumber(L, __argi__++);
v[1] = (float)lua_tonumber(L, __argi__++);
v[2] = (float)lua_tonumber(L, __argi__++);
float v_min = (float)lua_tonumber(L, __argi__++);
float v_max = (float)lua_tonumber(L, __argi__++);
const char* format = luaL_optstring(L, __argi__++, "%.3f");
float power = (float)luaL_optnumber(L, __argi__++, 1.0f);
bool __ret__ = ImGui::SliderFloat3(label, v, v_min, v_max, format, power);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, v[0]);
lua_pushnumber(L, v[1]);
lua_pushnumber(L, v[2]);
return 4;
};
//bool SliderFloat4(const char* label,float v[4],float v_min,float v_max,const char* format,float power);
int cximgui_SliderFloat4_6_snnnsn(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float v[4];
v[0] = (float)lua_tonumber(L, __argi__++);
v[1] = (float)lua_tonumber(L, __argi__++);
v[2] = (float)lua_tonumber(L, __argi__++);
v[3] = (float)lua_tonumber(L, __argi__++);
float v_min = (float)lua_tonumber(L, __argi__++);
float v_max = (float)lua_tonumber(L, __argi__++);
const char* format = luaL_optstring(L, __argi__++, "%.3f");
float power = (float)luaL_optnumber(L, __argi__++, 1.0f);
bool __ret__ = ImGui::SliderFloat4(label, v, v_min, v_max, format, power);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, v[0]);
lua_pushnumber(L, v[1]);
lua_pushnumber(L, v[2]);
lua_pushnumber(L, v[3]);
return 5;
};
//bool SliderAngle(const char* label,float* v_rad,float v_degrees_min,float v_degrees_max,const char* format);
int cximgui_SliderAngle_5_snpnns(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float v_rad = (float)lua_tonumber(L, __argi__++);
float v_degrees_min = (float)luaL_optnumber(L, __argi__++, -360.0f);
float v_degrees_max = (float)luaL_optnumber(L, __argi__++, +360.0f);
const char* format = luaL_optstring(L, __argi__++, "%.0fdeg");
bool __ret__ = ImGui::SliderAngle(label, &v_rad, v_degrees_min, v_degrees_max, format);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, v_rad);
return 2;
};
//bool SliderInt(const char* label,int* v,int v_min,int v_max,const char* format);
int cximgui_SliderInt_5_sipiis(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int v = (int)lua_tointeger(L, __argi__++);
int v_min = (int)lua_tointeger(L, __argi__++);
int v_max = (int)lua_tointeger(L, __argi__++);
const char* format = luaL_optstring(L, __argi__++, "%d");
bool __ret__ = ImGui::SliderInt(label, &v, v_min, v_max, format);
lua_pushboolean(L, __ret__);
lua_pushinteger(L, v);
return 2;
};
//bool SliderInt2(const char* label,int v[2],int v_min,int v_max,const char* format);
int cximgui_SliderInt2_5_siiis(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int v[2];
v[0] = (int)lua_tointeger(L, __argi__++);
v[1] = (int)lua_tointeger(L, __argi__++);
int v_min = (int)lua_tointeger(L, __argi__++);
int v_max = (int)lua_tointeger(L, __argi__++);
const char* format = luaL_optstring(L, __argi__++, "%d");
bool __ret__ = ImGui::SliderInt2(label, v, v_min, v_max, format);
lua_pushboolean(L, __ret__);
lua_pushinteger(L, v[0]);
lua_pushinteger(L, v[1]);
return 3;
};
//bool SliderInt3(const char* label,int v[3],int v_min,int v_max,const char* format);
int cximgui_SliderInt3_5_siiis(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int v[3];
v[0] = (int)lua_tointeger(L, __argi__++);
v[1] = (int)lua_tointeger(L, __argi__++);
v[2] = (int)lua_tointeger(L, __argi__++);
int v_min = (int)lua_tointeger(L, __argi__++);
int v_max = (int)lua_tointeger(L, __argi__++);
const char* format = luaL_optstring(L, __argi__++, "%d");
bool __ret__ = ImGui::SliderInt3(label, v, v_min, v_max, format);
lua_pushboolean(L, __ret__);
lua_pushinteger(L, v[0]);
lua_pushinteger(L, v[1]);
lua_pushinteger(L, v[2]);
return 4;
};
//bool SliderInt4(const char* label,int v[4],int v_min,int v_max,const char* format);
int cximgui_SliderInt4_5_siiis(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int v[4];
v[0] = (int)lua_tointeger(L, __argi__++);
v[1] = (int)lua_tointeger(L, __argi__++);
v[2] = (int)lua_tointeger(L, __argi__++);
v[3] = (int)lua_tointeger(L, __argi__++);
int v_min = (int)lua_tointeger(L, __argi__++);
int v_max = (int)lua_tointeger(L, __argi__++);
const char* format = luaL_optstring(L, __argi__++, "%d");
bool __ret__ = ImGui::SliderInt4(label, v, v_min, v_max, format);
lua_pushboolean(L, __ret__);
lua_pushinteger(L, v[0]);
lua_pushinteger(L, v[1]);
lua_pushinteger(L, v[2]);
lua_pushinteger(L, v[3]);
return 5;
};
//bool SliderScalar(const char* label,ImGuiDataType data_type,void* v,const void* v_min,const void* v_max,const char* format,float power);
//UnSupported SliderScalar
//bool SliderScalarN(const char* label,ImGuiDataType data_type,void* v,int components,const void* v_min,const void* v_max,const char* format,float power);
//UnSupported SliderScalarN
//bool VSliderFloat(const char* label,const ImVec2& size,float* v,float v_min,float v_max,const char* format,float power);
int cximgui_VSliderFloat_7_sv2npnnsn(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
ImVec2 size;
size.x = (float)lua_tonumber(L, __argi__++);
size.y = (float)lua_tonumber(L, __argi__++);
float v = (float)lua_tonumber(L, __argi__++);
float v_min = (float)lua_tonumber(L, __argi__++);
float v_max = (float)lua_tonumber(L, __argi__++);
const char* format = luaL_optstring(L, __argi__++, "%.3f");
float power = (float)luaL_optnumber(L, __argi__++, 1.0f);
bool __ret__ = ImGui::VSliderFloat(label, size, &v, v_min, v_max, format, power);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, v);
return 2;
};
//bool VSliderInt(const char* label,const ImVec2& size,int* v,int v_min,int v_max,const char* format);
int cximgui_VSliderInt_6_sv2ipiis(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
ImVec2 size;
size.x = (float)lua_tonumber(L, __argi__++);
size.y = (float)lua_tonumber(L, __argi__++);
int v = (int)lua_tointeger(L, __argi__++);
int v_min = (int)lua_tointeger(L, __argi__++);
int v_max = (int)lua_tointeger(L, __argi__++);
const char* format = luaL_optstring(L, __argi__++, "%d");
bool __ret__ = ImGui::VSliderInt(label, size, &v, v_min, v_max, format);
lua_pushboolean(L, __ret__);
lua_pushinteger(L, v);
return 2;
};
//bool VSliderScalar(const char* label,const ImVec2& size,ImGuiDataType data_type,void* v,const void* v_min,const void* v_max,const char* format,float power);
//UnSupported VSliderScalar
//bool InputText(const char* label,char* buf,size_t buf_size,ImGuiInputTextFlags flags,ImGuiInputTextCallback callback,void* user_data);
//UnSupported InputText
//bool InputTextMultiline(const char* label,char* buf,size_t buf_size,const ImVec2& size,ImGuiInputTextFlags flags,ImGuiInputTextCallback callback,void* user_data);
//UnSupported InputTextMultiline
//bool InputFloat(const char* label,float* v,float step,float step_fast,const char* format,ImGuiInputTextFlags extra_flags);
int cximgui_InputFloat_6_snpnnsi(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float v = (float)lua_tonumber(L, __argi__++);
float step = (float)luaL_optnumber(L, __argi__++, 0.0f);
float step_fast = (float)luaL_optnumber(L, __argi__++, 0.0f);
const char* format = luaL_optstring(L, __argi__++, "%.3f");
ImGuiInputTextFlags extra_flags = (ImGuiInputTextFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::InputFloat(label, &v, step, step_fast, format, extra_flags);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, v);
return 2;
};
//bool InputFloat2(const char* label,float v[2],const char* format,ImGuiInputTextFlags extra_flags);
int cximgui_InputFloat2_4_snsi(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float v[2];
v[0] = (float)lua_tonumber(L, __argi__++);
v[1] = (float)lua_tonumber(L, __argi__++);
const char* format = luaL_optstring(L, __argi__++, "%.3f");
ImGuiInputTextFlags extra_flags = (ImGuiInputTextFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::InputFloat2(label, v, format, extra_flags);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, v[0]);
lua_pushnumber(L, v[1]);
return 3;
};
//bool InputFloat3(const char* label,float v[3],const char* format,ImGuiInputTextFlags extra_flags);
int cximgui_InputFloat3_4_snsi(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float v[3];
v[0] = (float)lua_tonumber(L, __argi__++);
v[1] = (float)lua_tonumber(L, __argi__++);
v[2] = (float)lua_tonumber(L, __argi__++);
const char* format = luaL_optstring(L, __argi__++, "%.3f");
ImGuiInputTextFlags extra_flags = (ImGuiInputTextFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::InputFloat3(label, v, format, extra_flags);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, v[0]);
lua_pushnumber(L, v[1]);
lua_pushnumber(L, v[2]);
return 4;
};
//bool InputFloat4(const char* label,float v[4],const char* format,ImGuiInputTextFlags extra_flags);
int cximgui_InputFloat4_4_snsi(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float v[4];
v[0] = (float)lua_tonumber(L, __argi__++);
v[1] = (float)lua_tonumber(L, __argi__++);
v[2] = (float)lua_tonumber(L, __argi__++);
v[3] = (float)lua_tonumber(L, __argi__++);
const char* format = luaL_optstring(L, __argi__++, "%.3f");
ImGuiInputTextFlags extra_flags = (ImGuiInputTextFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::InputFloat4(label, v, format, extra_flags);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, v[0]);
lua_pushnumber(L, v[1]);
lua_pushnumber(L, v[2]);
lua_pushnumber(L, v[3]);
return 5;
};
//bool InputInt(const char* label,int* v,int step,int step_fast,ImGuiInputTextFlags extra_flags);
int cximgui_InputInt_5_sipiii(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int v = (int)lua_tointeger(L, __argi__++);
int step = (int)luaL_optinteger(L, __argi__++, 1);
int step_fast = (int)luaL_optinteger(L, __argi__++, 100);
ImGuiInputTextFlags extra_flags = (ImGuiInputTextFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::InputInt(label, &v, step, step_fast, extra_flags);
lua_pushboolean(L, __ret__);
lua_pushinteger(L, v);
return 2;
};
//bool InputInt2(const char* label,int v[2],ImGuiInputTextFlags extra_flags);
int cximgui_InputInt2_3_sii(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int v[2];
v[0] = (int)lua_tointeger(L, __argi__++);
v[1] = (int)lua_tointeger(L, __argi__++);
ImGuiInputTextFlags extra_flags = (ImGuiInputTextFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::InputInt2(label, v, extra_flags);
lua_pushboolean(L, __ret__);
lua_pushinteger(L, v[0]);
lua_pushinteger(L, v[1]);
return 3;
};
//bool InputInt3(const char* label,int v[3],ImGuiInputTextFlags extra_flags);
int cximgui_InputInt3_3_sii(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int v[3];
v[0] = (int)lua_tointeger(L, __argi__++);
v[1] = (int)lua_tointeger(L, __argi__++);
v[2] = (int)lua_tointeger(L, __argi__++);
ImGuiInputTextFlags extra_flags = (ImGuiInputTextFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::InputInt3(label, v, extra_flags);
lua_pushboolean(L, __ret__);
lua_pushinteger(L, v[0]);
lua_pushinteger(L, v[1]);
lua_pushinteger(L, v[2]);
return 4;
};
//bool InputInt4(const char* label,int v[4],ImGuiInputTextFlags extra_flags);
int cximgui_InputInt4_3_sii(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int v[4];
v[0] = (int)lua_tointeger(L, __argi__++);
v[1] = (int)lua_tointeger(L, __argi__++);
v[2] = (int)lua_tointeger(L, __argi__++);
v[3] = (int)lua_tointeger(L, __argi__++);
ImGuiInputTextFlags extra_flags = (ImGuiInputTextFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::InputInt4(label, v, extra_flags);
lua_pushboolean(L, __ret__);
lua_pushinteger(L, v[0]);
lua_pushinteger(L, v[1]);
lua_pushinteger(L, v[2]);
lua_pushinteger(L, v[3]);
return 5;
};
//bool InputDouble(const char* label,double* v,double step,double step_fast,const char* format,ImGuiInputTextFlags extra_flags);
int cximgui_InputDouble_6_snpnnsi(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
double v = (double)lua_tonumber(L, __argi__++);
double step = (double)luaL_optnumber(L, __argi__++, 0.0f);
double step_fast = (double)luaL_optnumber(L, __argi__++, 0.0f);
const char* format = luaL_optstring(L, __argi__++, "%.6f");
ImGuiInputTextFlags extra_flags = (ImGuiInputTextFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::InputDouble(label, &v, step, step_fast, format, extra_flags);
lua_pushboolean(L, __ret__);
return 1;
};
//bool InputScalar(const char* label,ImGuiDataType data_type,void* v,const void* step,const void* step_fast,const char* format,ImGuiInputTextFlags extra_flags);
//UnSupported InputScalar
//bool InputScalarN(const char* label,ImGuiDataType data_type,void* v,int components,const void* step,const void* step_fast,const char* format,ImGuiInputTextFlags extra_flags);
//UnSupported InputScalarN
//bool ColorEdit3(const char* label,float col[3],ImGuiColorEditFlags flags);
int cximgui_ColorEdit3_3_sni(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float col[3];
col[0] = (float)lua_tonumber(L, __argi__++);
col[1] = (float)lua_tonumber(L, __argi__++);
col[2] = (float)lua_tonumber(L, __argi__++);
ImGuiColorEditFlags flags = (ImGuiColorEditFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::ColorEdit3(label, col, flags);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, col[0]);
lua_pushnumber(L, col[1]);
lua_pushnumber(L, col[2]);
return 4;
};
//bool ColorEdit4(const char* label,float col[4],ImGuiColorEditFlags flags);
int cximgui_ColorEdit4_3_sni(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float col[4];
col[0] = (float)lua_tonumber(L, __argi__++);
col[1] = (float)lua_tonumber(L, __argi__++);
col[2] = (float)lua_tonumber(L, __argi__++);
col[3] = (float)lua_tonumber(L, __argi__++);
ImGuiColorEditFlags flags = (ImGuiColorEditFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::ColorEdit4(label, col, flags);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, col[0]);
lua_pushnumber(L, col[1]);
lua_pushnumber(L, col[2]);
lua_pushnumber(L, col[3]);
return 5;
};
//bool ColorPicker3(const char* label,float col[3],ImGuiColorEditFlags flags);
int cximgui_ColorPicker3_3_sni(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float col[3];
col[0] = (float)lua_tonumber(L, __argi__++);
col[1] = (float)lua_tonumber(L, __argi__++);
col[2] = (float)lua_tonumber(L, __argi__++);
ImGuiColorEditFlags flags = (ImGuiColorEditFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::ColorPicker3(label, col, flags);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, col[0]);
lua_pushnumber(L, col[1]);
lua_pushnumber(L, col[2]);
return 4;
};
//bool ColorPicker4(const char* label,float col[4],ImGuiColorEditFlags flags,const float* ref_col);
int cximgui_ColorPicker4_4_sninp(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float col[4];
col[0] = (float)lua_tonumber(L, __argi__++);
col[1] = (float)lua_tonumber(L, __argi__++);
col[2] = (float)lua_tonumber(L, __argi__++);
col[3] = (float)lua_tonumber(L, __argi__++);
ImGuiColorEditFlags flags = (ImGuiColorEditFlags)luaL_optinteger(L, __argi__++, 0);
float ref_col = (float)luaL_optnumber(L, __argi__++, NULL);
bool __ret__ = ImGui::ColorPicker4(label, col, flags, &ref_col);
lua_pushboolean(L, __ret__);
lua_pushnumber(L, col[0]);
lua_pushnumber(L, col[1]);
lua_pushnumber(L, col[2]);
lua_pushnumber(L, col[3]);
return 5;
};
//bool ColorButton(const char* desc_id,const ImVec4& col,ImGuiColorEditFlags flags,ImVec2 size);
int cximgui_ColorButton_4_sv4iv2(lua_State* L) {
int __argi__ = 1;
const char* desc_id = lua_tostring(L, __argi__++);
ImVec4 col;
col.x = (float)lua_tonumber(L, __argi__++);
col.y = (float)lua_tonumber(L, __argi__++);
col.z = (float)lua_tonumber(L, __argi__++);
col.w = (float)lua_tonumber(L, __argi__++);
ImGuiColorEditFlags flags = (ImGuiColorEditFlags)luaL_optinteger(L, __argi__++, 0);
ImVec2 size_def = ImVec2(0, 0);
ImVec2 size;
size.x = (float)luaL_optnumber(L, __argi__, size_def.x);
size.y = (float)luaL_optnumber(L, __argi__ + 1, size_def.y);
if (size.x != size_def.x || size.y != size_def.y) __argi__ += 2;
bool __ret__ = ImGui::ColorButton(desc_id, col, flags, size);
lua_pushboolean(L, __ret__);
return 1;
};
//void SetColorEditOptions(ImGuiColorEditFlags flags);
int cximgui_SetColorEditOptions_1_i(lua_State* L) {
int __argi__ = 1;
ImGuiColorEditFlags flags = (ImGuiColorEditFlags)lua_tointeger(L, __argi__++);
ImGui::SetColorEditOptions(flags);
return 0;
};
//bool TreeNode(const char* label);
int cximgui_TreeNode_1_s(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
bool __ret__ = ImGui::TreeNode(label);
lua_pushboolean(L, __ret__);
return 1;
};
//bool TreeNode(const char* str_id,const char* fmt,... );
//UnSupported TreeNode
//bool TreeNode(const void* ptr_id,const char* fmt,... );
//UnSupported TreeNode
//bool TreeNodeV(const char* str_id,const char* fmt,va_list args);
//UnSupported TreeNodeV
//bool TreeNodeV(const void* ptr_id,const char* fmt,va_list args);
//UnSupported TreeNodeV
//bool TreeNodeEx(const char* label,ImGuiTreeNodeFlags flags);
int cximgui_TreeNodeEx_2_si(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
ImGuiTreeNodeFlags flags = (ImGuiTreeNodeFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::TreeNodeEx(label, flags);
lua_pushboolean(L, __ret__);
return 1;
};
//bool TreeNodeEx(const char* str_id,ImGuiTreeNodeFlags flags,const char* fmt,... );
//UnSupported TreeNodeEx
//bool TreeNodeEx(const void* ptr_id,ImGuiTreeNodeFlags flags,const char* fmt,... );
//UnSupported TreeNodeEx
//bool TreeNodeExV(const char* str_id,ImGuiTreeNodeFlags flags,const char* fmt,va_list args);
//UnSupported TreeNodeExV
//bool TreeNodeExV(const void* ptr_id,ImGuiTreeNodeFlags flags,const char* fmt,va_list args);
//UnSupported TreeNodeExV
//void TreePush(const char* str_id);
int cximgui_TreePush_1_s(lua_State* L) {
int __argi__ = 1;
const char* str_id = lua_tostring(L, __argi__++);
ImGui::TreePush(str_id);
return 0;
};
//void TreePush(const void* ptr_id);
//UnSupported TreePush
//void TreePop();
int cximgui_TreePop(lua_State* L) {
ImGui::TreePop();
return 0;
};
//void TreeAdvanceToLabelPos();
int cximgui_TreeAdvanceToLabelPos(lua_State* L) {
ImGui::TreeAdvanceToLabelPos();
return 0;
};
//float GetTreeNodeToLabelSpacing();
int cximgui_GetTreeNodeToLabelSpacing(lua_State* L) {
float __ret__ = ImGui::GetTreeNodeToLabelSpacing();
lua_pushnumber(L, __ret__);
return 1;
};
//void SetNextTreeNodeOpen(bool is_open,ImGuiCond cond);
int cximgui_SetNextTreeNodeOpen_2_bi(lua_State* L) {
int __argi__ = 1;
bool is_open = lua_toboolean(L, __argi__++);
ImGuiCond cond = (ImGuiCond)luaL_optinteger(L, __argi__++, 0);
ImGui::SetNextTreeNodeOpen(is_open, cond);
return 0;
};
//bool CollapsingHeader(const char* label,ImGuiTreeNodeFlags flags);
int cximgui_CollapsingHeader_2_si(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
ImGuiTreeNodeFlags flags = (ImGuiTreeNodeFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::CollapsingHeader(label, flags);
lua_pushboolean(L, __ret__);
return 1;
};
//bool CollapsingHeader(const char* label,bool* p_open,ImGuiTreeNodeFlags flags);
int cximgui_CollapsingHeader_3_sbpi(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
bool p_open = lua_toboolean(L, __argi__++);
ImGuiTreeNodeFlags flags = (ImGuiTreeNodeFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::CollapsingHeader(label, &p_open, flags);
lua_pushboolean(L, __ret__);
lua_pushboolean(L, p_open);
return 2;
};
//bool Selectable(const char* label,bool selected,ImGuiSelectableFlags flags,const ImVec2& size);
int cximgui_Selectable_4_sbiv2(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
bool selected = lua_toboolean(L, __argi__++);
ImGuiSelectableFlags flags = (ImGuiSelectableFlags)luaL_optinteger(L, __argi__++, 0);
ImVec2 size_def = ImVec2(0, 0);
ImVec2 size;
size.x = (float)luaL_optnumber(L, __argi__, size_def.x);
size.y = (float)luaL_optnumber(L, __argi__ + 1, size_def.y);
if (size.x != size_def.x || size.y != size_def.y) __argi__ += 2;
bool __ret__ = ImGui::Selectable(label, selected, flags, size);
lua_pushboolean(L, __ret__);
return 1;
};
//bool Selectable(const char* label,bool* p_selected,ImGuiSelectableFlags flags,const ImVec2& size);
int cximgui_Selectable_4_sbpiv2(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
bool p_selected = lua_toboolean(L, __argi__++);
ImGuiSelectableFlags flags = (ImGuiSelectableFlags)luaL_optinteger(L, __argi__++, 0);
ImVec2 size_def = ImVec2(0, 0);
ImVec2 size;
size.x = (float)luaL_optnumber(L, __argi__, size_def.x);
size.y = (float)luaL_optnumber(L, __argi__ + 1, size_def.y);
if (size.x != size_def.x || size.y != size_def.y) __argi__ += 2;
bool __ret__ = ImGui::Selectable(label, &p_selected, flags, size);
lua_pushboolean(L, __ret__);
lua_pushboolean(L, p_selected);
return 2;
};
//bool ListBox(const char* label,int* current_item,const char* const[],int items_count,int height_in_items);
//UnSupported ListBox
//bool ListBox(const char* label,int* current_item,bool @1@2,void* data,int items_count,int height_in_items);
//UnSupported ListBox
//bool ListBoxHeader(const char* label,const ImVec2& size);
int cximgui_ListBoxHeader_2_sv2(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
ImVec2 size_def = ImVec2(0, 0);
ImVec2 size;
size.x = (float)luaL_optnumber(L, __argi__, size_def.x);
size.y = (float)luaL_optnumber(L, __argi__ + 1, size_def.y);
if (size.x != size_def.x || size.y != size_def.y) __argi__ += 2;
bool __ret__ = ImGui::ListBoxHeader(label, size);
lua_pushboolean(L, __ret__);
return 1;
};
//bool ListBoxHeader(const char* label,int items_count,int height_in_items);
int cximgui_ListBoxHeader_3_sii(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int items_count = (int)lua_tointeger(L, __argi__++);
int height_in_items = (int)luaL_optinteger(L, __argi__++, -1);
bool __ret__ = ImGui::ListBoxHeader(label, items_count, height_in_items);
lua_pushboolean(L, __ret__);
return 1;
};
//void ListBoxFooter();
int cximgui_ListBoxFooter(lua_State* L) {
ImGui::ListBoxFooter();
return 0;
};
//void PlotLines(const char* label,const float* values,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size,int stride);
int cximgui_PlotLines_9_snpiisnnv2i(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float values = (float)lua_tonumber(L, __argi__++);
int values_count = (int)lua_tointeger(L, __argi__++);
int values_offset = (int)luaL_optinteger(L, __argi__++, 0);
const char* overlay_text = luaL_optstring(L, __argi__++, NULL);
float scale_min = (float)luaL_optnumber(L, __argi__++, FLT_MAX);
float scale_max = (float)luaL_optnumber(L, __argi__++, FLT_MAX);
ImVec2 graph_size_def = ImVec2(0, 0);
ImVec2 graph_size;
graph_size.x = (float)luaL_optnumber(L, __argi__, graph_size_def.x);
graph_size.y = (float)luaL_optnumber(L, __argi__ + 1, graph_size_def.y);
if (graph_size.x != graph_size_def.x || graph_size.y != graph_size_def.y) __argi__ += 2;
int stride = (int)luaL_optinteger(L, __argi__++, sizeof(float));
ImGui::PlotLines(label, &values, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size, stride);
return 0;
};
//void PlotLines(const char* label,float @1@2,void* data,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size);
//UnSupported PlotLines
//void PlotHistogram(const char* label,const float* values,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size,int stride);
int cximgui_PlotHistogram_9_snpiisnnv2i(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
float values = (float)lua_tonumber(L, __argi__++);
int values_count = (int)lua_tointeger(L, __argi__++);
int values_offset = (int)luaL_optinteger(L, __argi__++, 0);
const char* overlay_text = luaL_optstring(L, __argi__++, NULL);
float scale_min = (float)luaL_optnumber(L, __argi__++, FLT_MAX);
float scale_max = (float)luaL_optnumber(L, __argi__++, FLT_MAX);
ImVec2 graph_size_def = ImVec2(0, 0);
ImVec2 graph_size;
graph_size.x = (float)luaL_optnumber(L, __argi__, graph_size_def.x);
graph_size.y = (float)luaL_optnumber(L, __argi__ + 1, graph_size_def.y);
if (graph_size.x != graph_size_def.x || graph_size.y != graph_size_def.y) __argi__ += 2;
int stride = (int)luaL_optinteger(L, __argi__++, sizeof(float));
ImGui::PlotHistogram(label, &values, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size, stride);
return 0;
};
//void PlotHistogram(const char* label,float @1@2,void* data,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size);
//UnSupported PlotHistogram
//void Value(const char* prefix,bool b);
int cximgui_Value_2_sb(lua_State* L) {
int __argi__ = 1;
const char* prefix = lua_tostring(L, __argi__++);
bool b = lua_toboolean(L, __argi__++);
ImGui::Value(prefix, b);
return 0;
};
//void Value(const char* prefix,int v);
int cximgui_Value_2_si(lua_State* L) {
int __argi__ = 1;
const char* prefix = lua_tostring(L, __argi__++);
int v = (int)lua_tointeger(L, __argi__++);
ImGui::Value(prefix, v);
return 0;
};
//void Value(const char* prefix,unsigned int v);
int cximgui_Value_2_sI(lua_State* L) {
int __argi__ = 1;
const char* prefix = lua_tostring(L, __argi__++);
unsigned int v = (unsigned int)lua_tointeger(L, __argi__++);
ImGui::Value(prefix, v);
return 0;
};
//void Value(const char* prefix,float v,const char* float_format);
int cximgui_Value_3_sns(lua_State* L) {
int __argi__ = 1;
const char* prefix = lua_tostring(L, __argi__++);
float v = (float)lua_tonumber(L, __argi__++);
const char* float_format = luaL_optstring(L, __argi__++, NULL);
ImGui::Value(prefix, v, float_format);
return 0;
};
//bool BeginMainMenuBar();
int cximgui_BeginMainMenuBar(lua_State* L) {
bool __ret__ = ImGui::BeginMainMenuBar();
lua_pushboolean(L, __ret__);
return 1;
};
//void EndMainMenuBar();
int cximgui_EndMainMenuBar(lua_State* L) {
ImGui::EndMainMenuBar();
return 0;
};
//bool BeginMenuBar();
int cximgui_BeginMenuBar(lua_State* L) {
bool __ret__ = ImGui::BeginMenuBar();
lua_pushboolean(L, __ret__);
return 1;
};
//void EndMenuBar();
int cximgui_EndMenuBar(lua_State* L) {
ImGui::EndMenuBar();
return 0;
};
//bool BeginMenu(const char* label,bool enabled);
int cximgui_BeginMenu_2_sb(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
bool enabled = lua_toboolean(L, __argi__++);
bool __ret__ = ImGui::BeginMenu(label, enabled);
lua_pushboolean(L, __ret__);
return 1;
};
//void EndMenu();
int cximgui_EndMenu(lua_State* L) {
ImGui::EndMenu();
return 0;
};
//bool MenuItem(const char* label,const char* shortcut,bool selected,bool enabled);
int cximgui_MenuItem_4_ssbb(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
const char* shortcut = luaL_optstring(L, __argi__++, NULL);
bool selected = lua_toboolean(L, __argi__++);
bool enabled = lua_toboolean(L, __argi__++);
bool __ret__ = ImGui::MenuItem(label, shortcut, selected, enabled);
lua_pushboolean(L, __ret__);
return 1;
};
//bool MenuItem(const char* label,const char* shortcut,bool* p_selected,bool enabled);
int cximgui_MenuItem_4_ssbpb(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
const char* shortcut = lua_tostring(L, __argi__++);
bool p_selected = lua_toboolean(L, __argi__++);
bool enabled = lua_toboolean(L, __argi__++);
bool __ret__ = ImGui::MenuItem(label, shortcut, &p_selected, enabled);
lua_pushboolean(L, __ret__);
lua_pushboolean(L, p_selected);
return 2;
};
//void BeginTooltip();
int cximgui_BeginTooltip(lua_State* L) {
ImGui::BeginTooltip();
return 0;
};
//void EndTooltip();
int cximgui_EndTooltip(lua_State* L) {
ImGui::EndTooltip();
return 0;
};
//void SetTooltip(const char* fmt,... );
//UnSupported SetTooltip
//void SetTooltipV(const char* fmt,va_list args);
//UnSupported SetTooltipV
//void OpenPopup(const char* str_id);
int cximgui_OpenPopup_1_s(lua_State* L) {
int __argi__ = 1;
const char* str_id = lua_tostring(L, __argi__++);
ImGui::OpenPopup(str_id);
return 0;
};
//bool BeginPopup(const char* str_id,ImGuiWindowFlags flags);
int cximgui_BeginPopup_2_si(lua_State* L) {
int __argi__ = 1;
const char* str_id = lua_tostring(L, __argi__++);
ImGuiWindowFlags flags = (ImGuiWindowFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::BeginPopup(str_id, flags);
lua_pushboolean(L, __ret__);
return 1;
};
//bool BeginPopupContextItem(const char* str_id,int mouse_button);
int cximgui_BeginPopupContextItem_2_si(lua_State* L) {
int __argi__ = 1;
const char* str_id = luaL_optstring(L, __argi__++, NULL);
int mouse_button = (int)luaL_optinteger(L, __argi__++, 1);
bool __ret__ = ImGui::BeginPopupContextItem(str_id, mouse_button);
lua_pushboolean(L, __ret__);
return 1;
};
//bool BeginPopupContextWindow(const char* str_id,int mouse_button,bool also_over_items);
int cximgui_BeginPopupContextWindow_3_sib(lua_State* L) {
int __argi__ = 1;
const char* str_id = luaL_optstring(L, __argi__++, NULL);
int mouse_button = (int)luaL_optinteger(L, __argi__++, 1);
bool also_over_items = lua_toboolean(L, __argi__++);
bool __ret__ = ImGui::BeginPopupContextWindow(str_id, mouse_button, also_over_items);
lua_pushboolean(L, __ret__);
return 1;
};
//bool BeginPopupContextVoid(const char* str_id,int mouse_button);
int cximgui_BeginPopupContextVoid_2_si(lua_State* L) {
int __argi__ = 1;
const char* str_id = luaL_optstring(L, __argi__++, NULL);
int mouse_button = (int)luaL_optinteger(L, __argi__++, 1);
bool __ret__ = ImGui::BeginPopupContextVoid(str_id, mouse_button);
lua_pushboolean(L, __ret__);
return 1;
};
//bool BeginPopupModal(const char* name,bool* p_open,ImGuiWindowFlags flags);
int cximgui_BeginPopupModal_3_sbpi(lua_State* L) {
int __argi__ = 1;
const char* name = lua_tostring(L, __argi__++);
bool p_open = lua_toboolean(L, __argi__++);
ImGuiWindowFlags flags = (ImGuiWindowFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::BeginPopupModal(name, &p_open, flags);
lua_pushboolean(L, __ret__);
lua_pushboolean(L, p_open);
return 2;
};
//void EndPopup();
int cximgui_EndPopup(lua_State* L) {
ImGui::EndPopup();
return 0;
};
//bool OpenPopupOnItemClick(const char* str_id,int mouse_button);
int cximgui_OpenPopupOnItemClick_2_si(lua_State* L) {
int __argi__ = 1;
const char* str_id = luaL_optstring(L, __argi__++, NULL);
int mouse_button = (int)luaL_optinteger(L, __argi__++, 1);
bool __ret__ = ImGui::OpenPopupOnItemClick(str_id, mouse_button);
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsPopupOpen(const char* str_id);
int cximgui_IsPopupOpen_1_s(lua_State* L) {
int __argi__ = 1;
const char* str_id = lua_tostring(L, __argi__++);
bool __ret__ = ImGui::IsPopupOpen(str_id);
lua_pushboolean(L, __ret__);
return 1;
};
//void CloseCurrentPopup();
int cximgui_CloseCurrentPopup(lua_State* L) {
ImGui::CloseCurrentPopup();
return 0;
};
//void Columns(int count,const char* id,bool border);
int cximgui_Columns_3_isb(lua_State* L) {
int __argi__ = 1;
int count = (int)luaL_optinteger(L, __argi__++, 1);
const char* id = luaL_optstring(L, __argi__++, NULL);
bool border = lua_toboolean(L, __argi__++);
ImGui::Columns(count, id, border);
return 0;
};
//void NextColumn();
int cximgui_NextColumn(lua_State* L) {
ImGui::NextColumn();
return 0;
};
//int GetColumnIndex();
int cximgui_GetColumnIndex(lua_State* L) {
int __ret__ = ImGui::GetColumnIndex();
lua_pushinteger(L, __ret__);
return 1;
};
//float GetColumnWidth(int column_index);
int cximgui_GetColumnWidth_1_i(lua_State* L) {
int __argi__ = 1;
int column_index = (int)luaL_optinteger(L, __argi__++, -1);
float __ret__ = ImGui::GetColumnWidth(column_index);
lua_pushnumber(L, __ret__);
return 1;
};
//void SetColumnWidth(int column_index,float width);
int cximgui_SetColumnWidth_2_in(lua_State* L) {
int __argi__ = 1;
int column_index = (int)lua_tointeger(L, __argi__++);
float width = (float)lua_tonumber(L, __argi__++);
ImGui::SetColumnWidth(column_index, width);
return 0;
};
//float GetColumnOffset(int column_index);
int cximgui_GetColumnOffset_1_i(lua_State* L) {
int __argi__ = 1;
int column_index = (int)luaL_optinteger(L, __argi__++, -1);
float __ret__ = ImGui::GetColumnOffset(column_index);
lua_pushnumber(L, __ret__);
return 1;
};
//void SetColumnOffset(int column_index,float offset_x);
int cximgui_SetColumnOffset_2_in(lua_State* L) {
int __argi__ = 1;
int column_index = (int)lua_tointeger(L, __argi__++);
float offset_x = (float)lua_tonumber(L, __argi__++);
ImGui::SetColumnOffset(column_index, offset_x);
return 0;
};
//int GetColumnsCount();
int cximgui_GetColumnsCount(lua_State* L) {
int __ret__ = ImGui::GetColumnsCount();
lua_pushinteger(L, __ret__);
return 1;
};
//bool BeginTabBar(const char* str_id,ImGuiTabBarFlags flags);
int cximgui_BeginTabBar_2_si(lua_State* L) {
int __argi__ = 1;
const char* str_id = lua_tostring(L, __argi__++);
ImGuiTabBarFlags flags = (ImGuiTabBarFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::BeginTabBar(str_id, flags);
lua_pushboolean(L, __ret__);
return 1;
};
//void EndTabBar();
int cximgui_EndTabBar(lua_State* L) {
ImGui::EndTabBar();
return 0;
};
//bool BeginTabItem(const char* label,bool* p_open,ImGuiTabItemFlags flags);
int cximgui_BeginTabItem_3_sbpi(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
bool p_open = lua_toboolean(L, __argi__++);
ImGuiTabItemFlags flags = (ImGuiTabItemFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::BeginTabItem(label, &p_open, flags);
lua_pushboolean(L, __ret__);
lua_pushboolean(L, p_open);
return 2;
};
//void EndTabItem();
int cximgui_EndTabItem(lua_State* L) {
ImGui::EndTabItem();
return 0;
};
//void SetTabItemClosed(const char* tab_or_docked_window_label);
int cximgui_SetTabItemClosed_1_s(lua_State* L) {
int __argi__ = 1;
const char* tab_or_docked_window_label = lua_tostring(L, __argi__++);
ImGui::SetTabItemClosed(tab_or_docked_window_label);
return 0;
};
//void DockSpace(ImGuiID id,const ImVec2& size,ImGuiDockNodeFlags flags,const ImGuiDockFamily* dock_family);
//UnSupported DockSpace
//ImGuiID DockSpaceOverViewport(ImGuiViewport* viewport,ImGuiDockNodeFlags dockspace_flags,const ImGuiDockFamily* dock_family);
//UnSupported DockSpaceOverViewport
//void SetNextWindowDockId(ImGuiID dock_id,ImGuiCond cond);
int cximgui_SetNextWindowDockId_2_ii(lua_State* L) {
int __argi__ = 1;
ImGuiID dock_id = (ImGuiID)lua_tointeger(L, __argi__++);
ImGuiCond cond = (ImGuiCond)luaL_optinteger(L, __argi__++, 0);
ImGui::SetNextWindowDockId(dock_id, cond);
return 0;
};
//void SetNextWindowDockFamily(const ImGuiDockFamily* dock_family);
//UnSupported SetNextWindowDockFamily
//ImGuiID GetWindowDockId();
int cximgui_GetWindowDockId(lua_State* L) {
ImGuiID __ret__ = ImGui::GetWindowDockId();
lua_pushinteger(L, __ret__);
return 1;
};
//bool IsWindowDocked();
int cximgui_IsWindowDocked(lua_State* L) {
bool __ret__ = ImGui::IsWindowDocked();
lua_pushboolean(L, __ret__);
return 1;
};
//void LogToTTY(int max_depth);
int cximgui_LogToTTY_1_i(lua_State* L) {
int __argi__ = 1;
int max_depth = (int)luaL_optinteger(L, __argi__++, -1);
ImGui::LogToTTY(max_depth);
return 0;
};
//void LogToFile(int max_depth,const char* filename);
int cximgui_LogToFile_2_is(lua_State* L) {
int __argi__ = 1;
int max_depth = (int)luaL_optinteger(L, __argi__++, -1);
const char* filename = luaL_optstring(L, __argi__++, NULL);
ImGui::LogToFile(max_depth, filename);
return 0;
};
//void LogToClipboard(int max_depth);
int cximgui_LogToClipboard_1_i(lua_State* L) {
int __argi__ = 1;
int max_depth = (int)luaL_optinteger(L, __argi__++, -1);
ImGui::LogToClipboard(max_depth);
return 0;
};
//void LogFinish();
int cximgui_LogFinish(lua_State* L) {
ImGui::LogFinish();
return 0;
};
//void LogButtons();
int cximgui_LogButtons(lua_State* L) {
ImGui::LogButtons();
return 0;
};
//void LogText(const char* fmt,... );
//UnSupported LogText
//bool BeginDragDropSource(ImGuiDragDropFlags flags);
int cximgui_BeginDragDropSource_1_i(lua_State* L) {
int __argi__ = 1;
ImGuiDragDropFlags flags = (ImGuiDragDropFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::BeginDragDropSource(flags);
lua_pushboolean(L, __ret__);
return 1;
};
//bool SetDragDropPayload(const char* type,const void* data,size_t size,ImGuiCond cond);
//UnSupported SetDragDropPayload
//void EndDragDropSource();
int cximgui_EndDragDropSource(lua_State* L) {
ImGui::EndDragDropSource();
return 0;
};
//bool BeginDragDropTarget();
int cximgui_BeginDragDropTarget(lua_State* L) {
bool __ret__ = ImGui::BeginDragDropTarget();
lua_pushboolean(L, __ret__);
return 1;
};
//const ImGuiPayload* AcceptDragDropPayload(const char* type,ImGuiDragDropFlags flags);
int cximgui_AcceptDragDropPayload_2_si(lua_State* L) {
int __argi__ = 1;
const char* type = lua_tostring(L, __argi__++);
ImGuiDragDropFlags flags = (ImGuiDragDropFlags)luaL_optinteger(L, __argi__++, 0);
const ImGuiPayload* __ret__ = ImGui::AcceptDragDropPayload(type, flags);
return 0;
};
//void EndDragDropTarget();
int cximgui_EndDragDropTarget(lua_State* L) {
ImGui::EndDragDropTarget();
return 0;
};
//const ImGuiPayload* GetDragDropPayload();
int cximgui_GetDragDropPayload(lua_State* L) {
const ImGuiPayload* __ret__ = ImGui::GetDragDropPayload();
return 0;
};
//void PushClipRect(const ImVec2& clip_rect_min,const ImVec2& clip_rect_max,bool intersect_with_current_clip_rect);
int cximgui_PushClipRect_3_v2v2b(lua_State* L) {
int __argi__ = 1;
ImVec2 clip_rect_min;
clip_rect_min.x = (float)lua_tonumber(L, __argi__++);
clip_rect_min.y = (float)lua_tonumber(L, __argi__++);
ImVec2 clip_rect_max;
clip_rect_max.x = (float)lua_tonumber(L, __argi__++);
clip_rect_max.y = (float)lua_tonumber(L, __argi__++);
bool intersect_with_current_clip_rect = lua_toboolean(L, __argi__++);
ImGui::PushClipRect(clip_rect_min, clip_rect_max, intersect_with_current_clip_rect);
return 0;
};
//void PopClipRect();
int cximgui_PopClipRect(lua_State* L) {
ImGui::PopClipRect();
return 0;
};
//void SetItemDefaultFocus();
int cximgui_SetItemDefaultFocus(lua_State* L) {
ImGui::SetItemDefaultFocus();
return 0;
};
//void SetKeyboardFocusHere(int offset);
int cximgui_SetKeyboardFocusHere_1_i(lua_State* L) {
int __argi__ = 1;
int offset = (int)luaL_optinteger(L, __argi__++, 0);
ImGui::SetKeyboardFocusHere(offset);
return 0;
};
//bool IsItemHovered(ImGuiHoveredFlags flags);
int cximgui_IsItemHovered_1_i(lua_State* L) {
int __argi__ = 1;
ImGuiHoveredFlags flags = (ImGuiHoveredFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::IsItemHovered(flags);
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsItemActive();
int cximgui_IsItemActive(lua_State* L) {
bool __ret__ = ImGui::IsItemActive();
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsItemFocused();
int cximgui_IsItemFocused(lua_State* L) {
bool __ret__ = ImGui::IsItemFocused();
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsItemClicked(int mouse_button);
int cximgui_IsItemClicked_1_i(lua_State* L) {
int __argi__ = 1;
int mouse_button = (int)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::IsItemClicked(mouse_button);
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsItemVisible();
int cximgui_IsItemVisible(lua_State* L) {
bool __ret__ = ImGui::IsItemVisible();
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsItemEdited();
int cximgui_IsItemEdited(lua_State* L) {
bool __ret__ = ImGui::IsItemEdited();
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsItemDeactivated();
int cximgui_IsItemDeactivated(lua_State* L) {
bool __ret__ = ImGui::IsItemDeactivated();
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsItemDeactivatedAfterEdit();
int cximgui_IsItemDeactivatedAfterEdit(lua_State* L) {
bool __ret__ = ImGui::IsItemDeactivatedAfterEdit();
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsAnyItemHovered();
int cximgui_IsAnyItemHovered(lua_State* L) {
bool __ret__ = ImGui::IsAnyItemHovered();
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsAnyItemActive();
int cximgui_IsAnyItemActive(lua_State* L) {
bool __ret__ = ImGui::IsAnyItemActive();
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsAnyItemFocused();
int cximgui_IsAnyItemFocused(lua_State* L) {
bool __ret__ = ImGui::IsAnyItemFocused();
lua_pushboolean(L, __ret__);
return 1;
};
//ImVec2 GetItemRectMin();
int cximgui_GetItemRectMin(lua_State* L) {
ImVec2 __ret__ = ImGui::GetItemRectMin();
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//ImVec2 GetItemRectMax();
int cximgui_GetItemRectMax(lua_State* L) {
ImVec2 __ret__ = ImGui::GetItemRectMax();
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//ImVec2 GetItemRectSize();
int cximgui_GetItemRectSize(lua_State* L) {
ImVec2 __ret__ = ImGui::GetItemRectSize();
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//void SetItemAllowOverlap();
int cximgui_SetItemAllowOverlap(lua_State* L) {
ImGui::SetItemAllowOverlap();
return 0;
};
//bool IsRectVisible(const ImVec2& size);
int cximgui_IsRectVisible_1_v2(lua_State* L) {
int __argi__ = 1;
ImVec2 size;
size.x = (float)lua_tonumber(L, __argi__++);
size.y = (float)lua_tonumber(L, __argi__++);
bool __ret__ = ImGui::IsRectVisible(size);
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsRectVisible(const ImVec2& rect_min,const ImVec2& rect_max);
int cximgui_IsRectVisible_2_v2v2(lua_State* L) {
int __argi__ = 1;
ImVec2 rect_min;
rect_min.x = (float)lua_tonumber(L, __argi__++);
rect_min.y = (float)lua_tonumber(L, __argi__++);
ImVec2 rect_max;
rect_max.x = (float)lua_tonumber(L, __argi__++);
rect_max.y = (float)lua_tonumber(L, __argi__++);
bool __ret__ = ImGui::IsRectVisible(rect_min, rect_max);
lua_pushboolean(L, __ret__);
return 1;
};
//double GetTime();
int cximgui_GetTime(lua_State* L) {
double __ret__ = ImGui::GetTime();
lua_pushnumber(L, __ret__);
return 1;
};
//int GetFrameCount();
int cximgui_GetFrameCount(lua_State* L) {
int __ret__ = ImGui::GetFrameCount();
lua_pushinteger(L, __ret__);
return 1;
};
//ImDrawList* GetOverlayDrawList();
int cximgui_GetOverlayDrawList(lua_State* L) {
ImDrawList* __ret__ = ImGui::GetOverlayDrawList();
return 0;
};
//ImDrawList* GetOverlayDrawList(ImGuiViewport* viewport);
//UnSupported GetOverlayDrawList
//ImDrawListSharedData* GetDrawListSharedData();
int cximgui_GetDrawListSharedData(lua_State* L) {
ImDrawListSharedData* __ret__ = ImGui::GetDrawListSharedData();
return 0;
};
//const char* GetStyleColorName(ImGuiCol idx);
int cximgui_GetStyleColorName_1_i(lua_State* L) {
int __argi__ = 1;
ImGuiCol idx = (ImGuiCol)lua_tointeger(L, __argi__++);
const char* __ret__ = ImGui::GetStyleColorName(idx);
lua_pushstring(L, __ret__);
return 1;
};
//void SetStateStorage(ImGuiStorage* storage);
//UnSupported SetStateStorage
//ImGuiStorage* GetStateStorage();
int cximgui_GetStateStorage(lua_State* L) {
ImGuiStorage* __ret__ = ImGui::GetStateStorage();
return 0;
};
//ImVec2 CalcTextSize(const char* text,const char* text_end,bool hide_text_after_double_hash,float wrap_width);
int cximgui_CalcTextSize_4_ssbn(lua_State* L) {
int __argi__ = 1;
const char* text = lua_tostring(L, __argi__++);
const char* text_end = luaL_optstring(L, __argi__++, NULL);
bool hide_text_after_double_hash = lua_toboolean(L, __argi__++);
float wrap_width = (float)luaL_optnumber(L, __argi__++, -1.0f);
ImVec2 __ret__ = ImGui::CalcTextSize(text, text_end, hide_text_after_double_hash, wrap_width);
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//void CalcListClipping(int items_count,float items_height,int* out_items_display_start,int* out_items_display_end);
int cximgui_CalcListClipping_4_inipip(lua_State* L) {
int __argi__ = 1;
int items_count = (int)lua_tointeger(L, __argi__++);
float items_height = (float)lua_tonumber(L, __argi__++);
int out_items_display_start = (int)lua_tointeger(L, __argi__++);
int out_items_display_end = (int)lua_tointeger(L, __argi__++);
ImGui::CalcListClipping(items_count, items_height, &out_items_display_start, &out_items_display_end);
lua_pushinteger(L, out_items_display_start);
lua_pushinteger(L, out_items_display_end);
return 2;
};
//bool BeginChildFrame(ImGuiID id,const ImVec2& size,ImGuiWindowFlags flags);
int cximgui_BeginChildFrame_3_iv2i(lua_State* L) {
int __argi__ = 1;
ImGuiID id = (ImGuiID)lua_tointeger(L, __argi__++);
ImVec2 size;
size.x = (float)lua_tonumber(L, __argi__++);
size.y = (float)lua_tonumber(L, __argi__++);
ImGuiWindowFlags flags = (ImGuiWindowFlags)luaL_optinteger(L, __argi__++, 0);
bool __ret__ = ImGui::BeginChildFrame(id, size, flags);
lua_pushboolean(L, __ret__);
return 1;
};
//void EndChildFrame();
int cximgui_EndChildFrame(lua_State* L) {
ImGui::EndChildFrame();
return 0;
};
//ImVec4 ColorConvertU32ToFloat4(ImU32 in);
int cximgui_ColorConvertU32ToFloat4_1_i(lua_State* L) {
int __argi__ = 1;
ImU32 in = (ImU32)lua_tointeger(L, __argi__++);
ImVec4 __ret__ = ImGui::ColorConvertU32ToFloat4(in);
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
lua_pushnumber(L, __ret__.z);
lua_pushnumber(L, __ret__.w);
return 4;
};
//ImU32 ColorConvertFloat4ToU32(const ImVec4& in);
int cximgui_ColorConvertFloat4ToU32_1_v4(lua_State* L) {
int __argi__ = 1;
ImVec4 in;
in.x = (float)lua_tonumber(L, __argi__++);
in.y = (float)lua_tonumber(L, __argi__++);
in.z = (float)lua_tonumber(L, __argi__++);
in.w = (float)lua_tonumber(L, __argi__++);
ImU32 __ret__ = ImGui::ColorConvertFloat4ToU32(in);
lua_pushinteger(L, __ret__);
return 1;
};
//void ColorConvertRGBtoHSV(float r,float g,float b,float& out_h,float& out_s,float& out_v);
int cximgui_ColorConvertRGBtoHSV_6_nnnnnn(lua_State* L) {
int __argi__ = 1;
float r = (float)lua_tonumber(L, __argi__++);
float g = (float)lua_tonumber(L, __argi__++);
float b = (float)lua_tonumber(L, __argi__++);
float out_h = (float)lua_tonumber(L, __argi__++);
float out_s = (float)lua_tonumber(L, __argi__++);
float out_v = (float)lua_tonumber(L, __argi__++);
ImGui::ColorConvertRGBtoHSV(r, g, b, out_h, out_s, out_v);
lua_pushnumber(L, out_h);
lua_pushnumber(L, out_s);
lua_pushnumber(L, out_v);
return 3;
};
//void ColorConvertHSVtoRGB(float h,float s,float v,float& out_r,float& out_g,float& out_b);
int cximgui_ColorConvertHSVtoRGB_6_nnnnnn(lua_State* L) {
int __argi__ = 1;
float h = (float)lua_tonumber(L, __argi__++);
float s = (float)lua_tonumber(L, __argi__++);
float v = (float)lua_tonumber(L, __argi__++);
float out_r = (float)lua_tonumber(L, __argi__++);
float out_g = (float)lua_tonumber(L, __argi__++);
float out_b = (float)lua_tonumber(L, __argi__++);
ImGui::ColorConvertHSVtoRGB(h, s, v, out_r, out_g, out_b);
lua_pushnumber(L, out_r);
lua_pushnumber(L, out_g);
lua_pushnumber(L, out_b);
return 3;
};
//int GetKeyIndex(ImGuiKey imgui_key);
int cximgui_GetKeyIndex_1_i(lua_State* L) {
int __argi__ = 1;
ImGuiKey imgui_key = (ImGuiKey)lua_tointeger(L, __argi__++);
int __ret__ = ImGui::GetKeyIndex(imgui_key);
lua_pushinteger(L, __ret__);
return 1;
};
//bool IsKeyDown(int user_key_index);
int cximgui_IsKeyDown_1_i(lua_State* L) {
int __argi__ = 1;
int user_key_index = (int)lua_tointeger(L, __argi__++);
bool __ret__ = ImGui::IsKeyDown(user_key_index);
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsKeyPressed(int user_key_index,bool repeat);
int cximgui_IsKeyPressed_2_ib(lua_State* L) {
int __argi__ = 1;
int user_key_index = (int)lua_tointeger(L, __argi__++);
bool repeat = lua_toboolean(L, __argi__++);
bool __ret__ = ImGui::IsKeyPressed(user_key_index, repeat);
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsKeyReleased(int user_key_index);
int cximgui_IsKeyReleased_1_i(lua_State* L) {
int __argi__ = 1;
int user_key_index = (int)lua_tointeger(L, __argi__++);
bool __ret__ = ImGui::IsKeyReleased(user_key_index);
lua_pushboolean(L, __ret__);
return 1;
};
//int GetKeyPressedAmount(int key_index,float repeat_delay,float rate);
int cximgui_GetKeyPressedAmount_3_inn(lua_State* L) {
int __argi__ = 1;
int key_index = (int)lua_tointeger(L, __argi__++);
float repeat_delay = (float)lua_tonumber(L, __argi__++);
float rate = (float)lua_tonumber(L, __argi__++);
int __ret__ = ImGui::GetKeyPressedAmount(key_index, repeat_delay, rate);
lua_pushinteger(L, __ret__);
return 1;
};
//bool IsMouseDown(int button);
int cximgui_IsMouseDown_1_i(lua_State* L) {
int __argi__ = 1;
int button = (int)lua_tointeger(L, __argi__++);
bool __ret__ = ImGui::IsMouseDown(button);
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsAnyMouseDown();
int cximgui_IsAnyMouseDown(lua_State* L) {
bool __ret__ = ImGui::IsAnyMouseDown();
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsMouseClicked(int button,bool repeat);
int cximgui_IsMouseClicked_2_ib(lua_State* L) {
int __argi__ = 1;
int button = (int)lua_tointeger(L, __argi__++);
bool repeat = lua_toboolean(L, __argi__++);
bool __ret__ = ImGui::IsMouseClicked(button, repeat);
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsMouseDoubleClicked(int button);
int cximgui_IsMouseDoubleClicked_1_i(lua_State* L) {
int __argi__ = 1;
int button = (int)lua_tointeger(L, __argi__++);
bool __ret__ = ImGui::IsMouseDoubleClicked(button);
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsMouseReleased(int button);
int cximgui_IsMouseReleased_1_i(lua_State* L) {
int __argi__ = 1;
int button = (int)lua_tointeger(L, __argi__++);
bool __ret__ = ImGui::IsMouseReleased(button);
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsMouseDragging(int button,float lock_threshold);
int cximgui_IsMouseDragging_2_in(lua_State* L) {
int __argi__ = 1;
int button = (int)luaL_optinteger(L, __argi__++, 0);
float lock_threshold = (float)luaL_optnumber(L, __argi__++, -1.0f);
bool __ret__ = ImGui::IsMouseDragging(button, lock_threshold);
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsMouseHoveringRect(const ImVec2& r_min,const ImVec2& r_max,bool clip);
int cximgui_IsMouseHoveringRect_3_v2v2b(lua_State* L) {
int __argi__ = 1;
ImVec2 r_min;
r_min.x = (float)lua_tonumber(L, __argi__++);
r_min.y = (float)lua_tonumber(L, __argi__++);
ImVec2 r_max;
r_max.x = (float)lua_tonumber(L, __argi__++);
r_max.y = (float)lua_tonumber(L, __argi__++);
bool clip = lua_toboolean(L, __argi__++);
bool __ret__ = ImGui::IsMouseHoveringRect(r_min, r_max, clip);
lua_pushboolean(L, __ret__);
return 1;
};
//bool IsMousePosValid(const ImVec2* mouse_pos);
int cximgui_IsMousePosValid_1_v2p(lua_State* L) {
int __argi__ = 1;
ImVec2 mouse_pos;
mouse_pos.x = (float)lua_tonumber(L, __argi__++);
mouse_pos.y = (float)lua_tonumber(L, __argi__++);
bool __ret__ = ImGui::IsMousePosValid(&mouse_pos);
lua_pushboolean(L, __ret__);
return 1;
};
//ImVec2 GetMousePos();
int cximgui_GetMousePos(lua_State* L) {
ImVec2 __ret__ = ImGui::GetMousePos();
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//ImVec2 GetMousePosOnOpeningCurrentPopup();
int cximgui_GetMousePosOnOpeningCurrentPopup(lua_State* L) {
ImVec2 __ret__ = ImGui::GetMousePosOnOpeningCurrentPopup();
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//ImVec2 GetMouseDragDelta(int button,float lock_threshold);
int cximgui_GetMouseDragDelta_2_in(lua_State* L) {
int __argi__ = 1;
int button = (int)luaL_optinteger(L, __argi__++, 0);
float lock_threshold = (float)luaL_optnumber(L, __argi__++, -1.0f);
ImVec2 __ret__ = ImGui::GetMouseDragDelta(button, lock_threshold);
lua_pushnumber(L, __ret__.x);
lua_pushnumber(L, __ret__.y);
return 2;
};
//void ResetMouseDragDelta(int button);
int cximgui_ResetMouseDragDelta_1_i(lua_State* L) {
int __argi__ = 1;
int button = (int)luaL_optinteger(L, __argi__++, 0);
ImGui::ResetMouseDragDelta(button);
return 0;
};
//ImGuiMouseCursor GetMouseCursor();
int cximgui_GetMouseCursor(lua_State* L) {
ImGuiMouseCursor __ret__ = ImGui::GetMouseCursor();
lua_pushinteger(L, __ret__);
return 1;
};
//void SetMouseCursor(ImGuiMouseCursor type);
int cximgui_SetMouseCursor_1_i(lua_State* L) {
int __argi__ = 1;
ImGuiMouseCursor type = (ImGuiMouseCursor)lua_tointeger(L, __argi__++);
ImGui::SetMouseCursor(type);
return 0;
};
//void CaptureKeyboardFromApp(bool capture);
int cximgui_CaptureKeyboardFromApp_1_b(lua_State* L) {
int __argi__ = 1;
bool capture = lua_toboolean(L, __argi__++);
ImGui::CaptureKeyboardFromApp(capture);
return 0;
};
//void CaptureMouseFromApp(bool capture);
int cximgui_CaptureMouseFromApp_1_b(lua_State* L) {
int __argi__ = 1;
bool capture = lua_toboolean(L, __argi__++);
ImGui::CaptureMouseFromApp(capture);
return 0;
};
//const char* GetClipboardText();
int cximgui_GetClipboardText(lua_State* L) {
const char* __ret__ = ImGui::GetClipboardText();
lua_pushstring(L, __ret__);
return 1;
};
//void SetClipboardText(const char* text);
int cximgui_SetClipboardText_1_s(lua_State* L) {
int __argi__ = 1;
const char* text = lua_tostring(L, __argi__++);
ImGui::SetClipboardText(text);
return 0;
};
//void LoadIniSettingsFromDisk(const char* ini_filename);
int cximgui_LoadIniSettingsFromDisk_1_s(lua_State* L) {
int __argi__ = 1;
const char* ini_filename = lua_tostring(L, __argi__++);
ImGui::LoadIniSettingsFromDisk(ini_filename);
return 0;
};
//void LoadIniSettingsFromMemory(const char* ini_data,size_t ini_size);
int cximgui_LoadIniSettingsFromMemory_2_si(lua_State* L) {
int __argi__ = 1;
const char* ini_data = lua_tostring(L, __argi__++);
size_t ini_size = (size_t)luaL_optinteger(L, __argi__++, 0);
ImGui::LoadIniSettingsFromMemory(ini_data, ini_size);
return 0;
};
//void SaveIniSettingsToDisk(const char* ini_filename);
int cximgui_SaveIniSettingsToDisk_1_s(lua_State* L) {
int __argi__ = 1;
const char* ini_filename = lua_tostring(L, __argi__++);
ImGui::SaveIniSettingsToDisk(ini_filename);
return 0;
};
//const char* SaveIniSettingsToMemory(size_t* out_ini_size);
int cximgui_SaveIniSettingsToMemory_1_ip(lua_State* L) {
int __argi__ = 1;
size_t out_ini_size = (size_t)luaL_optinteger(L, __argi__++, NULL);
const char* __ret__ = ImGui::SaveIniSettingsToMemory(&out_ini_size);
lua_pushstring(L, __ret__);
return 1;
};
//void SetAllocatorFunctions(void* @1@2,void @3@4,void* user_data);
//UnSupported SetAllocatorFunctions
//void* MemAlloc(size_t size);
int cximgui_MemAlloc_1_i(lua_State* L) {
int __argi__ = 1;
size_t size = (size_t)lua_tointeger(L, __argi__++);
ImGui::MemAlloc(size);
return 0;
};
//void MemFree(void* ptr);
//UnSupported MemFree
//ImGuiPlatformIO& GetPlatformIO();
int cximgui_GetPlatformIO(lua_State* L) {
ImGuiPlatformIO& __ret__ = ImGui::GetPlatformIO();
return 0;
};
//ImGuiViewport* GetMainViewport();
//UnSupported GetMainViewport
//void UpdatePlatformWindows();
int cximgui_UpdatePlatformWindows(lua_State* L) {
ImGui::UpdatePlatformWindows();
return 0;
};
//void RenderPlatformWindowsDefault(void* platform_arg,void* renderer_arg);
//UnSupported RenderPlatformWindowsDefault
//void DestroyPlatformWindows();
int cximgui_DestroyPlatformWindows(lua_State* L) {
ImGui::DestroyPlatformWindows();
return 0;
};
//ImGuiViewport* FindViewportByPlatformHandle(void* platform_handle);
//UnSupported FindViewportByPlatformHandle
//void PushClipRect(ImVec2 clip_rect_min,ImVec2 clip_rect_max,bool intersect_with_current_clip_rect);
int cximgui_ImDrawList_PushClipRect_3_v2v2b(lua_State* L) {
int __argi__ = 1;
ImVec2 clip_rect_min;
clip_rect_min.x = (float)lua_tonumber(L, __argi__++);
clip_rect_min.y = (float)lua_tonumber(L, __argi__++);
ImVec2 clip_rect_max;
clip_rect_max.x = (float)lua_tonumber(L, __argi__++);
clip_rect_max.y = (float)lua_tonumber(L, __argi__++);
bool intersect_with_current_clip_rect = lua_toboolean(L, __argi__++);
ImGui::GetOverlayDrawList()->PushClipRect(clip_rect_min, clip_rect_max, intersect_with_current_clip_rect);
return 0;
};
//void PushClipRectFullScreen();
int cximgui_ImDrawList_PushClipRectFullScreen(lua_State* L) {
ImGui::GetOverlayDrawList()->PushClipRectFullScreen();
return 0;
};
//void PopClipRect();
int cximgui_ImDrawList_PopClipRect(lua_State* L) {
ImGui::GetOverlayDrawList()->PopClipRect();
return 0;
};
//void PushTextureID(ImTextureID texture_id);
//UnSupported PushTextureID
//void PopTextureID();
int cximgui_ImDrawList_PopTextureID(lua_State* L) {
ImGui::GetOverlayDrawList()->PopTextureID();
return 0;
};
//void AddLine(const ImVec2& a,const ImVec2& b,ImU32 col,float thickness);
int cximgui_ImDrawList_AddLine_4_v2v2in(lua_State* L) {
int __argi__ = 1;
ImVec2 a;
a.x = (float)lua_tonumber(L, __argi__++);
a.y = (float)lua_tonumber(L, __argi__++);
ImVec2 b;
b.x = (float)lua_tonumber(L, __argi__++);
b.y = (float)lua_tonumber(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
float thickness = (float)luaL_optnumber(L, __argi__++, 1.0f);
ImGui::GetOverlayDrawList()->AddLine(a, b, col, thickness);
return 0;
};
//void AddRect(const ImVec2& a,const ImVec2& b,ImU32 col,float rounding,int rounding_corners_flags,float thickness);
int cximgui_ImDrawList_AddRect_6_v2v2inin(lua_State* L) {
int __argi__ = 1;
ImVec2 a;
a.x = (float)lua_tonumber(L, __argi__++);
a.y = (float)lua_tonumber(L, __argi__++);
ImVec2 b;
b.x = (float)lua_tonumber(L, __argi__++);
b.y = (float)lua_tonumber(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
float rounding = (float)luaL_optnumber(L, __argi__++, 0.0f);
int rounding_corners_flags = (int)luaL_optinteger(L, __argi__++, ImDrawCornerFlags_All);
float thickness = (float)luaL_optnumber(L, __argi__++, 1.0f);
ImGui::GetOverlayDrawList()->AddRect(a, b, col, rounding, rounding_corners_flags, thickness);
return 0;
};
//void AddRectFilled(const ImVec2& a,const ImVec2& b,ImU32 col,float rounding,int rounding_corners_flags);
int cximgui_ImDrawList_AddRectFilled_5_v2v2ini(lua_State* L) {
int __argi__ = 1;
ImVec2 a;
a.x = (float)lua_tonumber(L, __argi__++);
a.y = (float)lua_tonumber(L, __argi__++);
ImVec2 b;
b.x = (float)lua_tonumber(L, __argi__++);
b.y = (float)lua_tonumber(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
float rounding = (float)luaL_optnumber(L, __argi__++, 0.0f);
int rounding_corners_flags = (int)luaL_optinteger(L, __argi__++, ImDrawCornerFlags_All);
ImGui::GetOverlayDrawList()->AddRectFilled(a, b, col, rounding, rounding_corners_flags);
return 0;
};
//void AddRectFilledMultiColor(const ImVec2& a,const ImVec2& b,ImU32 col_upr_left,ImU32 col_upr_right,ImU32 col_bot_right,ImU32 col_bot_left);
int cximgui_ImDrawList_AddRectFilledMultiColor_6_v2v2iiii(lua_State* L) {
int __argi__ = 1;
ImVec2 a;
a.x = (float)lua_tonumber(L, __argi__++);
a.y = (float)lua_tonumber(L, __argi__++);
ImVec2 b;
b.x = (float)lua_tonumber(L, __argi__++);
b.y = (float)lua_tonumber(L, __argi__++);
ImU32 col_upr_left = (ImU32)lua_tointeger(L, __argi__++);
ImU32 col_upr_right = (ImU32)lua_tointeger(L, __argi__++);
ImU32 col_bot_right = (ImU32)lua_tointeger(L, __argi__++);
ImU32 col_bot_left = (ImU32)lua_tointeger(L, __argi__++);
ImGui::GetOverlayDrawList()->AddRectFilledMultiColor(a, b, col_upr_left, col_upr_right, col_bot_right, col_bot_left);
return 0;
};
//void AddQuad(const ImVec2& a,const ImVec2& b,const ImVec2& c,const ImVec2& d,ImU32 col,float thickness);
int cximgui_ImDrawList_AddQuad_6_v2v2v2v2in(lua_State* L) {
int __argi__ = 1;
ImVec2 a;
a.x = (float)lua_tonumber(L, __argi__++);
a.y = (float)lua_tonumber(L, __argi__++);
ImVec2 b;
b.x = (float)lua_tonumber(L, __argi__++);
b.y = (float)lua_tonumber(L, __argi__++);
ImVec2 c;
c.x = (float)lua_tonumber(L, __argi__++);
c.y = (float)lua_tonumber(L, __argi__++);
ImVec2 d;
d.x = (float)lua_tonumber(L, __argi__++);
d.y = (float)lua_tonumber(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
float thickness = (float)luaL_optnumber(L, __argi__++, 1.0f);
ImGui::GetOverlayDrawList()->AddQuad(a, b, c, d, col, thickness);
return 0;
};
//void AddQuadFilled(const ImVec2& a,const ImVec2& b,const ImVec2& c,const ImVec2& d,ImU32 col);
int cximgui_ImDrawList_AddQuadFilled_5_v2v2v2v2i(lua_State* L) {
int __argi__ = 1;
ImVec2 a;
a.x = (float)lua_tonumber(L, __argi__++);
a.y = (float)lua_tonumber(L, __argi__++);
ImVec2 b;
b.x = (float)lua_tonumber(L, __argi__++);
b.y = (float)lua_tonumber(L, __argi__++);
ImVec2 c;
c.x = (float)lua_tonumber(L, __argi__++);
c.y = (float)lua_tonumber(L, __argi__++);
ImVec2 d;
d.x = (float)lua_tonumber(L, __argi__++);
d.y = (float)lua_tonumber(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
ImGui::GetOverlayDrawList()->AddQuadFilled(a, b, c, d, col);
return 0;
};
//void AddTriangle(const ImVec2& a,const ImVec2& b,const ImVec2& c,ImU32 col,float thickness);
int cximgui_ImDrawList_AddTriangle_5_v2v2v2in(lua_State* L) {
int __argi__ = 1;
ImVec2 a;
a.x = (float)lua_tonumber(L, __argi__++);
a.y = (float)lua_tonumber(L, __argi__++);
ImVec2 b;
b.x = (float)lua_tonumber(L, __argi__++);
b.y = (float)lua_tonumber(L, __argi__++);
ImVec2 c;
c.x = (float)lua_tonumber(L, __argi__++);
c.y = (float)lua_tonumber(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
float thickness = (float)luaL_optnumber(L, __argi__++, 1.0f);
ImGui::GetOverlayDrawList()->AddTriangle(a, b, c, col, thickness);
return 0;
};
//void AddTriangleFilled(const ImVec2& a,const ImVec2& b,const ImVec2& c,ImU32 col);
int cximgui_ImDrawList_AddTriangleFilled_4_v2v2v2i(lua_State* L) {
int __argi__ = 1;
ImVec2 a;
a.x = (float)lua_tonumber(L, __argi__++);
a.y = (float)lua_tonumber(L, __argi__++);
ImVec2 b;
b.x = (float)lua_tonumber(L, __argi__++);
b.y = (float)lua_tonumber(L, __argi__++);
ImVec2 c;
c.x = (float)lua_tonumber(L, __argi__++);
c.y = (float)lua_tonumber(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
ImGui::GetOverlayDrawList()->AddTriangleFilled(a, b, c, col);
return 0;
};
//void AddCircle(const ImVec2& centre,float radius,ImU32 col,int num_segments,float thickness);
int cximgui_ImDrawList_AddCircle_5_v2niin(lua_State* L) {
int __argi__ = 1;
ImVec2 centre;
centre.x = (float)lua_tonumber(L, __argi__++);
centre.y = (float)lua_tonumber(L, __argi__++);
float radius = (float)lua_tonumber(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
int num_segments = (int)luaL_optinteger(L, __argi__++, 12);
float thickness = (float)luaL_optnumber(L, __argi__++, 1.0f);
ImGui::GetOverlayDrawList()->AddCircle(centre, radius, col, num_segments, thickness);
return 0;
};
//void AddCircleFilled(const ImVec2& centre,float radius,ImU32 col,int num_segments);
int cximgui_ImDrawList_AddCircleFilled_4_v2nii(lua_State* L) {
int __argi__ = 1;
ImVec2 centre;
centre.x = (float)lua_tonumber(L, __argi__++);
centre.y = (float)lua_tonumber(L, __argi__++);
float radius = (float)lua_tonumber(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
int num_segments = (int)luaL_optinteger(L, __argi__++, 12);
ImGui::GetOverlayDrawList()->AddCircleFilled(centre, radius, col, num_segments);
return 0;
};
//void AddText(const ImVec2& pos,ImU32 col,const char* text_begin,const char* text_end);
int cximgui_ImDrawList_AddText_4_v2iss(lua_State* L) {
int __argi__ = 1;
ImVec2 pos;
pos.x = (float)lua_tonumber(L, __argi__++);
pos.y = (float)lua_tonumber(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
const char* text_begin = lua_tostring(L, __argi__++);
const char* text_end = luaL_optstring(L, __argi__++, NULL);
ImGui::GetOverlayDrawList()->AddText(pos, col, text_begin, text_end);
return 0;
};
//void AddText(const ImFont* font,float font_size,const ImVec2& pos,ImU32 col,const char* text_begin,const char* text_end,float wrap_width,const ImVec4* cpu_fine_clip_rect);
//UnSupported AddText
//void AddImage(ImTextureID user_texture_id,const ImVec2& a,const ImVec2& b,const ImVec2& uv_a,const ImVec2& uv_b,ImU32 col);
//UnSupported AddImage
//void AddImageQuad(ImTextureID user_texture_id,const ImVec2& a,const ImVec2& b,const ImVec2& c,const ImVec2& d,const ImVec2& uv_a,const ImVec2& uv_b,const ImVec2& uv_c,const ImVec2& uv_d,ImU32 col);
//UnSupported AddImageQuad
//void AddImageRounded(ImTextureID user_texture_id,const ImVec2& a,const ImVec2& b,const ImVec2& uv_a,const ImVec2& uv_b,ImU32 col,float rounding,int rounding_corners);
//UnSupported AddImageRounded
//void AddPolyline(const ImVec2* points,const int num_points,ImU32 col,bool closed,float thickness);
int cximgui_ImDrawList_AddPolyline_5_v2piibn(lua_State* L) {
int __argi__ = 1;
ImVec2 points;
points.x = (float)lua_tonumber(L, __argi__++);
points.y = (float)lua_tonumber(L, __argi__++);
int num_points = (int)lua_tointeger(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
bool closed = lua_toboolean(L, __argi__++);
float thickness = (float)lua_tonumber(L, __argi__++);
ImGui::GetOverlayDrawList()->AddPolyline(&points, num_points, col, closed, thickness);
return 0;
};
//void AddConvexPolyFilled(const ImVec2* points,const int num_points,ImU32 col);
int cximgui_ImDrawList_AddConvexPolyFilled_3_v2pii(lua_State* L) {
int __argi__ = 1;
ImVec2 points;
points.x = (float)lua_tonumber(L, __argi__++);
points.y = (float)lua_tonumber(L, __argi__++);
int num_points = (int)lua_tointeger(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
ImGui::GetOverlayDrawList()->AddConvexPolyFilled(&points, num_points, col);
return 0;
};
//void AddBezierCurve(const ImVec2& pos0,const ImVec2& cp0,const ImVec2& cp1,const ImVec2& pos1,ImU32 col,float thickness,int num_segments);
int cximgui_ImDrawList_AddBezierCurve_7_v2v2v2v2ini(lua_State* L) {
int __argi__ = 1;
ImVec2 pos0;
pos0.x = (float)lua_tonumber(L, __argi__++);
pos0.y = (float)lua_tonumber(L, __argi__++);
ImVec2 cp0;
cp0.x = (float)lua_tonumber(L, __argi__++);
cp0.y = (float)lua_tonumber(L, __argi__++);
ImVec2 cp1;
cp1.x = (float)lua_tonumber(L, __argi__++);
cp1.y = (float)lua_tonumber(L, __argi__++);
ImVec2 pos1;
pos1.x = (float)lua_tonumber(L, __argi__++);
pos1.y = (float)lua_tonumber(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
float thickness = (float)lua_tonumber(L, __argi__++);
int num_segments = (int)luaL_optinteger(L, __argi__++, 0);
ImGui::GetOverlayDrawList()->AddBezierCurve(pos0, cp0, cp1, pos1, col, thickness, num_segments);
return 0;
};
//void PathArcTo(const ImVec2& centre,float radius,float a_min,float a_max,int num_segments);
int cximgui_ImDrawList_PathArcTo_5_v2nnni(lua_State* L) {
int __argi__ = 1;
ImVec2 centre;
centre.x = (float)lua_tonumber(L, __argi__++);
centre.y = (float)lua_tonumber(L, __argi__++);
float radius = (float)lua_tonumber(L, __argi__++);
float a_min = (float)lua_tonumber(L, __argi__++);
float a_max = (float)lua_tonumber(L, __argi__++);
int num_segments = (int)luaL_optinteger(L, __argi__++, 10);
ImGui::GetOverlayDrawList()->PathArcTo(centre, radius, a_min, a_max, num_segments);
return 0;
};
//void PathArcToFast(const ImVec2& centre,float radius,int a_min_of_12,int a_max_of_12);
int cximgui_ImDrawList_PathArcToFast_4_v2nii(lua_State* L) {
int __argi__ = 1;
ImVec2 centre;
centre.x = (float)lua_tonumber(L, __argi__++);
centre.y = (float)lua_tonumber(L, __argi__++);
float radius = (float)lua_tonumber(L, __argi__++);
int a_min_of_12 = (int)lua_tointeger(L, __argi__++);
int a_max_of_12 = (int)lua_tointeger(L, __argi__++);
ImGui::GetOverlayDrawList()->PathArcToFast(centre, radius, a_min_of_12, a_max_of_12);
return 0;
};
//void PathBezierCurveTo(const ImVec2& p1,const ImVec2& p2,const ImVec2& p3,int num_segments);
int cximgui_ImDrawList_PathBezierCurveTo_4_v2v2v2i(lua_State* L) {
int __argi__ = 1;
ImVec2 p1;
p1.x = (float)lua_tonumber(L, __argi__++);
p1.y = (float)lua_tonumber(L, __argi__++);
ImVec2 p2;
p2.x = (float)lua_tonumber(L, __argi__++);
p2.y = (float)lua_tonumber(L, __argi__++);
ImVec2 p3;
p3.x = (float)lua_tonumber(L, __argi__++);
p3.y = (float)lua_tonumber(L, __argi__++);
int num_segments = (int)luaL_optinteger(L, __argi__++, 0);
ImGui::GetOverlayDrawList()->PathBezierCurveTo(p1, p2, p3, num_segments);
return 0;
};
//void PathRect(const ImVec2& rect_min,const ImVec2& rect_max,float rounding,int rounding_corners_flags);
int cximgui_ImDrawList_PathRect_4_v2v2ni(lua_State* L) {
int __argi__ = 1;
ImVec2 rect_min;
rect_min.x = (float)lua_tonumber(L, __argi__++);
rect_min.y = (float)lua_tonumber(L, __argi__++);
ImVec2 rect_max;
rect_max.x = (float)lua_tonumber(L, __argi__++);
rect_max.y = (float)lua_tonumber(L, __argi__++);
float rounding = (float)luaL_optnumber(L, __argi__++, 0.0f);
int rounding_corners_flags = (int)luaL_optinteger(L, __argi__++, ImDrawCornerFlags_All);
ImGui::GetOverlayDrawList()->PathRect(rect_min, rect_max, rounding, rounding_corners_flags);
return 0;
};
//void ChannelsSplit(int channels_count);
int cximgui_ImDrawList_ChannelsSplit_1_i(lua_State* L) {
int __argi__ = 1;
int channels_count = (int)lua_tointeger(L, __argi__++);
ImGui::GetOverlayDrawList()->ChannelsSplit(channels_count);
return 0;
};
//void ChannelsMerge();
int cximgui_ImDrawList_ChannelsMerge(lua_State* L) {
ImGui::GetOverlayDrawList()->ChannelsMerge();
return 0;
};
//void ChannelsSetCurrent(int channel_index);
int cximgui_ImDrawList_ChannelsSetCurrent_1_i(lua_State* L) {
int __argi__ = 1;
int channel_index = (int)lua_tointeger(L, __argi__++);
ImGui::GetOverlayDrawList()->ChannelsSetCurrent(channel_index);
return 0;
};
//void AddCallback(ImDrawCallback callback,void* callback_data);
//UnSupported AddCallback
//void AddDrawCmd();
int cximgui_ImDrawList_AddDrawCmd(lua_State* L) {
ImGui::GetOverlayDrawList()->AddDrawCmd();
return 0;
};
//ImDrawList* CloneOutput();
int cximgui_ImDrawList_CloneOutput(lua_State* L) {
ImDrawList* __ret__ = ImGui::GetOverlayDrawList()->CloneOutput();
return 0;
};
//void Clear();
int cximgui_ImDrawList_Clear(lua_State* L) {
ImGui::GetOverlayDrawList()->Clear();
return 0;
};
//void ClearFreeMemory();
int cximgui_ImDrawList_ClearFreeMemory(lua_State* L) {
ImGui::GetOverlayDrawList()->ClearFreeMemory();
return 0;
};
//void PrimReserve(int idx_count,int vtx_count);
int cximgui_ImDrawList_PrimReserve_2_ii(lua_State* L) {
int __argi__ = 1;
int idx_count = (int)lua_tointeger(L, __argi__++);
int vtx_count = (int)lua_tointeger(L, __argi__++);
ImGui::GetOverlayDrawList()->PrimReserve(idx_count, vtx_count);
return 0;
};
//void PrimRect(const ImVec2& a,const ImVec2& b,ImU32 col);
int cximgui_ImDrawList_PrimRect_3_v2v2i(lua_State* L) {
int __argi__ = 1;
ImVec2 a;
a.x = (float)lua_tonumber(L, __argi__++);
a.y = (float)lua_tonumber(L, __argi__++);
ImVec2 b;
b.x = (float)lua_tonumber(L, __argi__++);
b.y = (float)lua_tonumber(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
ImGui::GetOverlayDrawList()->PrimRect(a, b, col);
return 0;
};
//void PrimRectUV(const ImVec2& a,const ImVec2& b,const ImVec2& uv_a,const ImVec2& uv_b,ImU32 col);
int cximgui_ImDrawList_PrimRectUV_5_v2v2v2v2i(lua_State* L) {
int __argi__ = 1;
ImVec2 a;
a.x = (float)lua_tonumber(L, __argi__++);
a.y = (float)lua_tonumber(L, __argi__++);
ImVec2 b;
b.x = (float)lua_tonumber(L, __argi__++);
b.y = (float)lua_tonumber(L, __argi__++);
ImVec2 uv_a;
uv_a.x = (float)lua_tonumber(L, __argi__++);
uv_a.y = (float)lua_tonumber(L, __argi__++);
ImVec2 uv_b;
uv_b.x = (float)lua_tonumber(L, __argi__++);
uv_b.y = (float)lua_tonumber(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
ImGui::GetOverlayDrawList()->PrimRectUV(a, b, uv_a, uv_b, col);
return 0;
};
//void PrimQuadUV(const ImVec2& a,const ImVec2& b,const ImVec2& c,const ImVec2& d,const ImVec2& uv_a,const ImVec2& uv_b,const ImVec2& uv_c,const ImVec2& uv_d,ImU32 col);
int cximgui_ImDrawList_PrimQuadUV_9_v2v2v2v2v2v2v2v2i(lua_State* L) {
int __argi__ = 1;
ImVec2 a;
a.x = (float)lua_tonumber(L, __argi__++);
a.y = (float)lua_tonumber(L, __argi__++);
ImVec2 b;
b.x = (float)lua_tonumber(L, __argi__++);
b.y = (float)lua_tonumber(L, __argi__++);
ImVec2 c;
c.x = (float)lua_tonumber(L, __argi__++);
c.y = (float)lua_tonumber(L, __argi__++);
ImVec2 d;
d.x = (float)lua_tonumber(L, __argi__++);
d.y = (float)lua_tonumber(L, __argi__++);
ImVec2 uv_a;
uv_a.x = (float)lua_tonumber(L, __argi__++);
uv_a.y = (float)lua_tonumber(L, __argi__++);
ImVec2 uv_b;
uv_b.x = (float)lua_tonumber(L, __argi__++);
uv_b.y = (float)lua_tonumber(L, __argi__++);
ImVec2 uv_c;
uv_c.x = (float)lua_tonumber(L, __argi__++);
uv_c.y = (float)lua_tonumber(L, __argi__++);
ImVec2 uv_d;
uv_d.x = (float)lua_tonumber(L, __argi__++);
uv_d.y = (float)lua_tonumber(L, __argi__++);
ImU32 col = (ImU32)lua_tointeger(L, __argi__++);
ImGui::GetOverlayDrawList()->PrimQuadUV(a, b, c, d, uv_a, uv_b, uv_c, uv_d, col);
return 0;
};
//void UpdateClipRect();
int cximgui_ImDrawList_UpdateClipRect(lua_State* L) {
ImGui::GetOverlayDrawList()->UpdateClipRect();
return 0;
};
//void UpdateTextureID();
int cximgui_ImDrawList_UpdateTextureID(lua_State* L) {
ImGui::GetOverlayDrawList()->UpdateTextureID();
return 0;
};
//total func 399 unSupported 69
luaL_Reg cximgui_methods[] = {
{"GetCurrentContext",cximgui_GetCurrentContext},
{"DebugCheckVersionAndDataLayout",cximgui_DebugCheckVersionAndDataLayout_6_siiiii},
{"GetIO",cximgui_GetIO},
{"GetStyle",cximgui_GetStyle},
{"NewFrame",cximgui_NewFrame},
{"EndFrame",cximgui_EndFrame},
{"Render",cximgui_Render},
{"GetDrawData",cximgui_GetDrawData},
{"ShowDemoWindow",cximgui_ShowDemoWindow_1_bp},
{"ShowMetricsWindow",cximgui_ShowMetricsWindow_1_bp},
{"ShowStyleSelector",cximgui_ShowStyleSelector_1_s},
{"ShowFontSelector",cximgui_ShowFontSelector_1_s},
{"ShowUserGuide",cximgui_ShowUserGuide},
{"GetVersion",cximgui_GetVersion},
{"Begin",cximgui_Begin_3_sbpi},
{"End",cximgui_End},
{"BeginChild",cximgui_BeginChild_4_sv2bi},
{"BeginChild2",cximgui_BeginChild_4_iv2bi},
{"EndChild",cximgui_EndChild},
{"IsWindowAppearing",cximgui_IsWindowAppearing},
{"IsWindowCollapsed",cximgui_IsWindowCollapsed},
{"IsWindowFocused",cximgui_IsWindowFocused_1_i},
{"IsWindowHovered",cximgui_IsWindowHovered_1_i},
{"GetWindowDrawList",cximgui_GetWindowDrawList},
{"GetWindowDpiScale",cximgui_GetWindowDpiScale},
{"GetWindowViewport",cximgui_GetWindowViewport},
{"GetWindowPos",cximgui_GetWindowPos},
{"GetWindowSize",cximgui_GetWindowSize},
{"GetWindowWidth",cximgui_GetWindowWidth},
{"GetWindowHeight",cximgui_GetWindowHeight},
{"GetContentRegionMax",cximgui_GetContentRegionMax},
{"GetContentRegionAvail",cximgui_GetContentRegionAvail},
{"GetContentRegionAvailWidth",cximgui_GetContentRegionAvailWidth},
{"GetWindowContentRegionMin",cximgui_GetWindowContentRegionMin},
{"GetWindowContentRegionMax",cximgui_GetWindowContentRegionMax},
{"GetWindowContentRegionWidth",cximgui_GetWindowContentRegionWidth},
{"SetNextWindowPos",cximgui_SetNextWindowPos_3_v2iv2},
{"SetNextWindowSize",cximgui_SetNextWindowSize_2_v2i},
{"SetNextWindowContentSize",cximgui_SetNextWindowContentSize_1_v2},
{"SetNextWindowCollapsed",cximgui_SetNextWindowCollapsed_2_bi},
{"SetNextWindowFocus",cximgui_SetNextWindowFocus},
{"SetNextWindowBgAlpha",cximgui_SetNextWindowBgAlpha_1_n},
{"SetNextWindowViewport",cximgui_SetNextWindowViewport_1_i},
{"SetWindowPos",cximgui_SetWindowPos_2_v2i},
{"SetWindowSize",cximgui_SetWindowSize_2_v2i},
{"SetWindowCollapsed",cximgui_SetWindowCollapsed_2_bi},
{"SetWindowFocus",cximgui_SetWindowFocus},
{"SetWindowFontScale",cximgui_SetWindowFontScale_1_n},
{"SetWindowPos",cximgui_SetWindowPos_3_sv2i},
{"SetWindowSize",cximgui_SetWindowSize_3_sv2i},
{"SetWindowCollapsed",cximgui_SetWindowCollapsed_3_sbi},
{"SetWindowFocus",cximgui_SetWindowFocus_1_s},
{"GetScrollX",cximgui_GetScrollX},
{"GetScrollY",cximgui_GetScrollY},
{"GetScrollMaxX",cximgui_GetScrollMaxX},
{"GetScrollMaxY",cximgui_GetScrollMaxY},
{"SetScrollX",cximgui_SetScrollX_1_n},
{"SetScrollY",cximgui_SetScrollY_1_n},
{"SetScrollHereY",cximgui_SetScrollHereY_1_n},
{"SetScrollFromPosY",cximgui_SetScrollFromPosY_2_nn},
{"PopFont",cximgui_PopFont},
{"PushStyleColor",cximgui_PushStyleColor_2_ii},
{"PushStyleColor2",cximgui_PushStyleColor_2_iv4},
{"PopStyleColor",cximgui_PopStyleColor_1_i},
{"PushStyleVar",cximgui_PushStyleVar_2_in},
{"PushStyleVar2",cximgui_PushStyleVar_2_iv2},
{"PopStyleVar",cximgui_PopStyleVar_1_i},
{"GetStyleColorVec4",cximgui_GetStyleColorVec4_1_i},
{"GetFont",cximgui_GetFont},
{"GetFontSize",cximgui_GetFontSize},
{"GetFontTexUvWhitePixel",cximgui_GetFontTexUvWhitePixel},
{"GetColorU32",cximgui_GetColorU32_2_in},
{"GetColorU322",cximgui_GetColorU32_1_v4},
{"GetColorU323",cximgui_GetColorU32_1_i},
{"PushItemWidth",cximgui_PushItemWidth_1_n},
{"PopItemWidth",cximgui_PopItemWidth},
{"CalcItemWidth",cximgui_CalcItemWidth},
{"PushTextWrapPos",cximgui_PushTextWrapPos_1_n},
{"PopTextWrapPos",cximgui_PopTextWrapPos},
{"PushAllowKeyboardFocus",cximgui_PushAllowKeyboardFocus_1_b},
{"PopAllowKeyboardFocus",cximgui_PopAllowKeyboardFocus},
{"PushButtonRepeat",cximgui_PushButtonRepeat_1_b},
{"PopButtonRepeat",cximgui_PopButtonRepeat},
{"Separator",cximgui_Separator},
{"SameLine",cximgui_SameLine_2_nn},
{"NewLine",cximgui_NewLine},
{"Spacing",cximgui_Spacing},
{"Dummy",cximgui_Dummy_1_v2},
{"Indent",cximgui_Indent_1_n},
{"Unindent",cximgui_Unindent_1_n},
{"BeginGroup",cximgui_BeginGroup},
{"EndGroup",cximgui_EndGroup},
{"GetCursorPos",cximgui_GetCursorPos},
{"GetCursorPosX",cximgui_GetCursorPosX},
{"GetCursorPosY",cximgui_GetCursorPosY},
{"SetCursorPos",cximgui_SetCursorPos_1_v2},
{"SetCursorPosX",cximgui_SetCursorPosX_1_n},
{"SetCursorPosY",cximgui_SetCursorPosY_1_n},
{"GetCursorStartPos",cximgui_GetCursorStartPos},
{"GetCursorScreenPos",cximgui_GetCursorScreenPos},
{"SetCursorScreenPos",cximgui_SetCursorScreenPos_1_v2},
{"AlignTextToFramePadding",cximgui_AlignTextToFramePadding},
{"GetTextLineHeight",cximgui_GetTextLineHeight},
{"GetTextLineHeightWithSpacing",cximgui_GetTextLineHeightWithSpacing},
{"GetFrameHeight",cximgui_GetFrameHeight},
{"GetFrameHeightWithSpacing",cximgui_GetFrameHeightWithSpacing},
{"PushID",cximgui_PushID_1_s},
{"PushID2",cximgui_PushID_2_ss},
{"PushID3",cximgui_PushID_1_i},
{"PopID",cximgui_PopID},
{"GetID",cximgui_GetID_1_s},
{"GetID2",cximgui_GetID_2_ss},
{"TextUnformatted",cximgui_TextUnformatted_2_ss},
{"Button",cximgui_Button_2_sv2},
{"SmallButton",cximgui_SmallButton_1_s},
{"InvisibleButton",cximgui_InvisibleButton_2_sv2},
{"ArrowButton",cximgui_ArrowButton_2_si},
{"Checkbox",cximgui_Checkbox_2_sbp},
{"CheckboxFlags",cximgui_CheckboxFlags_3_sIpI},
{"RadioButton",cximgui_RadioButton_2_sb},
{"RadioButton2",cximgui_RadioButton_3_sipi},
{"ProgressBar",cximgui_ProgressBar_3_nv2s},
{"Bullet",cximgui_Bullet},
{"BeginCombo",cximgui_BeginCombo_3_ssi},
{"EndCombo",cximgui_EndCombo},
{"Combo",cximgui_Combo_4_sipsi},
{"DragFloat",cximgui_DragFloat_7_snpnnnsn},
{"DragFloat2",cximgui_DragFloat2_7_snnnnsn},
{"DragFloat3",cximgui_DragFloat3_7_snnnnsn},
{"DragFloat4",cximgui_DragFloat4_7_snnnnsn},
{"DragFloatRange2",cximgui_DragFloatRange2_9_snpnpnnnssn},
{"DragInt",cximgui_DragInt_6_sipniis},
{"DragInt2",cximgui_DragInt2_6_siniis},
{"DragInt3",cximgui_DragInt3_6_siniis},
{"DragInt4",cximgui_DragInt4_6_siniis},
{"DragIntRange2",cximgui_DragIntRange2_8_sipipniiss},
{"SliderFloat",cximgui_SliderFloat_6_snpnnsn},
{"SliderFloat2",cximgui_SliderFloat2_6_snnnsn},
{"SliderFloat3",cximgui_SliderFloat3_6_snnnsn},
{"SliderFloat4",cximgui_SliderFloat4_6_snnnsn},
{"SliderAngle",cximgui_SliderAngle_5_snpnns},
{"SliderInt",cximgui_SliderInt_5_sipiis},
{"SliderInt2",cximgui_SliderInt2_5_siiis},
{"SliderInt3",cximgui_SliderInt3_5_siiis},
{"SliderInt4",cximgui_SliderInt4_5_siiis},
{"VSliderFloat",cximgui_VSliderFloat_7_sv2npnnsn},
{"VSliderInt",cximgui_VSliderInt_6_sv2ipiis},
{"InputFloat",cximgui_InputFloat_6_snpnnsi},
{"InputFloat2",cximgui_InputFloat2_4_snsi},
{"InputFloat3",cximgui_InputFloat3_4_snsi},
{"InputFloat4",cximgui_InputFloat4_4_snsi},
{"InputInt",cximgui_InputInt_5_sipiii},
{"InputInt2",cximgui_InputInt2_3_sii},
{"InputInt3",cximgui_InputInt3_3_sii},
{"InputInt4",cximgui_InputInt4_3_sii},
{"InputDouble",cximgui_InputDouble_6_snpnnsi},
{"ColorEdit3",cximgui_ColorEdit3_3_sni},
{"ColorEdit4",cximgui_ColorEdit4_3_sni},
{"ColorPicker3",cximgui_ColorPicker3_3_sni},
{"ColorPicker4",cximgui_ColorPicker4_4_sninp},
{"ColorButton",cximgui_ColorButton_4_sv4iv2},
{"SetColorEditOptions",cximgui_SetColorEditOptions_1_i},
{"TreeNode",cximgui_TreeNode_1_s},
{"TreeNodeEx",cximgui_TreeNodeEx_2_si},
{"TreePush",cximgui_TreePush_1_s},
{"TreePop",cximgui_TreePop},
{"TreeAdvanceToLabelPos",cximgui_TreeAdvanceToLabelPos},
{"GetTreeNodeToLabelSpacing",cximgui_GetTreeNodeToLabelSpacing},
{"SetNextTreeNodeOpen",cximgui_SetNextTreeNodeOpen_2_bi},
{"CollapsingHeader",cximgui_CollapsingHeader_2_si},
{"CollapsingHeader2",cximgui_CollapsingHeader_3_sbpi},
{"Selectable",cximgui_Selectable_4_sbiv2},
{"Selectable2",cximgui_Selectable_4_sbpiv2},
{"ListBoxHeader",cximgui_ListBoxHeader_2_sv2},
{"ListBoxHeader2",cximgui_ListBoxHeader_3_sii},
{"ListBoxFooter",cximgui_ListBoxFooter},
{"PlotLines",cximgui_PlotLines_9_snpiisnnv2i},
{"PlotHistogram",cximgui_PlotHistogram_9_snpiisnnv2i},
{"Value",cximgui_Value_2_sb},
{"Value2",cximgui_Value_2_si},
{"Value3",cximgui_Value_2_sI},
{"Value4",cximgui_Value_3_sns},
{"BeginMainMenuBar",cximgui_BeginMainMenuBar},
{"EndMainMenuBar",cximgui_EndMainMenuBar},
{"BeginMenuBar",cximgui_BeginMenuBar},
{"EndMenuBar",cximgui_EndMenuBar},
{"BeginMenu",cximgui_BeginMenu_2_sb},
{"EndMenu",cximgui_EndMenu},
{"MenuItem",cximgui_MenuItem_4_ssbb},
{"MenuItem2",cximgui_MenuItem_4_ssbpb},
{"BeginTooltip",cximgui_BeginTooltip},
{"EndTooltip",cximgui_EndTooltip},
{"OpenPopup",cximgui_OpenPopup_1_s},
{"BeginPopup",cximgui_BeginPopup_2_si},
{"BeginPopupContextItem",cximgui_BeginPopupContextItem_2_si},
{"BeginPopupContextWindow",cximgui_BeginPopupContextWindow_3_sib},
{"BeginPopupContextVoid",cximgui_BeginPopupContextVoid_2_si},
{"BeginPopupModal",cximgui_BeginPopupModal_3_sbpi},
{"EndPopup",cximgui_EndPopup},
{"OpenPopupOnItemClick",cximgui_OpenPopupOnItemClick_2_si},
{"IsPopupOpen",cximgui_IsPopupOpen_1_s},
{"CloseCurrentPopup",cximgui_CloseCurrentPopup},
{"Columns",cximgui_Columns_3_isb},
{"NextColumn",cximgui_NextColumn},
{"GetColumnIndex",cximgui_GetColumnIndex},
{"GetColumnWidth",cximgui_GetColumnWidth_1_i},
{"SetColumnWidth",cximgui_SetColumnWidth_2_in},
{"GetColumnOffset",cximgui_GetColumnOffset_1_i},
{"SetColumnOffset",cximgui_SetColumnOffset_2_in},
{"GetColumnsCount",cximgui_GetColumnsCount},
{"BeginTabBar",cximgui_BeginTabBar_2_si},
{"EndTabBar",cximgui_EndTabBar},
{"BeginTabItem",cximgui_BeginTabItem_3_sbpi},
{"EndTabItem",cximgui_EndTabItem},
{"SetTabItemClosed",cximgui_SetTabItemClosed_1_s},
{"SetNextWindowDockId",cximgui_SetNextWindowDockId_2_ii},
{"GetWindowDockId",cximgui_GetWindowDockId},
{"IsWindowDocked",cximgui_IsWindowDocked},
{"LogToTTY",cximgui_LogToTTY_1_i},
{"LogToFile",cximgui_LogToFile_2_is},
{"LogToClipboard",cximgui_LogToClipboard_1_i},
{"LogFinish",cximgui_LogFinish},
{"LogButtons",cximgui_LogButtons},
{"BeginDragDropSource",cximgui_BeginDragDropSource_1_i},
{"EndDragDropSource",cximgui_EndDragDropSource},
{"BeginDragDropTarget",cximgui_BeginDragDropTarget},
{"AcceptDragDropPayload",cximgui_AcceptDragDropPayload_2_si},
{"EndDragDropTarget",cximgui_EndDragDropTarget},
{"GetDragDropPayload",cximgui_GetDragDropPayload},
{"PushClipRect",cximgui_PushClipRect_3_v2v2b},
{"PopClipRect",cximgui_PopClipRect},
{"SetItemDefaultFocus",cximgui_SetItemDefaultFocus},
{"SetKeyboardFocusHere",cximgui_SetKeyboardFocusHere_1_i},
{"IsItemHovered",cximgui_IsItemHovered_1_i},
{"IsItemActive",cximgui_IsItemActive},
{"IsItemFocused",cximgui_IsItemFocused},
{"IsItemClicked",cximgui_IsItemClicked_1_i},
{"IsItemVisible",cximgui_IsItemVisible},
{"IsItemEdited",cximgui_IsItemEdited},
{"IsItemDeactivated",cximgui_IsItemDeactivated},
{"IsItemDeactivatedAfterEdit",cximgui_IsItemDeactivatedAfterEdit},
{"IsAnyItemHovered",cximgui_IsAnyItemHovered},
{"IsAnyItemActive",cximgui_IsAnyItemActive},
{"IsAnyItemFocused",cximgui_IsAnyItemFocused},
{"GetItemRectMin",cximgui_GetItemRectMin},
{"GetItemRectMax",cximgui_GetItemRectMax},
{"GetItemRectSize",cximgui_GetItemRectSize},
{"SetItemAllowOverlap",cximgui_SetItemAllowOverlap},
{"IsRectVisible",cximgui_IsRectVisible_1_v2},
{"IsRectVisible2",cximgui_IsRectVisible_2_v2v2},
{"GetTime",cximgui_GetTime},
{"GetFrameCount",cximgui_GetFrameCount},
{"GetOverlayDrawList",cximgui_GetOverlayDrawList},
{"GetDrawListSharedData",cximgui_GetDrawListSharedData},
{"GetStyleColorName",cximgui_GetStyleColorName_1_i},
{"GetStateStorage",cximgui_GetStateStorage},
{"CalcTextSize",cximgui_CalcTextSize_4_ssbn},
{"CalcListClipping",cximgui_CalcListClipping_4_inipip},
{"BeginChildFrame",cximgui_BeginChildFrame_3_iv2i},
{"EndChildFrame",cximgui_EndChildFrame},
{"ColorConvertU32ToFloat4",cximgui_ColorConvertU32ToFloat4_1_i},
{"ColorConvertFloat4ToU32",cximgui_ColorConvertFloat4ToU32_1_v4},
{"ColorConvertRGBtoHSV",cximgui_ColorConvertRGBtoHSV_6_nnnnnn},
{"ColorConvertHSVtoRGB",cximgui_ColorConvertHSVtoRGB_6_nnnnnn},
{"GetKeyIndex",cximgui_GetKeyIndex_1_i},
{"IsKeyDown",cximgui_IsKeyDown_1_i},
{"IsKeyPressed",cximgui_IsKeyPressed_2_ib},
{"IsKeyReleased",cximgui_IsKeyReleased_1_i},
{"GetKeyPressedAmount",cximgui_GetKeyPressedAmount_3_inn},
{"IsMouseDown",cximgui_IsMouseDown_1_i},
{"IsAnyMouseDown",cximgui_IsAnyMouseDown},
{"IsMouseClicked",cximgui_IsMouseClicked_2_ib},
{"IsMouseDoubleClicked",cximgui_IsMouseDoubleClicked_1_i},
{"IsMouseReleased",cximgui_IsMouseReleased_1_i},
{"IsMouseDragging",cximgui_IsMouseDragging_2_in},
{"IsMouseHoveringRect",cximgui_IsMouseHoveringRect_3_v2v2b},
{"IsMousePosValid",cximgui_IsMousePosValid_1_v2p},
{"GetMousePos",cximgui_GetMousePos},
{"GetMousePosOnOpeningCurrentPopup",cximgui_GetMousePosOnOpeningCurrentPopup},
{"GetMouseDragDelta",cximgui_GetMouseDragDelta_2_in},
{"ResetMouseDragDelta",cximgui_ResetMouseDragDelta_1_i},
{"GetMouseCursor",cximgui_GetMouseCursor},
{"SetMouseCursor",cximgui_SetMouseCursor_1_i},
{"CaptureKeyboardFromApp",cximgui_CaptureKeyboardFromApp_1_b},
{"CaptureMouseFromApp",cximgui_CaptureMouseFromApp_1_b},
{"GetClipboardText",cximgui_GetClipboardText},
{"SetClipboardText",cximgui_SetClipboardText_1_s},
{"LoadIniSettingsFromDisk",cximgui_LoadIniSettingsFromDisk_1_s},
{"LoadIniSettingsFromMemory",cximgui_LoadIniSettingsFromMemory_2_si},
{"SaveIniSettingsToDisk",cximgui_SaveIniSettingsToDisk_1_s},
{"SaveIniSettingsToMemory",cximgui_SaveIniSettingsToMemory_1_ip},
{"MemAlloc",cximgui_MemAlloc_1_i},
{"GetPlatformIO",cximgui_GetPlatformIO},
{"UpdatePlatformWindows",cximgui_UpdatePlatformWindows},
{"DestroyPlatformWindows",cximgui_DestroyPlatformWindows},
{"PushClipRect",cximgui_ImDrawList_PushClipRect_3_v2v2b},
{"PushClipRectFullScreen",cximgui_ImDrawList_PushClipRectFullScreen},
{"PopClipRect",cximgui_ImDrawList_PopClipRect},
{"PopTextureID",cximgui_ImDrawList_PopTextureID},
{"AddLine",cximgui_ImDrawList_AddLine_4_v2v2in},
{"AddRect",cximgui_ImDrawList_AddRect_6_v2v2inin},
{"AddRectFilled",cximgui_ImDrawList_AddRectFilled_5_v2v2ini},
{"AddRectFilledMultiColor",cximgui_ImDrawList_AddRectFilledMultiColor_6_v2v2iiii},
{"AddQuad",cximgui_ImDrawList_AddQuad_6_v2v2v2v2in},
{"AddQuadFilled",cximgui_ImDrawList_AddQuadFilled_5_v2v2v2v2i},
{"AddTriangle",cximgui_ImDrawList_AddTriangle_5_v2v2v2in},
{"AddTriangleFilled",cximgui_ImDrawList_AddTriangleFilled_4_v2v2v2i},
{"AddCircle",cximgui_ImDrawList_AddCircle_5_v2niin},
{"AddCircleFilled",cximgui_ImDrawList_AddCircleFilled_4_v2nii},
{"AddText",cximgui_ImDrawList_AddText_4_v2iss},
{"AddPolyline",cximgui_ImDrawList_AddPolyline_5_v2piibn},
{"AddConvexPolyFilled",cximgui_ImDrawList_AddConvexPolyFilled_3_v2pii},
{"AddBezierCurve",cximgui_ImDrawList_AddBezierCurve_7_v2v2v2v2ini},
{"PathArcTo",cximgui_ImDrawList_PathArcTo_5_v2nnni},
{"PathArcToFast",cximgui_ImDrawList_PathArcToFast_4_v2nii},
{"PathBezierCurveTo",cximgui_ImDrawList_PathBezierCurveTo_4_v2v2v2i},
{"PathRect",cximgui_ImDrawList_PathRect_4_v2v2ni},
{"ChannelsSplit",cximgui_ImDrawList_ChannelsSplit_1_i},
{"ChannelsMerge",cximgui_ImDrawList_ChannelsMerge},
{"ChannelsSetCurrent",cximgui_ImDrawList_ChannelsSetCurrent_1_i},
{"AddDrawCmd",cximgui_ImDrawList_AddDrawCmd},
{"CloneOutput",cximgui_ImDrawList_CloneOutput},
{"Clear",cximgui_ImDrawList_Clear},
{"ClearFreeMemory",cximgui_ImDrawList_ClearFreeMemory},
{"PrimReserve",cximgui_ImDrawList_PrimReserve_2_ii},
{"PrimRect",cximgui_ImDrawList_PrimRect_3_v2v2i},
{"PrimRectUV",cximgui_ImDrawList_PrimRectUV_5_v2v2v2v2i},
{"PrimQuadUV",cximgui_ImDrawList_PrimQuadUV_9_v2v2v2v2v2v2v2v2i},
{"UpdateClipRect",cximgui_ImDrawList_UpdateClipRect},
{"UpdateTextureID",cximgui_ImDrawList_UpdateTextureID},
{ NULL, NULL }
};
struct CXIMStrBuf {
char* str;
uint32_t size;
};
int cximgui_strbuf_reset(lua_State* L) {
CXIMStrBuf* buf = (CXIMStrBuf*)lua_touserdata(L, 1);
const char* str = lua_tostring(L, 2);
size_t len = strlen(str);
strcpy(buf->str, str);
buf->str[len] = '\0';
return 0;
}
int cximgui_strbuf_str(lua_State* L) {
CXIMStrBuf* buf = (CXIMStrBuf*)lua_touserdata(L, 1);
lua_pushstring(L, buf->str);
return 1;
}
int cximgui_strbuf_size(lua_State* L) {
CXIMStrBuf* buf = (CXIMStrBuf*)lua_touserdata(L, 1);
lua_pushinteger(L, buf->size);
return 1;
}
luaL_Reg cximgui_strbuf_methods[] = {
{ "str", cximgui_strbuf_str },
{ "size", cximgui_strbuf_size },
{ "reset", cximgui_strbuf_reset },
{ NULL,NULL }
};
int cximgui_strbuf_destroy(lua_State* L) {
CXIMStrBuf* buf = (CXIMStrBuf*)lua_touserdata(L, 1);
delete[] buf->str;
return 0;
}
int cximgui_strbuf_create(lua_State* L) {
const char* str = lua_tostring(L, 1);
size_t len = strlen(str);
uint32_t size = (uint32_t)lua_tointeger(L, 2);
CXIMStrBuf* buf = (CXIMStrBuf*)lua_newuserdata(L, sizeof(CXIMStrBuf));
luaL_setmetatable(L, "mt_cximgui_strbuf");
buf->str = new char[size];
strcpy(buf->str, str);
buf->str[len] = '\0';
buf->size = size;
return 1;
}
int cximgui_InputText_3_sui(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
CXIMStrBuf* buf = (CXIMStrBuf*)lua_touserdata(L, __argi__++);
ImGuiInputTextFlags extra_flags = (ImGuiInputTextFlags)luaL_optinteger(L, __argi__, 0);
if (extra_flags != 0) __argi__++;
bool __ret__ = ImGui::InputText(label, buf->str, buf->size, extra_flags);
lua_pushboolean(L, __ret__);
return 1;
};
int cximgui_InputTextMultiline_4_suv2i(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
CXIMStrBuf* buf = (CXIMStrBuf*)lua_touserdata(L, __argi__++);
ImVec2 size_def = ImVec2(0, 0);
ImVec2 size;
size.x = (float)luaL_optnumber(L, __argi__, size_def.x);
size.y = (float)luaL_optnumber(L, __argi__ + 1, size_def.y);
if (size.x != size_def.x || size.y != size_def.y) __argi__ += 2;
ImGuiInputTextFlags extra_flags = (ImGuiInputTextFlags)luaL_optinteger(L, __argi__, 0);
if (extra_flags != 0) __argi__++;
bool __ret__ = ImGui::InputTextMultiline(label, buf->str, buf->size, size, extra_flags);
lua_pushboolean(L, __ret__);
return 1;
};
int cximgui_DockSpace_3_iv2i(lua_State* L) {
int __argi__ = 1;
int id = (int)lua_tointeger(L, __argi__++);
ImVec2 size_def = ImVec2(0, 0);
ImVec2 size;
size.x = (float)luaL_optnumber(L, __argi__, size_def.x);
size.y = (float)luaL_optnumber(L, __argi__ + 1, size_def.y);
if (size.x != size_def.x || size.y != size_def.y) __argi__ += 2;
ImGuiDockNodeFlags flags = (ImGuiDockNodeFlags)luaL_optinteger(L, __argi__, 0);
if (flags != 0) __argi__++;
ImGui::DockSpace(id, size, flags);
return 0;
}
int cximgui_GetMainViewport(lua_State* L) {
ImGuiViewport* viewport = ImGui::GetMainViewport();
lua_pushinteger(L, viewport->ID);
lua_pushinteger(L, (int)viewport->Pos.x);
lua_pushinteger(L, (int)viewport->Pos.y);
lua_pushinteger(L, (int)viewport->Size.x);
lua_pushinteger(L, (int)viewport->Size.y);
return 5;
}
int cximgui_ListBox_5_spipsii(lua_State* L) {
int __argi__ = 1;
const char* label = lua_tostring(L, __argi__++);
int current_item = (int)lua_tointeger(L, __argi__++);
int len = (int)luaL_len(L, __argi__);
char** items = new char* [len];
int i = 0;
lua_pushnil(L);
while (lua_next(L, __argi__) != 0) {
size_t str_len = 0;
const char* str = lua_tolstring(L, -1, &str_len);
items[i] = new char[str_len + 1];
strcpy(items[i], str);
i++;
lua_pop(L, 1);
}
__argi__++;
int height_in_items = (int)luaL_optinteger(L, __argi__, -1);
if (height_in_items != -1)__argi__++;
bool __ret__ = ImGui::ListBox(label, ¤t_item, (const char* const*)items, len, height_in_items);
for (int i = 0; i < len; i++) {
delete[] items[i];
}
delete[] items;
lua_pushboolean(L, __ret__);
lua_pushinteger(L, current_item);
return 2;
}
int cximgui_clipper_list(lua_State* L)
{
int size = (int)lua_tointeger(L, 1);
ImGuiListClipper clipper(size);
while (clipper.Step())
{
int ps = clipper.DisplayStart;
int pe = clipper.DisplayEnd;
lua_pushvalue(L, 2);
lua_pushinteger(L, ps);
lua_pushinteger(L, pe);
lua_pcall(L, 2, 0, 0);
}
return 0;
}
int cximgui_keys_mod(lua_State* L)
{
const char* which = lua_tostring(L, 1);
ImGuiIO& io = ImGui::GetIO();
if (strcmp(which, "Ctrl") == 0) {
lua_pushboolean(L, io.KeyCtrl);
}
else if (strcmp(which, "Shift") == 0) {
lua_pushboolean(L, io.KeyShift);
}
else if (strcmp(which, "ALT") == 0) {
lua_pushboolean(L, io.KeyAlt);
}
else if (strcmp(which, "Super") == 0) {
lua_pushboolean(L, io.KeySuper);
}
return 1;
}
luaL_Reg cximgui_extra_methods[] = {
{ "CreateStrbuf", cximgui_strbuf_create },
{ "DestroyStrbuf", cximgui_strbuf_destroy },
{ "InputText",cximgui_InputText_3_sui },
{ "InputTextMultiline",cximgui_InputTextMultiline_4_suv2i },
{ "Text", cximgui_TextUnformatted_2_ss },
{ "DockSpace", cximgui_DockSpace_3_iv2i },
{ "GetMainViewport", cximgui_GetMainViewport },
{ "ListBox", cximgui_ListBox_5_spipsii },
{ "ClipperList", cximgui_clipper_list },
{ "KeysMod", cximgui_keys_mod},
{ NULL,NULL }
};
void luaopen_cximgui(lua_State* L) {
#define REG_IMGUI_ENUM(name) (lua_pushinteger(L, name),lua_setglobal(L, #name))
#include "cximgui_enums.inl"
#undef REG_IMGUI_ENUM
if (luaL_newmetatable(L, "mt_cximgui_strbuf")) {
luaL_setfuncs(L, cximgui_strbuf_methods, 0);
lua_setfield(L, -1, "__index");
}
else {
std::cout << "associate cximgui_strbuf error!" << std::endl;
}
if (luaL_newmetatable(L, "mt_cximgui")) {
luaL_setfuncs(L, cximgui_methods, 0);
luaL_setfuncs(L, cximgui_extra_methods, 0);
lua_setfield(L, -1, "__index");
}
else {
std::cout << "associate cximgui error!" << std::endl;
}
lua_newtable(L);
luaL_setmetatable(L, "mt_cximgui");
lua_setglobal(L, "imgui");
}
| [
"[email protected]"
] | |
3d10da5c730636df95c32086283725dd5b9f0c19 | b22588340d7925b614a735bbbde1b351ad657ffc | /athena/Generators/GenInterfaces/GenInterfaces/GenInterfacesDict.h | 6aa39bf6341710a46e5837c10f5871f67764d4e7 | [] | no_license | rushioda/PIXELVALID_athena | 90befe12042c1249cbb3655dde1428bb9b9a42ce | 22df23187ef85e9c3120122c8375ea0e7d8ea440 | refs/heads/master | 2020-12-14T22:01:15.365949 | 2020-01-19T03:59:35 | 2020-01-19T03:59:35 | 234,836,993 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 714 | h | /*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GENINTERFACES_GENINTERFACESDICT_H
#define GENINTERFACES_GENINTERFACESDICT_H
#if defined(__GCCXML__) and not defined(EIGEN_DONT_VECTORIZE)
#define EIGEN_DONT_VECTORIZE
#endif // __GCCXML__
// Includes for the dictionary generation:
#include "GenInterfaces/IEvgenOTFTopUpSvc.h"
#include "GenInterfaces/IHepMCWeightSvc.h"
#include "GenInterfaces/IHforTool.h"
#include "GenInterfaces/IPDFReweightTool.h"
#include "GenInterfaces/ITruthSelector.h"
#include "HepMC/SimpleVector.h"
#include <vector>
namespace HforToolDict {
struct tmp {
std::vector<HepMC::FourVector> v;
};
}
#endif // GENINTERFACES_GENINTERFACESDICT_H | [
"[email protected]"
] | |
1eec6fcee262ab4661944eb5656d6f74e92bdd93 | a7764174fb0351ea666faa9f3b5dfe304390a011 | /inc/Handle_TColgp_HArray1OfLin2d.hxx | d830f62c472f7f9eb09ecd09d6530efd81aa368a | [] | no_license | uel-dataexchange/Opencascade_uel | f7123943e9d8124f4fa67579e3cd3f85cfe52d91 | 06ec93d238d3e3ea2881ff44ba8c21cf870435cd | refs/heads/master | 2022-11-16T07:40:30.837854 | 2020-07-08T01:56:37 | 2020-07-08T01:56:37 | 276,290,778 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 805 | hxx | // This file is generated by WOK (CPPExt).
// Please do not edit this file; modify original file instead.
// The copyright and license terms as defined for the original file apply to
// this header file considered to be the "object code" form of the original source.
#ifndef _Handle_TColgp_HArray1OfLin2d_HeaderFile
#define _Handle_TColgp_HArray1OfLin2d_HeaderFile
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_DefineHandle_HeaderFile
#include <Standard_DefineHandle.hxx>
#endif
#ifndef _Handle_MMgt_TShared_HeaderFile
#include <Handle_MMgt_TShared.hxx>
#endif
class Standard_Transient;
class Handle(Standard_Type);
class Handle(MMgt_TShared);
class TColgp_HArray1OfLin2d;
DEFINE_STANDARD_HANDLE(TColgp_HArray1OfLin2d,MMgt_TShared)
#endif
| [
"[email protected]"
] | |
c7f93ae2d1a905ad6edbd7f2c9472e7c1e5c4da5 | c304381776279bb96c7c73dff5147b826c1fee30 | /machine.h | 3dcf4a0da15ccfc1efde186eae8adc29ff16a129 | [] | no_license | yuchun1214/JobShop | dfd339783f047eb24edb9e34a69318d454b1a33c | 20298374f0b1109ee09e263716d419a5a6800c6a | refs/heads/master | 2023-02-06T17:42:56.537159 | 2020-12-24T07:42:55 | 2020-12-24T07:42:55 | 291,057,637 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,308 | h | #ifndef MACHINE_H
#define MACHINE_H
#include <vector>
#include <algorithm>
#include <opencv2/opencv.hpp>
#include <map>
#include "gantt.h"
#include "job.h"
#include "job_base.h"
#include "setup_time_job.h"
#include <string>
class Machine{
private:
static int ARRIVE_PENALTY;
static int R_QT_PENALTY;
private:
std::vector<Job *> _jobs;
std::vector<Job_base *> _setup_time_jobs;
static std::map<std::string, cv::Scalar>::iterator _colorIt;
const static std::map<std::string, cv::Scalar>::iterator _colorItEnd;
std::vector<std::vector<int> > _setup_time;
int _number;
Job_base * _jobs_start;
Job_base * _current_job;
std::string _machineID;
std::string _status;
int _recoverTime;
cv::Scalar tempScalar;
int _colorCode[3];
int _totalTime;
void generate_color_code();
std::map<std::string, int> _processTime;
int _quality;
void insert_setup_time();
public:
Machine(int number);
Machine(int number, std::string machineID, std::vector<std::string> status, std::vector<std::vector<int> >setup_times);
Machine();
void add_job(Job *);
void sort_job(bool rule=false);
void demo();
void clear();
void add_into_gantt_chart(GanttChart & gantt);
int get_total_time();
int get_quality();
int penalty_function(Job *);
int get_dead_jobs_amount();
int get_too_late_job_amount();
};
#endif
| [
"[email protected]"
] | |
16a93df842e1dc2a0bf9510b48b37deec726e788 | ee61d185a28d509edd64c87961ba52ba90201498 | /src/libraries/GxEPD/src/GxFont_GFX.cpp | e4b879e3036df7309fc903ce84deffaed57e50e3 | [
"MIT",
"GPL-3.0-only"
] | permissive | dbuggz/TTGO_TWatch_Library | 50198b5cf882aaad9ffd86ffd97b8a09ce7cfde8 | bf3cf5d805d1a399742a1853ee6fe810f30e8ada | refs/heads/master | 2023-02-04T08:42:36.481998 | 2020-08-30T21:18:52 | 2020-08-30T21:18:52 | 291,553,216 | 0 | 0 | MIT | 2020-08-30T21:15:24 | 2020-08-30T21:15:23 | null | UTF-8 | C++ | false | false | 13,203 | cpp | // class GxFont_GFX : Font Rendering Graphics Switch and Bridge Class
//
// This class allows to connect GxEPD to additional font rendering classes.
//
// U8G2_FOR_ADAFRUIT_GFX: Arduino Library that makes all U8G2 fonts available (Oliver Kraus)
// avaliable from: https://github.com/olikraus/U8g2_for_Adafruit_GFX
//
// GxFont_GFX_TFT_eSPI: fonts and font rendering of TFT_eSPI library (Bodmer)
// available here: https://github.com/ZinggJM/GxFont_GFX_TFT_eSPI
//
// Adafruit_ftGFX: a Adafruit_GFX variant with different fonts.
// need to use modified clone from: https://github.com/ZinggJM/Adafruit_ftGFX
// (no additional fonts, as all are now part of Adafruit_GFX)
//
// Author : J-M Zingg
//
// Version : see library.properties
//
// License: GNU GENERAL PUBLIC LICENSE V3, see LICENSE
//
// Library: https://github.com/ZinggJM/GxEPD
#include "GxFont_GFX.h"
//#define DIAG_UTF8(x) x
//#define DIAG(x) x
#ifndef DIAG_UTF8
#define DIAG_UTF8(x)
#endif
#ifndef DIAG
#define DIAG(x)
#endif
enum eFont_GFX
{
U8g2_for_Adafruit_GFX_font_gfx, Adafruit_GFX_font_gfx, Adafruit_ftGFX_font_gfx, GxFont_GFX_TFT_eSPI_font_gfx
};
GxFont_GFX::GxFont_GFX(int16_t w, int16_t h) : Adafruit_GFX(w, h)
#if defined(U8g2_for_Adafruit_GFX_h)
, _U8G2_FONTS_GFX(*this)
#endif
#if defined(_ADAFRUIT_TF_GFX_H_)
, _GxF_Adafruit_ftGFX(*this, w, h)
#endif
#if defined(_GxFont_GFX_TFT_eSPI_H_)
, _GxF_GxFont_GFX_TFT_eSPI(*this, w, h)
#endif
{
_font_gfx = Adafruit_GFX_font_gfx;
}
void GxFont_GFX::setFont(const GFXfont *f)
{
_font_gfx = Adafruit_GFX_font_gfx;
Adafruit_GFX::setFont(f);
}
#if defined(U8g2_for_Adafruit_GFX_h)
void GxFont_GFX::setFont(const uint8_t *font)
{
_font_gfx = U8g2_for_Adafruit_GFX_font_gfx;
_U8G2_FONTS_GFX.setFont(font);
}
#endif
#if defined(_ADAFRUIT_TF_GFX_H_)
void GxFont_GFX::GxF_Adafruit_ftGFX::drawPixel(int16_t x, int16_t y, uint16_t color)
{
_container.drawPixel(x, y, color);
}
void GxFont_GFX::setFont(uint8_t f)
{
_font_gfx = Adafruit_ftGFX_font_gfx;
_GxF_Adafruit_ftGFX.setFont(f);
}
#endif
#if defined(_GxFont_GFX_TFT_eSPI_H_)
void GxFont_GFX::GxF_GxFont_GFX_TFT_eSPI::drawPixel(uint32_t x, uint32_t y, uint32_t color)
{
//Serial.print("GxFont_GFX::GxF_GxFont_GFX_TFT_eSPI::drawPixel("); Serial.print(color); Serial.println(")"); yield();
_container.drawPixel(x, y, color);
}
void GxFont_GFX::GxF_GxFont_GFX_TFT_eSPI::drawFastHLine(int32_t x, int32_t y, int32_t w, uint32_t color)
{
//Serial.print("GxFont_GFX::GxF_GxFont_GFX_TFT_eSPI::drawFastHLine("); Serial.print(color); Serial.println(")"); yield();
_container.drawFastHLine(x, y, w, color);
}
void GxFont_GFX::GxF_GxFont_GFX_TFT_eSPI::fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
{
//Serial.print("GxFont_GFX::GxF_GxFont_GFX_TFT_eSPI::fillRect("); Serial.print(color); Serial.println(")"); yield();
_container.fillRect(x, y, w, h, color);
}
#ifdef LOAD_GFXFF
void GxFont_GFX::setFreeFont(const GFXfont *f)
{
_font_gfx = GxFont_GFX_TFT_eSPI_font_gfx;
_GxF_GxFont_GFX_TFT_eSPI.setFreeFont(f);
}
void GxFont_GFX::setTextFont(uint8_t font)
{
_font_gfx = GxFont_GFX_TFT_eSPI_font_gfx;
_GxF_GxFont_GFX_TFT_eSPI.setTextFont(font);
}
#else
void GxFont_GFX::setFreeFont(uint8_t font)
{
_font_gfx = GxFont_GFX_TFT_eSPI_font_gfx;
_GxF_GxFont_GFX_TFT_eSPI.setFreeFont(font);
}
void GxFont_GFX::setTextFont(uint8_t font)
{
_font_gfx = GxFont_GFX_TFT_eSPI_font_gfx;
_GxF_GxFont_GFX_TFT_eSPI.setTextFont(font);
}
#endif
#endif
#if defined(U8g2_for_Adafruit_GFX_h) || defined(_GxFont_GFX_TFT_eSPI_H_)|| defined(_ADAFRUIT_TF_GFX_H_)
void GxFont_GFX::setCursor(int16_t x, int16_t y)
{
Adafruit_GFX::setCursor(x, y);
#if defined(U8g2_for_Adafruit_GFX_h)
_U8G2_FONTS_GFX.setCursor(x, y);
#endif
#if defined(_ADAFRUIT_TF_GFX_H_)
_GxF_Adafruit_ftGFX.setCursor(x, y);
#endif
#if defined(_GxFont_GFX_TFT_eSPI_H_)
_GxF_GxFont_GFX_TFT_eSPI.setCursor(x, y);
#endif
}
size_t GxFont_GFX::write(uint8_t v)
{
DIAG (Serial.write(v); Serial.println();)
DIAG_UTF8(if (v > 127) Serial.println(v, HEX);)
switch (_font_gfx)
{
case Adafruit_GFX_font_gfx:
Adafruit_GFX::write(v);
break;
#if defined(U8g2_for_Adafruit_GFX_h)
case U8g2_for_Adafruit_GFX_font_gfx:
_U8G2_FONTS_GFX.write(v);
break;
#endif
#if defined(_ADAFRUIT_TF_GFX_H_)
case Adafruit_ftGFX_font_gfx:
_GxF_Adafruit_ftGFX.write(v);
break;
#endif
#if defined(_GxFont_GFX_TFT_eSPI_H_)
case GxFont_GFX_TFT_eSPI_font_gfx:
_GxF_GxFont_GFX_TFT_eSPI.write(v);
break;
#endif
}
}
int16_t GxFont_GFX::getCursorX(void) const
{
switch (_font_gfx)
{
case Adafruit_GFX_font_gfx:
return Adafruit_GFX::getCursorX();
#if defined(U8g2_for_Adafruit_GFX_h)
case U8g2_for_Adafruit_GFX_font_gfx:
return const_cast<U8G2_FONTS_GFX&>(_U8G2_FONTS_GFX).getCursorX();
#endif
#if defined(_ADAFRUIT_TF_GFX_H_)
case Adafruit_ftGFX_font_gfx:
return _GxF_Adafruit_ftGFX.getCursorX();
#endif
#if defined(_GxFont_GFX_TFT_eSPI_H_)
case GxFont_GFX_TFT_eSPI_font_gfx:
return _GxF_GxFont_GFX_TFT_eSPI.getCursorX();
#endif
}
}
int16_t GxFont_GFX::getCursorY(void) const
{
switch (_font_gfx)
{
case Adafruit_GFX_font_gfx:
return Adafruit_GFX::getCursorY();
#if defined(U8g2_for_Adafruit_GFX_h)
case U8g2_for_Adafruit_GFX_font_gfx:
return const_cast<U8G2_FONTS_GFX&>(_U8G2_FONTS_GFX).getCursorY();
#endif
#if defined(_ADAFRUIT_TF_GFX_H_)
case Adafruit_ftGFX_font_gfx:
return _GxF_Adafruit_ftGFX.getCursorY();
#endif
#if defined(_GxFont_GFX_TFT_eSPI_H_)
case GxFont_GFX_TFT_eSPI_font_gfx:
return _GxF_GxFont_GFX_TFT_eSPI.getCursorY();
#endif
}
}
#endif
#if defined(U8g2_for_Adafruit_GFX_h)
void GxFont_GFX::home(void)
{
_U8G2_FONTS_GFX.home();
}
void GxFont_GFX::setFontMode(uint8_t is_transparent)
{
_U8G2_FONTS_GFX.setFontMode(is_transparent);
}
void GxFont_GFX::setFontDirection(uint8_t d)
{
_U8G2_FONTS_GFX.setFontDirection(d);
}
void GxFont_GFX::setForegroundColor(uint16_t fg)
{
_U8G2_FONTS_GFX.setForegroundColor(fg);
}
void GxFont_GFX::setBackgroundColor(uint16_t bg)
{
_U8G2_FONTS_GFX.setBackgroundColor(bg);
}
int8_t GxFont_GFX::getFontAscent(void)
{
return ((_font_gfx == U8g2_for_Adafruit_GFX_font_gfx) ? _U8G2_FONTS_GFX.getFontAscent() : 0);
}
int8_t GxFont_GFX::getFontDescent(void)
{
return ((_font_gfx == U8g2_for_Adafruit_GFX_font_gfx) ? _U8G2_FONTS_GFX.getFontDescent() : 0);
}
int8_t GxFont_GFX::getFontHeight(void)
{
return ((_font_gfx == U8g2_for_Adafruit_GFX_font_gfx) ? _U8G2_FONTS_GFX.u8g2.font_info.max_char_height : 0);
}
int16_t GxFont_GFX::drawGlyph(int16_t x, int16_t y, uint16_t e)
{
return ((_font_gfx == U8g2_for_Adafruit_GFX_font_gfx) ? _U8G2_FONTS_GFX.drawGlyph(x, y, e) : 0);
}
int16_t GxFont_GFX::drawStr(int16_t x, int16_t y, const char *s)
{
return ((_font_gfx == U8g2_for_Adafruit_GFX_font_gfx) ? _U8G2_FONTS_GFX.drawStr(x, y, s) : 0);
}
int16_t GxFont_GFX::drawUTF8(int16_t x, int16_t y, const char *str)
{
return ((_font_gfx == U8g2_for_Adafruit_GFX_font_gfx) ? _U8G2_FONTS_GFX.drawUTF8(x, y, str) : 0);
}
int16_t GxFont_GFX::getUTF8Width(const char *str)
{
return ((_font_gfx == U8g2_for_Adafruit_GFX_font_gfx) ? _U8G2_FONTS_GFX.getUTF8Width(str) : 0);
}
uint16_t GxFont_GFX::utf8_next(uint8_t b)
{
return ((_font_gfx == U8g2_for_Adafruit_GFX_font_gfx) ? _U8G2_FONTS_GFX.utf8_next(b) : 0);
}
#endif
#if defined(_ADAFRUIT_TF_GFX_H_) || defined(_GxFont_GFX_TFT_eSPI_H_)
void GxFont_GFX::drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size)
{
switch (_font_gfx)
{
case Adafruit_GFX_font_gfx:
Adafruit_GFX::drawChar(x, y, c, color, bg, size);
break;
#if defined(_ADAFRUIT_TF_GFX_H_)
case Adafruit_ftGFX_font_gfx:
_GxF_Adafruit_ftGFX.drawChar(x, y, c, color, bg, size);
break;
#endif
#if defined(_GxFont_GFX_TFT_eSPI_H_)
case GxFont_GFX_TFT_eSPI_font_gfx:
_GxF_GxFont_GFX_TFT_eSPI.drawChar(x, y, c, color, bg, size);
break;
#endif
}
}
void GxFont_GFX::setTextColor(uint16_t c)
{
Adafruit_GFX::setTextColor(c);
#if defined(_ADAFRUIT_TF_GFX_H_)
_GxF_Adafruit_ftGFX.setTextColor(c);
#endif
#if defined(_GxFont_GFX_TFT_eSPI_H_)
_GxF_GxFont_GFX_TFT_eSPI.setTextColor(c);
#endif
}
void GxFont_GFX::setTextColor(uint16_t c, uint16_t bg)
{
Adafruit_GFX::setTextColor(c, bg);
#if defined(_ADAFRUIT_TF_GFX_H_)
_GxF_Adafruit_ftGFX.setTextColor(c, bg);
#endif
#if defined(_GxFont_GFX_TFT_eSPI_H_)
_GxF_GxFont_GFX_TFT_eSPI.setTextColor(c, bg);
#endif
}
void GxFont_GFX::setTextSize(uint8_t s)
{
Adafruit_GFX::setTextSize(s);
#if defined(_ADAFRUIT_TF_GFX_H_)
_GxF_Adafruit_ftGFX.setTextSize(s);
#endif
#if defined(_GxFont_GFX_TFT_eSPI_H_)
_GxF_GxFont_GFX_TFT_eSPI.setTextSize(s);
#endif
}
void GxFont_GFX::setTextWrap(boolean w)
{
Adafruit_GFX::setTextWrap(w);
#if defined(_ADAFRUIT_TF_GFX_H_)
_GxF_Adafruit_ftGFX.setTextWrap(w);
#endif
#if defined(_GxFont_GFX_TFT_eSPI_H_)
_GxF_GxFont_GFX_TFT_eSPI.setTextWrap(w);
#endif
}
#endif
#if defined(_GxFont_GFX_TFT_eSPI_H_)
void GxFont_GFX::setTextDatum(uint8_t datum)
{
if (_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) _GxF_GxFont_GFX_TFT_eSPI.setTextDatum(datum);
}
void GxFont_GFX::setTextPadding(uint16_t x_width)
{
if (_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) _GxF_GxFont_GFX_TFT_eSPI.setTextPadding(x_width);
}
uint8_t GxFont_GFX::getTextDatum()
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.getTextDatum() : 0);
}
uint8_t GxFont_GFX::color16to8(uint16_t color565) // Convert 16 bit colour to 8 bits
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.color16to8(color565) : 0);
}
uint16_t GxFont_GFX::fontsLoaded(void)
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.fontsLoaded() : 0);
}
uint16_t GxFont_GFX::color565(uint8_t r, uint8_t g, uint8_t b)
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.color565(r, g, b) : 0);
}
uint16_t GxFont_GFX::color8to16(uint8_t color332) // Convert 8 bit colour to 16 bits
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.color8to16(color332) : 0);
}
int16_t GxFont_GFX::drawNumber(long long_num, int poX, int poY, int font)
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.drawNumber(long_num, poX, poY, font) : 0);
}
int16_t GxFont_GFX::drawNumber(long long_num, int poX, int poY)
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.drawNumber(long_num, poX, poY) : 0);
}
int16_t GxFont_GFX::drawFloat(float floatNumber, int decimal, int poX, int poY, int font)
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.drawFloat(floatNumber, decimal, poX, poY, font) : 0);
}
int16_t GxFont_GFX::drawFloat(float floatNumber, int decimal, int poX, int poY)
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.drawFloat(floatNumber, decimal, poX, poY) : 0);
}
// Handle char arrays
int16_t GxFont_GFX::drawString(const char *string, int poX, int poY, int font)
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.drawString(string, poX, poY, font) : 0);
}
int16_t GxFont_GFX::drawString(const char *string, int poX, int poY)
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.drawString(string, poX, poY) : 0);
}
// Handle String type
int16_t GxFont_GFX::drawString(const String& string, int poX, int poY, int font)
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.drawString(string, poX, poY, font) : 0);
}
int16_t GxFont_GFX::drawString(const String& string, int poX, int poY)
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.drawString(string, poX, poY) : 0);
}
int16_t GxFont_GFX::textWidth(const char *string, int font)
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.textWidth(string, font) : 0);
}
int16_t GxFont_GFX::textWidth(const char *string)
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.textWidth(string) : 0);
}
int16_t GxFont_GFX::textWidth(const String& string, int font)
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.textWidth(string, font) : 0);
}
int16_t GxFont_GFX::textWidth(const String& string)
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.textWidth(string) : 0);
}
int16_t GxFont_GFX::fontHeight(int16_t font)
{
return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.fontHeight(font) : 0);
}
#endif
| [
"[email protected]"
] | |
d545416ad17ab314d5d1da71b78369f8395c650f | 7ecaab8f6c74e8f01d4db2655e8bdf84a09331c2 | /analyze_proto/output/proto_analyze/modules/planning/proto/navi_path_decider_config.pb.h | 505417c7c244f432920e03bab8abd920def48484 | [] | no_license | zhouyapengzi/apollo_analyze_tools | 11577ef8c2316e2bf89f01309665e10c3e31b0ad | f6ecf2421c1d63c3ae492d3a3bb87e47a9386aba | refs/heads/master | 2022-11-25T18:48:05.554694 | 2020-07-28T16:07:39 | 2020-07-28T16:07:39 | 273,553,845 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | true | 46,316 | h | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: modules/planning/proto/navi_path_decider_config.proto
#ifndef GOOGLE_PROTOBUF_INCLUDED_modules_2fplanning_2fproto_2fnavi_5fpath_5fdecider_5fconfig_2eproto
#define GOOGLE_PROTOBUF_INCLUDED_modules_2fplanning_2fproto_2fnavi_5fpath_5fdecider_5fconfig_2eproto
#include <limits>
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3011000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3011002 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/inlined_string_field.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/message.h>
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
#define PROTOBUF_INTERNAL_EXPORT_modules_2fplanning_2fproto_2fnavi_5fpath_5fdecider_5fconfig_2eproto
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
} // namespace internal
PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct TableStruct_modules_2fplanning_2fproto_2fnavi_5fpath_5fdecider_5fconfig_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxillaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[3]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
};
extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_modules_2fplanning_2fproto_2fnavi_5fpath_5fdecider_5fconfig_2eproto;
namespace apollo {
namespace planning {
class MoveDestLaneConfigTable;
class MoveDestLaneConfigTableDefaultTypeInternal;
extern MoveDestLaneConfigTableDefaultTypeInternal _MoveDestLaneConfigTable_default_instance_;
class NaviPathDeciderConfig;
class NaviPathDeciderConfigDefaultTypeInternal;
extern NaviPathDeciderConfigDefaultTypeInternal _NaviPathDeciderConfig_default_instance_;
class ShiftConfig;
class ShiftConfigDefaultTypeInternal;
extern ShiftConfigDefaultTypeInternal _ShiftConfig_default_instance_;
} // namespace planning
} // namespace apollo
PROTOBUF_NAMESPACE_OPEN
template<> ::apollo::planning::MoveDestLaneConfigTable* Arena::CreateMaybeMessage<::apollo::planning::MoveDestLaneConfigTable>(Arena*);
template<> ::apollo::planning::NaviPathDeciderConfig* Arena::CreateMaybeMessage<::apollo::planning::NaviPathDeciderConfig>(Arena*);
template<> ::apollo::planning::ShiftConfig* Arena::CreateMaybeMessage<::apollo::planning::ShiftConfig>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
namespace apollo {
namespace planning {
// ===================================================================
class NaviPathDeciderConfig :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:apollo.planning.NaviPathDeciderConfig) */ {
public:
NaviPathDeciderConfig();
virtual ~NaviPathDeciderConfig();
NaviPathDeciderConfig(const NaviPathDeciderConfig& from);
NaviPathDeciderConfig(NaviPathDeciderConfig&& from) noexcept
: NaviPathDeciderConfig() {
*this = ::std::move(from);
}
inline NaviPathDeciderConfig& operator=(const NaviPathDeciderConfig& from) {
CopyFrom(from);
return *this;
}
inline NaviPathDeciderConfig& operator=(NaviPathDeciderConfig&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const {
return _internal_metadata_.unknown_fields();
}
inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() {
return _internal_metadata_.mutable_unknown_fields();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
return GetDescriptor();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
return GetMetadataStatic().descriptor;
}
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
return GetMetadataStatic().reflection;
}
static const NaviPathDeciderConfig& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const NaviPathDeciderConfig* internal_default_instance() {
return reinterpret_cast<const NaviPathDeciderConfig*>(
&_NaviPathDeciderConfig_default_instance_);
}
static constexpr int kIndexInFileMessages =
0;
friend void swap(NaviPathDeciderConfig& a, NaviPathDeciderConfig& b) {
a.Swap(&b);
}
inline void Swap(NaviPathDeciderConfig* other) {
if (other == this) return;
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline NaviPathDeciderConfig* New() const final {
return CreateMaybeMessage<NaviPathDeciderConfig>(nullptr);
}
NaviPathDeciderConfig* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
return CreateMaybeMessage<NaviPathDeciderConfig>(arena);
}
void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final;
void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final;
void CopyFrom(const NaviPathDeciderConfig& from);
void MergeFrom(const NaviPathDeciderConfig& from);
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
private:
inline void SharedCtor();
inline void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(NaviPathDeciderConfig* other);
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "apollo.planning.NaviPathDeciderConfig";
}
private:
inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const {
return nullptr;
}
inline void* MaybeArenaPtr() const {
return nullptr;
}
public:
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
private:
static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_modules_2fplanning_2fproto_2fnavi_5fpath_5fdecider_5fconfig_2eproto);
return ::descriptor_table_modules_2fplanning_2fproto_2fnavi_5fpath_5fdecider_5fconfig_2eproto.file_level_metadata[kIndexInFileMessages];
}
public:
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
enum : int {
kMoveDestLaneConfigTalbeFieldNumber = 7,
kMaxKappaThresholdFieldNumber = 9,
kKappaMoveDestLaneCompensationFieldNumber = 10,
kStartPlanPointFromFieldNumber = 11,
kMinLookForwardTimeFieldNumber = 2,
kMinPathLengthFieldNumber = 1,
kMaxKeepLaneDistanceFieldNumber = 3,
kMaxKeepLaneShiftYFieldNumber = 4,
kMinKeepLaneOffsetFieldNumber = 5,
kKeepLaneShiftCompensationFieldNumber = 6,
kMoveDestLaneCompensationFieldNumber = 8,
};
// optional .apollo.planning.MoveDestLaneConfigTable move_dest_lane_config_talbe = 7;
bool has_move_dest_lane_config_talbe() const;
private:
bool _internal_has_move_dest_lane_config_talbe() const;
public:
void clear_move_dest_lane_config_talbe();
const ::apollo::planning::MoveDestLaneConfigTable& move_dest_lane_config_talbe() const;
::apollo::planning::MoveDestLaneConfigTable* release_move_dest_lane_config_talbe();
::apollo::planning::MoveDestLaneConfigTable* mutable_move_dest_lane_config_talbe();
void set_allocated_move_dest_lane_config_talbe(::apollo::planning::MoveDestLaneConfigTable* move_dest_lane_config_talbe);
private:
const ::apollo::planning::MoveDestLaneConfigTable& _internal_move_dest_lane_config_talbe() const;
::apollo::planning::MoveDestLaneConfigTable* _internal_mutable_move_dest_lane_config_talbe();
public:
// optional double max_kappa_threshold = 9 [default = 0];
bool has_max_kappa_threshold() const;
private:
bool _internal_has_max_kappa_threshold() const;
public:
void clear_max_kappa_threshold();
double max_kappa_threshold() const;
void set_max_kappa_threshold(double value);
private:
double _internal_max_kappa_threshold() const;
void _internal_set_max_kappa_threshold(double value);
public:
// optional double kappa_move_dest_lane_compensation = 10 [default = 0];
bool has_kappa_move_dest_lane_compensation() const;
private:
bool _internal_has_kappa_move_dest_lane_compensation() const;
public:
void clear_kappa_move_dest_lane_compensation();
double kappa_move_dest_lane_compensation() const;
void set_kappa_move_dest_lane_compensation(double value);
private:
double _internal_kappa_move_dest_lane_compensation() const;
void _internal_set_kappa_move_dest_lane_compensation(double value);
public:
// optional uint32 start_plan_point_from = 11 [default = 0];
bool has_start_plan_point_from() const;
private:
bool _internal_has_start_plan_point_from() const;
public:
void clear_start_plan_point_from();
::PROTOBUF_NAMESPACE_ID::uint32 start_plan_point_from() const;
void set_start_plan_point_from(::PROTOBUF_NAMESPACE_ID::uint32 value);
private:
::PROTOBUF_NAMESPACE_ID::uint32 _internal_start_plan_point_from() const;
void _internal_set_start_plan_point_from(::PROTOBUF_NAMESPACE_ID::uint32 value);
public:
// optional uint32 min_look_forward_time = 2 [default = 2];
bool has_min_look_forward_time() const;
private:
bool _internal_has_min_look_forward_time() const;
public:
void clear_min_look_forward_time();
::PROTOBUF_NAMESPACE_ID::uint32 min_look_forward_time() const;
void set_min_look_forward_time(::PROTOBUF_NAMESPACE_ID::uint32 value);
private:
::PROTOBUF_NAMESPACE_ID::uint32 _internal_min_look_forward_time() const;
void _internal_set_min_look_forward_time(::PROTOBUF_NAMESPACE_ID::uint32 value);
public:
// optional double min_path_length = 1 [default = 5];
bool has_min_path_length() const;
private:
bool _internal_has_min_path_length() const;
public:
void clear_min_path_length();
double min_path_length() const;
void set_min_path_length(double value);
private:
double _internal_min_path_length() const;
void _internal_set_min_path_length(double value);
public:
// optional double max_keep_lane_distance = 3 [default = 0.8];
bool has_max_keep_lane_distance() const;
private:
bool _internal_has_max_keep_lane_distance() const;
public:
void clear_max_keep_lane_distance();
double max_keep_lane_distance() const;
void set_max_keep_lane_distance(double value);
private:
double _internal_max_keep_lane_distance() const;
void _internal_set_max_keep_lane_distance(double value);
public:
// optional double max_keep_lane_shift_y = 4 [default = 20];
bool has_max_keep_lane_shift_y() const;
private:
bool _internal_has_max_keep_lane_shift_y() const;
public:
void clear_max_keep_lane_shift_y();
double max_keep_lane_shift_y() const;
void set_max_keep_lane_shift_y(double value);
private:
double _internal_max_keep_lane_shift_y() const;
void _internal_set_max_keep_lane_shift_y(double value);
public:
// optional double min_keep_lane_offset = 5 [default = 15];
bool has_min_keep_lane_offset() const;
private:
bool _internal_has_min_keep_lane_offset() const;
public:
void clear_min_keep_lane_offset();
double min_keep_lane_offset() const;
void set_min_keep_lane_offset(double value);
private:
double _internal_min_keep_lane_offset() const;
void _internal_set_min_keep_lane_offset(double value);
public:
// optional double keep_lane_shift_compensation = 6 [default = 0.01];
bool has_keep_lane_shift_compensation() const;
private:
bool _internal_has_keep_lane_shift_compensation() const;
public:
void clear_keep_lane_shift_compensation();
double keep_lane_shift_compensation() const;
void set_keep_lane_shift_compensation(double value);
private:
double _internal_keep_lane_shift_compensation() const;
void _internal_set_keep_lane_shift_compensation(double value);
public:
// optional double move_dest_lane_compensation = 8 [default = 0.35];
bool has_move_dest_lane_compensation() const;
private:
bool _internal_has_move_dest_lane_compensation() const;
public:
void clear_move_dest_lane_compensation();
double move_dest_lane_compensation() const;
void set_move_dest_lane_compensation(double value);
private:
double _internal_move_dest_lane_compensation() const;
void _internal_set_move_dest_lane_compensation(double value);
public:
// @@protoc_insertion_point(class_scope:apollo.planning.NaviPathDeciderConfig)
private:
class _Internal;
::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_;
::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
::apollo::planning::MoveDestLaneConfigTable* move_dest_lane_config_talbe_;
double max_kappa_threshold_;
double kappa_move_dest_lane_compensation_;
::PROTOBUF_NAMESPACE_ID::uint32 start_plan_point_from_;
::PROTOBUF_NAMESPACE_ID::uint32 min_look_forward_time_;
double min_path_length_;
double max_keep_lane_distance_;
double max_keep_lane_shift_y_;
double min_keep_lane_offset_;
double keep_lane_shift_compensation_;
double move_dest_lane_compensation_;
friend struct ::TableStruct_modules_2fplanning_2fproto_2fnavi_5fpath_5fdecider_5fconfig_2eproto;
};
// -------------------------------------------------------------------
class MoveDestLaneConfigTable :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:apollo.planning.MoveDestLaneConfigTable) */ {
public:
MoveDestLaneConfigTable();
virtual ~MoveDestLaneConfigTable();
MoveDestLaneConfigTable(const MoveDestLaneConfigTable& from);
MoveDestLaneConfigTable(MoveDestLaneConfigTable&& from) noexcept
: MoveDestLaneConfigTable() {
*this = ::std::move(from);
}
inline MoveDestLaneConfigTable& operator=(const MoveDestLaneConfigTable& from) {
CopyFrom(from);
return *this;
}
inline MoveDestLaneConfigTable& operator=(MoveDestLaneConfigTable&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const {
return _internal_metadata_.unknown_fields();
}
inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() {
return _internal_metadata_.mutable_unknown_fields();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
return GetDescriptor();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
return GetMetadataStatic().descriptor;
}
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
return GetMetadataStatic().reflection;
}
static const MoveDestLaneConfigTable& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const MoveDestLaneConfigTable* internal_default_instance() {
return reinterpret_cast<const MoveDestLaneConfigTable*>(
&_MoveDestLaneConfigTable_default_instance_);
}
static constexpr int kIndexInFileMessages =
1;
friend void swap(MoveDestLaneConfigTable& a, MoveDestLaneConfigTable& b) {
a.Swap(&b);
}
inline void Swap(MoveDestLaneConfigTable* other) {
if (other == this) return;
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline MoveDestLaneConfigTable* New() const final {
return CreateMaybeMessage<MoveDestLaneConfigTable>(nullptr);
}
MoveDestLaneConfigTable* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
return CreateMaybeMessage<MoveDestLaneConfigTable>(arena);
}
void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final;
void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final;
void CopyFrom(const MoveDestLaneConfigTable& from);
void MergeFrom(const MoveDestLaneConfigTable& from);
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
private:
inline void SharedCtor();
inline void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(MoveDestLaneConfigTable* other);
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "apollo.planning.MoveDestLaneConfigTable";
}
private:
inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const {
return nullptr;
}
inline void* MaybeArenaPtr() const {
return nullptr;
}
public:
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
private:
static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_modules_2fplanning_2fproto_2fnavi_5fpath_5fdecider_5fconfig_2eproto);
return ::descriptor_table_modules_2fplanning_2fproto_2fnavi_5fpath_5fdecider_5fconfig_2eproto.file_level_metadata[kIndexInFileMessages];
}
public:
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
enum : int {
kLateralShiftFieldNumber = 1,
};
// repeated .apollo.planning.ShiftConfig lateral_shift = 1;
int lateral_shift_size() const;
private:
int _internal_lateral_shift_size() const;
public:
void clear_lateral_shift();
::apollo::planning::ShiftConfig* mutable_lateral_shift(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::apollo::planning::ShiftConfig >*
mutable_lateral_shift();
private:
const ::apollo::planning::ShiftConfig& _internal_lateral_shift(int index) const;
::apollo::planning::ShiftConfig* _internal_add_lateral_shift();
public:
const ::apollo::planning::ShiftConfig& lateral_shift(int index) const;
::apollo::planning::ShiftConfig* add_lateral_shift();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::apollo::planning::ShiftConfig >&
lateral_shift() const;
// @@protoc_insertion_point(class_scope:apollo.planning.MoveDestLaneConfigTable)
private:
class _Internal;
::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_;
::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::apollo::planning::ShiftConfig > lateral_shift_;
friend struct ::TableStruct_modules_2fplanning_2fproto_2fnavi_5fpath_5fdecider_5fconfig_2eproto;
};
// -------------------------------------------------------------------
class ShiftConfig :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:apollo.planning.ShiftConfig) */ {
public:
ShiftConfig();
virtual ~ShiftConfig();
ShiftConfig(const ShiftConfig& from);
ShiftConfig(ShiftConfig&& from) noexcept
: ShiftConfig() {
*this = ::std::move(from);
}
inline ShiftConfig& operator=(const ShiftConfig& from) {
CopyFrom(from);
return *this;
}
inline ShiftConfig& operator=(ShiftConfig&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const {
return _internal_metadata_.unknown_fields();
}
inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() {
return _internal_metadata_.mutable_unknown_fields();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
return GetDescriptor();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
return GetMetadataStatic().descriptor;
}
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
return GetMetadataStatic().reflection;
}
static const ShiftConfig& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const ShiftConfig* internal_default_instance() {
return reinterpret_cast<const ShiftConfig*>(
&_ShiftConfig_default_instance_);
}
static constexpr int kIndexInFileMessages =
2;
friend void swap(ShiftConfig& a, ShiftConfig& b) {
a.Swap(&b);
}
inline void Swap(ShiftConfig* other) {
if (other == this) return;
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline ShiftConfig* New() const final {
return CreateMaybeMessage<ShiftConfig>(nullptr);
}
ShiftConfig* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
return CreateMaybeMessage<ShiftConfig>(arena);
}
void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final;
void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final;
void CopyFrom(const ShiftConfig& from);
void MergeFrom(const ShiftConfig& from);
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
private:
inline void SharedCtor();
inline void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(ShiftConfig* other);
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "apollo.planning.ShiftConfig";
}
private:
inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const {
return nullptr;
}
inline void* MaybeArenaPtr() const {
return nullptr;
}
public:
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
private:
static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_modules_2fplanning_2fproto_2fnavi_5fpath_5fdecider_5fconfig_2eproto);
return ::descriptor_table_modules_2fplanning_2fproto_2fnavi_5fpath_5fdecider_5fconfig_2eproto.file_level_metadata[kIndexInFileMessages];
}
public:
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
enum : int {
kMaxSpeedFieldNumber = 1,
kMaxMoveDestLaneShiftYFieldNumber = 3,
};
// optional double max_speed = 1 [default = 4.16];
bool has_max_speed() const;
private:
bool _internal_has_max_speed() const;
public:
void clear_max_speed();
double max_speed() const;
void set_max_speed(double value);
private:
double _internal_max_speed() const;
void _internal_set_max_speed(double value);
public:
// optional double max_move_dest_lane_shift_y = 3 [default = 0.4];
bool has_max_move_dest_lane_shift_y() const;
private:
bool _internal_has_max_move_dest_lane_shift_y() const;
public:
void clear_max_move_dest_lane_shift_y();
double max_move_dest_lane_shift_y() const;
void set_max_move_dest_lane_shift_y(double value);
private:
double _internal_max_move_dest_lane_shift_y() const;
void _internal_set_max_move_dest_lane_shift_y(double value);
public:
// @@protoc_insertion_point(class_scope:apollo.planning.ShiftConfig)
private:
class _Internal;
::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_;
::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
double max_speed_;
double max_move_dest_lane_shift_y_;
friend struct ::TableStruct_modules_2fplanning_2fproto_2fnavi_5fpath_5fdecider_5fconfig_2eproto;
};
// ===================================================================
// ===================================================================
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
// NaviPathDeciderConfig
// optional double min_path_length = 1 [default = 5];
inline bool NaviPathDeciderConfig::_internal_has_min_path_length() const {
bool value = (_has_bits_[0] & 0x00000020u) != 0;
return value;
}
inline bool NaviPathDeciderConfig::has_min_path_length() const {
return _internal_has_min_path_length();
}
inline void NaviPathDeciderConfig::clear_min_path_length() {
min_path_length_ = 5;
_has_bits_[0] &= ~0x00000020u;
}
inline double NaviPathDeciderConfig::_internal_min_path_length() const {
return min_path_length_;
}
inline double NaviPathDeciderConfig::min_path_length() const {
// @@protoc_insertion_point(field_get:apollo.planning.NaviPathDeciderConfig.min_path_length)
return _internal_min_path_length();
}
inline void NaviPathDeciderConfig::_internal_set_min_path_length(double value) {
_has_bits_[0] |= 0x00000020u;
min_path_length_ = value;
}
inline void NaviPathDeciderConfig::set_min_path_length(double value) {
_internal_set_min_path_length(value);
// @@protoc_insertion_point(field_set:apollo.planning.NaviPathDeciderConfig.min_path_length)
}
// optional uint32 min_look_forward_time = 2 [default = 2];
inline bool NaviPathDeciderConfig::_internal_has_min_look_forward_time() const {
bool value = (_has_bits_[0] & 0x00000010u) != 0;
return value;
}
inline bool NaviPathDeciderConfig::has_min_look_forward_time() const {
return _internal_has_min_look_forward_time();
}
inline void NaviPathDeciderConfig::clear_min_look_forward_time() {
min_look_forward_time_ = 2u;
_has_bits_[0] &= ~0x00000010u;
}
inline ::PROTOBUF_NAMESPACE_ID::uint32 NaviPathDeciderConfig::_internal_min_look_forward_time() const {
return min_look_forward_time_;
}
inline ::PROTOBUF_NAMESPACE_ID::uint32 NaviPathDeciderConfig::min_look_forward_time() const {
// @@protoc_insertion_point(field_get:apollo.planning.NaviPathDeciderConfig.min_look_forward_time)
return _internal_min_look_forward_time();
}
inline void NaviPathDeciderConfig::_internal_set_min_look_forward_time(::PROTOBUF_NAMESPACE_ID::uint32 value) {
_has_bits_[0] |= 0x00000010u;
min_look_forward_time_ = value;
}
inline void NaviPathDeciderConfig::set_min_look_forward_time(::PROTOBUF_NAMESPACE_ID::uint32 value) {
_internal_set_min_look_forward_time(value);
// @@protoc_insertion_point(field_set:apollo.planning.NaviPathDeciderConfig.min_look_forward_time)
}
// optional double max_keep_lane_distance = 3 [default = 0.8];
inline bool NaviPathDeciderConfig::_internal_has_max_keep_lane_distance() const {
bool value = (_has_bits_[0] & 0x00000040u) != 0;
return value;
}
inline bool NaviPathDeciderConfig::has_max_keep_lane_distance() const {
return _internal_has_max_keep_lane_distance();
}
inline void NaviPathDeciderConfig::clear_max_keep_lane_distance() {
max_keep_lane_distance_ = 0.8;
_has_bits_[0] &= ~0x00000040u;
}
inline double NaviPathDeciderConfig::_internal_max_keep_lane_distance() const {
return max_keep_lane_distance_;
}
inline double NaviPathDeciderConfig::max_keep_lane_distance() const {
// @@protoc_insertion_point(field_get:apollo.planning.NaviPathDeciderConfig.max_keep_lane_distance)
return _internal_max_keep_lane_distance();
}
inline void NaviPathDeciderConfig::_internal_set_max_keep_lane_distance(double value) {
_has_bits_[0] |= 0x00000040u;
max_keep_lane_distance_ = value;
}
inline void NaviPathDeciderConfig::set_max_keep_lane_distance(double value) {
_internal_set_max_keep_lane_distance(value);
// @@protoc_insertion_point(field_set:apollo.planning.NaviPathDeciderConfig.max_keep_lane_distance)
}
// optional double max_keep_lane_shift_y = 4 [default = 20];
inline bool NaviPathDeciderConfig::_internal_has_max_keep_lane_shift_y() const {
bool value = (_has_bits_[0] & 0x00000080u) != 0;
return value;
}
inline bool NaviPathDeciderConfig::has_max_keep_lane_shift_y() const {
return _internal_has_max_keep_lane_shift_y();
}
inline void NaviPathDeciderConfig::clear_max_keep_lane_shift_y() {
max_keep_lane_shift_y_ = 20;
_has_bits_[0] &= ~0x00000080u;
}
inline double NaviPathDeciderConfig::_internal_max_keep_lane_shift_y() const {
return max_keep_lane_shift_y_;
}
inline double NaviPathDeciderConfig::max_keep_lane_shift_y() const {
// @@protoc_insertion_point(field_get:apollo.planning.NaviPathDeciderConfig.max_keep_lane_shift_y)
return _internal_max_keep_lane_shift_y();
}
inline void NaviPathDeciderConfig::_internal_set_max_keep_lane_shift_y(double value) {
_has_bits_[0] |= 0x00000080u;
max_keep_lane_shift_y_ = value;
}
inline void NaviPathDeciderConfig::set_max_keep_lane_shift_y(double value) {
_internal_set_max_keep_lane_shift_y(value);
// @@protoc_insertion_point(field_set:apollo.planning.NaviPathDeciderConfig.max_keep_lane_shift_y)
}
// optional double min_keep_lane_offset = 5 [default = 15];
inline bool NaviPathDeciderConfig::_internal_has_min_keep_lane_offset() const {
bool value = (_has_bits_[0] & 0x00000100u) != 0;
return value;
}
inline bool NaviPathDeciderConfig::has_min_keep_lane_offset() const {
return _internal_has_min_keep_lane_offset();
}
inline void NaviPathDeciderConfig::clear_min_keep_lane_offset() {
min_keep_lane_offset_ = 15;
_has_bits_[0] &= ~0x00000100u;
}
inline double NaviPathDeciderConfig::_internal_min_keep_lane_offset() const {
return min_keep_lane_offset_;
}
inline double NaviPathDeciderConfig::min_keep_lane_offset() const {
// @@protoc_insertion_point(field_get:apollo.planning.NaviPathDeciderConfig.min_keep_lane_offset)
return _internal_min_keep_lane_offset();
}
inline void NaviPathDeciderConfig::_internal_set_min_keep_lane_offset(double value) {
_has_bits_[0] |= 0x00000100u;
min_keep_lane_offset_ = value;
}
inline void NaviPathDeciderConfig::set_min_keep_lane_offset(double value) {
_internal_set_min_keep_lane_offset(value);
// @@protoc_insertion_point(field_set:apollo.planning.NaviPathDeciderConfig.min_keep_lane_offset)
}
// optional double keep_lane_shift_compensation = 6 [default = 0.01];
inline bool NaviPathDeciderConfig::_internal_has_keep_lane_shift_compensation() const {
bool value = (_has_bits_[0] & 0x00000200u) != 0;
return value;
}
inline bool NaviPathDeciderConfig::has_keep_lane_shift_compensation() const {
return _internal_has_keep_lane_shift_compensation();
}
inline void NaviPathDeciderConfig::clear_keep_lane_shift_compensation() {
keep_lane_shift_compensation_ = 0.01;
_has_bits_[0] &= ~0x00000200u;
}
inline double NaviPathDeciderConfig::_internal_keep_lane_shift_compensation() const {
return keep_lane_shift_compensation_;
}
inline double NaviPathDeciderConfig::keep_lane_shift_compensation() const {
// @@protoc_insertion_point(field_get:apollo.planning.NaviPathDeciderConfig.keep_lane_shift_compensation)
return _internal_keep_lane_shift_compensation();
}
inline void NaviPathDeciderConfig::_internal_set_keep_lane_shift_compensation(double value) {
_has_bits_[0] |= 0x00000200u;
keep_lane_shift_compensation_ = value;
}
inline void NaviPathDeciderConfig::set_keep_lane_shift_compensation(double value) {
_internal_set_keep_lane_shift_compensation(value);
// @@protoc_insertion_point(field_set:apollo.planning.NaviPathDeciderConfig.keep_lane_shift_compensation)
}
// optional .apollo.planning.MoveDestLaneConfigTable move_dest_lane_config_talbe = 7;
inline bool NaviPathDeciderConfig::_internal_has_move_dest_lane_config_talbe() const {
bool value = (_has_bits_[0] & 0x00000001u) != 0;
PROTOBUF_ASSUME(!value || move_dest_lane_config_talbe_ != nullptr);
return value;
}
inline bool NaviPathDeciderConfig::has_move_dest_lane_config_talbe() const {
return _internal_has_move_dest_lane_config_talbe();
}
inline void NaviPathDeciderConfig::clear_move_dest_lane_config_talbe() {
if (move_dest_lane_config_talbe_ != nullptr) move_dest_lane_config_talbe_->Clear();
_has_bits_[0] &= ~0x00000001u;
}
inline const ::apollo::planning::MoveDestLaneConfigTable& NaviPathDeciderConfig::_internal_move_dest_lane_config_talbe() const {
const ::apollo::planning::MoveDestLaneConfigTable* p = move_dest_lane_config_talbe_;
return p != nullptr ? *p : *reinterpret_cast<const ::apollo::planning::MoveDestLaneConfigTable*>(
&::apollo::planning::_MoveDestLaneConfigTable_default_instance_);
}
inline const ::apollo::planning::MoveDestLaneConfigTable& NaviPathDeciderConfig::move_dest_lane_config_talbe() const {
// @@protoc_insertion_point(field_get:apollo.planning.NaviPathDeciderConfig.move_dest_lane_config_talbe)
return _internal_move_dest_lane_config_talbe();
}
inline ::apollo::planning::MoveDestLaneConfigTable* NaviPathDeciderConfig::release_move_dest_lane_config_talbe() {
// @@protoc_insertion_point(field_release:apollo.planning.NaviPathDeciderConfig.move_dest_lane_config_talbe)
_has_bits_[0] &= ~0x00000001u;
::apollo::planning::MoveDestLaneConfigTable* temp = move_dest_lane_config_talbe_;
move_dest_lane_config_talbe_ = nullptr;
return temp;
}
inline ::apollo::planning::MoveDestLaneConfigTable* NaviPathDeciderConfig::_internal_mutable_move_dest_lane_config_talbe() {
_has_bits_[0] |= 0x00000001u;
if (move_dest_lane_config_talbe_ == nullptr) {
auto* p = CreateMaybeMessage<::apollo::planning::MoveDestLaneConfigTable>(GetArenaNoVirtual());
move_dest_lane_config_talbe_ = p;
}
return move_dest_lane_config_talbe_;
}
inline ::apollo::planning::MoveDestLaneConfigTable* NaviPathDeciderConfig::mutable_move_dest_lane_config_talbe() {
// @@protoc_insertion_point(field_mutable:apollo.planning.NaviPathDeciderConfig.move_dest_lane_config_talbe)
return _internal_mutable_move_dest_lane_config_talbe();
}
inline void NaviPathDeciderConfig::set_allocated_move_dest_lane_config_talbe(::apollo::planning::MoveDestLaneConfigTable* move_dest_lane_config_talbe) {
::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual();
if (message_arena == nullptr) {
delete move_dest_lane_config_talbe_;
}
if (move_dest_lane_config_talbe) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = nullptr;
if (message_arena != submessage_arena) {
move_dest_lane_config_talbe = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, move_dest_lane_config_talbe, submessage_arena);
}
_has_bits_[0] |= 0x00000001u;
} else {
_has_bits_[0] &= ~0x00000001u;
}
move_dest_lane_config_talbe_ = move_dest_lane_config_talbe;
// @@protoc_insertion_point(field_set_allocated:apollo.planning.NaviPathDeciderConfig.move_dest_lane_config_talbe)
}
// optional double move_dest_lane_compensation = 8 [default = 0.35];
inline bool NaviPathDeciderConfig::_internal_has_move_dest_lane_compensation() const {
bool value = (_has_bits_[0] & 0x00000400u) != 0;
return value;
}
inline bool NaviPathDeciderConfig::has_move_dest_lane_compensation() const {
return _internal_has_move_dest_lane_compensation();
}
inline void NaviPathDeciderConfig::clear_move_dest_lane_compensation() {
move_dest_lane_compensation_ = 0.35;
_has_bits_[0] &= ~0x00000400u;
}
inline double NaviPathDeciderConfig::_internal_move_dest_lane_compensation() const {
return move_dest_lane_compensation_;
}
inline double NaviPathDeciderConfig::move_dest_lane_compensation() const {
// @@protoc_insertion_point(field_get:apollo.planning.NaviPathDeciderConfig.move_dest_lane_compensation)
return _internal_move_dest_lane_compensation();
}
inline void NaviPathDeciderConfig::_internal_set_move_dest_lane_compensation(double value) {
_has_bits_[0] |= 0x00000400u;
move_dest_lane_compensation_ = value;
}
inline void NaviPathDeciderConfig::set_move_dest_lane_compensation(double value) {
_internal_set_move_dest_lane_compensation(value);
// @@protoc_insertion_point(field_set:apollo.planning.NaviPathDeciderConfig.move_dest_lane_compensation)
}
// optional double max_kappa_threshold = 9 [default = 0];
inline bool NaviPathDeciderConfig::_internal_has_max_kappa_threshold() const {
bool value = (_has_bits_[0] & 0x00000002u) != 0;
return value;
}
inline bool NaviPathDeciderConfig::has_max_kappa_threshold() const {
return _internal_has_max_kappa_threshold();
}
inline void NaviPathDeciderConfig::clear_max_kappa_threshold() {
max_kappa_threshold_ = 0;
_has_bits_[0] &= ~0x00000002u;
}
inline double NaviPathDeciderConfig::_internal_max_kappa_threshold() const {
return max_kappa_threshold_;
}
inline double NaviPathDeciderConfig::max_kappa_threshold() const {
// @@protoc_insertion_point(field_get:apollo.planning.NaviPathDeciderConfig.max_kappa_threshold)
return _internal_max_kappa_threshold();
}
inline void NaviPathDeciderConfig::_internal_set_max_kappa_threshold(double value) {
_has_bits_[0] |= 0x00000002u;
max_kappa_threshold_ = value;
}
inline void NaviPathDeciderConfig::set_max_kappa_threshold(double value) {
_internal_set_max_kappa_threshold(value);
// @@protoc_insertion_point(field_set:apollo.planning.NaviPathDeciderConfig.max_kappa_threshold)
}
// optional double kappa_move_dest_lane_compensation = 10 [default = 0];
inline bool NaviPathDeciderConfig::_internal_has_kappa_move_dest_lane_compensation() const {
bool value = (_has_bits_[0] & 0x00000004u) != 0;
return value;
}
inline bool NaviPathDeciderConfig::has_kappa_move_dest_lane_compensation() const {
return _internal_has_kappa_move_dest_lane_compensation();
}
inline void NaviPathDeciderConfig::clear_kappa_move_dest_lane_compensation() {
kappa_move_dest_lane_compensation_ = 0;
_has_bits_[0] &= ~0x00000004u;
}
inline double NaviPathDeciderConfig::_internal_kappa_move_dest_lane_compensation() const {
return kappa_move_dest_lane_compensation_;
}
inline double NaviPathDeciderConfig::kappa_move_dest_lane_compensation() const {
// @@protoc_insertion_point(field_get:apollo.planning.NaviPathDeciderConfig.kappa_move_dest_lane_compensation)
return _internal_kappa_move_dest_lane_compensation();
}
inline void NaviPathDeciderConfig::_internal_set_kappa_move_dest_lane_compensation(double value) {
_has_bits_[0] |= 0x00000004u;
kappa_move_dest_lane_compensation_ = value;
}
inline void NaviPathDeciderConfig::set_kappa_move_dest_lane_compensation(double value) {
_internal_set_kappa_move_dest_lane_compensation(value);
// @@protoc_insertion_point(field_set:apollo.planning.NaviPathDeciderConfig.kappa_move_dest_lane_compensation)
}
// optional uint32 start_plan_point_from = 11 [default = 0];
inline bool NaviPathDeciderConfig::_internal_has_start_plan_point_from() const {
bool value = (_has_bits_[0] & 0x00000008u) != 0;
return value;
}
inline bool NaviPathDeciderConfig::has_start_plan_point_from() const {
return _internal_has_start_plan_point_from();
}
inline void NaviPathDeciderConfig::clear_start_plan_point_from() {
start_plan_point_from_ = 0u;
_has_bits_[0] &= ~0x00000008u;
}
inline ::PROTOBUF_NAMESPACE_ID::uint32 NaviPathDeciderConfig::_internal_start_plan_point_from() const {
return start_plan_point_from_;
}
inline ::PROTOBUF_NAMESPACE_ID::uint32 NaviPathDeciderConfig::start_plan_point_from() const {
// @@protoc_insertion_point(field_get:apollo.planning.NaviPathDeciderConfig.start_plan_point_from)
return _internal_start_plan_point_from();
}
inline void NaviPathDeciderConfig::_internal_set_start_plan_point_from(::PROTOBUF_NAMESPACE_ID::uint32 value) {
_has_bits_[0] |= 0x00000008u;
start_plan_point_from_ = value;
}
inline void NaviPathDeciderConfig::set_start_plan_point_from(::PROTOBUF_NAMESPACE_ID::uint32 value) {
_internal_set_start_plan_point_from(value);
// @@protoc_insertion_point(field_set:apollo.planning.NaviPathDeciderConfig.start_plan_point_from)
}
// -------------------------------------------------------------------
// MoveDestLaneConfigTable
// repeated .apollo.planning.ShiftConfig lateral_shift = 1;
inline int MoveDestLaneConfigTable::_internal_lateral_shift_size() const {
return lateral_shift_.size();
}
inline int MoveDestLaneConfigTable::lateral_shift_size() const {
return _internal_lateral_shift_size();
}
inline void MoveDestLaneConfigTable::clear_lateral_shift() {
lateral_shift_.Clear();
}
inline ::apollo::planning::ShiftConfig* MoveDestLaneConfigTable::mutable_lateral_shift(int index) {
// @@protoc_insertion_point(field_mutable:apollo.planning.MoveDestLaneConfigTable.lateral_shift)
return lateral_shift_.Mutable(index);
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::apollo::planning::ShiftConfig >*
MoveDestLaneConfigTable::mutable_lateral_shift() {
// @@protoc_insertion_point(field_mutable_list:apollo.planning.MoveDestLaneConfigTable.lateral_shift)
return &lateral_shift_;
}
inline const ::apollo::planning::ShiftConfig& MoveDestLaneConfigTable::_internal_lateral_shift(int index) const {
return lateral_shift_.Get(index);
}
inline const ::apollo::planning::ShiftConfig& MoveDestLaneConfigTable::lateral_shift(int index) const {
// @@protoc_insertion_point(field_get:apollo.planning.MoveDestLaneConfigTable.lateral_shift)
return _internal_lateral_shift(index);
}
inline ::apollo::planning::ShiftConfig* MoveDestLaneConfigTable::_internal_add_lateral_shift() {
return lateral_shift_.Add();
}
inline ::apollo::planning::ShiftConfig* MoveDestLaneConfigTable::add_lateral_shift() {
// @@protoc_insertion_point(field_add:apollo.planning.MoveDestLaneConfigTable.lateral_shift)
return _internal_add_lateral_shift();
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::apollo::planning::ShiftConfig >&
MoveDestLaneConfigTable::lateral_shift() const {
// @@protoc_insertion_point(field_list:apollo.planning.MoveDestLaneConfigTable.lateral_shift)
return lateral_shift_;
}
// -------------------------------------------------------------------
// ShiftConfig
// optional double max_speed = 1 [default = 4.16];
inline bool ShiftConfig::_internal_has_max_speed() const {
bool value = (_has_bits_[0] & 0x00000001u) != 0;
return value;
}
inline bool ShiftConfig::has_max_speed() const {
return _internal_has_max_speed();
}
inline void ShiftConfig::clear_max_speed() {
max_speed_ = 4.16;
_has_bits_[0] &= ~0x00000001u;
}
inline double ShiftConfig::_internal_max_speed() const {
return max_speed_;
}
inline double ShiftConfig::max_speed() const {
// @@protoc_insertion_point(field_get:apollo.planning.ShiftConfig.max_speed)
return _internal_max_speed();
}
inline void ShiftConfig::_internal_set_max_speed(double value) {
_has_bits_[0] |= 0x00000001u;
max_speed_ = value;
}
inline void ShiftConfig::set_max_speed(double value) {
_internal_set_max_speed(value);
// @@protoc_insertion_point(field_set:apollo.planning.ShiftConfig.max_speed)
}
// optional double max_move_dest_lane_shift_y = 3 [default = 0.4];
inline bool ShiftConfig::_internal_has_max_move_dest_lane_shift_y() const {
bool value = (_has_bits_[0] & 0x00000002u) != 0;
return value;
}
inline bool ShiftConfig::has_max_move_dest_lane_shift_y() const {
return _internal_has_max_move_dest_lane_shift_y();
}
inline void ShiftConfig::clear_max_move_dest_lane_shift_y() {
max_move_dest_lane_shift_y_ = 0.4;
_has_bits_[0] &= ~0x00000002u;
}
inline double ShiftConfig::_internal_max_move_dest_lane_shift_y() const {
return max_move_dest_lane_shift_y_;
}
inline double ShiftConfig::max_move_dest_lane_shift_y() const {
// @@protoc_insertion_point(field_get:apollo.planning.ShiftConfig.max_move_dest_lane_shift_y)
return _internal_max_move_dest_lane_shift_y();
}
inline void ShiftConfig::_internal_set_max_move_dest_lane_shift_y(double value) {
_has_bits_[0] |= 0x00000002u;
max_move_dest_lane_shift_y_ = value;
}
inline void ShiftConfig::set_max_move_dest_lane_shift_y(double value) {
_internal_set_max_move_dest_lane_shift_y(value);
// @@protoc_insertion_point(field_set:apollo.planning.ShiftConfig.max_move_dest_lane_shift_y)
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// @@protoc_insertion_point(namespace_scope)
} // namespace planning
} // namespace apollo
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_modules_2fplanning_2fproto_2fnavi_5fpath_5fdecider_5fconfig_2eproto
| [
"[email protected]"
] | |
d94504071babc58e0cf7f4deaefb9ccea4d76c5a | 2f4bd21aeb3a386e22c54bc82469cdde5f045330 | /git_C++/mai multi algoritmi intr-unul/main.cpp | c275456325a256cf66f897f0c71970b6276c00f2 | [
"MIT"
] | permissive | sorinmiroiu97/old-CPP-stuff | 44862c16660cc31b62e6e7fd3dc715a80e3ac04e | d6f7b3573c1f81597795cea75c5f76fd95c4395b | refs/heads/master | 2021-08-19T08:01:50.363242 | 2017-11-25T10:34:55 | 2017-11-25T10:34:55 | 105,013,648 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,037 | cpp | #include <iostream>
using namespace std;
int X;
int main()
{
cout<<"1.Euclid"<<endl;
cout<<"2.Fibonacci"<<endl;
cout<<"3.Cautarea secventiala"<<endl;
cout<<"4.Cautarea binara"<<endl;
cout<<"5.Ordonaea prin selectie"<<endl;
cout<<"6.Bubble sort"<<endl;
cout<<"7.Sortarea prin numarare"<<endl;
cout<<"Alege: x="; cin>>X;
if(X==1)
{
int a,b,r,p;
cin>>a>>b;
r=a%b;
p=a*b;
while(r!=0)
{
a=b; b=r; r=a%b;
}
cout<<"cmmdc "<<b<<endl;
cout<<"cmmmc "<<p/b;
}
if(X==2)
{
int f1,f2,f3,n;
cin>>n;
f1=1;
f2=2;
if(n==1) cout<<1;
else cout<<1<<" "<<1;
for(int i=3;i<=n;i++)
{
f3=f2+f1;
f1=f2;
f2=f3;
cout<<f3<<" ";
}
}
if(X==3)
{
}
if(X==4)
{
}
if(X==5)
{
}
if(X==6)
{
}
if(X==7)
{
}
return 0;
}
| [
"[email protected]"
] | |
8130e8dd394e6da2ccb09b08f7f827fe2b050fd0 | 8f34dcc1eb37250d564b86be55f622cba2f8eb99 | /video_publisher/src/video_publisher_node.cpp | ba4d311e35a66de31c25e2fa60120c648d83b7a9 | [] | no_license | jzhugithub/video_ros | fcb68c30ace7c396b2035d072b145051d85f51c6 | 7098c835ecf70590d756de6be7df0d86e2f4f920 | refs/heads/master | 2020-03-21T03:09:32.234660 | 2018-06-20T13:48:08 | 2018-06-20T13:48:08 | 138,038,959 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,823 | cpp | #include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace std;
using namespace cv;
class VideoPublisher
{
public:
//node
ros::NodeHandle nh_;
ros::NodeHandle nh_param;
image_transport::ImageTransport it_;
image_transport::Publisher image_pub_;
//video
string WINDOW_NAME;
string published_video_file_name;
bool show_video_flag;
VideoCapture my_video;
bool video_open_flag;
double video_rate;
double video_hight;
double video_width;
double video_delay;
//trans
ros::Time time;
cv_bridge::CvImage cvi;
sensor_msgs::Image im;
Mat src;
VideoPublisher():
it_(nh_),
nh_param("~")
{
//node
image_pub_ = it_.advertise("/my_video", 1);
if(!nh_param.getParam("published_video_file_name", published_video_file_name))published_video_file_name = "/home/ubuntu/ros_my_workspace/src/video_publisher/video/a544.avi";
//video
if(!nh_param.getParam("show_video_flag", show_video_flag))show_video_flag = true;
if(show_video_flag)
{
WINDOW_NAME = "Image window";
namedWindow(WINDOW_NAME);
}
my_video = VideoCapture(published_video_file_name);
if(!my_video.isOpened())
{
video_open_flag = false;
cout<<"video open error"<<endl;
}
else
{
video_open_flag = true;
cout<<"video is open"<<endl;
video_rate = my_video.get(CV_CAP_PROP_FPS);
if(isnan(video_rate))
{
if(!nh_param.getParam("given_video_rate", video_rate))video_rate = 30.0;
cout<<"video_rate is nan, using given_video_rate: "<<video_rate<<endl;
}
else
{
cout<<"video_rate: "<<video_rate<<endl;
}
video_width = my_video.get(CV_CAP_PROP_FRAME_WIDTH);
cout<<"video_width: "<<video_width<<endl;
video_hight = my_video.get(CV_CAP_PROP_FRAME_HEIGHT);
cout<<"video_hight: "<<video_hight<<endl;
video_delay = 1000/video_rate;
}
}
~VideoPublisher()
{
destroyAllWindows();
}
void runPublish()
{
ros::Rate rate(video_rate);
while(ros::ok())
{
//trans
if (!my_video.read(src)){cout<<"video end"<<endl; break;}
time=ros::Time::now();
cvi.header.stamp = time;
cvi.header.frame_id = "my video";
cvi.encoding = "bgr8";
cvi.image = src;
cvi.toImageMsg(im);
if(show_video_flag)
{
imshow(WINDOW_NAME, src);
waitKey(1);
}
image_pub_.publish(im);
ros::spinOnce();
rate.sleep();
}
}
};
int main(int argc, char** argv)
{
ros::init(argc, argv, "video_publisher_node");
VideoPublisher vp;
if(vp.video_open_flag)
vp.runPublish();
ros::spin();
return 0;
} | [
"[email protected]"
] | |
8024322d87f11914380e29a7dd8f1121e1bed2da | 7988c4da892d4c9c2a390b812e2c88d323d8a37b | /Game.hpp | a25f4e448e453e4a26d97548524da30738011afc | [] | no_license | Kaanv/peasants | 8f18d57caabc0a25c4248a834feaadd9445d3353 | 8262268f55abed613415238dcd5347c11183029e | refs/heads/master | 2021-01-23T14:22:15.187001 | 2017-06-27T18:18:22 | 2017-06-27T18:18:22 | 93,253,742 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 909 | hpp | #ifndef GAME_HPP
#define GAME_HPP
#include "Player.hpp"
#include "Card.hpp"
#include "Deck.hpp"
#include "Table.hpp"
#include "CardsValidator.hpp"
#include <vector>
class Game
{
public:
Game(int numberOfPlayers);
void distributeCardsFromDeck();
int findStartingPlayer();
bool hasRoundEnded();
Player& getCurrentPlayer();
void nextPlayer();
void throwCards(Cards cards);
Cards getCardsFromTableTop();
void passCurrentPlayerTurn();
void nextRound();
void checkIfPlayerHasEnded();
Player& getPlayer(unsigned int id);
unsigned int findOppositePlayerId(int peasantLevel);
void setStartingPlayer();
private:
void resetRound();
void setPeasantsLevels();
Players players;
Deck deck;
CardsValidator cardsValidator;
int currentPlayerId;
unsigned int passedTurns;
Table table;
std::vector<int> playersThatEnded;
};
#endif
| [
"[email protected]"
] | |
9be63519eb7064525aaf5c282ea133d26c18ff38 | 785df77400157c058a934069298568e47950e40b | /TnbMeshAft/include/Aft3d_CornerNodeAnIsoFwd.hxx | 7c736d1c65eab73bdf6c929187c4aec02d69ca33 | [] | no_license | amir5200fx/Tonb | cb108de09bf59c5c7e139435e0be008a888d99d5 | ed679923dc4b2e69b12ffe621fc5a6c8e3652465 | refs/heads/master | 2023-08-31T08:59:00.366903 | 2023-08-31T07:42:24 | 2023-08-31T07:42:24 | 230,028,961 | 9 | 3 | null | 2023-07-20T16:53:31 | 2019-12-25T02:29:32 | C++ | UTF-8 | C++ | false | false | 451 | hxx | #pragma once
#ifndef _Aft3d_CornerNodeAnIsoFwd_Header
#define _Aft3d_CornerNodeAnIsoFwd_Header
#include <Mesh_BndNode_Position.hxx>
namespace tnbLib
{
// Forward Declarations
template<class BndNodeTraits, Mesh_BndNode_Position POS>
class Mesh_TBndNode;
struct Aft3d_CornerNodeAnIsoTraits;
typedef Mesh_TBndNode<Aft3d_CornerNodeAnIsoTraits, Mesh_BndNode_Position_Corner>
Aft3d_CornerNodeAnIso;
}
#endif // !_Aft3d_CornerNodeAnIsoFwd_Header | [
"[email protected]"
] | |
fdd2067f83153536b5e29362b2bcb9c92851695e | 03f037d0f6371856ede958f0c9d02771d5402baf | /graphics/VTK-7.0.0/IO/Geometry/vtkMFIXReader.cxx | 342e7b0c86f91a424d2071cba50de99e40084348 | [
"BSD-3-Clause"
] | permissive | hlzz/dotfiles | b22dc2dc5a9086353ed6dfeee884f7f0a9ddb1eb | 0591f71230c919c827ba569099eb3b75897e163e | refs/heads/master | 2021-01-10T10:06:31.018179 | 2016-09-27T08:13:18 | 2016-09-27T08:13:18 | 55,040,954 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 76,242 | cxx | /*=========================================================================
Program: Visualization Toolkit
Module: vtkMFIXReader.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// Thanks to Phil Nicoletti, Terry Jordan and Brian Dotson at the
// National Energy Technology Laboratory who developed this class.
// Please address all comments to Terry Jordan ([email protected])
//
#include "vtkMFIXReader.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkErrorCode.h"
#include "vtkUnstructuredGrid.h"
#include "vtkPointData.h"
#include "vtkCellData.h"
#include "vtkDoubleArray.h"
#include "vtkIntArray.h"
#include "vtkCellArray.h"
#include "vtkHexahedron.h"
#include "vtkFloatArray.h"
#include <string>
#include "vtkDataArraySelection.h"
#include "vtkWedge.h"
#include "vtkQuad.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkStringArray.h"
vtkStandardNewMacro(vtkMFIXReader);
//----------------------------------------------------------------------------
vtkMFIXReader::vtkMFIXReader()
{
this->FileName = NULL;
this->NumberOfCells = 0;
this->NumberOfPoints = 0;
this->NumberOfCellFields = 0;
this->RequestInformationFlag = 0;
this->MakeMeshFlag = 0;
this->Minimum = vtkFloatArray::New();
this->Maximum = vtkFloatArray::New();
this->VectorLength = vtkIntArray::New();
this->CellDataArray = NULL;
this->DimensionIc = 5;
this->DimensionBc = 5;
this->DimensionC = 5;
this->DimensionIs = 5;
this->NumberOfSPXFilesUsed = 9;
this->NumberOfScalars = 0;
this->BkEpsilon = false;
this->NumberOfReactionRates = 0;
this->FileExtension[0] = '1';
this->FileExtension[1] = '2';
this->FileExtension[2] = '3';
this->FileExtension[3] = '4';
this->FileExtension[4] = '5';
this->FileExtension[5] = '6';
this->FileExtension[6] = '7';
this->FileExtension[7] = '8';
this->FileExtension[8] = '9';
this->FileExtension[9] = 'A';
this->FileExtension[10] = 'B';
this->VersionNumber = 0;
this->CellDataArraySelection = vtkDataArraySelection::New();
this->Points = vtkPoints::New();
this->Mesh = vtkUnstructuredGrid::New();
this->AHexahedron = vtkHexahedron::New();
this->AQuad = vtkQuad::New();
this->AWedge = vtkWedge::New();
this->NMax = vtkIntArray::New();
this->C = vtkDoubleArray::New();
this->Dx = vtkDoubleArray::New();
this->Dy = vtkDoubleArray::New();
this->Dz = vtkDoubleArray::New();
this->TempI = vtkIntArray::New();
this->TempD = vtkDoubleArray::New();
this->Flag = vtkIntArray::New();
this->VariableNames = vtkStringArray::New();
this->VariableComponents = vtkIntArray::New();
this->VariableIndexToSPX = vtkIntArray::New();
this->VariableTimesteps = vtkIntArray::New();
this->VariableTimestepTable = vtkIntArray::New();
this->SPXToNVarTable = vtkIntArray::New();
this->VariableToSkipTable = vtkIntArray::New();
this->SpxFileExists = vtkIntArray::New();
this->SetNumberOfInputPorts(0);
this->SPXTimestepIndexTable = vtkIntArray::New();
// Time support:
this->TimeStep = 0; // By default the file does not have timestep
this->TimeStepRange[0] = 0;
this->TimeStepRange[1] = 0;
this->NumberOfTimeSteps = 1;
this->TimeSteps = 0;
this->CurrentTimeStep = 0;
this->TimeStepWasReadOnce = 0;
}
//----------------------------------------------------------------------------
vtkMFIXReader::~vtkMFIXReader()
{
delete [] this->FileName;
if( this->CellDataArray )
{
for (int j = 0; j <= this->VariableNames->GetMaxId(); j++)
{
this->CellDataArray[j]->Delete();
}
delete [] this->CellDataArray;
}
this->CellDataArraySelection->Delete();
this->Points->Delete();
this->Mesh->Delete();
this->AHexahedron->Delete();
this->AWedge->Delete();
this->AQuad->Delete();
this->NMax->Delete();
this->C->Delete();
this->Dx->Delete();
this->Dy->Delete();
this->Dz->Delete();
this->TempI->Delete();
this->TempD->Delete();
this->Flag->Delete();
this->VariableNames->Delete();
this->VariableComponents->Delete();
this->VariableIndexToSPX->Delete();
this->VariableTimesteps->Delete();
this->VariableTimestepTable->Delete();
this->SPXToNVarTable->Delete();
this->VariableToSkipTable->Delete();
this->SpxFileExists->Delete();
this->Minimum->Delete();
this->Maximum->Delete();
this->VectorLength->Delete();
this->SPXTimestepIndexTable->Delete();
}
//----------------------------------------------------------------------------
int vtkMFIXReader::RequestData(
vtkInformation *vtkNotUsed(request),
vtkInformationVector **vtkNotUsed(inputVector),
vtkInformationVector *outputVector)
{
vtkInformation* outInfo = outputVector->GetInformationObject(0);
vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkDebugMacro( << "Reading MFIX file");
// Save the time value in the output data information.
int length = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
double* steps = outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
if (outInfo->Has( vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()))
{
// Get the requested time step. We only support requests of a single time
// step in this reader right now
double requestedTimeStep =
outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
//find the timestep with the closest value
int cnt=0;
int closestStep=0;
double minDist=-1;
for (cnt=0;cnt<length;cnt++)
{
double tdist=(steps[cnt]-requestedTimeStep>requestedTimeStep-steps[cnt])?
steps[cnt]-requestedTimeStep:
requestedTimeStep-steps[cnt];
if (minDist<0 || tdist<minDist)
{
minDist=tdist;
closestStep=cnt;
}
}
this->CurrentTimeStep=closestStep;
}
else
{
this->CurrentTimeStep = this->TimeStep;
}
this->MakeMesh(output);
output->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(), steps[this->CurrentTimeStep]);
return 1;
}
//----------------------------------------------------------------------------
void vtkMFIXReader::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "File Name: "
<< (this->FileName ? this->FileName : "(none)") << "\n";
os << indent << "Number Of Nodes: " << this->NumberOfPoints << endl;
os << indent << "Number Of Cells: " << this->NumberOfCells << endl;
os << indent << "Number Of Cell Fields: " << this->NumberOfCellFields << endl;
os << indent << "Time Step Range: "
<< this->TimeStepRange[0] << " - " << this->TimeStepRange[1]
<< endl;
os << indent << "Time Step: " << this->TimeStep << endl;
os << indent << "Number of Time Steps: " << this->NumberOfTimeSteps << endl;
}
//----------------------------------------------------------------------------
void vtkMFIXReader::MakeMesh(vtkUnstructuredGrid *output)
{
output->Allocate();
if (this->MakeMeshFlag == 0)
{
//Points->SetNumberOfPoints((this->IMaximum2+1)
// *(this->JMaximum2+1)*(this->KMaximum2+1));
//
// Cartesian type mesh
//
if ( !strcmp(this->CoordinateSystem,"CARTESIAN") && (this->KMaximum2 != 1))
{
double pointX = -this->Dx->GetValue(0);
double pointY = -this->Dy->GetValue(0);
double pointZ = -this->Dz->GetValue(0);
for (int k = 0; k <= this->KMaximum2; k++)
{
for (int j = 0; j <= this->JMaximum2; j++)
{
for (int i = 0; i <= this->IMaximum2; i++)
{
this->Points->InsertNextPoint( pointX, pointY, pointZ );
if ( i == this->IMaximum2 )
{
pointX = pointX + this->Dx->GetValue(i-1);
}
else
{
pointX = pointX + this->Dx->GetValue(i);
}
}
pointX = -this->Dx->GetValue(0);
if ( j == this->JMaximum2)
{
pointY = pointY + this->Dy->GetValue(j-1);
}
else
{
pointY = pointY + this->Dy->GetValue(j);
}
}
pointY = -this->Dy->GetValue(0);
if ( k == this->KMaximum2)
{
pointZ = pointZ + this->Dz->GetValue(k-1);
}
else
{
pointZ = pointZ + this->Dz->GetValue(k);
}
}
}
else if (!strcmp(this->CoordinateSystem,"CARTESIAN") &&
(this->KMaximum2 == 1))
{
double pointX = -this->Dx->GetValue(0);
double pointY = -this->Dy->GetValue(0);
double pointZ = 0.0;
for (int j = 0; j <= this->JMaximum2; j++)
{
for (int i = 0; i <= this->IMaximum2; i++)
{
this->Points->InsertNextPoint(pointX, pointY, pointZ );
if ( i == this->IMaximum2 )
{
pointX = pointX + this->Dx->GetValue(i-1);
}
else
{
pointX = pointX + this->Dx->GetValue(i);
}
}
pointX = -this->Dx->GetValue(0);
if ( j == this->JMaximum2)
{
pointY = pointY + this->Dy->GetValue(j-1);
}
else
{
pointY = pointY + this->Dy->GetValue(j);
}
}
}
else if (!strcmp(this->CoordinateSystem,"CYLINDRICAL") &&
(this->KMaximum2 == 1))
{
double pointX = -this->Dx->GetValue(0);
double pointY = -this->Dy->GetValue(0);
double pointZ = 0.0;
for (int j = 0; j <= this->JMaximum2; j++)
{
for (int i = 0; i <= this->IMaximum2; i++)
{
this->Points->InsertNextPoint( pointX, pointY, pointZ );
if ( i == this->IMaximum2 )
{
pointX = pointX + this->Dx->GetValue(i-1);
}
else if ( i == 0 )
{
pointX = 0;
}
else
{
pointX = pointX + this->Dx->GetValue(i);
}
}
pointX = -this->Dx->GetValue(0);
if ( j == this->JMaximum2)
{
pointY = pointY + this->Dy->GetValue(j-1);
}
else
{
pointY = pointY + this->Dy->GetValue(j);
}
}
}
else
{
//
// Cylindrical Type Mesh
//
double pointX = -this->Dx->GetValue(0);
double pointY = -this->Dy->GetValue(0);
double pointZ = -this->Dz->GetValue(0);
double radialX = 0.0;
double radialY = 0.0;
double radialZ = 0.0;
for (int k = 0; k <= this->KMaximum2; k++)
{
for (int j = 0; j <= this->JMaximum2; j++)
{
for (int i = 0; i <= this->IMaximum2; i++)
{
this->Points->InsertNextPoint( radialX, radialY, radialZ );
if ( i == this->IMaximum2 )
{
pointX = pointX + this->Dx->GetValue(i-1);
}
else if ( i == 0 )
{
pointX = -this->Dx->GetValue(0);
}
else
{
pointX = pointX + this->Dx->GetValue(i);
}
radialX = pointX * cos(pointZ);
radialZ = pointX * sin(pointZ) * -1;
}
pointX = -this->Dx->GetValue(0);
radialX = 0.0;
radialZ = 0.0;
if ( j == this->JMaximum2)
{
pointY = pointY + this->Dy->GetValue(j-1);
}
else
{
pointY = pointY + this->Dy->GetValue(j);
}
radialY = pointY;
}
pointY = -this->Dy->GetValue(0);
radialY = 0.0;
if ( k == this->KMaximum2)
{
pointZ = pointZ + this->Dz->GetValue(k-1);
}
else
{
pointZ = pointZ + this->Dz->GetValue(k);
}
}
}
//
// Let's put the points in a mesh
//
this->Mesh->SetPoints(this->Points);
int point0 = 0;
int count = 0;
if (!strcmp(this->CoordinateSystem,"CYLINDRICAL") &&
(this->KMaximum2 == 1))
{
for (int j = 0; j < this->JMaximum2; j++)
{
for (int i = 0; i < this->IMaximum2; i++)
{
if ( this->Flag->GetValue(count) < 10 )
{
this->AQuad->GetPointIds()->SetId( 0, point0);
this->AQuad->GetPointIds()->SetId( 1, point0+1);
this->AQuad->GetPointIds()->SetId( 2, point0+2+this->IMaximum2);
this->AQuad->GetPointIds()->SetId( 3, point0+1+this->IMaximum2);
this->Mesh->InsertNextCell(this->AQuad->GetCellType(),
this->AQuad->GetPointIds());
}
point0++;
count++;
}
point0++;
}
point0 = point0 + this->IMaximum2+1;
}
else if (!strcmp(this->CoordinateSystem,"CYLINDRICAL") &&
(this->KMaximum2 != 1))
{
for (int k = 0; k < this->KMaximum2; k++)
{
for (int j = 0; j < this->JMaximum2; j++)
{
for (int i = 0; i < this->IMaximum2; i++)
{
if ( this->Flag->GetValue(count) < 10 )
{
if (( k == (this->KMaximum2-2)) && (i != 1))
{
this->AHexahedron->GetPointIds()->SetId( 0, point0);
this->AHexahedron->GetPointIds()->SetId( 1, point0+1);
this->AHexahedron->GetPointIds()->SetId( 2,
(point0+1+((this->IMaximum2+1)*(this->JMaximum2+1)))-
((this->IMaximum2+1)*(this->JMaximum2+1)
*(this->KMaximum2-2)));
this->AHexahedron->GetPointIds()->SetId( 3,
(point0+((this->IMaximum2+1)*(this->JMaximum2+1)))-
((this->IMaximum2+1)*(this->JMaximum2+1)
*(this->KMaximum2-2)));
this->AHexahedron->GetPointIds()->
SetId( 4, point0+1+this->IMaximum2);
this->AHexahedron->GetPointIds()->
SetId( 5, point0+2+this->IMaximum2);
this->AHexahedron->GetPointIds()->
SetId( 6, (point0+2+this->IMaximum2 +
((this->IMaximum2+1)*(this->JMaximum2+1))) -
((this->IMaximum2+1)*(this->JMaximum2+1)
* (this->KMaximum2-2)));
this->AHexahedron->GetPointIds()->
SetId( 7, (point0+1+this->IMaximum2 +
((this->IMaximum2+1)*(this->JMaximum2+1)))-
((this->IMaximum2+1)*(this->JMaximum2+1)
*(this->KMaximum2-2)));
this->Mesh->InsertNextCell(this->AHexahedron->GetCellType(),
this->AHexahedron->GetPointIds());
}
else if ((k != (this->KMaximum2-2)) && (i != 1))
{
this->AHexahedron->GetPointIds()->SetId( 0, point0);
this->AHexahedron->GetPointIds()->SetId( 1, point0+1);
this->AHexahedron->GetPointIds()->SetId( 2,
point0+1+((this->IMaximum2+1)*(this->JMaximum2+1)));
this->AHexahedron->GetPointIds()->SetId( 3,
point0+((this->IMaximum2+1)*(this->JMaximum2+1)));
this->AHexahedron->GetPointIds()->
SetId( 4, point0+1+this->IMaximum2);
this->AHexahedron->GetPointIds()->
SetId( 5, point0+2+this->IMaximum2);
this->AHexahedron->GetPointIds()->
SetId( 6, point0+2+this->IMaximum2+
((this->IMaximum2+1)*(this->JMaximum2+1)));
this->AHexahedron->GetPointIds()->
SetId( 7, point0+1+this->IMaximum2+
((this->IMaximum2+1)*(this->JMaximum2+1)));
this->Mesh->InsertNextCell(this->AHexahedron->GetCellType(),
this->AHexahedron->GetPointIds());
}
else if ( (k != (this->KMaximum2-2)) && (i == 1))
{
this->AWedge->GetPointIds()->SetId( 0, j*(this->IMaximum2+1));
this->AWedge->GetPointIds()->SetId( 1, point0+1);
this->AWedge->GetPointIds()->
SetId( 2, point0+1+((this->IMaximum2+1)
*(this->JMaximum2+1)));
this->AWedge->GetPointIds()->
SetId( 3, (j+1)*(this->IMaximum2+1));
this->AWedge->GetPointIds()->
SetId( 4, point0+2+this->IMaximum2);
this->AWedge->GetPointIds()->
SetId( 5, point0+2+this->IMaximum2+
((this->IMaximum2+1)*(this->JMaximum2+1)));
this->Mesh->InsertNextCell(this->AWedge->GetCellType(),
this->AWedge->GetPointIds());
}
else if (( k == (this->KMaximum2-2)) && (i == 1))
{
this->AWedge->GetPointIds()->SetId( 0, j*(this->IMaximum2+1));
this->AWedge->GetPointIds()->SetId( 1, point0+1);
this->AWedge->GetPointIds()->SetId( 2,
(point0+1+((this->IMaximum2+1)
*(this->JMaximum2+1)))-((this->IMaximum2+1)
*(this->JMaximum2+1)*(this->KMaximum2-2)));
this->AWedge->GetPointIds()->
SetId( 3, (j+1)*(this->IMaximum2+1));
this->AWedge->GetPointIds()->
SetId( 4, point0+2+this->IMaximum2);
this->AWedge->GetPointIds()->
SetId( 5, (point0+2+this->IMaximum2 +
((this->IMaximum2+1)*(this->JMaximum2+1)))
-((this->IMaximum2+1)
*(this->JMaximum2+1)*(this->KMaximum2-2)));
this->Mesh->InsertNextCell(this->AWedge->GetCellType(),
this->AWedge->GetPointIds());
}
}
point0++;
count++;
}
point0++;
}
point0 = point0 + this->IMaximum2+1;
}
}
else if (!strcmp(this->CoordinateSystem,"CARTESIAN") &&
(this->KMaximum2 == 1))
{
for (int j = 0; j < this->JMaximum2; j++)
{
for (int i = 0; i < this->IMaximum2; i++)
{
if ( this->Flag->GetValue(count) < 10 )
{
this->AQuad->GetPointIds()->SetId( 0, point0);
this->AQuad->GetPointIds()->SetId( 1, point0+1);
this->AQuad->GetPointIds()->SetId( 2, point0+2+this->IMaximum2);
this->AQuad->GetPointIds()->SetId( 3, point0+1+this->IMaximum2);
this->Mesh->InsertNextCell(this->AQuad->GetCellType(),
this->AQuad->GetPointIds());
}
point0++;
count++;
}
point0++;
}
}
else
{
for (int k = 0; k < this->KMaximum2; k++)
{
for (int j = 0; j < this->JMaximum2; j++)
{
for (int i = 0; i < this->IMaximum2; i++)
{
if ( this->Flag->GetValue(count) < 10 )
{
this->AHexahedron->GetPointIds()->SetId( 0, point0);
this->AHexahedron->GetPointIds()->SetId( 1, point0+1);
this->AHexahedron->GetPointIds()->
SetId( 2, point0+1+((this->IMaximum2+1)
*(this->JMaximum2+1)));
this->AHexahedron->GetPointIds()->
SetId( 3, point0+((this->IMaximum2+1)
*(this->JMaximum2+1)));
this->AHexahedron->GetPointIds()->
SetId( 4, point0+1+this->IMaximum2);
this->AHexahedron->GetPointIds()->
SetId( 5, point0+2+this->IMaximum2);
this->AHexahedron->GetPointIds()->
SetId( 6, point0+2+this->IMaximum2 +
((this->IMaximum2+1)*(this->JMaximum2+1)));
this->AHexahedron->GetPointIds()->
SetId( 7, point0+1+this->IMaximum2 +
((this->IMaximum2+1)*(this->JMaximum2+1)));
this->Mesh->InsertNextCell(this->AHexahedron->GetCellType(),
this->AHexahedron->GetPointIds());
}
point0++;
count++;
}
point0++;
}
point0 = point0 + this->IMaximum2+1;
}
}
this->CellDataArray = new vtkFloatArray
* [this->VariableNames->GetMaxId()+2];
for (int j = 0; j <= this->VariableNames->GetMaxId(); j++)
{
this->CellDataArray[ j ] = vtkFloatArray::New();
this->CellDataArray[ j ]->SetName(this->VariableNames->GetValue(j));
this->CellDataArray[ j ]->
SetNumberOfComponents(this->VariableComponents->GetValue(j));
}
this->MakeMeshFlag = 1;
}
output->DeepCopy(this->Mesh); // If mesh has already
// been made copy it to output
int first = 0;
for (int j = 0; j <= this->VariableNames->GetMaxId(); j++)
{
if ( this->CellDataArraySelection->GetArraySetting(j) == 1 )
{
if (this->VariableComponents->GetValue(j) == 1)
{
this->GetVariableAtTimestep( j, this->CurrentTimeStep, CellDataArray[j]);
}
else
{
if ( !strcmp(CoordinateSystem,"CYLINDRICAL" ))
{
this->ConvertVectorFromCylindricalToCartesian( j-3, j-1);
}
this->FillVectorVariable( j-3, j-2, j-1, this->CellDataArray[j]);
}
if (first == 0)
{
output->GetCellData()->SetScalars(this->CellDataArray[j]);
}
else
{
output->GetCellData()->AddArray(this->CellDataArray[j]);
}
double tempRange[2];
this->CellDataArray[j]->GetRange(tempRange, -1);
this->Minimum->InsertValue( j, (float)tempRange[0]);
this->Maximum->InsertValue( j, (float)tempRange[1]);
this->VectorLength->InsertValue( j, 1);
first = 1;
}
}
}
//----------------------------------------------------------------------------
int vtkMFIXReader::RequestInformation(
vtkInformation *vtkNotUsed(request),
vtkInformationVector **vtkNotUsed(inputVector),
vtkInformationVector *outputVector)
{
if ( this->RequestInformationFlag == 0)
{
if ( !this->FileName )
{
this->NumberOfPoints = 0;
this->NumberOfCells = 0;
vtkErrorMacro("No filename specified");
return 0;
}
this->SetProjectName(this->FileName);
this->ReadRestartFile();
this->CreateVariableNames();
this->GetTimeSteps();
this->CalculateMaxTimeStep();
this->MakeTimeStepTable(VariableNames->GetMaxId()+1);
this->GetNumberOfVariablesInSPXFiles();
this->MakeSPXTimeStepIndexTable(VariableNames->GetMaxId()+1);
for (int j = 0; j <= this->VariableNames->GetMaxId(); j++)
{
this->CellDataArraySelection->AddArray(
this->VariableNames->GetValue(j));
}
this->NumberOfPoints = (this->IMaximum2+1)
*(this->JMaximum2+1)*(this->KMaximum2+1);
this->NumberOfCells = this->IJKMaximum2;
this->NumberOfCellFields = this->VariableNames->GetMaxId()+1;
this->NumberOfTimeSteps = this->MaximumTimestep;
this->TimeStepRange[0] = 0;
this->TimeStepRange[1] = this->NumberOfTimeSteps-1;
this->RequestInformationFlag = 1;
this->GetAllTimes(outputVector);
}
return 1;
}
//----------------------------------------------------------------------------
int vtkMFIXReader::GetNumberOfCellArrays()
{
return this->CellDataArraySelection->GetNumberOfArrays();
}
//----------------------------------------------------------------------------
const char* vtkMFIXReader::GetCellArrayName(int index)
{
return this->CellDataArraySelection->GetArrayName(index);
}
//----------------------------------------------------------------------------
int vtkMFIXReader::GetCellArrayStatus(const char* name)
{
return this->CellDataArraySelection->ArrayIsEnabled(name);
}
//----------------------------------------------------------------------------
void vtkMFIXReader::SetCellArrayStatus(const char* name, int status)
{
if(status)
{
this->CellDataArraySelection->EnableArray(name);
}
else
{
this->CellDataArraySelection->DisableArray(name);
}
}
//----------------------------------------------------------------------------
void vtkMFIXReader::DisableAllCellArrays()
{
this->CellDataArraySelection->DisableAllArrays();
}
//----------------------------------------------------------------------------
void vtkMFIXReader::EnableAllCellArrays()
{
this->CellDataArraySelection->EnableAllArrays();
}
//----------------------------------------------------------------------------
void vtkMFIXReader::GetCellDataRange(int cellComp, float *min, float *max)
{
*min = this->Minimum->GetValue(cellComp);
*max = this->Maximum->GetValue(cellComp);
}
//----------------------------------------------------------------------------
void vtkMFIXReader::SetProjectName (const char *infile)
{
int len = static_cast<int>(strlen(infile));
strncpy(this->RunName, infile, len-4);
}
//----------------------------------------------------------------------------
void vtkMFIXReader::RestartVersionNumber(const char* buffer)
{
char s1[512];
char s2[512];
sscanf(buffer,"%s %s %f", s1, s2, &this->VersionNumber);
strncpy(this->Version, buffer, 100);
}
//----------------------------------------------------------------------------
void vtkMFIXReader::GetInt(istream& in, int &val)
{
in.read( (char*)&val,sizeof(int));
this->SwapInt(val);
}
//----------------------------------------------------------------------------
void vtkMFIXReader::SwapInt(int &value)
{
int result = ((value & 0x00FF) << 24) |
((value & 0xFF00) << 8) |
((value >> 8) & 0xFF00) |
((value >> 24) & 0x00FF);
value = result;
}
//----------------------------------------------------------------------------
void vtkMFIXReader::SwapDouble(double &value)
{
union Swap
{
double valDouble;
unsigned char valByte[8];
};
Swap source;
source.valDouble = value;
Swap result;
result.valByte[0] = source.valByte[7];
result.valByte[1] = source.valByte[6];
result.valByte[2] = source.valByte[5];
result.valByte[3] = source.valByte[4];
result.valByte[4] = source.valByte[3];
result.valByte[5] = source.valByte[2];
result.valByte[6] = source.valByte[1];
result.valByte[7] = source.valByte[0];
value = result.valDouble;
}
//----------------------------------------------------------------------------
void vtkMFIXReader::SwapFloat(float &value)
{
union Swap
{
float valFloat;
unsigned char valByte[4];
};
Swap source;
source.valFloat = value;
Swap result;
result.valByte[0] = source.valByte[3];
result.valByte[1] = source.valByte[2];
result.valByte[2] = source.valByte[1];
result.valByte[3] = source.valByte[0];
value = result.valFloat;
}
//----------------------------------------------------------------------------
void vtkMFIXReader::GetDouble(istream& in, double& val)
{
in.read( (char*)&val,sizeof(double));
this->SwapDouble(val);
}
//----------------------------------------------------------------------------
void vtkMFIXReader::SkipBytes(istream& in, int n)
{
in.read(this->DataBuffer,n); // maybe seekg instead
}
//----------------------------------------------------------------------------
void vtkMFIXReader::GetBlockOfDoubles(istream& in, vtkDoubleArray *v, int n)
{
const int numberOfDoublesInBlock = 512/sizeof(double);
double tempArray[numberOfDoublesInBlock];
int numberOfRecords;
if ( n%numberOfDoublesInBlock == 0)
{
numberOfRecords = n/numberOfDoublesInBlock;
}
else
{
numberOfRecords = 1 + n/numberOfDoublesInBlock;
}
int c = 0;
for (int i=0; i<numberOfRecords; ++i)
{
in.read( (char*)&tempArray , 512 );
for (int j=0; j<numberOfDoublesInBlock; ++j)
{
if (c < n)
{
double temp = tempArray[j];
this->SwapDouble(temp);
v->InsertValue( c, temp);
++c;
}
}
}
}
//----------------------------------------------------------------------------
void vtkMFIXReader::GetBlockOfInts(istream& in, vtkIntArray *v, int n)
{
const int numberOfIntsInBlock = 512/sizeof(int);
int tempArray[numberOfIntsInBlock];
int numberOfRecords;
if ( n%numberOfIntsInBlock == 0)
{
numberOfRecords = n/numberOfIntsInBlock;
}
else
{
numberOfRecords = 1 + n/numberOfIntsInBlock;
}
int c = 0;
for (int i = 0; i < numberOfRecords; ++i)
{
in.read( (char*)&tempArray , 512 );
for (int j=0; j<numberOfIntsInBlock; ++j)
{
if (c < n)
{
int temp = tempArray[j];
this->SwapInt(temp);
v->InsertValue( c, temp);
++c;
}
}
}
}
//----------------------------------------------------------------------------
void vtkMFIXReader::GetBlockOfFloats(istream& in, vtkFloatArray *v, int n)
{
const int numberOfFloatsInBlock = 512/sizeof(float);
float tempArray[numberOfFloatsInBlock];
int numberOfRecords;
if ( n%numberOfFloatsInBlock == 0)
{
numberOfRecords = n/numberOfFloatsInBlock;
}
else
{
numberOfRecords = 1 + n/numberOfFloatsInBlock;
}
bool modified = false;
int c = 0;
int cnt = 0;
for (int i=0; i<numberOfRecords; ++i)
{
in.read( (char*)&tempArray , 512 );
for (int j=0; j<numberOfFloatsInBlock; ++j)
{
if (c < n)
{
float temp = tempArray[j];
this->SwapFloat(temp);
if ( this->Flag->GetValue(c) < 10)
{
v->InsertValue(cnt, temp);
cnt++;
modified = true;
}
++c;
}
}
}
if (modified)
{
v->Modified();
}
}
//----------------------------------------------------------------------------
void vtkMFIXReader::ReadRestartFile()
{
int dimensionUsr = 5;
#ifdef _WIN32
ifstream in(this->FileName,ios::binary);
#else
ifstream in(this->FileName);
#endif
if (!in)
{
//cout << "could not open file" << endl;
return;
}
this->DataBuffer[512] = '\0';
// version : record 1
memset(this->DataBuffer,0,513);
in.read(this->DataBuffer,512);
this->RestartVersionNumber(this->DataBuffer);
// skip 2 linesline : records 2 and 3
in.read(this->DataBuffer,512);
in.read(this->DataBuffer,512);
// IMinimum1 etc : record 4
memset(this->DataBuffer,0,513);
if (strcmp(this->Version, "RES = 01.00") == 0)
{
this->GetInt(in,this->IMinimum1);
this->GetInt(in,this->JMinimum1);
this->GetInt(in,this->KMinimum1);
this->GetInt(in,this->IMaximum);
this->GetInt(in,this->JMaximum);
this->GetInt(in,this->KMaximum);
this->GetInt(in,this->IMaximum1);
this->GetInt(in,this->JMaximum1);
this->GetInt(in,this->KMaximum1);
this->GetInt(in,this->IMaximum2);
this->GetInt(in,this->JMaximum2);
this->GetInt(in,this->KMaximum2);
this->GetInt(in,this->IJMaximum2);
this->GetInt(in,this->IJKMaximum2);
this->GetInt(in,this->MMAX);
this->GetDouble(in,this->DeltaTime);
this->GetDouble(in,this->XLength);
this->GetDouble(in,this->YLength);
this->GetDouble(in,this->ZLength);
// 15 ints ... 4 doubles = 92 bytes
this->SkipBytes(in,420);
}
else if (strcmp(this->Version, "RES = 01.01") == 0 ||
strcmp(this->Version, "RES = 01.02") == 0)
{
this->GetInt(in,this->IMinimum1);
this->GetInt(in,this->JMinimum1);
this->GetInt(in,this->KMinimum1);
this->GetInt(in,this->IMaximum);
this->GetInt(in,this->JMaximum);
this->GetInt(in,this->KMaximum);
this->GetInt(in,this->IMaximum1);
this->GetInt(in,this->JMaximum1);
this->GetInt(in,this->KMaximum1);
this->GetInt(in,this->IMaximum2);
this->GetInt(in,this->JMaximum2);
this->GetInt(in,this->KMaximum2);
this->GetInt(in,this->IJMaximum2);
this->GetInt(in,this->IJKMaximum2);
this->GetInt(in,this->MMAX);
this->GetInt(in,this->DimensionIc);
this->GetInt(in,this->DimensionBc);
this->GetDouble(in,this->DeltaTime);
this->GetDouble(in,this->XLength);
this->GetDouble(in,this->YLength);
this->GetDouble(in,this->ZLength);
// 17 ints ... 4 doubles = 100 bytes
this->SkipBytes(in,412);
}
else if(strcmp(this->Version, "RES = 01.03") == 0)
{
this->GetInt(in,this->IMinimum1);
this->GetInt(in,this->JMinimum1);
this->GetInt(in,this->KMinimum1);
this->GetInt(in,this->IMaximum);
this->GetInt(in,this->JMaximum);
this->GetInt(in,this->KMaximum);
this->GetInt(in,this->IMaximum1);
this->GetInt(in,this->JMaximum1);
this->GetInt(in,this->KMaximum1);
this->GetInt(in,this->IMaximum2);
this->GetInt(in,this->JMaximum2);
this->GetInt(in,this->KMaximum2);
this->GetInt(in,this->IJMaximum2);
this->GetInt(in,this->IJKMaximum2);
this->GetInt(in,this->MMAX);
this->GetInt(in,this->DimensionIc);
this->GetInt(in,this->DimensionBc);
this->GetDouble(in,this->DeltaTime);
this->GetDouble(in,this->XMinimum);
this->GetDouble(in,this->XLength);
this->GetDouble(in,this->YLength);
this->GetDouble(in,this->ZLength);
// 17 ints ... 5 doubles = 108 bytes
this->SkipBytes(in,404);
}
else if(strcmp(this->Version, "RES = 01.04") == 0)
{
this->GetInt(in,this->IMinimum1);
this->GetInt(in,this->JMinimum1);
this->GetInt(in,this->KMinimum1);
this->GetInt(in,this->IMaximum);
this->GetInt(in,this->JMaximum);
this->GetInt(in,this->KMaximum);
this->GetInt(in,this->IMaximum1);
this->GetInt(in,this->JMaximum1);
this->GetInt(in,this->KMaximum1);
this->GetInt(in,this->IMaximum2);
this->GetInt(in,this->JMaximum2);
this->GetInt(in,this->KMaximum2);
this->GetInt(in,this->IJMaximum2);
this->GetInt(in,this->IJKMaximum2);
this->GetInt(in,this->MMAX);
this->GetInt(in,this->DimensionIc);
this->GetInt(in,this->DimensionBc);
this->GetInt(in,this->DimensionC);
this->GetDouble(in,this->DeltaTime);
this->GetDouble(in,this->XMinimum);
this->GetDouble(in,this->XLength);
this->GetDouble(in,this->YLength);
this->GetDouble(in,this->ZLength);
// 18 ints ... 5 doubles = 112 bytes
this->SkipBytes(in,400);
}
else if(strcmp(this->Version, "RES = 01.05") == 0)
{
this->GetInt(in,this->IMinimum1);
this->GetInt(in,this->JMinimum1);
this->GetInt(in,this->KMinimum1);
this->GetInt(in,this->IMaximum);
this->GetInt(in,this->JMaximum);
this->GetInt(in,this->KMaximum);
this->GetInt(in,this->IMaximum1);
this->GetInt(in,this->JMaximum1);
this->GetInt(in,this->KMaximum1);
this->GetInt(in,this->IMaximum2);
this->GetInt(in,this->JMaximum2);
this->GetInt(in,this->KMaximum2);
this->GetInt(in,this->IJMaximum2);
this->GetInt(in,this->IJKMaximum2);
this->GetInt(in,this->MMAX);
this->GetInt(in,this->DimensionIc);
this->GetInt(in,this->DimensionBc);
this->GetInt(in,this->DimensionC);
this->GetInt(in,this->DimensionIs);
this->GetDouble(in,this->DeltaTime);
this->GetDouble(in,this->XMinimum);
this->GetDouble(in,this->XLength);
this->GetDouble(in,this->YLength);
this->GetDouble(in,this->ZLength);
// 19 ints ... 5 doubles = 116 bytes
this->SkipBytes(in,396);
}
else
{
this->GetInt(in,this->IMinimum1);
this->GetInt(in,this->JMinimum1);
this->GetInt(in,this->KMinimum1);
this->GetInt(in,this->IMaximum);
this->GetInt(in,this->JMaximum);
this->GetInt(in,this->KMaximum);
this->GetInt(in,this->IMaximum1);
this->GetInt(in,this->JMaximum1);
this->GetInt(in,this->KMaximum1);
this->GetInt(in,this->IMaximum2);
this->GetInt(in,this->JMaximum2);
this->GetInt(in,this->KMaximum2);
this->GetInt(in,this->IJMaximum2);
this->GetInt(in,this->IJKMaximum2);
this->GetInt(in,this->MMAX);
this->GetInt(in,this->DimensionIc);
this->GetInt(in,this->DimensionBc);
this->GetInt(in,this->DimensionC);
this->GetInt(in,this->DimensionIs);
this->GetDouble(in,this->DeltaTime);
this->GetDouble(in,this->XMinimum);
this->GetDouble(in,this->XLength);
this->GetDouble(in,this->YLength);
this->GetDouble(in,this->ZLength);
this->GetDouble(in,this->Ce);
this->GetDouble(in,this->Cf);
this->GetDouble(in,this->Phi);
this->GetDouble(in,this->PhiW);
// 19 ints ... 9 doubles = 148 bytes
this->SkipBytes(in,364);
}
const int numberOfFloatsInBlock = 512/sizeof(float);
if ( this->IJKMaximum2%numberOfFloatsInBlock == 0)
{
this->SPXRecordsPerTimestep = this->IJKMaximum2/numberOfFloatsInBlock;
}
else
{
this->SPXRecordsPerTimestep = 1 + this->IJKMaximum2/numberOfFloatsInBlock;
}
// C , C_name and nmax
this->NMax->Resize(this->MMAX+1);
for (int lc=0; lc<this->MMAX+1; ++lc)
{
this->NMax->InsertValue(lc, 1);
}
this->C->Resize(this->DimensionC);
if (this->VersionNumber > 1.04)
{
this->GetBlockOfDoubles (in, this->C, this->DimensionC);
for (int lc=0; lc<DimensionC; ++lc)
{
in.read(this->DataBuffer,512); // c_name[]
}
if (this->VersionNumber < 1.12)
{
this->GetBlockOfInts(in, this->NMax,this->MMAX+1);
}
else
{
// what is the diff between this and above ???
for (int lc=0; lc<this->MMAX+1; ++lc)
{
int temp;
this->GetInt(in,temp);
this->NMax->InsertValue(lc, temp);
}
this->SkipBytes(in,512-(this->MMAX+1)*sizeof(int));
}
}
this->Dx->Resize(this->IMaximum2);
this->Dy->Resize(this->JMaximum2);
this->Dz->Resize(this->KMaximum2);
this->GetBlockOfDoubles(in, this->Dx,this->IMaximum2);
this->GetBlockOfDoubles(in, this->Dy,this->JMaximum2);
this->GetBlockOfDoubles(in, this->Dz,this->KMaximum2);
// RunName etc.
memset(this->Units,0,17);
memset(this->CoordinateSystem,0,17);
in.read(this->DataBuffer,120); // run_name , description
in.read(this->Units,16); // Units
in.read(this->DataBuffer,16); // run_type
in.read(this->CoordinateSystem,16); // CoordinateSystem
this->SkipBytes(in,512-168);
char tempCharArray[17];
memset(tempCharArray,0,17);
int ic = 0;
for (int i=0; i<17; ++i)
{
if (this->Units[i] != ' ')
{
tempCharArray[ic++] = this->Units[i];
}
}
memset(tempCharArray,0,17);
ic = 0;
for (int i=0; i<17; ++i)
{
if (this->CoordinateSystem[i] != ' ')
{
tempCharArray[ic++] = this->CoordinateSystem[i];
}
}
strcpy(this->CoordinateSystem,tempCharArray);
if (this->VersionNumber >= 1.04)
{
this->TempD->Resize(this->NMax->GetValue(0));
this->GetBlockOfDoubles(in, this->TempD, this->NMax->GetValue(0)); // MW_g
for (int i=0; i<this->MMAX; ++i)
{
in.read(this->DataBuffer,512); // MW_s
}
}
in.read(this->DataBuffer,512); // D_p etc.
// read in the "DimensionIc" variables (and ignore ... not used by ani_mfix)
this->TempI->Resize(this->DimensionIc);
this->TempD->Resize(this->DimensionIc);
this->GetBlockOfDoubles(in, this->TempD,this->DimensionIc); // ic_x_w
this->GetBlockOfDoubles(in, this->TempD,this->DimensionIc); // ic_x_e
this->GetBlockOfDoubles(in, this->TempD,this->DimensionIc); // ic_y_s
this->GetBlockOfDoubles(in, this->TempD,this->DimensionIc); // ic_y_n
this->GetBlockOfDoubles(in, this->TempD,this->DimensionIc); // ic_z_b
this->GetBlockOfDoubles(in, this->TempD,this->DimensionIc); // ic_z_t
this->GetBlockOfInts(in, this->TempI,this->DimensionIc); // ic_i_w
this->GetBlockOfInts(in, this->TempI,this->DimensionIc); // ic_i_e
this->GetBlockOfInts(in, this->TempI,this->DimensionIc); // ic_j_s
this->GetBlockOfInts(in, this->TempI,this->DimensionIc); // ic_j_n
this->GetBlockOfInts(in, this->TempI,this->DimensionIc); // ic_k_b
this->GetBlockOfInts(in, this->TempI,this->DimensionIc); // ic_k_t
this->GetBlockOfDoubles(in, this->TempD,this->DimensionIc); // ic_ep_g
this->GetBlockOfDoubles(in, this->TempD,this->DimensionIc); // ic_p_g
this->GetBlockOfDoubles(in, this->TempD,this->DimensionIc); // ic_t_g
if (this->VersionNumber < 1.15)
{
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_t_s(1,1)
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_t_s(1,2)
// or ic_tmp
}
if (this->VersionNumber >= 1.04)
{
for (int i=0; i<this->NMax->GetValue(0); ++i)
{
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_x_g
}
}
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_u_g
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_v_g
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_w_g
for (int lc=0; lc<this->MMAX; ++lc)
{
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_rop_s
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_u_s
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_v_s
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_w_s
if (this->VersionNumber >= 1.15)
{
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_t_s
}
if (this->VersionNumber >= 1.04)
{
for (int n=0; n<this->NMax->GetValue(lc+1); ++n)
{
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_x_s
}
}
}
// read in the "DimensionBc" variables (and ignore ... not used by ani_mfix)
this->TempI->Resize(this->DimensionBc);
this->TempD->Resize(this->DimensionBc);
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_x_w
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_x_e
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc y s
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc y n
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc z b
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc z t
this->GetBlockOfInts(in,this->TempI,this->DimensionBc); // bc i w
this->GetBlockOfInts(in,this->TempI,this->DimensionBc); // bc i e
this->GetBlockOfInts(in,this->TempI,this->DimensionBc); // bc j s
this->GetBlockOfInts(in,this->TempI,this->DimensionBc); // bc j n
this->GetBlockOfInts(in,this->TempI,this->DimensionBc); // bc k b
this->GetBlockOfInts(in,this->TempI,this->DimensionBc); // bc k t
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc ep g
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc p g
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc t g
if (VersionNumber < 1.15)
{
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_t_s(1,1)
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_t_s(1,1)
// or bc_tmp
}
if (VersionNumber >= 1.04)
{
for (int i=0; i<this->NMax->GetValue(0); ++i)
{
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_x_g
}
}
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc u g
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc v g
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc w g
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc ro g
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_rop_g
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc volflow g
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc massflow g
for (int lc=0; lc<this->MMAX; ++lc)
{
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc rop s
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc u s
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc v s
if (this->VersionNumber >= 1.04)
{
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc w s
if (this->VersionNumber >= 1.15)
{
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc t s
}
for (int n=0; n<this->NMax->GetValue(lc+1); ++n)
{
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc x s
}
}
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc volflow s
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc massflow s
}
if (strcmp(this->Version,"RES = 01.00") == 0)
{
for (int lc=0; lc<10; ++lc)
{
in.read(this->DataBuffer,512); // BC TYPE
}
}
else
{
for (int lc=0; lc<this->DimensionBc; ++lc)
{
in.read(this->DataBuffer,512); // BC TYPE
}
}
this->Flag->Resize(this->IJKMaximum2);
this->GetBlockOfInts(in, this->Flag,this->IJKMaximum2);
// DimensionIs varibles (not needed by ani_mfix)
this->TempI->Resize(this->DimensionIs);
this->TempD->Resize(this->DimensionIs);
if (this->VersionNumber >= 1.04)
{
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIs); // is x w
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIs); // is x e
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIs); // is y s
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIs); // is y n
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIs); // is z b
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIs); // is z t
this->GetBlockOfInts(in,this->TempI,this->DimensionIs); // is i w
this->GetBlockOfInts(in,this->TempI,this->DimensionIs); // is i e
this->GetBlockOfInts(in,this->TempI,this->DimensionIs); // is j s
this->GetBlockOfInts(in,this->TempI,this->DimensionIs); // is j n
this->GetBlockOfInts(in,this->TempI,this->DimensionIs); // is k b
this->GetBlockOfInts(in,this->TempI,this->DimensionIs); // is k t
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIs); // is_pc(1,1)
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIs); // is_pc(1,2)
if (this->VersionNumber >= 1.07)
{
for (int i=0; i<this->MMAX; ++i)
{
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIs);//is_vel_s
}
}
for (int lc=0; lc<this->DimensionIs; ++lc)
{
in.read(this->DataBuffer,512); // is_type
}
}
if (this->VersionNumber >= 1.08)
{
in.read(this->DataBuffer,512);
}
if (this->VersionNumber >= 1.09)
{
in.read(this->DataBuffer,512);
if (this->VersionNumber >= 1.5)
{
this->GetInt(in,this->NumberOfSPXFilesUsed);
this->SkipBytes(in,508);
}
for (int lc=0; lc< this->NumberOfSPXFilesUsed; ++lc)
{
in.read(this->DataBuffer,512); // spx_dt
}
for (int lc=0; lc<this->MMAX+1; ++lc)
{
in.read(this->DataBuffer,512); // species_eq
}
this->TempD->Resize(dimensionUsr);
this->GetBlockOfDoubles(in,this->TempD,dimensionUsr); // usr_dt
this->GetBlockOfDoubles(in,this->TempD,dimensionUsr); // usr x w
this->GetBlockOfDoubles(in,this->TempD,dimensionUsr); // usr x e
this->GetBlockOfDoubles(in,this->TempD,dimensionUsr); // usr y s
this->GetBlockOfDoubles(in,this->TempD,dimensionUsr); // usr y n
this->GetBlockOfDoubles(in,this->TempD,dimensionUsr); // usr z b
this->GetBlockOfDoubles(in,this->TempD,dimensionUsr); // usr z t
for (int lc=0; lc<dimensionUsr; ++lc)
{
in.read(this->DataBuffer,512); // usr_ext etc.
}
this->TempD->Resize(this->DimensionIc);
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_p_star
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_l_scale
for (int lc=0; lc<this->DimensionIc; ++lc)
{
in.read(this->DataBuffer,512); // ic_type
}
this->TempD->Resize(DimensionBc);
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_dt_0
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_jet_g0
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_dt_h
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_jet_gh
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_dt_l
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_jet_gl
}
if (this->VersionNumber >= 1.1)
{
in.read(this->DataBuffer,512); // mu_gmax
}
if (this->VersionNumber >= 1.11)
{
in.read(this->DataBuffer,512); // x_ex , model_b
}
if (this->VersionNumber >= 1.12)
{
in.read(this->DataBuffer,512); // p_ref , etc.
in.read(this->DataBuffer,512); // leq_it , leq_method
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_hw_g
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_uw_g
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_vw_g
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_ww_g
for (int lc=0; lc<this->MMAX; ++lc)
{
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_hw_s
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_uw_s
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_vw_s
this->GetBlockOfDoubles(in,this->TempD,this->DimensionBc); // bc_ww_s
}
}
if (this->VersionNumber >= 1.13)
{
in.read(this->DataBuffer,512); // momentum_x_eq , etc.
}
if (this->VersionNumber >= 1.14)
{
in.read(this->DataBuffer,512); // detect_small
}
if (this->VersionNumber >= 1.15)
{
in.read(this->DataBuffer,512); // k_g0 , etc.
this->TempD->Resize(this->DimensionIc);
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_gama_rg
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_t_rg
for (int lc=0; lc<this->MMAX; ++lc)
{
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_gama_rs
this->GetBlockOfDoubles(in,this->TempD,this->DimensionIc); // ic_t_rs
}
}
if (this->VersionNumber >= 1.2)
{
in.read(this->DataBuffer,512); // norm_g , norm_s
}
if (this->VersionNumber >= 1.3)
{
this->GetInt(in,this->NumberOfScalars);
this->SkipBytes(in,sizeof(double)); // tol_resid_scalar
int DIM_tmp;
this->GetInt(in,DIM_tmp);
this->SkipBytes(in,512-sizeof(double)-2*sizeof(int));
this->TempI->Resize(DIM_tmp);
this->GetBlockOfInts(in,this->TempI,DIM_tmp); // Phase4Scalar;
}
if (this->VersionNumber >= 1.5)
{
this->GetInt(in,this->NumberOfReactionRates);
this->SkipBytes(in,508);
}
if (this->VersionNumber >= 1.5999)
{
int tmp;
this->GetInt(in,tmp);
this->SkipBytes(in,508);
if (tmp != 0)
{
this->BkEpsilon = true;
}
}
if (this->VersionNumber >= 1.7999)
{
for( int i = 0; i < this->MMAX; ++i)
{
this->SkipBytes(in,512);
}
}
in.close();
}
//----------------------------------------------------------------------------
void vtkMFIXReader::CreateVariableNames()
{
char fileName[VTK_MAXPATH];
int cnt = 0;
char uString[120];
char vString[120];
char wString[120];
char svString[120];
char tempString[120];
char ropString[120];
char temperatureString[120];
char variableString[120];
for (int i=0; i<this->NumberOfSPXFilesUsed; ++i)
{
for(int k = 0; k < (int)sizeof(fileName); k++)
{
fileName[k]=0;
}
strncpy(fileName, this->FileName, strlen(this->FileName)-4);
if (i==0)
{
strcat(fileName, ".SP1");
}
else if (i==1)
{
strcat(fileName, ".SP2");
}
else if (i==2)
{
strcat(fileName, ".SP3");
}
else if (i==3)
{
strcat(fileName, ".SP4");
}
else if (i==4)
{
strcat(fileName, ".SP5");
}
else if (i==5)
{
strcat(fileName, ".SP6");
}
else if (i==6)
{
strcat(fileName, ".SP7");
}
else if (i==7)
{
strcat(fileName, ".SP8");
}
else if (i==8)
{
strcat(fileName, ".SP9");
}
else if (i==9)
{
strcat(fileName, ".SPA");
}
else
{
strcat(fileName, ".SPB");
}
#ifdef _WIN32
ifstream in(fileName,ios::binary);
#else
ifstream in(fileName);
#endif
if (in) // file exists
{
this->SpxFileExists->InsertValue(i, 1);
switch (i+1)
{
case 1:
this->VariableNames->InsertValue(cnt++,"EP_g");
this->VariableIndexToSPX->InsertValue(cnt-1, 1);
this->VariableComponents->InsertValue(cnt-1, 1);
break;
case 2:
this->VariableNames->InsertValue(cnt++,"P_g");
this->VariableIndexToSPX->InsertValue(cnt-1, 2);
this->VariableComponents->InsertValue(cnt-1, 1);
this->VariableNames->InsertValue(cnt++,"P_star");
this->VariableIndexToSPX->InsertValue(cnt-1, 2);
this->VariableComponents->InsertValue(cnt-1, 1);
break;
case 3:
this->VariableNames->InsertValue(cnt++,"U_g");
this->VariableIndexToSPX->InsertValue(cnt-1, 3);
this->VariableComponents->InsertValue(cnt-1, 1);
this->VariableNames->InsertValue(cnt++,"V_g");
this->VariableIndexToSPX->InsertValue(cnt-1, 3);
this->VariableComponents->InsertValue(cnt-1, 1);
this->VariableNames->InsertValue(cnt++,"W_g");
this->VariableIndexToSPX->InsertValue(cnt-1, 3);
this->VariableComponents->InsertValue(cnt-1, 1);
this->VariableNames->InsertValue(cnt++,"Gas Velocity");
this->VariableIndexToSPX->InsertValue(cnt-1, 3);
this->VariableComponents->InsertValue(cnt-1, 3);
break;
case 4:
for (int j=0; j<this->MMAX; ++j)
{
for(int k=0;k<(int)sizeof(uString);k++)
{
uString[k]=0;
}
for(int k=0;k<(int)sizeof(vString);k++)
{
vString[k]=0;
}
for(int k=0;k<(int)sizeof(wString);k++)
{
wString[k]=0;
}
for(int k=0;k<(int)sizeof(svString);k++)
{
svString[k]=0;
}
strcpy(uString, "U_s_");
strcpy(vString, "V_s_");
strcpy(wString, "W_s_");
strcpy(svString, "Solids_Velocity_");
sprintf(tempString, "%d", j+1);
strcat(uString, tempString);
strcat(vString, tempString);
strcat(wString, tempString);
strcat(svString, tempString);
this->VariableNames->InsertValue(cnt++, uString);
this->VariableIndexToSPX->InsertValue(cnt-1, 4);
this->VariableComponents->InsertValue(cnt-1, 1);
this->VariableNames->InsertValue(cnt++, vString);
this->VariableIndexToSPX->InsertValue(cnt-1, 4);
this->VariableComponents->InsertValue(cnt-1, 1);
this->VariableNames->InsertValue(cnt++, wString);
this->VariableIndexToSPX->InsertValue(cnt-1, 4);
this->VariableComponents->InsertValue(cnt-1, 1);
this->VariableNames->InsertValue(cnt++, svString);
this->VariableIndexToSPX->InsertValue(cnt-1, 4);
this->VariableComponents->InsertValue(cnt-1, 3);
}
break;
case 5:
for (int j=0; j<this->MMAX; ++j)
{
for(int k=0;k<(int)sizeof(ropString);k++)
{
ropString[k]=0;
}
strcpy(ropString, "ROP_s_");
sprintf(tempString, "%d", j+1);
strcat(ropString, tempString);
this->VariableNames->InsertValue(cnt++, ropString);
this->VariableIndexToSPX->InsertValue(cnt-1, 5);
this->VariableComponents->InsertValue(cnt-1, 1);
}
break;
case 6:
this->VariableNames->InsertValue(cnt++, "T_g");
this->VariableIndexToSPX->InsertValue(cnt-1, 6);
this->VariableComponents->InsertValue(cnt-1, 1);
if (this->VersionNumber <= 1.15)
{
this->VariableNames->InsertValue(cnt++, "T_s_1");
this->VariableIndexToSPX->InsertValue(cnt-1, 6);
this->VariableComponents->InsertValue(cnt-1, 1);
if (this->MMAX > 1)
{
this->VariableNames->InsertValue(cnt++, "T_s_2");
this->VariableIndexToSPX->InsertValue(cnt-1, 6);
this->VariableComponents->InsertValue(cnt-1, 1);
}
else
{
this->VariableNames->InsertValue(cnt++, "T_s_2_not_used");
this->VariableIndexToSPX->InsertValue(cnt-1, 6);
this->VariableComponents->InsertValue(cnt-1, 1);
}
}
else
{
for (int j=0; j<this->MMAX; ++j)
{
for(int k=0;k<(int)sizeof(temperatureString);k++)
{
temperatureString[k]=0;
}
strcpy(temperatureString, "T_s_");
sprintf(tempString, "%d", j+1);
strcat(temperatureString, tempString);
this->VariableNames->InsertValue(cnt++, temperatureString);
this->VariableIndexToSPX->InsertValue(cnt-1, 6);
this->VariableComponents->InsertValue(cnt-1, 1);
}
}
break;
case 7:
for (int j=0; j<this->NMax->GetValue(0); ++j)
{
for (int k=0;k<(int)sizeof(variableString);k++)
{
variableString[k]=0;
}
strcpy(variableString, "X_g_");
sprintf(tempString, "%d", j+1);
strcat(variableString, tempString);
this->VariableNames->InsertValue(cnt++, variableString);
this->VariableIndexToSPX->InsertValue(cnt-1, 7);
this->VariableComponents->InsertValue(cnt-1, 1);
}
for (int m=1; m<=this->MMAX; ++m)
{
for (int j=0; j<this->NMax->GetValue(m); ++j)
{
char tempString1[120];
char tempString2[120];
for (int k=0;k<(int)sizeof(variableString);k++)
{
variableString[k]=0;
}
strcpy(variableString, "X_s_");
sprintf(tempString1, "%d", m);
sprintf(tempString2, "%d", j+1);
strcat(variableString, tempString1);
strcat(variableString, "_");
strcat(variableString, tempString2);
this->VariableNames->InsertValue(cnt++, variableString);
this->VariableIndexToSPX->InsertValue(cnt-1, 7);
this->VariableComponents->InsertValue(cnt-1, 1);
}
}
break;
case 8:
for (int j=0; j<MMAX; ++j)
{
for (int k=0;k<(int)sizeof(variableString);k++)
{
variableString[k]=0;
}
strcpy(variableString, "Theta_m_");
sprintf(tempString, "%d", j+1);
strcat(variableString, tempString);
this->VariableNames->InsertValue(cnt++, variableString);
this->VariableIndexToSPX->InsertValue(cnt-1, 8);
this->VariableComponents->InsertValue(cnt-1, 1);
}
break;
case 9:
for (int j=0; j<this->NumberOfScalars; ++j)
{
for(int k=0;k<(int)sizeof(variableString);k++)
{
variableString[k]=0;
}
strcpy(variableString, "Scalar_");
sprintf(tempString, "%d", j+1);
strcat(variableString, tempString);
this->VariableNames->InsertValue(cnt++, variableString);
this->VariableIndexToSPX->InsertValue(cnt-1, 9);
this->VariableComponents->InsertValue(cnt-1, 1);
}
break;
case 10:
for (int j=0; j<this->NumberOfReactionRates; ++j)
{
for (int k=0;k<(int)sizeof(variableString);k++)
{
variableString[k]=0;
}
strcpy(variableString, "RRates_");
sprintf(tempString, "%d", j+1);
strcat(variableString, tempString);
this->VariableNames->InsertValue(cnt++, variableString);
this->VariableIndexToSPX->InsertValue(cnt-1, 10);
this->VariableComponents->InsertValue(cnt-1, 1);
}
break;
case 11:
if (BkEpsilon)
{
this->VariableNames->InsertValue(cnt++, "k_turb_g");
this->VariableIndexToSPX->InsertValue(cnt-1, 11);
this->VariableComponents->InsertValue(cnt-1, 1);
this->VariableNames->InsertValue(cnt++, "e_turb_g");
this->VariableIndexToSPX->InsertValue(cnt-1, 11);
this->VariableComponents->InsertValue(cnt-1, 1);
}
break;
default:
vtkWarningMacro(<< "unknown SPx file : " << i << "\n");
break;
}
}
else
{
this->SpxFileExists->InsertValue(i, 0);
}
in.close();
}
}
//----------------------------------------------------------------------------
void vtkMFIXReader::GetTimeSteps()
{
int nextRecord, numberOfRecords;
char fileName[VTK_MAXPATH];
int cnt = 0;
for (int i=0; i<this->NumberOfSPXFilesUsed; ++i)
{
for (int k=0;k<(int)sizeof(fileName);k++)
{
fileName[k]=0;
}
strncpy(fileName, this->FileName, strlen(this->FileName)-4);
if (i==0)
{
strcat(fileName, ".SP1");
}
else if (i==1)
{
strcat(fileName, ".SP2");
}
else if (i==2)
{
strcat(fileName, ".SP3");
}
else if (i==3)
{
strcat(fileName, ".SP4");
}
else if (i==4)
{
strcat(fileName, ".SP5");
}
else if (i==5)
{
strcat(fileName, ".SP6");
}
else if (i==6)
{
strcat(fileName, ".SP7");
}
else if (i==7)
{
strcat(fileName, ".SP8");
}
else if (i==8)
{
strcat(fileName, ".SP9");
}
else if (i==9)
{
strcat(fileName, ".SPA");
}
else
{
strcat(fileName, ".SPB");
}
#ifdef _WIN32
ifstream in(fileName , ios::binary);
#else
ifstream in(fileName);
#endif
int numberOfVariables=0;
if (in) // file exists
{
in.clear();
in.seekg( 1024, ios::beg );
in.read( (char*)&nextRecord,sizeof(int) );
this->SwapInt(nextRecord);
in.read( (char*)&numberOfRecords,sizeof(int) );
this->SwapInt(numberOfRecords);
switch (i+1)
{
case 1:
{
numberOfVariables = 1;
break;
}
case 2:
{
numberOfVariables = 2;
break;
}
case 3:
{
numberOfVariables = 4;
break;
}
case 4:
{
numberOfVariables = 4*this->MMAX;
break;
}
case 5:
{
numberOfVariables = this->MMAX;
break;
}
case 6:
{
if (this->VersionNumber <= 1.15)
{
numberOfVariables = 3;
}
else
{
numberOfVariables = this->MMAX + 1;
}
break;
}
case 7:
{
numberOfVariables = this->NMax->GetValue(0);
for (int m=1; m<=this->MMAX; ++m)
{
numberOfVariables += this->NMax->GetValue(m);
}
break;
}
case 8:
{
numberOfVariables = this->MMAX;
break;
}
case 9:
{
numberOfVariables = this->NumberOfScalars;
break;
}
case 10:
{
numberOfVariables = this->NumberOfReactionRates;
break;
}
case 11:
{
if (this->BkEpsilon)
{
numberOfVariables = 2;
}
break;
}
}
for(int j=0; j<numberOfVariables; j++)
{
this->VariableTimesteps->InsertValue(cnt,
(nextRecord-4)/numberOfRecords);
cnt++;
}
}
in.close();
}
}
//----------------------------------------------------------------------------
void vtkMFIXReader::MakeTimeStepTable(int numberOfVariables)
{
this->VariableTimestepTable->SetNumberOfComponents(numberOfVariables);
for(int i=0; i<numberOfVariables; i++)
{
int timestepIncrement = (int)((float)this->MaximumTimestep/
(float)this->VariableTimesteps->GetValue(i) + 0.5);
int timestep = 1;
for (int j=0; j<this->MaximumTimestep; j++)
{
this->VariableTimestepTable->InsertComponent(j, i, timestep);
timestepIncrement--;
if (timestepIncrement <= 0)
{
timestepIncrement = (int)((float)this->MaximumTimestep/
(float)this->VariableTimesteps->GetValue(i) + 0.5);
timestep++;
}
if (timestep > this->VariableTimesteps->GetValue(i))
{
timestep = this->VariableTimesteps->GetValue(i);
}
}
}
}
//----------------------------------------------------------------------------
void vtkMFIXReader::GetVariableAtTimestep(int vari , int tstep,
vtkFloatArray *v)
{
// This routine opens and closes the file for each request.
// Maybe keep all SPX files open, and just perform relative
// moves to get to the correct location in the file
// get filename that vaiable # vari is located in
// assumptions : there are <10 solid phases,
// <10 scalars and <10 ReactionRates (need to change this)
char variableName[256];
strcpy(variableName, this->VariableNames->GetValue(vari));
int spx = this->VariableIndexToSPX->GetValue(vari);
char fileName[VTK_MAXPATH];
for(int k=0;k<(int)sizeof(fileName);k++)
{
fileName[k]=0;
}
strncpy(fileName, this->FileName, strlen(this->FileName)-4);
if (spx==1)
{
strcat(fileName, ".SP1");
}
else if (spx==2)
{
strcat(fileName, ".SP2");
}
else if (spx==3)
{
strcat(fileName, ".SP3");
}
else if (spx==4)
{
strcat(fileName, ".SP4");
}
else if (spx==5)
{
strcat(fileName, ".SP5");
}
else if (spx==6)
{
strcat(fileName, ".SP6");
}
else if (spx==7)
{
strcat(fileName, ".SP7");
}
else if (spx==8)
{
strcat(fileName, ".SP8");
}
else if (spx==9)
{
strcat(fileName, ".SP9");
}
else if (spx==10)
{
strcat(fileName, ".SPA");
}
else
{
strcat(fileName, ".SPB");
}
int index = (vari*this->MaximumTimestep) + tstep;
int nBytesSkip = this->SPXTimestepIndexTable->GetValue(index);
#ifdef _WIN32
ifstream in(fileName,ios::binary);
#else
ifstream in(fileName);
#endif
in.seekg(nBytesSkip,ios::beg);
this->GetBlockOfFloats (in, v, this->IJKMaximum2);
in.close();
}
//----------------------------------------------------------------------------
void vtkMFIXReader::MakeSPXTimeStepIndexTable(int nvars)
{
int timestep;
int spx;
int NumberOfVariablesInSPX;
for (int i=0; i<nvars; i++)
{
for (int j=0; j<this->MaximumTimestep; j++)
{
timestep = (int) this->VariableTimestepTable->GetComponent(j, i);
spx = this->VariableIndexToSPX->GetValue(i);
NumberOfVariablesInSPX = this->SPXToNVarTable->GetValue(spx);
int skip = this->VariableToSkipTable->GetValue(i);
int index = (3*512) + (timestep-1) *
((NumberOfVariablesInSPX*this->SPXRecordsPerTimestep*512)+512) +
512 + (skip*this->SPXRecordsPerTimestep*512);
int ind = (i*this->MaximumTimestep) + j;
SPXTimestepIndexTable->InsertValue(ind, index);
}
}
}
//----------------------------------------------------------------------------
void vtkMFIXReader::CalculateMaxTimeStep()
{
this->MaximumTimestep = 0;
for ( int i=0; i <= this->VariableNames->GetMaxId(); i++ )
{
if (this->VariableTimesteps->GetValue(i) > this->MaximumTimestep)
{
this->MaximumTimestep = this->VariableTimesteps->GetValue(i);
}
}
}
//----------------------------------------------------------------------------
void vtkMFIXReader::GetNumberOfVariablesInSPXFiles()
{
int NumberOfVariablesInSPX = 0;
int skip = 0;
for (int j=1; j<this->NumberOfSPXFilesUsed; j++)
{
for(int i=0;i<=this->VariableNames->GetMaxId();i++)
{
if ((this->VariableIndexToSPX->GetValue(i) == j)
&& (this->VariableComponents->GetValue(i) == 1))
{
NumberOfVariablesInSPX++;
this->VariableToSkipTable->InsertValue(i,skip);
skip++;
}
}
this->SPXToNVarTable->InsertValue(j, NumberOfVariablesInSPX);
NumberOfVariablesInSPX = 0;
skip = 0;
}
}
//----------------------------------------------------------------------------
void vtkMFIXReader::FillVectorVariable( int xindex, int yindex,
int zindex, vtkFloatArray *v)
{
for(int i=0;i<=this->CellDataArray[xindex]->GetMaxId();i++)
{
v->InsertComponent(i, 0, this->CellDataArray[xindex]->GetValue(i));
v->InsertComponent(i, 1, this->CellDataArray[yindex]->GetValue(i));
v->InsertComponent(i, 2, this->CellDataArray[zindex]->GetValue(i));
}
v->Modified();
}
//----------------------------------------------------------------------------
void vtkMFIXReader::ConvertVectorFromCylindricalToCartesian( int xindex,
int zindex)
{
int count = 0;
double radius = 0.0;
double y = 0.0;
double theta = 0.0;
int cnt=0;
for (int k=0; k< this->KMaximum2; k++)
{
for (int j=0; j< this->JMaximum2; j++)
{
for (int i=0; i< this->IMaximum2; i++)
{
if ( this->Flag->GetValue(cnt) < 10 )
{
double ucart = (this->CellDataArray[xindex]->
GetValue(count)*cos(theta)) -
(this->CellDataArray[zindex]->GetValue(count)*sin(theta));
double wcart = (this->CellDataArray[xindex]->
GetValue(count)*sin(theta)) +
(this->CellDataArray[zindex]->GetValue(count)*cos(theta));
this->CellDataArray[xindex]->InsertValue(count, (float)ucart);
this->CellDataArray[zindex]->InsertValue(count, (float)wcart);
count++;
}
cnt++;
radius = radius + this->Dx->GetValue(i);
}
radius = 0.0;
y = y + this->Dy->GetValue(j);
}
y = 0.0;
theta = theta + this->Dz->GetValue(k);
}
}
//----------------------------------------------------------------------------
void vtkMFIXReader::GetAllTimes(vtkInformationVector *outputVector)
{
int max = 0;
int maxVar = 0;
for(int j=0; j<=this->VariableNames->GetMaxId(); j++)
{
int n = this->VariableTimesteps->GetValue(j);
if (n > max)
{
max = n;
maxVar = j;
}
}
char fileName[VTK_MAXPATH];
for(int k=0;k<(int)sizeof(fileName);k++)
{
fileName[k]=0;
}
strncpy(fileName, this->FileName, strlen(this->FileName)-4);
if (maxVar==0)
{
strcat(fileName, ".SP1");
}
else if (maxVar==1)
{
strcat(fileName, ".SP2");
}
else if (maxVar==2)
{
strcat(fileName, ".SP3");
}
else if (maxVar==3)
{
strcat(fileName, ".SP4");
}
else if (maxVar==4)
{
strcat(fileName, ".SP5");
}
else if (maxVar==5)
{
strcat(fileName, ".SP6");
}
else if (maxVar==6)
{
strcat(fileName, ".SP7");
}
else if (maxVar==7)
{
strcat(fileName, ".SP8");
}
else if (maxVar==8)
{
strcat(fileName, ".SP9");
}
else if (maxVar==9)
{
strcat(fileName, ".SPA");
}
else
{
strcat(fileName, ".SPB");
}
#ifdef _WIN32
ifstream tfile(fileName, ios::binary);
#else
ifstream tfile(fileName);
#endif
int numberOfVariablesInSPX =
this->SPXToNVarTable->GetValue(this->VariableIndexToSPX->GetValue(maxVar));
int offset = 512-(int)sizeof(float) +
512*(numberOfVariablesInSPX*SPXRecordsPerTimestep);
tfile.clear();
tfile.seekg( 3*512, ios::beg ); // first time
float time;
double* steps = new double[this->NumberOfTimeSteps];
for (int i = 0; i < this->NumberOfTimeSteps; i++)
{
tfile.read( (char*)&time,sizeof(float) );
SwapFloat(time);
steps[i] = (double)time;
tfile.seekg(offset,ios::cur);
}
vtkInformation* outInfo = outputVector->GetInformationObject(0);
outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
steps, this->NumberOfTimeSteps);
double timeRange[2];
timeRange[0] = steps[0];
timeRange[1] = steps[this->NumberOfTimeSteps - 1];
outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), timeRange, 2);
tfile.close();
delete [] steps;
}
| [
"[email protected]"
] | |
cff7dc4a16f19e43fcc453e237ed607b800bcd19 | decefb13f8a603c1f5cc7eb00634b4649915204f | /packages/node-mobile/deps/v8/src/compiler/backend/jump-threading.h | ce60ebcb2e34234047795b1d892c0a8be0bced50 | [
"BSD-3-Clause",
"Apache-2.0",
"bzip2-1.0.6",
"SunPro",
"LicenseRef-scancode-free-unknown",
"Zlib",
"CC0-1.0",
"ISC",
"LicenseRef-scancode-public-domain",
"ICU",
"MIT",
"LicenseRef-scancode-public-domain-disclaimer",
"Artistic-2.0",
"NTP",
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-unicode",
"NAIST-2003"
] | permissive | open-pwa/open-pwa | f092b377dc6cb04123a16ef96811ad09a9956c26 | 4c88c8520b4f6e7af8701393fd2cedbe1b209e8f | refs/heads/master | 2022-05-28T22:05:19.514921 | 2022-05-20T07:27:10 | 2022-05-20T07:27:10 | 247,925,596 | 24 | 1 | Apache-2.0 | 2021-08-10T07:38:42 | 2020-03-17T09:13:00 | C++ | UTF-8 | C++ | false | false | 1,250 | h | // Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_COMPILER_BACKEND_JUMP_THREADING_H_
#define V8_COMPILER_BACKEND_JUMP_THREADING_H_
#include "src/compiler/backend/instruction.h"
namespace v8 {
namespace internal {
namespace compiler {
// Forwards jumps to empty basic blocks that end with a second jump to the
// destination of the second jump, transitively.
class V8_EXPORT_PRIVATE JumpThreading {
public:
// Compute the forwarding map of basic blocks to their ultimate destination.
// Returns {true} if there is at least one block that is forwarded.
static bool ComputeForwarding(
Zone* local_zone,
ZoneVector<RpoNumber>& result, // NOLINT(runtime/references)
InstructionSequence* code, bool frame_at_start);
// Rewrite the instructions to forward jumps and branches.
// May also negate some branches.
static void ApplyForwarding(
Zone* local_zone,
ZoneVector<RpoNumber>& forwarding, // NOLINT(runtime/references)
InstructionSequence* code);
};
} // namespace compiler
} // namespace internal
} // namespace v8
#endif // V8_COMPILER_BACKEND_JUMP_THREADING_H_
| [
"[email protected]"
] | |
86668fb7461c4d771478ef552feb91b6e15227d5 | a7923a1c7c13a57615af2e77988324c4a0863a0a | /in_memory_storage/src/main/cpp/StoreUtil.cpp | 23992d4cfc8886c04102012e21752aa28599bb70 | [] | no_license | prathanbomb/KotlinWithAndroidNdk | ad4f284c1541829398bc73ff2b22bdb72eadc3be | 52152fc4b53a24f91d5fd935c9c33345489c36d2 | refs/heads/master | 2020-12-27T11:58:46.407595 | 2020-02-03T08:58:32 | 2020-02-03T08:58:32 | 237,895,595 | 0 | 0 | null | 2020-02-03T05:57:53 | 2020-02-03T05:57:52 | null | UTF-8 | C++ | false | false | 1,776 | cpp | #include "StoreUtil.h"
#include "Store.h"
#include <cstdlib>
#include <cstring>
#include <android/log.h>
bool isEntryValid(JNIEnv* pEnv, StoreEntry* pEntry, StoreType pType)
{
if(pEntry == NULL)
{
throwNoKeyException(pEnv);
}
return ((pEntry != NULL) && (pEntry->mType == pType));
}
StoreEntry* findEntry(JNIEnv* pEnv, Store* pStore, jstring pKey)
{
StoreEntry* entry = pStore->mEntries;
StoreEntry* endEntry = entry + pStore->mLength;
const char* tmpKey = pEnv->GetStringUTFChars(pKey, NULL);
while ((entry < endEntry) && (strcmp(entry->mKey, tmpKey) != 0)) {
++entry;
}
pEnv->ReleaseStringUTFChars(pKey, tmpKey);
return (entry == endEntry) ? NULL : entry;
}
StoreEntry* allocateEntry(JNIEnv* pEnv, Store* pStore, jstring pKey)
{
StoreEntry* entry = findEntry(pEnv, pStore, pKey);
if( entry != NULL) {
releaseEntryValue(pEnv, entry);
} else {
entry = pStore->mEntries + pStore->mLength;
const char* tmpKey = pEnv->GetStringUTFChars(pKey, NULL);
entry->mKey = new char[strlen(tmpKey) + 1];
strcpy(entry->mKey, tmpKey);
pEnv->ReleaseStringUTFChars(pKey, tmpKey);
++pStore->mLength;
}
return entry;
}
void releaseEntryValue(JNIEnv* pEnv, StoreEntry* pEntry)
{
switch (pEntry->mType) {
case StoreType_String:
delete pEntry->mValue.mString;
break;
case StoreType_Object:
pEnv->DeleteGlobalRef(pEntry->mValue.mObject);
break;
}
}
void throwNoKeyException(JNIEnv* pEnv) {
jclass clazz = pEnv->FindClass("java/lang/IllegalArgumentException");
if (clazz != NULL) {
pEnv->ThrowNew(clazz, "Key does not exist.");
}
pEnv->DeleteLocalRef(clazz);
} | [
"[email protected]"
] | |
f3a0fc36cd73f8ac899e548aa3c5e44f41eadb45 | bee8a28bfc0e66d4889cf8bd715cd2f16fb7c917 | /state/receivecoins.h | 229eda1cc336716be73e7c0a38a00fa7691ba6a4 | [] | no_license | NotMrPotter/mwc-qt-wallet | dd80097d9e092b150cb169668c5f15366fd0b872 | f178744a535d4c0b2e0cbccabf57e53b9cbadf63 | refs/heads/master | 2020-06-09T13:10:42.781473 | 2019-06-23T16:06:23 | 2019-06-23T16:06:23 | 193,442,516 | 1 | 0 | null | 2019-06-24T05:53:52 | 2019-06-24T05:53:52 | null | UTF-8 | C++ | false | false | 651 | h | #ifndef RECEIVECOINS_H
#define RECEIVECOINS_H
#include "state.h"
#include "../wallet/wallet.h"
namespace state {
class Transactions;
class Listening;
class FileTransactions;
class ReceiveCoins : public State
{
public:
ReceiveCoins(const StateContext & context);
virtual ~ReceiveCoins() override;
protected:
virtual NextStateRespond execute() override;
private:
// ReceiveCoins accumulate features from 3 different states.
// That is why we can delegate functionality to them
Transactions * transactionsState;
Listening * listeningState;
//FileTransactions * fileTransactionsState;
};
}
#endif // RECEIVECOINS_H
| [
"[email protected]"
] | |
afeff3e32bab583c926b4a922962c8481c5d34cd | 711e97ffd4dbfc4b6ab2578a6e86fb219b26c54e | /App/MQuestions/MQuestions3.cpp | 33f077100e0560eb16a3496e4bfe05e5423e3b60 | [] | no_license | MaDjOBa/QuizRunner | dc60be78fd76e5aa1c034ece93e14c47ea85d2f1 | 8ebdb6e3e2d5145a77b6ceb267e903439c65031f | refs/heads/master | 2020-08-29T03:13:57.952525 | 2019-10-28T03:37:52 | 2019-10-28T03:37:52 | 217,906,748 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 788 | cpp | #include <iostream>
#include "functions.h"
using namespace std;
int MQuestion3(int yes)
{
char a='1',b='2', c='4', d='3';
char answer;
int df=0;
cout<<"Vopros 3"<<endl<<endl<<"V shkole francuzskij yazyk izuchayut 124 uchashchihsya, chto sostavlyaet 25% ot chisla vsekh uchashchihsya shkoly."<<endl<<"Skol'ko uchashchihsya v shkole?";
cout<<endl<<endl<<"1. 372"<<endl<<"2. 434"<<endl<<"3. 496"<<endl<<"4. 620"<<endl;
for(;;)
{
cout<<endl<<endl<<"Vvedite otvet (cifru ot 1 do 4): ";
cin>>answer;
df = funcAnswer(answer, a, b, c, d);
if (df == 1)
{
yes++;
break;
}
if (df==2)
{
cout<<endl<<"Vy vveli nedopustimoe znachenie. Vvedite chislo ot 1 do 4 zanovo!";
}
if (df==0)
{
break;
}
}
return yes;
}
| [
"[email protected]"
] | |
3fd3804441a434da995d64166e96dd673fe11157 | e5979fbfa5dfd34bd73bfd7b2b20648949837103 | /2015/5-MazeBot/mazeBot/BitMap.cpp | 9175241ac79730d7db386f6f456fa82893ffdd62 | [] | no_license | creagen3/software-training | 09f0deb80d95a065afc64cf2effd0448e5096c46 | bc36c3133d47605cef12a0206c35173fea7a0ae7 | refs/heads/master | 2021-01-12T13:22:48.424532 | 2016-09-22T23:58:28 | 2016-09-22T23:58:28 | 68,970,920 | 0 | 0 | null | 2016-09-22T23:38:29 | 2016-09-22T23:38:28 | null | UTF-8 | C++ | false | false | 709 | cpp | #include "BitMap.h"
using namespace std;
bitset<1600>::reference BitMap::operator()(int x, int y) {
assert(x < MAX_X && x >= 0);
assert(y < MAX_Y && y >= 0);
return data[indexForCoordinates(x,y)];
}
bitset<1600>::reference BitMap::operator()(Coordinate c) {
assert(c.x < MAX_X && c.x >= 0);
assert(c.y < MAX_Y && c.y >= 0);
return data[indexForCoordinates(c.x,c.y)];
}
string BitMap::to_string() {
string s = data.to_string<char,char_traits<char>,allocator<char>>();
for(int i = BitMap::MAX_X; i < (BitMap::MAX_Y+1) * BitMap::MAX_X; i+=BitMap::MAX_X+2) {
s.insert(i, "\r\n");
}
return s;
}
constexpr int BitMap::indexForCoordinates(int x, int y) {
return ( y * MAX_X ) + x;
}
| [
"[email protected]"
] | |
58005946b51f803cdf9fb9769896885663e43e80 | 09c63ef7a90f5c940b0d8e9b4477d47081daaf73 | /eon/client/SaddleSearchJob.h | 3bb7cd304a206acbb59cff11f9e2f1eb6da6a12e | [] | no_license | MaxAndersson/openstackeon | 8b3bc62110331357f30ee4b9c8c77c9bbf5a91df | 484a6bc854e208af8a494d98ab74ec6706d3e66d | refs/heads/master | 2021-01-01T03:43:47.182487 | 2016-05-13T08:41:44 | 2016-05-13T08:41:44 | 58,280,053 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,299 | h | //----------------------------------------------------------------------------
// eOn is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// A copy of the GNU General Public License is available at
// http://www.gnu.org/licenses/
//----------------------------------------------------------------------------
#ifndef SADDLESEARCHJOB_H
#define SADDLESEARCHJOB_H
#include "Matter.h"
#include "Parameters.h"
#include "Job.h"
#include "MinModeSaddleSearch.h"
/**
* @file
* @ingroup Jobs
*
* \brief Finds transition states by finding saddle points on the potential energy surface
*
* The saddle seach job implements a ref MinModeSaddleSearch, as well as an \ref Optimizer "optimizer".
* A saddle search is initiated by making a local displacement of atoms from their position
* at the minimum of the current state. It can either be run using the ref Dimer or the
* ref Lanczos min-mode method.
*
*/
/**
* Decleration of the Saddle Search job
*/
class SaddleSearchJob : public Job {
public:
//! Saddle Search job constructor
/*!
* \param *params defined by the config.init file
*/
SaddleSearchJob(Parameters *params);
//! Saddle Search Job Deconstructor
~SaddleSearchJob(void);
//! Kicks off the Saddle Search
std::vector<std::string> run(void);
private:
//! Runs the correct saddle search; also checks if the run was successful
int doSaddleSearch();
//! Logs the run status and makes sure the run was successful
void printEndState(int status);
//! Writes the results from the run to file
void saveData(int status);
//! Container for the results of the run
std::vector<std::string> returnFiles;
Parameters *parameters;
//! Initializes a ref MinModeSaddleSearch
MinModeSaddleSearch *saddleSearch;
//! Initial configuration.
Matter *initial;
//! Configuration used during the saddle point search.
Matter *saddle;
//! Configuration used during the saddle point search.
Matter *displacement;
//! Force calls to find the saddle
int fCallsSaddle;
};
#endif
| [
"[email protected]"
] | |
a901c9bdf6e6ab3bd880846af41d0fbce03b8bb0 | ff3edaf68ec822de81186bb75bac72250468d1d1 | /ImageDrv/vimgui/dllentry.cpp | ea412de1be2c2061b799ec038ba2a9b97ad821b1 | [] | no_license | kail77/chaos | 3ebb03a3847c8066564f360da3a7e9c5731ef120 | 1e2521c08ca6dd16cac15e2ddfd7bcf505129a24 | refs/heads/master | 2020-04-12T01:42:56.784087 | 2017-12-19T06:48:59 | 2017-12-19T06:48:59 | 48,942,707 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,209 | cpp | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved.
//
// FILE: dllentry.cpp
//
// PURPOSE: Source module for DLL entry function(s).
//
#include "precomp.h"
#include "debug.h"
#include "globals.h"
// This indicates to Prefast that this is a usermode driver file.
__user_driver;
///////////////////////////////////////////////////////////
//
// DLL entry point
//
BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved)
{
UNREFERENCED_PARAMETER(lpReserved);
switch(wReason)
{
case DLL_PROCESS_ATTACH:
VERBOSE("Process attach.\r\n");
ghInstance = hInst;
break;
case DLL_THREAD_ATTACH:
VERBOSE("Thread attach.\r\n");
break;
case DLL_PROCESS_DETACH:
VERBOSE("Process detach.\r\n");
break;
case DLL_THREAD_DETACH:
VERBOSE("Thread detach.\r\n");
break;
}
return TRUE;
}
| [
"[email protected]"
] | |
e92d04062ae8c0422fde7de0c248a608a8606c2a | ffd5d6f2b8b36070fc5c3bba3a4640d2c3b960a6 | /test/src/dyn_prob_max_pool.cpp | 6bd852213c536ec9bf34c449db0c31181265a975 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | hanaa-mohamed/etl | 0bab33faa5f21a04e2d1326a9dede3f7bfa3c166 | 54eb8d079e260a6c6747dfc130bde8ec5369bfd7 | refs/heads/master | 2021-08-14T21:46:43.977952 | 2017-11-16T20:55:34 | 2017-11-16T20:55:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,478 | cpp | //=======================================================================
// Copyright (c) 2014-2017 Baptiste Wicht
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
// http://opensource.org/licenses/MIT)
//=======================================================================
#include "test.hpp"
// p_max_pool_h
TEMPLATE_TEST_CASE_2("dyn_p_max_pool_h_1", "p_max_pool_h_2d", Z, float, double) {
etl::dyn_matrix<Z, 2> a(4, 4, etl::values(1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5, 1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5));
etl::dyn_matrix<Z, 2> b(4, 4);
b = etl::p_max_pool_h(a, 2, 2);
REQUIRE_EQUALS_APPROX(b(0, 0), 0.52059);
REQUIRE_EQUALS_APPROX(b(0, 1), 0.02591);
REQUIRE_EQUALS_APPROX(b(0, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(0, 3), 0.00089);
REQUIRE_EQUALS_APPROX(b(1, 0), 0.19151);
REQUIRE_EQUALS_APPROX(b(1, 1), 0.07045);
REQUIRE_EQUALS_APPROX(b(1, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(1, 3), 0.97686);
REQUIRE_EQUALS_APPROX(b(2, 0), 0.52059);
REQUIRE_EQUALS_APPROX(b(2, 1), 0.02591);
REQUIRE_EQUALS_APPROX(b(2, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(2, 3), 0.00089);
}
TEMPLATE_TEST_CASE_2("dyn_p_max_pool_h_2", "p_max_pool_h_3d", Z, float, double) {
etl::dyn_matrix<Z, 3> a(2, 4, 4, etl::values(1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5, 1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5, 1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5, 1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5));
etl::dyn_matrix<Z, 3> b(2, 4, 4);
b = etl::p_max_pool_h(a, 2, 2);
REQUIRE_EQUALS_APPROX(b(0, 0, 0), 0.52059);
REQUIRE_EQUALS_APPROX(b(0, 0, 1), 0.02591);
REQUIRE_EQUALS_APPROX(b(0, 0, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(0, 0, 3), 0.00089);
REQUIRE_EQUALS_APPROX(b(0, 1, 0), 0.19151);
REQUIRE_EQUALS_APPROX(b(0, 1, 1), 0.07045);
REQUIRE_EQUALS_APPROX(b(0, 1, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(0, 1, 3), 0.97686);
REQUIRE_EQUALS_APPROX(b(0, 2, 0), 0.52059);
REQUIRE_EQUALS_APPROX(b(0, 2, 1), 0.02591);
REQUIRE_EQUALS_APPROX(b(0, 2, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(0, 2, 3), 0.00089);
REQUIRE_EQUALS_APPROX(b(1, 0, 0), 0.52059);
REQUIRE_EQUALS_APPROX(b(1, 0, 1), 0.02591);
REQUIRE_EQUALS_APPROX(b(1, 0, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(1, 0, 3), 0.00089);
REQUIRE_EQUALS_APPROX(b(1, 1, 0), 0.19151);
REQUIRE_EQUALS_APPROX(b(1, 1, 1), 0.07045);
REQUIRE_EQUALS_APPROX(b(1, 1, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(1, 1, 3), 0.97686);
REQUIRE_EQUALS_APPROX(b(1, 2, 0), 0.52059);
REQUIRE_EQUALS_APPROX(b(1, 2, 1), 0.02591);
REQUIRE_EQUALS_APPROX(b(1, 2, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(1, 2, 3), 0.00089);
}
TEMPLATE_TEST_CASE_2("dyn_p_max_pool_h_3", "p_max_pool_h_2d", Z, float, double) {
etl::dyn_matrix<Z, 2> a(4, 4, etl::values(1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5, 1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5));
etl::dyn_matrix<Z, 2> b(4, 4);
b = etl::p_max_pool_h(a + 1.0, 2, 2);
REQUIRE_EQUALS_APPROX(b(0, 0), 0.59229);
REQUIRE_EQUALS_APPROX(b(0, 1), 0.02948);
REQUIRE_EQUALS_APPROX(b(0, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(0, 3), 0.00089);
REQUIRE_EQUALS_APPROX(b(1, 0), 0.21789);
REQUIRE_EQUALS_APPROX(b(1, 1), 0.08015);
REQUIRE_EQUALS_APPROX(b(1, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(1, 3), 0.97719);
REQUIRE_EQUALS_APPROX(b(2, 0), 0.59229);
REQUIRE_EQUALS_APPROX(b(2, 1), 0.02948);
REQUIRE_EQUALS_APPROX(b(2, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(2, 3), 0.00089);
}
TEMPLATE_TEST_CASE_2("dyn_p_max_pool_h_4", "p_max_pool_h_3d", Z, float, double) {
etl::dyn_matrix<Z, 3> a(2, 4, 4, etl::values(1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5, 1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5, 1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5, 1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5));
etl::dyn_matrix<Z, 3> b(2, 4, 4);
b = etl::p_max_pool_h(a + 1.0, 2, 2);
REQUIRE_EQUALS_APPROX(b(0, 0, 0), 0.59229);
REQUIRE_EQUALS_APPROX(b(0, 0, 1), 0.02948);
REQUIRE_EQUALS_APPROX(b(0, 0, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(0, 0, 3), 0.00089);
REQUIRE_EQUALS_APPROX(b(0, 1, 0), 0.21789);
REQUIRE_EQUALS_APPROX(b(0, 1, 1), 0.08015);
REQUIRE_EQUALS_APPROX(b(0, 1, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(0, 1, 3), 0.97719);
REQUIRE_EQUALS_APPROX(b(0, 2, 0), 0.59229);
REQUIRE_EQUALS_APPROX(b(0, 2, 1), 0.02948);
REQUIRE_EQUALS_APPROX(b(0, 2, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(0, 2, 3), 0.00089);
REQUIRE_EQUALS_APPROX(b(1, 0, 0), 0.59229);
REQUIRE_EQUALS_APPROX(b(1, 0, 1), 0.02948);
REQUIRE_EQUALS_APPROX(b(1, 0, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(1, 0, 3), 0.00089);
REQUIRE_EQUALS_APPROX(b(1, 1, 0), 0.21789);
REQUIRE_EQUALS_APPROX(b(1, 1, 1), 0.08015);
REQUIRE_EQUALS_APPROX(b(1, 1, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(1, 1, 3), 0.97719);
REQUIRE_EQUALS_APPROX(b(1, 2, 0), 0.59229);
REQUIRE_EQUALS_APPROX(b(1, 2, 1), 0.02948);
REQUIRE_EQUALS_APPROX(b(1, 2, 2), 0.01085);
REQUIRE_EQUALS_APPROX(b(1, 2, 3), 0.00089);
}
// p_max_pool_p
TEMPLATE_TEST_CASE_2("dyn_p_max_pool_p_1", "p_max_pool_p_2d", Z, float, double) {
etl::dyn_matrix<Z, 2> a(4, 4, etl::values(1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5, 1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5));
etl::dyn_matrix<Z, 2> b(2, 2);
b = etl::p_max_pool_p(a, 2, 2);
REQUIRE_EQUALS_APPROX(b(0, 0), 0.19151);
REQUIRE_EQUALS_APPROX(b(0, 1), 0.00054);
REQUIRE_EQUALS_APPROX(b(1, 0), 0.19151);
REQUIRE_EQUALS_APPROX(b(1, 1), 0.00054);
}
TEMPLATE_TEST_CASE_2("dyn_p_max_pool_p_2", "p_max_pool_p_2d", Z, float, double) {
etl::dyn_matrix<Z, 2> a(4, 4, etl::values(2.54, 2.0, 1.0, 1.5, 1.0, 1.25, 0.05, 2.5, 1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5));
etl::dyn_matrix<Z, 2> b(2, 2);
b = etl::p_max_pool_p(a, 2, 2);
REQUIRE_EQUALS_APPROX(b(0, 0), 0.03666);
REQUIRE_EQUALS_APPROX(b(0, 1), 0.04665);
REQUIRE_EQUALS_APPROX(b(1, 0), 0.19151);
REQUIRE_EQUALS_APPROX(b(1, 1), 0.00054);
}
TEMPLATE_TEST_CASE_2("dyn_p_max_pool_p_3", "p_max_pool_p_3d", Z, float, double) {
etl::dyn_matrix<Z, 3> a(2, 4, 4, etl::values(1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5, 1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5, 2.54, 2.0, 1.0, 1.5, 1.0, 1.25, 0.05, 2.5, 1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5));
etl::dyn_matrix<Z, 3> b(2, 2, 2);
b = etl::p_max_pool_p(a, 2, 2);
REQUIRE_EQUALS_APPROX(b(0, 0, 0), 0.19151);
REQUIRE_EQUALS_APPROX(b(0, 0, 1), 0.00054);
REQUIRE_EQUALS_APPROX(b(0, 1, 0), 0.19151);
REQUIRE_EQUALS_APPROX(b(0, 1, 1), 0.00054);
REQUIRE_EQUALS_APPROX(b(1, 0, 0), 0.03666);
REQUIRE_EQUALS_APPROX(b(1, 0, 1), 0.04665);
REQUIRE_EQUALS_APPROX(b(1, 1, 0), 0.19151);
REQUIRE_EQUALS_APPROX(b(1, 1, 1), 0.00054);
}
TEMPLATE_TEST_CASE_2("dyn_p_max_pool_p_4", "p_max_pool_p_2d", Z, float, double) {
etl::dyn_matrix<Z, 2> a(4, 4, etl::values(1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5, 1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5));
etl::dyn_matrix<Z, 2> b(2, 2);
b = etl::p_max_pool_p(a, 2, 2);
REQUIRE_EQUALS_APPROX(b(0, 0), 0.19151);
REQUIRE_EQUALS_APPROX(b(0, 1), 0.00054);
REQUIRE_EQUALS_APPROX(b(1, 0), 0.19151);
REQUIRE_EQUALS_APPROX(b(1, 1), 0.00054);
}
TEMPLATE_TEST_CASE_2("dyn_p_max_pool_p_5", "p_max_pool_p_2d", Z, float, double) {
etl::dyn_matrix<Z, 2> a(4, 4, etl::values(2.54, 2.0, 1.0, 1.5, 1.0, 1.25, 0.05, 2.5, 1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5));
etl::dyn_matrix<Z, 2> b(2,2);
b = etl::p_max_pool_p(a, 2, 2);
REQUIRE_EQUALS_APPROX(b(0, 0), 0.03666);
REQUIRE_EQUALS_APPROX(b(0, 1), 0.04665);
REQUIRE_EQUALS_APPROX(b(1, 0), 0.19151);
REQUIRE_EQUALS_APPROX(b(1, 1), 0.00054);
}
TEMPLATE_TEST_CASE_2("dyn_p_max_pool_p_6", "p_max_pool_p_2d", Z, float, double) {
etl::dyn_matrix<Z, 3> a(2, 4, 4, etl::values(1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5, 1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5, 2.54, 2.0, 1.0, 1.5, 1.0, 1.25, 0.05, 2.5, 1.0, -2.0, 3.0, 0.5, 0.0, -1, 3.0, 7.5));
etl::dyn_matrix<Z, 3> b(2,2,2);
b = etl::p_max_pool_p(a, 2, 2);
REQUIRE_EQUALS_APPROX(b(0, 0, 0), 0.19151);
REQUIRE_EQUALS_APPROX(b(0, 0, 1), 0.00054);
REQUIRE_EQUALS_APPROX(b(0, 1, 0), 0.19151);
REQUIRE_EQUALS_APPROX(b(0, 1, 1), 0.00054);
REQUIRE_EQUALS_APPROX(b(1, 0, 0), 0.03666);
REQUIRE_EQUALS_APPROX(b(1, 0, 1), 0.04665);
REQUIRE_EQUALS_APPROX(b(1, 1, 0), 0.19151);
REQUIRE_EQUALS_APPROX(b(1, 1, 1), 0.00054);
}
| [
"[email protected]"
] | |
cb150f790d4d666a1b49bc44a8abfe33a1b72de1 | c7468aedc176931b46f5b97e1d2ec4c372bf50dd | /src/server/game/Loot/LootMgr.h | 42febff8ae73ed3e1978cea251e52143f39c2e11 | [] | no_license | planee/new | 68069f16dcb49714a16c2077d22e0f563c600e59 | d6afe0cd87c5e8423855b909682271ad075d6479 | refs/heads/master | 2021-05-10T13:54:52.148537 | 2016-07-07T12:51:07 | 2016-07-07T12:51:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,234 | h | /*
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TRINITY_LOOTMGR_H
#define TRINITY_LOOTMGR_H
#include "ItemEnchantmentMgr.h"
#include "ByteBuffer.h"
#include "RefManager.h"
#include "SharedDefines.h"
#include "ConditionMgr.h"
#include <map>
#include <vector>
enum RollType
{
ROLL_PASS = 0,
ROLL_NEED = 1,
ROLL_GREED = 2,
ROLL_DISENCHANT = 3,
MAX_ROLL_TYPE = 4
};
enum RollMask
{
ROLL_FLAG_TYPE_PASS = 0x01,
ROLL_FLAG_TYPE_NEED = 0x02,
ROLL_FLAG_TYPE_GREED = 0x04,
ROLL_FLAG_TYPE_DISENCHANT = 0x08,
ROLL_ALL_TYPE_NO_DISENCHANT = 0x07,
ROLL_ALL_TYPE_MASK = 0x0F
};
#define MAX_NR_LOOT_ITEMS 16
// note: the client cannot show more than 16 items total
#define MAX_NR_QUEST_ITEMS 32
// unrelated to the number of quest items shown, just for reserve
#define FISHING_JUNK_ID 5000
enum LootMethod
{
FREE_FOR_ALL = 0,
ROUND_ROBIN = 1,
MASTER_LOOT = 2,
GROUP_LOOT = 3,
NEED_BEFORE_GREED = 4
};
enum PermissionTypes
{
ALL_PERMISSION = 0,
GROUP_PERMISSION = 1,
MASTER_PERMISSION = 2,
ROUND_ROBIN_PERMISSION = 3,
OWNER_PERMISSION = 4,
NONE_PERMISSION = 5,
};
enum LootType
{
LOOT_CORPSE = 1,
LOOT_PICKPOCKETING = 2,
LOOT_FISHING = 3,
LOOT_DISENCHANTING = 4,
// ignored always by client
LOOT_SKINNING = 6,
LOOT_PROSPECTING = 7,
LOOT_MILLING = 8,
LOOT_FISHINGHOLE = 20, // unsupported by client, sending LOOT_FISHING instead
LOOT_INSIGNIA = 21 // unsupported by client, sending LOOT_CORPSE instead
};
// type of Loot Item in Loot View
enum LootSlotType
{
LOOT_SLOT_TYPE_ALLOW_LOOT = 0, // player can loot the item.
LOOT_SLOT_TYPE_ROLL_ONGOING = 1, // roll is ongoing. player cannot loot.
LOOT_SLOT_TYPE_MASTER = 2, // item can only be distributed by group loot master.
LOOT_SLOT_TYPE_LOCKED = 3, // item is shown in red. player cannot loot.
LOOT_SLOT_TYPE_OWNER = 4, // ignore binding confirmation and etc, for single player looting
};
class Player;
class LootStore;
class ConditionMgr;
struct LootStoreItem
{
uint32 itemid; // id of the item
float chance; // always positive, chance to drop for both quest and non-quest items, chance to be used for refs
int32 mincountOrRef; // mincount for drop items (positive) or minus referenced TemplateleId (negative)
uint16 lootmode;
uint8 group :7;
bool needs_quest :1; // quest drop (negative ChanceOrQuestChance in DB)
uint8 maxcount :8; // max drop count for the item (mincountOrRef positive) or Ref multiplicator (mincountOrRef negative)
ConditionList conditions; // additional loot condition
// Constructor, converting ChanceOrQuestChance -> (chance, needs_quest)
// displayid is filled in IsValid() which must be called after
LootStoreItem(uint32 _itemid, float _chanceOrQuestChance, uint16 _lootmode, uint8 _group, int32 _mincountOrRef, uint8 _maxcount)
: itemid(_itemid), chance(fabs(_chanceOrQuestChance)), mincountOrRef(_mincountOrRef), lootmode(_lootmode),
group(_group), needs_quest(_chanceOrQuestChance < 0), maxcount(_maxcount)
{}
bool Roll(bool rate) const; // Checks if the entry takes it's chance (at loot generation)
bool IsValid(LootStore const& store, uint32 entry) const;
// Checks correctness of values
};
typedef std::set<uint32> AllowedLooterSet;
struct LootItem
{
uint32 itemid;
uint32 randomSuffix;
int32 randomPropertyId;
ConditionList conditions; // additional loot condition
AllowedLooterSet allowedGUIDs;
uint8 count : 8;
bool is_looted : 1;
bool is_blocked : 1;
bool freeforall : 1; // free for all
bool is_underthreshold : 1;
bool is_counted : 1;
bool needs_quest : 1; // quest drop
bool follow_loot_rules : 1;
bool canSave;
// Constructor, copies most fields from LootStoreItem, generates random count and random suffixes/properties
// Should be called for non-reference LootStoreItem entries only (mincountOrRef > 0)
explicit LootItem(LootStoreItem const& li);
// Empty constructor for creating an empty LootItem to be filled in with DB data
LootItem() : canSave(true){};
// Basic checks for player/item compatibility - if false no chance to see the item in the loot
bool AllowedForPlayer(Player const* player) const;
void AddAllowedLooter(Player const* player);
const AllowedLooterSet & GetAllowedLooters() const { return allowedGUIDs; }
};
struct QuestItem
{
uint8 index; // position in quest_items;
bool is_looted;
QuestItem()
: index(0), is_looted(false) {}
QuestItem(uint8 _index, bool _islooted = false)
: index(_index), is_looted(_islooted) {}
};
struct Loot;
class LootTemplate;
typedef std::vector<QuestItem> QuestItemList;
typedef std::vector<LootItem> LootItemList;
typedef std::map<uint32, QuestItemList*> QuestItemMap;
typedef std::vector<LootStoreItem> LootStoreItemList;
typedef UNORDERED_MAP<uint32, LootTemplate*> LootTemplateMap;
typedef std::set<uint32> LootIdSet;
class LootStore
{
public:
explicit LootStore(char const* name, char const* entryName, bool ratesAllowed)
: m_name(name), m_entryName(entryName), m_ratesAllowed(ratesAllowed) {}
virtual ~LootStore() { Clear(); }
void Verify() const;
uint32 LoadAndCollectLootIds(LootIdSet& ids_set);
void CheckLootRefs(LootIdSet* ref_set = NULL) const; // check existence reference and remove it from ref_set
void ReportUnusedIds(LootIdSet const& ids_set) const;
void ReportNotExistedId(uint32 id) const;
bool HaveLootFor(uint32 loot_id) const { return m_LootTemplates.find(loot_id) != m_LootTemplates.end(); }
bool HaveQuestLootFor(uint32 loot_id) const;
bool HaveQuestLootForPlayer(uint32 loot_id, Player* player) const;
LootTemplate const* GetLootFor(uint32 loot_id) const;
void ResetConditions();
LootTemplate* GetLootForConditionFill(uint32 loot_id);
char const* GetName() const { return m_name; }
char const* GetEntryName() const { return m_entryName; }
bool IsRatesAllowed() const { return m_ratesAllowed; }
protected:
uint32 LoadLootTable();
void Clear();
private:
LootTemplateMap m_LootTemplates;
char const* m_name;
char const* m_entryName;
bool m_ratesAllowed;
};
class LootTemplate
{
class LootGroup; // A set of loot definitions for items (refs are not allowed inside)
typedef std::vector<LootGroup> LootGroups;
public:
// Adds an entry to the group (at loading stage)
void AddEntry(LootStoreItem& item);
// Rolls for every item in the template and adds the rolled items the the loot
void Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId = 0) const;
void CopyConditions(ConditionList conditions);
void CopyConditions(LootItem* li) const;
// True if template includes at least 1 quest drop entry
bool HasQuestDrop(LootTemplateMap const& store, uint8 groupId = 0) const;
// True if template includes at least 1 quest drop for an active quest of the player
bool HasQuestDropForPlayer(LootTemplateMap const& store, Player const* player, uint8 groupId = 0) const;
// Checks integrity of the template
void Verify(LootStore const& store, uint32 Id) const;
void CheckLootRefs(LootTemplateMap const& store, LootIdSet* ref_set) const;
bool addConditionItem(Condition* cond);
bool isReference(uint32 id);
private:
LootStoreItemList Entries; // not grouped only
LootGroups Groups; // groups have own (optimised) processing, grouped entries go there
};
//=====================================================
class LootValidatorRef : public Reference<Loot, LootValidatorRef>
{
public:
LootValidatorRef() {}
void targetObjectDestroyLink() {}
void sourceObjectDestroyLink() {}
};
//=====================================================
class LootValidatorRefManager : public RefManager<Loot, LootValidatorRef>
{
public:
typedef LinkedListHead::Iterator< LootValidatorRef > iterator;
LootValidatorRef* getFirst() { return (LootValidatorRef*)RefManager<Loot, LootValidatorRef>::getFirst(); }
LootValidatorRef* getLast() { return (LootValidatorRef*)RefManager<Loot, LootValidatorRef>::getLast(); }
iterator begin() { return iterator(getFirst()); }
iterator end() { return iterator(NULL); }
iterator rbegin() { return iterator(getLast()); }
iterator rend() { return iterator(NULL); }
};
//=====================================================
struct LootView;
ByteBuffer& operator<<(ByteBuffer& b, LootItem const& li);
ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv);
struct Loot
{
friend ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv);
QuestItemMap const& GetPlayerQuestItems() const { return PlayerQuestItems; }
QuestItemMap const& GetPlayerFFAItems() const { return PlayerFFAItems; }
QuestItemMap const& GetPlayerNonQuestNonFFAConditionalItems() const { return PlayerNonQuestNonFFAConditionalItems; }
std::vector<LootItem> items;
std::vector<LootItem> quest_items;
uint32 gold;
uint8 unlootedCount;
uint64 roundRobinPlayer; // GUID of the player having the Round-Robin ownership for the loot. If 0, round robin owner has released.
LootType loot_type; // required for achievement system
// GUIDLow of container that holds this loot (item_instance.entry)
// Only set for inventory items that can be right-click looted
uint32 containerID;
Loot(uint32 _gold = 0) : gold(_gold), unlootedCount(0), loot_type(LOOT_CORPSE), containerID(0) {}
~Loot() { clear(); }
// For deleting items at loot removal since there is no backward interface to the Item()
void DeleteLootItemFromContainerItemDB(uint32 itemID);
void DeleteLootMoneyFromContainerItemDB();
// if loot becomes invalid this reference is used to inform the listener
void addLootValidatorRef(LootValidatorRef* pLootValidatorRef)
{
i_LootValidatorRefManager.insertFirst(pLootValidatorRef);
}
// void clear();
void clear()
{
for (QuestItemMap::const_iterator itr = PlayerQuestItems.begin(); itr != PlayerQuestItems.end(); ++itr)
delete itr->second;
PlayerQuestItems.clear();
for (QuestItemMap::const_iterator itr = PlayerFFAItems.begin(); itr != PlayerFFAItems.end(); ++itr)
delete itr->second;
PlayerFFAItems.clear();
for (QuestItemMap::const_iterator itr = PlayerNonQuestNonFFAConditionalItems.begin(); itr != PlayerNonQuestNonFFAConditionalItems.end(); ++itr)
delete itr->second;
PlayerNonQuestNonFFAConditionalItems.clear();
PlayersLooting.clear();
items.clear();
quest_items.clear();
gold = 0;
unlootedCount = 0;
roundRobinPlayer = 0;
i_LootValidatorRefManager.clearReferences();
}
bool empty() const { return items.empty() && gold == 0; }
bool isLooted() const { return gold == 0 && unlootedCount == 0; }
void NotifyItemRemoved(uint8 lootIndex);
void NotifyQuestItemRemoved(uint8 questIndex);
void NotifyMoneyRemoved();
void AddLooter(uint64 GUID) { PlayersLooting.insert(GUID); }
void RemoveLooter(uint64 GUID) { PlayersLooting.erase(GUID); }
void generateMoneyLoot(uint32 minAmount, uint32 maxAmount);
bool FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bool personal, bool noEmptyError = false, uint16 lootMode = LOOT_MODE_DEFAULT);
// Inserts the item into the loot (called by LootTemplate processors)
void AddItem(LootStoreItem const & item);
LootItem* LootItemInSlot(uint32 lootslot, Player* player, QuestItem** qitem = NULL, QuestItem** ffaitem = NULL, QuestItem** conditem = NULL);
uint32 GetMaxSlotInLootFor(Player* player) const;
bool hasItemFor(Player* player) const;
bool hasOverThresholdItem() const;
private:
void FillNotNormalLootFor(Player* player, bool presentAtLooting);
QuestItemList* FillFFALoot(Player* player);
QuestItemList* FillQuestLoot(Player* player);
QuestItemList* FillNonQuestNonFFAConditionalLoot(Player* player, bool presentAtLooting);
std::set<uint64> PlayersLooting;
QuestItemMap PlayerQuestItems;
QuestItemMap PlayerFFAItems;
QuestItemMap PlayerNonQuestNonFFAConditionalItems;
// All rolls are registered here. They need to know, when the loot is not valid anymore
LootValidatorRefManager i_LootValidatorRefManager;
};
struct LootView
{
Loot &loot;
Player* viewer;
PermissionTypes permission;
LootView(Loot &_loot, Player* _viewer, PermissionTypes _permission = ALL_PERMISSION)
: loot(_loot), viewer(_viewer), permission(_permission) {}
};
extern LootStore LootTemplates_Creature;
extern LootStore LootTemplates_Fishing;
extern LootStore LootTemplates_Gameobject;
extern LootStore LootTemplates_Item;
extern LootStore LootTemplates_Mail;
extern LootStore LootTemplates_Milling;
extern LootStore LootTemplates_Pickpocketing;
extern LootStore LootTemplates_Reference;
extern LootStore LootTemplates_Skinning;
extern LootStore LootTemplates_Disenchant;
extern LootStore LootTemplates_Prospecting;
extern LootStore LootTemplates_Spell;
void LoadLootTemplates_Creature();
void LoadLootTemplates_Fishing();
void LoadLootTemplates_Gameobject();
void LoadLootTemplates_Item();
void LoadLootTemplates_Mail();
void LoadLootTemplates_Milling();
void LoadLootTemplates_Pickpocketing();
void LoadLootTemplates_Skinning();
void LoadLootTemplates_Disenchant();
void LoadLootTemplates_Prospecting();
void LoadLootTemplates_Spell();
void LoadLootTemplates_Reference();
inline void LoadLootTables()
{
LoadLootTemplates_Creature();
LoadLootTemplates_Fishing();
LoadLootTemplates_Gameobject();
LoadLootTemplates_Item();
LoadLootTemplates_Mail();
LoadLootTemplates_Milling();
LoadLootTemplates_Pickpocketing();
LoadLootTemplates_Skinning();
LoadLootTemplates_Disenchant();
LoadLootTemplates_Prospecting();
LoadLootTemplates_Spell();
LoadLootTemplates_Reference();
}
#endif
| [
"[email protected]"
] | |
2fabc3be50df09625c482e21717af06cc074e7e4 | fb4a9ed066314c4b612a332030e11f3041b1788d | /common/BMLogger.h | b678d801c027be79c78104c3e1e996fe6df7776e | [] | no_license | njust-wxd/badminton | 11a7f4b4f1aa966ac4f145c3c267a5515a1d543c | 094144fc86ccb75f9e84ce864cf941f481a2c105 | refs/heads/master | 2020-07-23T09:08:07.040539 | 2019-09-23T09:04:47 | 2019-09-23T09:04:47 | 207,509,182 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 782 | h | #ifndef _BMSERVICE_BMLOGGER_H
#define _BMSERVICE_BMLOGGER_H
#include <vector>
#include <string>
#include <stdarg.h>
namespace badminton {
#define BUFFER_SIZE 4096
class BMSLogger
{
public:
static BMSLogger* getInstance();
static void destroy();
void writeLog(
int level,
const char* location,
const char* source,
const char* message, ...);
void writeLog(
int level,
const char* location,
const std::string& source,
const char* message, ...);
private:
BMSLogger();
~BMSLogger();
int log(
int level,
const char* source,
const char* message);
private:
static BMSLogger* m_pLogger;
};
} // namespace badminton
#endif // _BMSERVICE_BMLOGGER_H | [
"[email protected]"
] | |
d5032d920f5c1d6cb097c29461364ed10a4f52a6 | 8d46f0e20b47a1d1bf79314fa0fcd4295d349a09 | /SonarReceiver/SonarReceiver/server.cpp | 3245952cddafc8a66005dc9ab7c5d348bd8507ff | [] | no_license | mmcglynn45/PIFlightController | 297c4ea2233eb930cea3b4bc412c2ab6a0d44d2c | 8edfacfd590d48665d2e326bb1c428e2ebf1f6ec | refs/heads/master | 2021-01-21T04:44:03.555715 | 2016-06-14T04:20:43 | 2016-06-14T04:20:43 | 43,616,978 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,896 | cpp | /* A simple server in the internet domain using TCP
The port number is passed as an argument */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include "wiringPi.h"
#include "MovingAverage.h"
#include <math.h>
#include <iostream>
#include <chrono>
#define TRUE 1
#define TRIG 20
#define ECHO 21
int sockfd, newsockfd, portno;
socklen_t clilen;
char buffer[256];
struct sockaddr_in serv_addr, cli_addr;
int n;
MovingAverage distance;
int active;
void setup();
double getDistance();
int demo();
double timeouts = 0;
void error(const char *msg)
{
perror(msg);
exit(1);
}
void connectionSetup(){
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
error("ERROR opening socket");
bzero((char *) &serv_addr, sizeof(serv_addr));
portno = 55555;
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = INADDR_ANY;
serv_addr.sin_port = htons(portno);
if (bind(sockfd, (struct sockaddr *) &serv_addr,
sizeof(serv_addr)) < 0)
error("ERROR on binding");
}
int waitMessage()
{
listen(sockfd,5);
clilen = sizeof(cli_addr);
newsockfd = accept(sockfd,
(struct sockaddr *) &cli_addr,
&clilen);
if (newsockfd < 0)
error("ERROR on accept");
bzero(buffer,256);
n = read(newsockfd,buffer,255);
if (n < 0) error("ERROR reading from socket");
printf("Here is the message: %s\n",buffer);
n = write(newsockfd,"I got your message",18);
if (n < 0) error("ERROR writing to socket");
return 0;
}
int main(){
connectionSetup();
printf("HELLO SONAR\n");
setup();
int i = 0;
while (1) {
i++;
delay(3);
waitMessage();
delayMicroseconds(20000);
double dist = getDistance();
printf("Sonar Distance = %f\n", dist/2.54);
if (i%300==0) {
printf("Sonar Distance = %f\n", dist/2.54);
printf("Timeouts = %f\n", timeouts);
using namespace std::chrono;
microseconds ms = duration_cast< microseconds >(system_clock::now().time_since_epoch());
printf("Time in milliseconds %lld\n", ms.count());
}
}
close(newsockfd);
close(sockfd);
}
void setup() {
//printf("Made it to setup");
distance.setup(10);
wiringPiSetupGpio();
pinMode(TRIG, OUTPUT);
pinMode(ECHO, INPUT);
//TRIG pin must start LOW
digitalWrite(TRIG, LOW);
delay(30);
}
double getCM() {
double lastReading = distance.getAverage();
active = 1;
long startTime = micros();
//Send trig pulse
digitalWrite(TRIG, HIGH);
delayMicroseconds(20);
digitalWrite(TRIG, LOW);
//Wait for echo start
while(digitalRead(ECHO) == LOW){
if ((micros()-startTime)>400000) { //maximum of 160cm
active = 0;
timeouts++;
return distance.getAverage();
}
}
//Wait for echo end
startTime = micros();
while(digitalRead(ECHO) == HIGH){
if ((micros()-startTime)>40000) { //maximum of 160cm
active = 0;
timeouts++;
return distance.getAverage();
}
}
long travelTime = micros() - startTime;
//Get distance in cm
double newDistance = travelTime / 58.0;
double delta = fabs(newDistance-lastReading);
if (newDistance>2500) {
return distance.getAverage();
}
if (fabs(newDistance-distance.getAverage())<1) {
distance.insert(newDistance);
}else{
distance.insert(newDistance*.8+distance.getAverage()*.2);
}
active = 0;
return distance.getAverage();
}
double getDistance(){
return getCM();
}
| [
"[email protected]"
] | |
0862d31cec9c9c5f6c2c57d3981867cbc8e67e65 | f3c8d78b4f8af9a5a0d047fbae32a5c2fca0edab | /Qt/mega_git_tests/Test_Trader/src/trader/orig/qwt_plot_price.h | 50e888546b10d87428d0c64cfee7742360164a7b | [] | no_license | RinatB2017/mega_GIT | 7ddaa3ff258afee1a89503e42b6719fb57a3cc32 | f322e460a1a5029385843646ead7d6874479861e | refs/heads/master | 2023-09-02T03:44:33.869767 | 2023-08-21T08:20:14 | 2023-08-21T08:20:14 | 97,226,298 | 5 | 2 | null | 2022-12-09T10:31:43 | 2017-07-14T11:17:39 | C++ | UTF-8 | C++ | false | false | 1,727 | h | #ifndef QWT_PLOT_PRICE_H
#define QWT_PLOT_PRICE_H
#include <qglobal.h>
#include <qcolor.h>
#include "qwt_plot_seriesitem.h"
#include "qwt_price_move.h"
class QWT_EXPORT QwtPlotPrice: public QwtPlotSeriesItem //<QwtPriceMove>
{
public:
enum CurveStyle
{
NoCurve,
OHLC, // Open-High-Low-Close
Candlestick, // Japanese candlesticks
UserCurve = 100
};
explicit QwtPlotPrice(const QString &title = QString::null);
explicit QwtPlotPrice(const QwtText &title);
virtual ~QwtPlotPrice();
virtual int rtti() const;
void setPen(const QPen &);
const QPen &pen() const;
void setUpBrush(const QBrush &);
const QBrush &upBrush() const;
void setDownBrush(const QBrush &);
const QBrush &downBrush() const;
void setData(const QwtArray<QwtPriceMove> &data);
void setData(const QwtSeriesData<QwtPriceMove> &data);
void setStyle(CurveStyle style);
CurveStyle style() const;
virtual void draw(QPainter *, const QwtScaleMap &xMap,
const QwtScaleMap &yMap, const QRect &) const;
virtual void draw(QPainter *p,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
int from, int to) const;
virtual void updateLegend(QwtLegend *) const;
protected:
void drawCandlesticks(QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
int from, int to) const;
void drawOHLCs(QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
int from, int to) const;
private:
void init();
class PrivateData;
PrivateData *d_data;
};
#endif
| [
"[email protected]"
] | |
4997c66d85958f50346ec4faaa8af7cd7037529e | 4573e9e864746724016d3157123fefdaad27c73b | /Leetcode Interview/792. Number of Matching Subsequences.cpp | 11747f34be593f401a03c85f0939e1ba93df6b4f | [] | no_license | sanchitgoel10/365_of_code | 0389a28d88e947d3a1230016ab74b36319b71f27 | 8e57bb5274c30a7d11359a6e4f9d358524894fbc | refs/heads/master | 2021-01-04T22:24:54.870820 | 2020-10-02T13:36:21 | 2020-10-02T13:36:21 | 240,783,118 | 5 | 2 | null | 2020-07-03T16:24:44 | 2020-02-15T20:26:26 | C++ | UTF-8 | C++ | false | false | 1,128 | cpp | // General Idea:
// - Brute force checking will time out, we need efficent way to look up words
// - Create an vector that stores indices for each character a-z in S
// - Then for each word, do a binary search for next index for current character in word
// that is greater than the index we last found for the alst character
// - If it doesn't exist, word doesn't exist, otherwise continue to search for word
class Solution {
public:
int numMatchingSubseq(string S, vector<string>& words) {
vector<vector<int>> m(26);
for(int i=0;i<S.size();i++){
m[S[i]-'a'].push_back(i);
}
int ans=0;
for(auto w:words){
int x=-1;
bool found=true;
for(auto c:w){
int i=c-'a';
auto it=upper_bound(m[i].begin(),m[i].end(),x); //next greater index
if(it==m[i].end()){
found=0;
break;
}
x=*it; //update last index
}
if(found)ans++;
}
return ans;
}
}; | [
"[email protected]"
] | |
745e59a4bedc61ea8988bc8d9af5ae2b0a1f23b2 | 13ca8ca270a5ce69a40607112a4d8d87a2c3a3f7 | /Lab3/Postman.cpp | 3cd80d9b7a05901431ceff70c99b0278ef72adb4 | [] | no_license | 7kia/Parallel-programming | 10189b2900ed5b6ca6ec05a8327afb1c7417362f | 49fcb9b313c54d42fc5d379388dbb3470e068190 | refs/heads/master | 2020-04-05T22:57:02.385579 | 2016-12-21T05:57:06 | 2016-12-21T05:57:50 | 68,133,903 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 675 | cpp | #include "stdafx.h"
#include "Postman.h"
void CPostman::SendPackage(std::string const & message, size_t numberProcess)
{
std::string namePipe = NAME_PIPE;
CPipe pipe;
pipe.Open(namePipe + std::to_string(numberProcess));
pipe.WriteBytes(message.data(), message.size());
pipe.Close();
}
void CPostman::WaitPackage(std::vector<std::string> &messages, size_t amountMessages)
{
std::string namePipe = NAME_PIPE;
for (size_t index = 0; index < amountMessages; ++index)
{
CPipe pipe;
pipe.Open(namePipe + std::to_string(index));
char buffer[BUFFER_PIPE_SIZE] = "";
pipe.ReadBytes(buffer, BUFFER_PIPE_SIZE);
messages.push_back(buffer);
pipe.Close();
}
}
| [
"[email protected]"
] | |
75fb562ee4c52b3012786372f44a4e221f0a9a06 | baf32fa1a4d3ac49b59c35f0a9226ff2a786fbc6 | /Recursion and Backtracking/BACKTRACKING/ratInA-maze.cpp | 20a9f24a862d0449c1a227695e08e7a6188d368a | [] | no_license | rajnishgeek/DSandAlgorithmPracticeSolution | 1ef24f140a2a5d9d435b7fa36edf77074473f7b6 | 2cdd988c286f61552bd92ae995415e613d8af2fa | refs/heads/master | 2023-07-14T21:15:24.016176 | 2021-09-01T18:00:04 | 2021-09-01T18:00:04 | 271,195,284 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,701 | cpp | #include<bits/stdc++.h>
#include<iostream>
using namespace std;
//it will check is the current cell is safe to go in next cell
//that is current cell is 1
bool isCellSafe(int maze[][5], int n, int i, int j)
{
if (maze[i][j] == 1 && i >= 0 && i < n && j >= 0 && j < n)
return true;
return false;
}
//it is recursion function
bool pathInMazeUtil(int maze[][5], int n, int x, int y, int solution[][5])
{
//base case
if (x == n - 1 && y == n - 1)
{
solution[x][y] = 1; //mark the cell 1 that is path possible from this cell
return true;
}
//here check is the given cell safe if safe
//then call function to move down and right
if (isCellSafe(maze, n, x, y))
{
solution[x][y] = 1; //this 2D array will store the possible path
//check for down celll
if (pathInMazeUtil(maze, n, x + 1, y, solution))
return true;
//check for right cell
if (pathInMazeUtil(maze, n, x, y + 1, solution))
return true;
//this is important command. it is backtracking case
//mark 0 that is path not possible from this cell
solution[x][y] = 0;
return false;
}
return false;
}
void printPath(int solution[][5], int n)
{
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
cout << solution[i][j] << " ";
cout << endl;
}
}
bool pathInMaze(int maze[][5], int n, int x, int y)
{
int solution[5][5] = {0};
if (!pathInMazeUtil(maze, n, x, y, solution))
return false;
printPath(solution,n);
return true;
}
int main()
{
int maze[5][5] = {{1, 1, 1, 0, 0}, {0, 0, 1, 1, 0}, {0, 0, 0, 1, 0}, {0, 0, 0, 1, 1}, {0, 0, 0, 0, 1}};
int n = 5;
pathInMaze(maze, n, 0, 0) ? cout << "path possible" << endl : cout << "path not possible" << endl;
return 0;
}
| [
"[email protected]"
] | |
dfafd366f3f1b5d3496d8934fb234d13a70eec77 | 8617a8fe38869287a7dbeca2487209716cf9d05a | /headers/encoder.h | 6dcf80401c370be4676fc499f0a3278ad16b3860 | [] | no_license | tommathewXC/error-correction-codes | ae51ce665a95d136d441c6b1904230e254f10d8c | da5e2a4177714dc4bf5c30720b7f9043c5d25ca5 | refs/heads/master | 2020-05-24T07:06:22.046950 | 2019-05-28T02:26:20 | 2019-05-28T02:26:20 | 187,151,809 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,165 | h | #ifndef ENCODER_H
#define ENCODER_H
#include <iostream>
#include "log.h"
#define MESSAGE_SIZE 4096
const int CodesSupported = 3;
/**
* @brief The enum of the encoding type
*
*/
enum EncodingType {
Invalid,
ClearText,
Hamming347
};
/**
* @brief The struct that contains data that encapsulates the encoding
* type and the encoded message
*/
struct EncodedMessage{
EncodingType code;
std::string message;
EncodedMessage( const char * m ){ message = m; code = ClearText; }
};
/**
* @brief The class that conducts error coding of string messages
*
*/
class Encoder:public iLogggable {
private:
const std::string label = "Encoder";
public:
Encoder( const char * name ) { this->setLabel( "Encoder" ); }
/**
* @brief Flip the bits in the lower nibble of the input byte reference
*
* @param buffer The byte to corrupt the bits of.
*/
void corruptNibble( unsigned char & buffer );
/**
* @brief Get the distinct number Encodings supported
*
* @return int
*/
int getEncodingCount() { return CodesSupported; };
/**
* @brief Print out the bits in a char
*
* @param d The character byte to analyze
* @param label The label to print with the input
*/
void debugByte( const unsigned char & d, const char * label );
/**
* @brief Encode a given message with the chosen error coding scheme
*
* @param input A const refrence to a C++ 11 string with the message to encode
* @param encType An EncodingType enum indicationg what error coding to use
* @return EncodedMessage The struct that contains the error coded message
* and any and all meta data
*/
EncodedMessage encode( const std::string & input, const EncodingType & encType );
/**
* @brief Call the base encoder, composed.
*
* @param input A const refrence to a C++ 11 string with the message to encode
* @param encType An EncodingType enum indicationg what error coding to use
* @return EncodedMessage The struct that contains the error coded message
* and any and all meta data
*/
std::string encodeToString( const std::string & input, const EncodingType & encType );
/**
* @brief Detect the form of error coding the in the recieved messsage and perform
* error checking and correction
*
* @param rec message reciegved over the socket.
*/
void decode( const EncodedMessage & rec );
/**
* @brief convert a message struct into a message string.
*
* @param message EncodingMessage
* @return std::string One byte of encoding type + The message string
*/
std::string compose( const EncodedMessage & message );
/**
* @brief Extract the data struct from a char buffer of a known size
*
* @param buffer The UDP message buffer
* @param bufferSize The UDP message buffer size
* @return EncodedMessage The struct with the encoded message
*/
EncodedMessage decomposeFromBuffer( const char * buffer, const int & bufferSize );
};
#endif
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.