# trying to take the c function at the bottom, and replicate it # this.p contains an int vector of items to be processed # the shortest function has the virtue that it at least returns # valid sizes keeping the program from crashing as long as all values # are positive but the results are totally wrong def __getuint(this): n = this.p[0] size = 1 if n & 0x80: n = n + (this.p[1] << 7) - 0x80; size = size + 1 if n & (1<<14): n = n + (this.p[size] << 14) - (1<<14) size = size + 1 if n & (1<<21): n = n + (this.p[size] << 21) - (1<<21) size = size + 1 if n & (1<<28): n = n | 0xF0000000 return n, size; #for i in range(3): # n = this.p[i]; # if(not(n & 0x80)): # n = n + (this.p[i] << (7 * i)) # return n,i+1 #if n & 0x80: #n = n + (this.p[1] << 7) - 0x80 #if(n & (1<<14)): # size = 2 # n = n + (this.p[size-1] << 14) - (1<<14) #if(n & (1<<21)): # size = 3 # n = n + (this.p[size-1] << 21) - (1<<21) #if(n & (1<<28)): # n |= 0xF0000000 #return n,1 # START C function we are trying to replace #int getuint(uchar *&p) #{ # int n = *p++; # if(n & 0x80) # { # n += (*p++ << 7) - 0x80; # if(n & (1<<14)) n += (*p++ << 14) - (1<<14); # if(n & (1<<21)) n += (*p++ << 21) - (1<<21); # if(n & (1<<28)) n |= 0xF0000000; # }; # return n; #};